/* ServGo Mail adapter: legacy mail layout + canonical ServGo Air tokens.
 * Load after existing Mail page styles and exported servgo-air-tokens.css.
 * The long-form redesign and one-origin PWA routing are separate follow-up PRs.
 */
html[data-theme] {
  --blue: var(--s-accent);
  --line: var(--s-line);
  --border: var(--s-line);
  --muted: var(--s-muted);
  --shadow: var(--sh-2);
  background: var(--s-bg);
  color: var(--s-text);
  font-family: var(--ds-font);
}
html[data-theme] body { color: var(--s-text); background: var(--s-bg); }
html[data-theme] aside {
  color: var(--s-text);
  background: var(--s-surface);
  border-color: var(--s-line);
}
html[data-theme] .brand,
html[data-theme] .heading h1,
html[data-theme] .top h1,
html[data-theme] .panel h2,
html[data-theme] .metric strong,
html[data-theme] .number strong {
  color: var(--s-text);
}
html[data-theme] .sub,
html[data-theme] .muted,
html[data-theme] .hint,
html[data-theme] .heading p,
html[data-theme] .top p,
html[data-theme] .little,
html[data-theme] .field span,
html[data-theme] .field label,
html[data-theme] .message span,
html[data-theme] .detail p,
html[data-theme] .campaign small,
html[data-theme] th {
  color: var(--s-muted);
}
html[data-theme] .panel,
html[data-theme] .metric,
html[data-theme] .number,
html[data-theme] .auto,
html[data-theme] dialog {
  background: var(--s-surface);
  color: var(--s-text);
  border-color: var(--s-line);
  box-shadow: var(--sh-2);
}
html[data-theme] .message,
html[data-theme] .campaign,
html[data-theme] .panel h2,
html[data-theme] .panel-head,
html[data-theme] th,
html[data-theme] td,
html[data-theme] .status-line {
  border-color: var(--s-line);
}
html[data-theme] .message:hover,
html[data-theme] .message.selected,
html[data-theme] .campaign:hover,
html[data-theme] .campaign.selected,
html[data-theme] .nav button.active,
html[data-theme] nav a.on,
html[data-theme] .nav a:hover,
html[data-theme] nav a:hover {
  background: var(--s-accent-soft);
  color: var(--s-accent);
}
html[data-theme] .little,
html[data-theme] .back-admin,
html[data-theme] .idea,
html[data-theme] .note,
html[data-theme] .btn.alt,
html[data-theme] .secondary,
html[data-theme] .tag,
html[data-theme] .label,
html[data-theme] td button {
  background: var(--s-surface-2);
  color: var(--s-text-2);
  border-color: var(--s-line);
}
html[data-theme] .field input,
html[data-theme] .field textarea,
html[data-theme] .field select,
html[data-theme] #search-dialog select,
html[data-theme] .outline,
html[data-theme] .btn.light {
  background: var(--s-surface-2);
  border-color: var(--s-line);
  color: var(--s-text);
}
html[data-theme] .field input::placeholder,
html[data-theme] .field textarea::placeholder { color: var(--s-muted-2); }
html[data-theme] .primary,
html[data-theme] .btn:not(.alt):not(.light):not(.warn):not(.danger) {
  color: var(--s-accent-ink);
  background: var(--s-accent-grad);
}
html[data-theme] .stickybar { background: var(--s-surface); border-color: var(--s-line); }
html[data-theme] .empty { color: var(--s-muted); }
html[data-theme] .empty strong,
html[data-theme] .sent-body { color: var(--s-text); }

.servgo-mail-theme-picker {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--s-muted); white-space: nowrap;
}
.servgo-mail-theme-picker select {
  font: inherit; min-height: 39px; border: 1px solid var(--s-line);
  border-radius: 12px; padding: 6px 8px; color: var(--s-text);
  background: var(--s-surface-2);
}
.servgo-mail-theme-picker select:focus-visible {
  outline: 2px solid var(--s-accent); outline-offset: 2px;
}
@media (max-width: 760px) {
  .servgo-mail-theme-picker { flex: none; }
}


/* ================================================================
   ServGo Mail Air V2 — real inbox and campaign UI, no demo actions.
   Shared canonical ServGo Air tokens. Both legacy and PWA origins.
   Scoped by body class so existing mail owner pages remain stable.
   ================================================================ */
html[data-theme] body.servgo-mail-v2 {
  --mail-nav-width: 244px;
  --mail-bottom-safe: env(safe-area-inset-bottom, 0px);
  color: var(--s-text);
  background: var(--s-bg);
  font-family: var(--ds-font);
  min-width: 280px;
  overflow-x: clip;
}
html[data-theme] body.servgo-mail-v2 :is(button, a, input, textarea, select):focus-visible {
  outline: 2px solid var(--s-accent);
  outline-offset: 3px;
}
body.servgo-mail-v2 .mail-skip-link {
  position: fixed;
  z-index: 100;
  top: -80px;
  left: 18px;
  border-radius: var(--r-sm);
  padding: 12px 16px;
  color: var(--s-accent-ink);
  background: var(--s-accent);
  font-weight: 750;
  text-decoration: none;
}
body.servgo-mail-v2 .mail-skip-link:focus { top: 12px; }
body.servgo-mail-v2 .mail-eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 3px 0 8px;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: var(--s-accent-soft);
  color: var(--s-accent);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: .02em;
  font-weight: 780;
}
body.servgo-mail-v2 .mail-eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  background: currentColor;
  border-radius: 50%;
}
html[data-theme] body.servgo-mail-v2 :is(main, .app) { min-width: 0; }
html[data-theme] body.servgo-mail-v2 > main,
html[data-theme] body.servgo-mail-v2 > .app {
  max-width: 1740px;
  margin-inline: auto;
  min-height: 100dvh;
}
html[data-theme] body.servgo-mail-inbox > main {
  grid-template-columns: var(--mail-nav-width) minmax(0, 1fr);
}
html[data-theme] body.servgo-mail-campaigns > .app {
  grid-template-columns: var(--mail-nav-width) minmax(0, 1fr);
}
html[data-theme] body.servgo-mail-v2 :is(main > aside, .app > aside) {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 24px 14px;
  border-right: 1px solid var(--s-line);
  background: var(--s-surface-2);
  box-shadow: none;
}
html[data-theme] body.servgo-mail-v2 .brand {
  margin: 0 0 16px;
  padding: 0 12px 18px;
  color: var(--s-text);
  line-height: 1.15;
  font-size: 23px;
  font-weight: 850;
  letter-spacing: -.6px;
}
html[data-theme] body.servgo-mail-v2 .brand small,
html[data-theme] body.servgo-mail-v2 .brand .sub {
  color: var(--s-muted);
  font-size: 11px;
  font-weight: 560;
  margin-top: 6px;
  letter-spacing: 0;
}
html[data-theme] body.servgo-mail-v2 .brand-mark {
  border-radius: 14px;
  background: var(--s-accent-grad);
  color: var(--s-accent-ink);
  box-shadow: var(--sh-2);
}
html[data-theme] body.servgo-mail-v2 :is(.nav button, .nav a, aside nav a) {
  min-height: 46px;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--r-md);
  color: var(--s-text-2);
  background: transparent;
  font-size: 13px;
  font-weight: 670;
  text-align: left;
  text-decoration: none;
  transition: background .17s ease, color .17s ease, transform .17s ease;
}
html[data-theme] body.servgo-mail-v2 :is(.nav button.active, .nav a.active, aside nav a.on) {
  background: var(--s-accent-soft);
  color: var(--s-accent);
}
html[data-theme] body.servgo-mail-v2 :is(.nav button:hover, .nav a:hover, aside nav a:hover) {
  background: var(--s-surface-3);
  color: var(--s-accent);
}
html[data-theme] body.servgo-mail-v2 .little,
html[data-theme] body.servgo-mail-v2 aside > .hint {
  border: 1px solid var(--s-line-2);
  background: var(--s-surface);
  color: var(--s-muted);
  padding: 15px;
  border-radius: var(--r-lg);
  line-height: 1.55;
  margin-top: auto;
}
html[data-theme] body.servgo-mail-v2 .little b { color: var(--s-text); }
html[data-theme] body.servgo-mail-v2 :is(.main, .app > main) {
  min-width: 0;
  padding: clamp(18px, 2.8vw, 40px);
}
html[data-theme] body.servgo-mail-v2 :is(.heading, .top) {
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}
html[data-theme] body.servgo-mail-v2 :is(.heading h1, .top h1) {
  margin: 0 0 6px;
  font-size: clamp(25px, 2.6vw, 34px);
  line-height: 1.12;
  color: var(--s-text);
  letter-spacing: -.8px;
}
html[data-theme] body.servgo-mail-v2 :is(.heading p, .top p) {
  max-width: 560px;
  color: var(--s-muted);
  line-height: 1.5;
}
html[data-theme] body.servgo-mail-v2 :is(.heading .row, .top .row) {
  justify-content: flex-end;
  align-self: center;
  min-width: 0;
  gap: 8px;
}
html[data-theme] body.servgo-mail-v2 :is(.btn, .primary, .secondary, .outline, .danger, .back-admin) {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  font-weight: 720;
  box-shadow: none;
  line-height: 1.25;
  transition: background .17s ease, transform .17s ease;
}
html[data-theme] body.servgo-mail-v2 :is(.btn, .primary, .secondary, .outline):not(:disabled):active {
  transform: scale(.985);
}
html[data-theme] body.servgo-mail-v2 :is(.btn.alt, .btn.light, .secondary, .outline, .back-admin) {
  background: var(--s-surface-3);
  color: var(--s-text-2);
  border: 1px solid var(--s-line-2);
}
html[data-theme] body.servgo-mail-v2 :is(.btn:not(.alt):not(.light):not(.warn):not(.danger), .primary) {
  color: var(--s-accent-ink);
  background: var(--s-accent-grad);
}
html[data-theme] body.servgo-mail-v2 :is(.cards, .numbers) { gap: 12px; }
html[data-theme] body.servgo-mail-v2 :is(.metric, .number, .panel, .auto) {
  border: 1px solid var(--s-line);
  border-radius: var(--r-xl);
  background: var(--s-surface);
  box-shadow: var(--sh-2);
}
html[data-theme] body.servgo-mail-v2 :is(.metric, .number) {
  background: var(--s-surface-2);
  padding: clamp(13px, 1.3vw, 20px);
}
html[data-theme] body.servgo-mail-v2 :is(.metric small, .number small) {
  color: var(--s-muted);
  line-height: 1.35;
  font-weight: 600;
}
html[data-theme] body.servgo-mail-v2 :is(.metric strong, .number strong) {
  color: var(--s-text);
  font-size: clamp(23px, 2.3vw, 31px);
  font-variant-numeric: tabular-nums;
}
html[data-theme] body.servgo-mail-v2 .workspace,
html[data-theme] body.servgo-mail-v2 .panels {
  gap: 16px;
  align-items: start;
}
html[data-theme] body.servgo-mail-v2 .workspace { grid-template-columns: minmax(245px, 37%) minmax(0, 1fr); }
html[data-theme] body.servgo-mail-v2 .panels { grid-template-columns: minmax(250px, 35%) minmax(0, 1fr); }
html[data-theme] body.servgo-mail-v2 .panel { min-width: 0; overflow: hidden; }
html[data-theme] body.servgo-mail-v2 :is(.panel-head, .panel h2) {
  border-color: var(--s-line);
  background: var(--s-surface);
  padding: 17px 20px;
  color: var(--s-text);
}
html[data-theme] body.servgo-mail-v2 :is(.message, .campaign) {
  position: relative;
  border-color: var(--s-line);
  padding: 16px 20px;
  background: var(--s-surface);
  transition: background .15s ease;
}
html[data-theme] body.servgo-mail-v2 :is(.message, .campaign):hover {
  background: var(--s-surface-2);
}
html[data-theme] body.servgo-mail-v2 :is(.message.selected, .campaign.selected) {
  background: var(--s-accent-soft);
  color: var(--s-text);
}
html[data-theme] body.servgo-mail-v2 :is(.message.selected, .campaign.selected)::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  bottom: 8px;
  width: 3px;
  border-radius: var(--r-pill);
  background: var(--s-accent);
}
html[data-theme] body.servgo-mail-v2 .message strong,
html[data-theme] body.servgo-mail-v2 .campaign b {
  color: var(--s-text);
  font-size: 13px;
  line-height: 1.35;
}
html[data-theme] body.servgo-mail-v2 .message :is(span, .meta),
html[data-theme] body.servgo-mail-v2 .campaign small,
html[data-theme] body.servgo-mail-v2 .detail p {
  color: var(--s-muted);
}
html[data-theme] body.servgo-mail-v2 .message-list {
  min-height: 240px;
  max-height: min(72dvh, 950px);
  scrollbar-width: thin;
}
html[data-theme] body.servgo-mail-v2 .detail {
  min-height: 360px;
  padding: clamp(17px, 2vw, 26px);
  overflow-wrap: anywhere;
}
html[data-theme] body.servgo-mail-v2 :is(.field input, .field textarea, .field select) {
  min-height: 44px;
  border: 1px solid var(--s-line-2);
  background: var(--s-surface-2);
  color: var(--s-text);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
html[data-theme] body.servgo-mail-v2 :is(.field input, .field textarea, .field select):focus {
  border-color: var(--s-accent);
  box-shadow: 0 0 0 3px var(--s-accent-soft);
}
html[data-theme] body.servgo-mail-v2 :is(dialog, .stickybar) {
  background: var(--s-surface);
  color: var(--s-text);
  border-color: var(--s-line-2);
}
html[data-theme] body.servgo-mail-v2 dialog {
  width: min(660px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(18px, 2.5vw, 28px);
  border-radius: var(--r-xl);
}
html[data-theme] body.servgo-mail-v2 dialog::backdrop { background: rgba(8, 19, 35, .65); }
html[data-theme] body.servgo-mail-v2 .auto {
  padding: 18px 20px;
  gap: 18px;
}
html[data-theme] body.servgo-mail-v2 .auto small {
  color: var(--s-muted);
}
html[data-theme] body.servgo-mail-v2 :is(.toast, #notice) {
  background: var(--s-text);
  color: var(--s-bg);
  border-radius: var(--r-lg);
}
html[data-theme] body.servgo-mail-v2 .fab {
  color: var(--s-accent-ink);
  background: var(--s-accent-grad);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
}

/* Responsive hierarchy: action row scrolls rather than clipping controls.
 * All forms and tables retain their existing IDs, actions and validation. */
@media (min-width: 761px) and (max-width: 1220px) {
  html[data-theme] body.servgo-mail-inbox .workspace { grid-template-columns: 1fr; }
  html[data-theme] body.servgo-mail-inbox .message-list { max-height: 310px; min-height: 140px; }
  html[data-theme] body.servgo-mail-v2 :is(.heading, .top) { flex-direction: column; align-items: stretch; }
  html[data-theme] body.servgo-mail-v2 :is(.heading .row, .top .row) {
    align-self: stretch; justify-content: flex-start;
  }
}
@media (max-width: 850px) {
  html[data-theme] body.servgo-mail-campaigns > .app { display: block; }
  html[data-theme] body.servgo-mail-campaigns .app > aside {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 25;
    height: auto;
    min-height: 64px;
    padding: 7px 8px calc(7px + var(--mail-bottom-safe));
    overflow: visible;
    border: 0;
    border-top: 1px solid var(--s-line-2);
    box-shadow: var(--sh-pop);
    background: var(--s-surface);
  }
  html[data-theme] body.servgo-mail-campaigns .app > aside > :is(.brand, .hint) { display: none; }
  html[data-theme] body.servgo-mail-campaigns .app > aside nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
  }
  html[data-theme] body.servgo-mail-campaigns .app > aside nav a {
    min-width: 0;
    min-height: 51px;
    padding: 9px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 11px;
    line-height: 1.25;
    margin: 0;
  }
  html[data-theme] body.servgo-mail-campaigns .app > main {
    max-width: 100%;
    padding: 18px 15px calc(122px + var(--mail-bottom-safe));
  }
  html[data-theme] body.servgo-mail-campaigns .panels { grid-template-columns: 1fr; }
  html[data-theme] body.servgo-mail-campaigns .fab {
    bottom: calc(82px + var(--mail-bottom-safe));
    right: 14px;
  }
  html[data-theme] body.servgo-mail-campaigns #notice {
    bottom: calc(149px + var(--mail-bottom-safe));
  }
  html[data-theme] body.servgo-mail-campaigns .top {
    flex-direction: column;
    align-items: stretch;
  }
  html[data-theme] body.servgo-mail-campaigns .top .row {
    flex-wrap: nowrap;
    align-self: stretch;
    justify-content: flex-start;
    max-width: calc(100vw - 30px);
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
  }
  html[data-theme] body.servgo-mail-campaigns .top .row > * { flex: none; }
}
@media (max-width: 760px) {
  html[data-theme] body.servgo-mail-inbox > main { display: block; }
  html[data-theme] body.servgo-mail-inbox main > aside {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 25;
    height: auto;
    padding: 7px 5px calc(7px + var(--mail-bottom-safe));
    overflow: visible;
    border: 0;
    border-top: 1px solid var(--s-line-2);
    box-shadow: var(--sh-pop);
    background: var(--s-surface);
  }
  html[data-theme] body.servgo-mail-inbox aside :is(.brand, .little) { display: none; }
  html[data-theme] body.servgo-mail-inbox .nav { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 2px; }
  html[data-theme] body.servgo-mail-inbox :is(.nav button, .nav a) {
    min-width: 0;
    min-height: 52px;
    padding: 6px 2px;
    border-radius: var(--r-md);
    gap: 4px;
    flex-direction: column;
    text-align: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1.1;
  }
  html[data-theme] body.servgo-mail-inbox .nav b { font-size: 18px; }
  html[data-theme] body.servgo-mail-inbox .nav span {
    max-width: 100%;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  html[data-theme] body.servgo-mail-inbox .main {
    padding: 18px 14px calc(130px + var(--mail-bottom-safe));
  }
  html[data-theme] body.servgo-mail-inbox .heading {
    flex-direction: column; align-items: stretch; gap: 14px;
  }
  html[data-theme] body.servgo-mail-inbox .heading .row {
    justify-content: flex-start;
    align-self: stretch;
    flex-wrap: nowrap;
    max-width: calc(100vw - 28px);
    overflow-x: auto;
    scrollbar-width: none;
    padding: 3px 0 7px;
    margin: 0;
  }
  html[data-theme] body.servgo-mail-inbox .heading .row > * { flex: none; }
  html[data-theme] body.servgo-mail-inbox .cards {
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: 7px;
  }
  html[data-theme] body.servgo-mail-inbox .metric { padding: 11px; border-radius: var(--r-lg); }
  html[data-theme] body.servgo-mail-inbox .metric small { font-size: 10px; }
  html[data-theme] body.servgo-mail-inbox .metric strong { font-size: clamp(19px,5vw,24px); }
  html[data-theme] body.servgo-mail-inbox .workspace { grid-template-columns: 1fr; gap: 13px; }
  html[data-theme] body.servgo-mail-inbox .message-list { min-height: 110px; max-height: 48dvh; }
  html[data-theme] body.servgo-mail-inbox .detail { min-height: 180px; padding: 18px 15px; }
  html[data-theme] body.servgo-mail-inbox .fab {
    right: 14px; bottom: calc(83px + var(--mail-bottom-safe));
  }
  html[data-theme] body.servgo-mail-inbox .toast {
    bottom: calc(148px + var(--mail-bottom-safe));
  }
  html[data-theme] body.servgo-mail-v2 dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 18px 15px;
  }
  html[data-theme] body.servgo-mail-v2 dialog .row {
    flex-wrap: wrap;
  }
}
@media (max-width: 370px) {
  html[data-theme] body.servgo-mail-v2 .mail-eyebrow { font-size: 10px; }
  html[data-theme] body.servgo-mail-inbox .metric { padding: 9px 7px; }
  html[data-theme] body.servgo-mail-inbox .metric strong { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme] body.servgo-mail-v2 :is(button, a, .message, .campaign) {
    transition: none !important;
    animation: none !important;
  }
}

/* Mail V3 — one task-first bottom dock, no separate Contacts tab. */
html[data-theme] body.servgo-mail-v2 > main,
html[data-theme] body.servgo-mail-campaigns > .app {display:block;max-width:1500px;min-height:100dvh}
html[data-theme] body.servgo-mail-v2 > main > aside,
html[data-theme] body.servgo-mail-campaigns > .app > aside {display:none!important}
html[data-theme] body.servgo-mail-v2 :is(.main,.app > main) {padding:clamp(12px,2vw,24px) clamp(12px,3vw,36px) calc(180px + env(safe-area-inset-bottom,0px));max-width:1500px;margin-inline:auto}
html[data-theme] body.servgo-mail-v2 :is(.heading,.top) {margin-bottom:12px;gap:6px}
html[data-theme] body.servgo-mail-v2 :is(.heading h1,.top h1) {font-size:clamp(21px,2vw,27px);margin-bottom:3px}
html[data-theme] body.servgo-mail-v2 :is(.heading p,.top p) {font-size:12px;margin:0}
html[data-theme] body.servgo-mail-v2 .mail-eyebrow {margin:0 0 5px;padding:3px 8px}
html[data-theme] body.servgo-mail-v2 .back-admin {display:none}
html[data-theme] body.servgo-mail-v2 .fab {display:none!important}
html[data-theme] body.servgo-mail-v2 .mail-v3-dock {position:fixed;bottom:0;left:0;right:0;z-index:50;background:var(--s-surface);border-top:1px solid var(--s-line);padding:6px 12px calc(8px + env(safe-area-inset-bottom,0px));box-shadow:0 -8px 22px rgba(0,0,0,.055);display:flex;flex-direction:column;align-items:center;gap:5px}
html[data-theme] body.servgo-mail-v2 .mail-v3-dock [hidden] {display:none!important}
html[data-theme] body.servgo-mail-v2 .mail-v3-actionbar {display:flex;width:min(100%,950px);align-items:center;justify-content:flex-end;gap:8px;min-height:38px}
html[data-theme] body.servgo-mail-v2 .mail-v3-actionbar :is(button,.btn,summary) {min-height:38px;padding:7px 12px;font-size:12px;border-radius:10px}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav {width:min(100%,650px);display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;min-height:52px}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a {display:flex;position:relative;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:0;min-height:51px;padding:6px 7px 10px;text-decoration:none;border-radius:12px;color:var(--s-text-2);font-size:11px;font-weight:700;white-space:nowrap}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a b {font-size:20px;font-weight:600;line-height:1.05}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a[aria-current="page"],
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a[aria-current=""] {color:var(--s-accent);background:var(--s-accent-soft)}
/* Exact ServGo design-system.css .ds-bn::after indicator, including the
   animation and double-tapered shape. Not a flat rounded rectangle. */
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a[aria-current]::after {
  content: ""; display: block; position: absolute; left: 22%; right: 22%; bottom: 0; height: 2px; width: auto; pointer-events: none;
  background: var(--s-flow-grad, linear-gradient(104deg, #307be8, #8ad8f3, #686fe4, #336be2, #67baf4, #307be8));
  background-size: 310% 100%;
  clip-path: polygon(0% 50%, 10% 45%, 24% 36%, 36% 23%, 45% 10%, 55% 10%, 64% 23%, 76% 36%, 90% 45%, 100% 50%, 90% 55%, 76% 64%, 64% 77%, 55% 90%, 45% 90%, 36% 77%, 24% 64%, 10% 55%);
  animation: dsFlowLine 3.7s linear infinite;
}
@keyframes dsFlowLine { 0% { background-position: 0 50%; } 100% { background-position: 100% 50%; } }
html[data-theme] body.servgo-mail-v2 .mail-v3-popover {position:relative}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover > summary {display:flex;align-items:center;justify-content:center;list-style:none;cursor:pointer;padding:8px 13px;min-width:88px;color:var(--s-text-2);background:var(--s-surface-2);border:1px solid var(--s-line);font-weight:700}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover > summary::-webkit-details-marker {display:none}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover[open] > summary {background:var(--s-accent-soft);color:var(--s-accent)}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover > :is(nav,.mail-v3-popover-content) {position:absolute;z-index:52;bottom:calc(100% + 10px);right:0;display:flex;flex-direction:column;gap:7px;min-width:min(320px,calc(100vw - 24px));max-width:min(410px,calc(100vw - 24px));max-height:65dvh;overflow-y:auto;padding:12px;border:1px solid var(--s-line);border-radius:16px;background:var(--s-surface);box-shadow:var(--sh-pop)}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover:not([open]) > :is(nav,.mail-v3-popover-content) {display:none}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover .nav :is(button,a) {min-height:42px;justify-content:flex-start;text-align:left;font-size:13px;display:flex;flex-direction:row;gap:8px}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover .nav span {font-size:13px;display:inline;max-width:none}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content :is(button:not(.switch),a,.btn) {min-height:42px;width:100%;justify-content:center;white-space:normal}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content .row {display:flex;flex-direction:column;align-items:stretch;gap:7px;width:100%;overflow:visible;max-width:100%;padding:0}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content .auto {margin:8px 0;padding:10px}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content .mail-campaign-controls {flex-wrap:wrap}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content .mail-campaign-controls button {width:100%}
html[data-theme] body.servgo-mail-v2 .cards {margin-bottom:12px;gap:8px}
html[data-theme] body.servgo-mail-v2 .metric {padding:10px 13px;border-radius:12px;box-shadow:none}
html[data-theme] body.servgo-mail-v2 .metric strong {font-size:21px;margin-top:2px}
html[data-theme] body.servgo-mail-v2 .metric small {font-size:11px}
html[data-theme] body.servgo-mail-v2 :is(.panel,.detail) {border-radius:14px}
html[data-theme] body.servgo-mail-v2 .panel-head {padding:10px 13px}
html[data-theme] body.servgo-mail-v2 :is(.message,.campaign) {padding:11px 13px}
html[data-theme] body.servgo-mail-v2 .mail-v3-search {display:block;min-width:0;max-width:1050px;margin:0 auto}
html[data-theme] body.servgo-mail-v2 .mail-v3-search[hidden],html[data-theme] body.servgo-mail-v2 #campaigns-screen[hidden] {display:none!important}
html[data-theme] body.servgo-mail-v2 .mail-v3-search form {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 12px;align-items:end}
html[data-theme] body.servgo-mail-v2 .mail-v3-search :is(h2,.hint,#search-ideas,#search-status,#search-results,.mail-v3-search-actions) {grid-column:1/-1}
html[data-theme] body.servgo-mail-v2 .mail-v3-search h2 {margin:0;font-size:23px;line-height:1.3}
html[data-theme] body.servgo-mail-v2 .mail-v3-search .hint {font-size:12px;margin:0 0 4px;line-height:1.4}
html[data-theme] body.servgo-mail-v2 .mail-v3-search .field {min-width:0;margin:0}
html[data-theme] body.servgo-mail-v2 .mail-v3-search :is(input,select) {width:100%;min-width:0;padding:10px 12px;min-height:43px}
html[data-theme] body.servgo-mail-v2 #search-results {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr));gap:9px;margin:10px 0}
html[data-theme] body.servgo-mail-v2 .hit {min-width:0;padding:12px;border:1px solid var(--s-line);border-radius:13px;background:var(--s-surface);overflow-wrap:anywhere}
html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions {position:fixed;z-index:49;left:0;right:0;bottom:calc(77px + env(safe-area-inset-bottom,0px));display:flex;align-items:center;justify-content:center!important;gap:6px;flex-wrap:nowrap!important;overflow-x:auto;scrollbar-width:none;background:var(--s-surface);padding:7px 9px;border-top:1px solid var(--s-line);box-shadow:0 -5px 18px rgba(0,0,0,.06);margin:0}
html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions :is(button,.btn) {flex:none;min-height:39px;font-size:12px;padding:8px 11px}
html[data-theme] body.servgo-mail-v2 #search-add:not(:disabled) {font-weight:750}
html[data-theme] body.servgo-mail-v2 :is(.toast,#notice) {bottom:calc(145px + env(safe-area-inset-bottom,0px));z-index:65}
@media(max-width:850px) {
html[data-theme] body.servgo-mail-campaigns > .app {display:block}
html[data-theme] body.servgo-mail-campaigns .app > main {padding:12px 12px calc(185px + env(safe-area-inset-bottom,0px));max-width:100%}
html[data-theme] body.servgo-mail-campaigns .panels {grid-template-columns:1fr}
html[data-theme] body.servgo-mail-v2 .mail-v3-search form {grid-template-columns:repeat(2,minmax(0,1fr))}
html[data-theme] body.servgo-mail-v2 .mail-v3-search :is(.field:first-of-type,.field:nth-of-type(2)) {grid-column:1/-1}
html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions {bottom:calc(78px + env(safe-area-inset-bottom,0px));justify-content:flex-start!important}
html[data-theme] body.servgo-mail-v2 .mail-v3-actionbar {justify-content:center}
html[data-theme] body.servgo-mail-v2 .message-list {max-height:52dvh}
}
@media(max-width:370px){
html[data-theme] body.servgo-mail-v2 .mail-v3-popover > summary {min-width:76px;padding:7px}
html[data-theme] body.servgo-mail-v2 .mail-v3-actionbar {gap:5px}
}

/* Search is an inline workspace, not a constrained modal. */
html[data-theme] body.servgo-mail-v2 #search-dialog {max-height:none;overflow:visible;position:static;width:100%;padding:0;border:0;box-shadow:none;background:transparent;color:var(--s-text)}
@media (max-width:850px) {
  html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions {flex-wrap:wrap!important;overflow:visible;justify-content:space-between!important;padding:7px 12px}
  html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions #search-go,
  html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions #search-suggest {flex:1 1 calc(50% - 6px);order:0;white-space:nowrap;padding-inline:8px}
  html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions #search-add:not(:disabled) {flex:1 1 100%;order:1}
  html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions #search-add:disabled {display:none}
  html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions #search-stop {flex:1 1 100%;order:2}
  html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions #search-close {display:none}
  html[data-theme] body.servgo-mail-v2 .app > main {padding-bottom:calc(235px + env(safe-area-inset-bottom,0px))}
}

/* Keep the real mobile compose/reply control visible after moving it into the dock. */
html[data-theme] body.servgo-mail-inbox .mail-v3-actionbar #compose {display:inline-flex!important;align-items:center;justify-content:center}

/* Global navigation and duplicate outbox composer do not occupy the top of Mail V3. */
html[data-theme] body.servgo-mail-inbox #list-compose {display:none!important}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content > .sg-pwa-workspace-nav {display:flex;flex-wrap:wrap;gap:4px 12px;margin:0 0 10px;padding-bottom:8px;border-bottom:1px solid var(--s-line)}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content > .sg-pwa-workspace-nav a {font-size:12px;min-height:34px;padding:6px}

/* Mail V4 lead search controls: source/history are optional, selections remain visible. */
html[data-theme] body.servgo-mail-campaigns .mail-v4-create {align-self:end;min-height:43px;max-width:220px}
html[data-theme] body.servgo-mail-campaigns .mail-v4-hit-choice {display:flex;align-items:flex-start;gap:9px;min-width:0;flex:1;cursor:pointer}
html[data-theme] body.servgo-mail-campaigns .mail-v4-hit-choice b {overflow-wrap:anywhere;line-height:1.4}
html[data-theme] body.servgo-mail-campaigns .mail-v4-hit-choice input {width:20px;min-width:20px;min-height:20px;height:20px;margin:1px 0 0;accent-color:var(--s-accent)}
html[data-theme] body.servgo-mail-campaigns .mail-v4-hit-review {display:flex;gap:8px;margin-top:10px}
html[data-theme] body.servgo-mail-campaigns .mail-v4-hit-review button {background:var(--s-surface-2);border:1px solid var(--s-line);border-radius:9px;padding:7px 9px;color:var(--s-text-2);font-size:12px}
html[data-theme] body.servgo-mail-campaigns .mail-v4-hit-review button:disabled {opacity:.5}
html[data-theme] body.servgo-mail-campaigns .mail-v4-hit-review button:not(:disabled):focus-visible {outline:2px solid var(--s-accent);outline-offset:2px}
html[data-theme] body.servgo-mail-v2 .mail-v3-dock {background:var(--s-surface);box-shadow:none;border-top-color:transparent}
html[data-theme] body.servgo-mail-v2 .mail-v3-search-actions {box-shadow:none;border-top-color:var(--s-line)}
@media(max-width:650px) {
 html[data-theme] body.servgo-mail-campaigns .mail-v4-create {max-width:100%;width:100%;grid-column:1/-1}
 html[data-theme] body.servgo-mail-campaigns .mail-v3-search :is(#search-provider,#search-history) {min-height:44px}
 html[data-theme] body.servgo-mail-campaigns #search-help {font-size:11px}
}

/* Exactly one prominent next step for the current campaign stays in the bottom action row. */
html[data-theme] body.servgo-mail-campaigns .mail-v4-primary {display:flex;flex:1;min-width:0;max-width:260px}
html[data-theme] body.servgo-mail-campaigns .mail-v4-primary:empty {display:none}
html[data-theme] body.servgo-mail-campaigns .mail-v4-primary button {width:100%;min-height:38px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
html[data-theme] body.servgo-mail-campaigns .mail-v4-automation-status {max-width:650px;margin:0 auto 14px;text-align:center}
@media(max-width:450px) {
 html[data-theme] body.servgo-mail-campaigns #mail-campaign-toolbar {justify-content:space-between;gap:4px}
 html[data-theme] body.servgo-mail-campaigns #mail-campaign-toolbar #create {padding:7px 8px;font-size:11px;white-space:nowrap}
 html[data-theme] body.servgo-mail-campaigns #mail-campaign-toolbar .mail-v3-popover > summary {min-width:69px;font-size:11px;padding:7px 8px}
 html[data-theme] body.servgo-mail-campaigns #mail-campaign-toolbar .mail-v4-primary button {padding:7px 5px;font-size:11px}
}

@media(max-width:650px) {
 html[data-theme] body.servgo-mail-campaigns.mail-search-active .app > main {padding-bottom:calc(255px + env(safe-area-inset-bottom,0px))}
 html[data-theme] body.servgo-mail-campaigns .mail-v3-search-actions #search-resume {flex:1 1 100%;order:3}
 html[data-theme] body.servgo-mail-campaigns .mail-v3-search-actions #search-resume:not([style*="display: none"]) {min-width:0}
}


/* Mail V5: primary workspace navigation belongs in the page, not in the
 * bottom overflow sheet. Keep all three destinations visible on mobile. */
html[data-theme] body.servgo-mail-v2 .mail-workspace-links {
  display:flex;
  position:sticky;
  top:0;
  z-index:21;
  align-items:center;
  justify-content:flex-start;
  gap:8px;
  width:100%;
  margin:0 0 16px;
  padding:7px 0;
  background:var(--s-bg);
}
html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-link {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 1 auto;
  min-width:0;
  min-height:42px;
  padding:9px 13px;
  margin:0;
  text-align:center;
  line-height:1.25;
  font-size:12px;
  font-weight:700;
  white-space:normal;
  text-decoration:none;
  border:1px solid transparent;
  border-radius:12px;
  background:var(--s-surface-2);
  color:var(--s-text-2);
}
html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-studio {
  background:var(--s-accent-soft);
  color:var(--s-accent);
}
html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-logout {
  margin-left:auto;
  color:var(--s-muted);
}
html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-link:focus-visible {
  outline:2px solid var(--s-accent);
  outline-offset:2px;
}

/* Prevent an ordinary full-width menu-button rule from expanding the
 * auto-send switch and reducing its adjacent text to one-word lines. */
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content .auto {
  display:grid;
  grid-template-columns:minmax(0,1fr) 52px;
  align-items:center;
  gap:10px;
  width:100%;
  min-width:0;
  margin:8px 0;
  padding:12px;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content .auto > div {
  min-width:0;
  width:100%;
  overflow-wrap:normal;
  word-break:normal;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content #auto-switch {
  display:block;
  width:52px;
  min-width:52px;
  max-width:52px;
  height:30px;
  min-height:30px;
  padding:0;
  margin:0;
  flex:none;
  justify-self:end;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover > .mail-v3-popover-content {
  width:min(360px,calc(100vw - 24px));
  min-width:0;
  max-width:calc(100vw - 24px);
  overflow-x:hidden;
  overscroll-behavior:contain;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-popover-content :is(a,button) {
  box-sizing:border-box;
}
@media (max-width:650px) {
  html[data-theme] body.servgo-mail-v2 .mail-workspace-links {
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:6px;
    padding:5px 0 9px;
    margin-bottom:10px;
  }
  html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-link {
    flex:none;
    width:100%;
    min-height:44px;
    padding:8px 5px;
    font-size:11.5px;
    line-height:1.2;
    overflow-wrap:normal;
    word-break:normal;
  }
  html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-logout {
    margin-left:0;
  }
  html[data-theme] body.servgo-mail-v2 .mail-v3-popover > .mail-v3-popover-content {
    max-height:min(58dvh,480px);
  }
}

/* On narrow phones the Details trigger is not centered; anchoring the sheet
 * to its right edge can push the sheet off the left side of the viewport. */
@media (max-width:650px) {
  html[data-theme] body.servgo-mail-v2 .mail-v3-popover > :is(nav,.mail-v3-popover-content) {
    position:fixed;
    left:12px;
    right:12px;
    bottom:calc(112px + env(safe-area-inset-bottom,0px));
    width:auto;
    min-width:0;
    max-width:none;
    max-height:min(58dvh,480px);
    margin:0;
    overflow-x:hidden;
    overscroll-behavior:contain;
  }
}


/* ServGo Air V5: same native Onest as BookingBot PWA. Font files are served
   locally by mail_campaign_ui.py; URLs are CSS-relative so both Mail origins
   resolve their OWN /api/... path without cross-origin requests. */
@font-face {
  font-family: "Onest Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("servgo-air-onest-cyrillic.woff2") format("woff2");
  unicode-range: U+0400-052F, U+1C80-1C8F, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: "Onest Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("servgo-air-onest-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Reuse the published typography, palette, density, button and radius tokens
   from web/frontend/src/styles/design-system.css. All overrides scoped to Mail. */
html[data-theme] body.servgo-mail-v2,
html[data-theme] body.servgo-mail-v2 :is(button, input, textarea, select) {
  font-family: var(--ds-font);
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
}
html[data-theme] body.servgo-mail-v2 {
  font-size: 13.5px;
  line-height: 1.45;
}
html[data-theme] body.servgo-mail-v2 :is(.heading h1, .top h1) {
  font-size: clamp(21px, 2.6vw, 27px);
  font-weight: 550;
  letter-spacing: -0.038em;
  line-height: 1.12;
}
html[data-theme] body.servgo-mail-v2 :is(.panel h2, .panel-head, .detail h2, dialog h2) {
  font-weight: 550;
  letter-spacing: -0.03em;
  color: var(--s-text);
}
html[data-theme] body.servgo-mail-v2 :is(.brand, .metric strong, .number strong) {
  font-weight: 500;
  letter-spacing: -0.04em;
}
html[data-theme] body.servgo-mail-v2 :is(.metric small, .number small, .hint, .muted, .campaign small) {
  font-weight: 350;
  line-height: 1.45;
  color: var(--s-muted);
}
html[data-theme] body.servgo-mail-v2 :is(.btn, .primary, .secondary, .outline, .danger, .back-admin,
  .mail-v3-popover > summary, .mail-workspace-links .mail-workspace-link) {
  font-family: var(--ds-font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.015em;
  border-radius: 13px;
  box-shadow: none;
}
html[data-theme] body.servgo-mail-v2 :is(.btn:not(.alt):not(.light):not(.warn):not(.danger), .primary) {
  background: var(--s-accent-grad);
  color: var(--s-accent-ink);
}
html[data-theme] body.servgo-mail-v2 :is(.btn.alt, .btn.light, .secondary, .outline, .back-admin) {
  border: 0;
  background: var(--s-surface-2);
  color: var(--s-muted);
}
html[data-theme] body.servgo-mail-v2 :is(.panel,.metric,.number,.auto) {
  background: var(--s-surface);
  border-color: var(--s-line);
  color: var(--s-text);
}
html[data-theme] body.servgo-mail-v2 :is(.field input,.field textarea,.field select,#search-dialog select) {
  font-family: var(--ds-font);
  border-radius: 13px;
  background: var(--s-surface-2);
  color: var(--s-text);
  border-color: transparent;
  font-weight: 350;
}
html[data-theme] body.servgo-mail-v2 :is(.field input,.field textarea,.field select,#search-dialog select):focus-visible {
  outline: 2px solid var(--s-accent);
  outline-offset: 1px;
}
html[data-theme] body.servgo-mail-v2 :is(.mail-v3-dock, .mail-v3-nav) {
  background: var(--s-bg);
  border-color: transparent;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav {
  gap: 0;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a {
  min-height: 54px;
  gap: 4px;
  padding: 3px 1px 5px;
  border-radius: 0;
  background: transparent;
  color: var(--s-muted-2);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 1.05;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a[aria-current] {
  color: var(--s-accent);
  background: transparent;
  font-weight: 500;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-nav a svg {
  display: block;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
html[data-theme] body.servgo-mail-v2 .mail-v3-dock {
  padding: 3px 8px calc(5px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 25px rgba(45,92,146,.018);
}
html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-link {
  border-radius: 13px;
  font-weight: 500;
}
html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-studio {
  background: var(--s-accent-soft);
  color: var(--s-accent);
}
@media (max-width: 650px) {
  html[data-theme] body.servgo-mail-v2 .mail-workspace-links .mail-workspace-link {
    font-size: 11px;
    padding-inline: 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme] body.servgo-mail-v2 .mail-v3-nav a::after {animation:none;}
}
