/* Progressive custom selects: the named native input retains form semantics. */
html:root select.cm-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  clip-path: inset(50%);
}

html:root .cm-select {
  display: inline-flex;
  position: relative;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  vertical-align: middle;
}

html:root .cm-select[hidden],
html:root .cm-select-error[hidden] {
  display: none !important;
}

html:root .input-group > .cm-select {
  flex: 1 1 auto;
  width: 1%;
}

html:root .cm-select-button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  min-height: 44px;
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--cm-line, #e0e3e7);
  border-radius: 8px;
  background: var(--cm-surface, #fff);
  color: var(--cm-text, #202124);
  font: inherit;
  line-height: 22px;
  text-align: left;
  cursor: pointer;
  appearance: none;
  outline: 0;
  outline-offset: 0;
  box-shadow: none;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}

html:root .cm-select-button:hover:not(:disabled) {
  border-color: var(--cm-muted, #5f6368);
  background: var(--cm-bg, #f6f8fc);
}

html:root .cm-select > .cm-select-button:is(:focus, [aria-expanded="true"]),
html:root .cm-select.cm-select-open > .cm-select-button {
  border-color: transparent;
  outline: 0;
  outline-offset: 0;
  box-shadow: inset 0 0 0 2px var(--cm-primary, #0b57d0);
}

html:root .cm-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html:root .cm-select-arrow {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  margin: -3px 3px 0 0;
  border: solid var(--cm-muted, #5f6368);
  border-width: 0 1.7px 1.7px 0;
  transform: rotate(45deg);
}

html:root .cm-select-open .cm-select-arrow {
  margin-top: 3px;
  transform: rotate(225deg);
}

html:root .cm-select-disabled .cm-select-button {
  opacity: .5;
  cursor: not-allowed;
  background: var(--cm-bg, #f6f8fc);
}

html:root .cm-select-invalid .cm-select-button {
  border-color: #b3261e;
}

html.dark-mode .cm-select-invalid .cm-select-button {
  border-color: #f2b8b5;
}

html:root .cm-select-error {
  padding: 6px 2px 0;
  color: #b3261e;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

html.dark-mode .cm-select-error {
  color: #f2b8b5;
}

html:root .cm-select-popup {
  box-sizing: border-box;
  position: fixed;
  z-index: 3000;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px;
  border: 1px solid var(--cm-line, #e0e3e7);
  border-radius: 12px;
  background: var(--cm-panel, #fff);
  color: var(--cm-text, #202124);
  box-shadow: 0 8px 28px rgb(0 0 0 / 18%), 0 2px 6px rgb(0 0 0 / 10%);
  outline: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--cm-muted, #5f6368) transparent;
  text-align: left;
  font: 14px/1.5 Arial, "Helvetica Neue", system-ui, sans-serif;
}

html:root .cm-select-option {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 6px;
  outline: 0;
  box-shadow: none;
  color: var(--cm-text, #202124);
  cursor: pointer;
  user-select: none;
}

html:root .cm-select-option-label {
  flex: 1;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

html:root .cm-select-check {
  flex: 0 0 18px;
  color: var(--cm-primary, #0b57d0);
  font-size: 18px;
  font-weight: 500;
  text-align: center;
  visibility: hidden;
}

html:root .cm-select-option[aria-selected="true"] {
  background: var(--cm-selected, #d3e3fd);
  color: var(--cm-text, #202124);
  font-weight: 500;
}

html:root .cm-select-option[aria-selected="true"] .cm-select-check {
  visibility: visible;
}

html:root .cm-select-option.cm-select-active:not([aria-disabled="true"]) {
  background: var(--cm-hover, #eaf1fb);
}

html:root .cm-select-option.cm-select-active[aria-selected="true"] {
  background: var(--cm-selected, #d3e3fd);
}

html:root .cm-select-option[aria-disabled="true"] {
  color: var(--cm-muted, #5f6368);
  opacity: .45;
  cursor: not-allowed;
}

html:root .cm-select-group + .cm-select-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--cm-line, #e0e3e7);
}

html:root .cm-select-group-label,
html:root .cm-select-empty {
  padding: 10px 12px;
  color: var(--cm-muted, #5f6368);
  font-size: 12px;
  line-height: 1.5;
}

html:root .cm-select-group-label {
  font-weight: 500;
}

html:root .cm-select-owner .cm-select-button {
  border-color: transparent;
  background: transparent;
  padding-inline: 8px;
  font-size: 12px;
}

html:root .cm-select-owner .cm-select-button:hover:not(:disabled) {
  background: var(--cm-hover, #eaf1fb);
}

/* The account header clips outer focus shadows. Paint one ring inside the
   button instead of combining its transparent border with an outer outline. */
html:root #owner-mailboxes + .cm-select-owner > .cm-select-button {
  border-color: transparent;
  outline: 0;
  outline-offset: 0;
  box-shadow: none;
}

html:root #owner-mailboxes + .cm-select-owner > .cm-select-button:is(:focus, [aria-expanded="true"]) {
  box-shadow: inset 0 0 0 2px var(--cm-primary, #0b57d0);
}

html:root .cm-select-account-popup {
  border-radius: 18px;
  padding: 8px;
}

html:root .cm-select-account-popup .cm-select-option {
  min-height: 52px;
  gap: 12px;
  border-radius: 10px;
  padding: 8px 12px;
}

html:root .cm-select-account-popup .cm-select-option + .cm-select-option {
  margin-top: 4px;
}

html:root .cm-select-account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cm-primary, #0b57d0);
  color: var(--cm-on-primary, #fff);
  font-size: 14px;
  font-weight: 500;
}

html:root .cm-select-account-popup .cm-select-option-label {
  font-size: 13px;
  line-height: 1.6;
}

html:root .cm-select-account-popup .cm-select-check {
  align-self: center;
  width: 18px;
  line-height: 20px;
}

html:root #compose-headers .cm-select-button {
  border-color: transparent;
  background: transparent;
  padding-left: 8px;
}

html:root .input-group > .cm-select:not(:last-child) .cm-select-button {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

html:root .propform.grouped .row.input-group > select.cm-select-native:first-child + .cm-select {
  flex: 0 1 120px;
  width: 120px;
  max-width: 36%;
}

html:root .propform td.rowactions .cm-select {
  width: auto;
  min-width: 80px;
}

@media (max-width: 575px) {
  html:root .cm-select-button {
    min-height: 46px;
    font-size: 16px;
  }
  html:root .cm-select-owner .cm-select-button {
    font-size: 12px;
  }
  html:root .cm-select-option {
    min-height: 48px;
  }
  html:root .cm-select-popup {
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:root .cm-select-button { transition: none; }
}

/* One account entry point, in the top bar. Native select keeps switch semantics. */
html:root body:has(#cm-topbar .cm-avatar) #owner-mailboxes + .cm-select-owner {display:none!important;}
html:root .cm-select-account-popup {padding:12px;background:var(--cm-bg);border-radius:28px;border:1px solid var(--cm-line);}
html:root .cm-account-heading {display:flex;align-items:center;justify-content:space-between;padding:0 4px 10px 12px;color:var(--cm-muted);font-size:13px;}
html:root .cm-account-close {display:flex;align-items:center;justify-content:center;flex:0 0 40px;width:40px;height:40px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--cm-muted);font:30px/1 Arial;cursor:pointer;}
html:root .cm-account-close:hover {background:var(--cm-hover);}
html:root .cm-account-list {display:flex;flex-direction:column;gap:3px;border-radius:20px;overflow:hidden;}
html:root .cm-select-account-popup .cm-select-option {min-height:70px;padding:12px 14px;border-radius:4px;background:var(--cm-surface);margin:0;gap:12px;}
html:root .cm-select-account-popup .cm-select-option + .cm-select-option {margin:0;}
html:root .cm-select-account-popup .cm-select-option[aria-selected="true"] {min-height:96px;background:var(--cm-surface);margin-bottom:8px;border-radius:20px 20px 4px 4px;}
html:root .cm-select-account-popup .cm-select-option.cm-select-active:not([aria-selected="true"]) {background:var(--cm-hover);}
html:root .cm-select-account-popup .cm-select-option-label {display:flex;flex-direction:column;gap:2px;line-height:1.4;overflow:hidden;}
html:root .cm-select-account-popup .cm-select-option-label strong {font-size:15px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
html:root .cm-select-account-popup .cm-select-option-label>span {font-size:12px;font-weight:400;color:var(--cm-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
html:root .cm-select-account-popup .cm-select-account-avatar {width:36px;height:36px;flex-basis:36px;background:#00695c;color:#fff;font-size:17px;}
html:root .cm-select-account-popup [aria-selected="true"] .cm-select-account-avatar {width:48px;height:48px;flex-basis:48px;font-size:22px;}
html:root .cm-select-account-popup .cm-select-account-avatar[data-account="admin"] {background:#5e35b1;}
html:root .cm-select-account-popup .cm-select-account-avatar[data-account="sales"] {background:#1565c0;}
html:root .cm-select-account-popup .cm-select-account-avatar[data-account="orders"] {background:#a14275;}
html:root .cm-select-account-popup .cm-select-account-avatar[data-account="accounting"] {background:#b06000;}
@media(max-width:400px) {html:root .cm-select-account-popup {padding:8px;border-radius:24px;}html:root .cm-select-account-popup .cm-select-option {padding:12px 10px;gap:10px;}}
