/* Design 3 app layer. Kept after the legacy page CSS so existing forms and routes retain their behavior. */
:root {
  color-scheme: light;
  /* CD-814: the Ask light ground — a warm page with white surfaces on it
     (ask-design3.css, body.ask-page[data-ask-theme="light"] .chat-shell). */
  --paper-0: #ffffff;
  --paper-1: #f4f4f1;
  --paper-2: #efefec;
  --paper-3: #e3e3df;
  --ink-0: #17181a;
  --ink-1: #1d1f1e;
  --ink-2: #545756;
  --ink-3: #868988;
  --violet: #7f5dea;
  --violet-deep: #5c3fc0;
  --violet-wash: #efeafb;
  --neon: #7f5dea;
  --neon-deep: #5c3fc0;
  --surface-page: #f4f4f1;
  --surface-card: #ffffff;
  --surface-sunken: #efefec;
  --text-body: #17181a;
  --text-muted: #545756;
  --text-faint: #868988;
  --border-soft: #e3e3df;
  --border-hard: #d6d6d1;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #efefec;
  --surface-3: #e3e3df;
  --text: #17181a;
  --text-2: #545756;
  --muted: #868988;
  --border: #e3e3df;
  --border-strong: #d6d6d1;
  /* CD-814: the call to action of the Ask page — ink pill in light, cream pill in dark. */
  --cta: #17181a;
  --cta-hover: #2a2c2e;
  --cta-fg: #ffffff;
  /* CD-847: the lime call to action of the workflow screens (CD-837/840) — same in both themes. */
  --brand: #e1f233;
  --brand-ink: #111213;
  --accent: #7f5dea;
  --accent-hover: #5c3fc0;
  --accent-soft: #efeafb;
  --btn-primary-fg: #fff;
  --text-on-signal: #fff;
  --focus-ring: #8f73ee;
  --success: #2e6b3c;
  --warning: #96591f;
  --danger: #be2c56;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-button: 13px;
  --r-sm: 10px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --text-on-invert: #1e201f;
  --text-on-invert-muted: #545756;
  --fill-on-ink: #eaebe9;
  --fill-on-ink-strong: #efeafb;
  --border-on-ink: #e2e3e0;
}
:root[data-design3-theme="dark"] {
  color-scheme: dark;
  /* CD-814: the Ask dark ground (.chat-shell in HomeController::askPageCss). */
  --paper-0: #262827;
  --paper-1: #1b1d1c;
  --paper-2: #333534;
  --paper-3: #3e403f;
  --ink-0: #f2f3f1;
  --ink-1: #1b1d1c;
  --ink-2: #c6c8c6;
  --ink-3: #9a9c9b;
  --violet: #7f5dea;
  --violet-deep: #c3b0fb;
  --violet-wash: #3a3157;
  --neon: #7f5dea;
  --neon-deep: #9678f0;
  --surface-page: #1b1d1c;
  --surface-card: #262827;
  --surface-sunken: #333534;
  --text-body: #f2f3f1;
  --text-muted: #c6c8c6;
  --text-faint: #9a9c9b;
  --border-soft: #2c2e2d;
  --border-hard: #3a3c3b;
  --bg: #1b1d1c;
  --surface: #262827;
  --surface-2: #333534;
  --surface-3: #3e403f;
  --text: #f2f3f1;
  --text-2: #c6c8c6;
  --muted: #9a9c9b;
  --border: #2c2e2d;
  --border-strong: #3a3c3b;
  --cta: #ddd9ce;
  --cta-hover: #ccc7b8;
  --cta-fg: #1e201f;
  --accent: #7f5dea;
  --accent-hover: #9678f0;
  --accent-soft: #3a3157;
  --btn-primary-fg: #fff;
  --text-on-signal: #fff;
  --success: #6fbf82;
  --warning: #dfa36b;
  --danger: #ed7d92;
  /* CD-442: the status washes sit behind --text; the light washes from
     BrandTokensCss would put light text on a light fill here. */
  --success-soft: #1f3a2a;
  --warning-soft: #3d2c1c;
  --danger-soft: #3f1e27;
  --info-soft: #333534;
  --text-on-invert: #f2f3f1;
  --text-on-invert-muted: #adafae;
  --fill-on-ink: #333534;
  --fill-on-ink-strong: #3a3157;
  --border-on-ink: #2c2e2d;
  /* CD-721: the CI token names (docs/ui/resources/tokens.css) are not on the
     runtime layer yet, so screens written against them (channels,
     connections, account …) fell back to their light literals and showed
     white grounds under the dark --text. Light keeps the fallbacks; dark
     defines them here. --white is the raised surface on a --wash-muted
     panel, --ink the inverted fill, exactly mirroring the light pairs. */
  --white: #333534;
  --wash-muted: #262827;
  --ink: #f2f3f1;
  --ink-soft: #c6c8c6;
  --ink-faint: #9a9c9b;
  --text-interactive: #c3b0fb;
  --accent-ink: #9678f0;
  --accent-deep: #9678f0;
  --tint-violet: #3a3157;
  --tint-lime: #2b3317;
  --tint-sage: #1f3a2a;
  --tint-sky: #1c2b42;
  --tint-clay: #3d2a1e;
  --mark-sage: #6fbf82;
  --mark-clay: #dfa36b;
  --mark-sky: #6f9fe6;
  --mark-violet: #9678f0;
  --mark-lime: #b5cc3a;
}
body { background: var(--bg); color: var(--text); font-family: 'Geist', sans-serif; font-size: 13.5px; }
header.topbar { background: var(--bg); color: var(--text); border-bottom: 1px solid var(--border); box-shadow: none; }
header.topbar .logo img:first-child { filter: invert(1); }
:root[data-design3-theme="dark"] header.topbar .logo img:first-child { filter: none; }
header.topbar nav a { color: var(--text-2); }
header.topbar nav a:hover { color: var(--text); background: var(--surface-2); }
header.topbar .user-menu-toggle { color: var(--text); border-color: var(--border); }
header.topbar .user-menu-toggle:hover { color: var(--text); background: var(--surface-2); border-color: var(--border-strong); }
.design3-theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 10px; flex: none; width: 38px; height: 38px; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; font: 500 13px 'Geist', sans-serif; }
.design3-theme-toggle:hover { background: var(--surface-2); border-color: var(--border-strong); }
/* CD-717: the icon shows the current App Theme mode (light/dark/auto). */
.design3-theme-toggle :is(.design3-theme-sun, .design3-theme-moon, .design3-theme-auto) { display: none; font-size: 20px; line-height: 1; }
:root:not([data-design3-theme-mode="dark"]):not([data-design3-theme-mode="auto"]) .design3-theme-toggle .design3-theme-sun,
:root[data-design3-theme-mode="dark"] .design3-theme-toggle .design3-theme-moon,
:root[data-design3-theme-mode="auto"] .design3-theme-toggle .design3-theme-auto { display: inline; }
header.topbar .user-menu-avatar { background: var(--violet); color: #fff; border-radius: 11px; }
header.topbar .topbar-search { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.topbar-mobile-heading { display: none; }
:root[data-design3-theme="dark"] #system-health-banner { background: #33291d; border-color: #33291d; color: #dfa36b; }
:root[data-design3-theme="dark"] #system-health-banner .sys-health-dot { background: #dfa36b; }
:root[data-design3-theme="dark"] #system-health-banner .sys-health-cta { background: #382f23; border-color: #70543a; color: #f2f3f1; }
h1, h2, h3, h4, .content > h2:first-of-type { font-family: 'Geist', sans-serif; letter-spacing: -.01em; color: var(--text); }
body h1, body h2, body h3, body h4 { font-family: 'Geist', sans-serif !important; }
.content > h2:first-of-type, .content > h1:first-of-type { font-size: clamp(20px, 2.2vw, 24px); line-height: 1.2; font-weight: 700; }
.content { padding: 28px; max-width: 1480px; }
.content .lede { font-size: 13px; color: var(--text-2); }
.card { background: var(--surface); border: 0; border-radius: 16px; box-shadow: none; }
.dash-kpi { background: var(--surface); border: 0; border-radius: 16px; }
.empty-state .title { font: 600 16px/1.3 'Geist', sans-serif !important; }
.user-row { border: 0; border-radius: 16px; padding: 16px; }
.user-row:hover { background: var(--surface-2); }
.card h3 { font-size: 15px; }
.shell { grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
body:has(.sidebar-settings) > header.topbar { display: none; }
.sidebar-settings { display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; padding: 18px 14px 14px; background: var(--bg); border-right: 0; color: var(--text); }
body:has(#system-health-banner:not([hidden])) .sidebar-settings { height: calc(100vh - 56px); top: 56px; }
body:has(.impersonate-banner) .sidebar-settings { height: calc(100vh - var(--impersonate-banner-h)); top: var(--impersonate-banner-h); }
.sidebar-settings .drawer-head { display: flex; padding: 2px 10px 22px; }
.drawer-brand img { display: block; width: 120px; height: auto; }
:root[data-design3-theme="dark"] .drawer-brand img { filter: invert(1); }
.sidebar-settings .drawer-nav, .sidebar-settings .drawer-foot { display: none; }
.drawer-back { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; margin-bottom: 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 13px; font-weight: 500; }
.drawer-back:hover { background: var(--surface-3); color: var(--text); }
.drawer-zone { padding: 8px 12px 12px; color: var(--muted); font: 500 10px/1.2 'Geist Mono', monospace; letter-spacing: .16em; text-transform: uppercase; }
.sidebar-settings .side { position: static; top: auto; max-height: none; min-height: 0; overflow-y: auto; flex: 1; }
.sidebar-settings .side summary { padding: 10px 12px; color: var(--text); text-transform: none; letter-spacing: 0; font: 500 13.5px/1.3 'Geist', sans-serif; border-radius: 10px; }
.sidebar-settings .side summary::after, .sidebar-settings .side details.nested > summary::after { content: none; }
.sidebar-settings .side details[open] summary::after, .sidebar-settings .side details.nested[open] > summary::after { content: none; }
.sidebar-settings .side details a, .sidebar-settings .side a.top-sub { padding: 8px 12px 8px 36px; color: var(--text-2); font-size: 13px; border-radius: 10px; }
.sidebar-settings .side details.nested > summary { padding-left: 28px; font-size: 13px; color: var(--text-2); }
.sidebar-settings .side details.nested > a { padding-left: 48px; }
.sidebar-settings .side .side-section-divider, .sidebar-settings .side .side-sub-cat { font: 500 10px/1.3 'Geist Mono', monospace; letter-spacing: .16em; color: var(--muted); }
.sidebar-settings .side .side-zone { margin: 18px 0 6px; padding: 7px 12px; font: 500 10px/1.3 'Geist Mono', monospace; letter-spacing: .16em; color: var(--muted); }
.sidebar-settings .side .side-section-divider::before, .sidebar-settings .side .side-section-divider::after { display: none; }
.sidebar-settings .side a.top, .sidebar-settings .side > a { color: var(--text); font-size: 13.5px; border-radius: 10px; }
.sidebar-settings .side :is(summary, a):hover { background: var(--surface-2); color: var(--text); }
.sidebar-settings .side :is(a.active, a.top.active, a.top-sub.active) { background: var(--surface); color: var(--text); font-weight: 500; }
.drawer-user-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; border-top: 0; padding: 10px 0 0; }
.drawer-user-footer .design3-theme-toggle { width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--surface-2); }
.drawer-user-footer .design3-theme-toggle:hover { background: var(--surface-3); }
.drawer-user-footer .user-menu { flex: 1 1 auto; min-width: 0; margin-left: 0; }
.drawer-user-footer .user-menu-toggle { width: 100%; justify-content: flex-start; border: 0; background: transparent; color: var(--text); }
.user-menu-identity { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.user-menu-company-name { font-size: 11px; font-weight: 400; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.topbar .user-menu-company-name { display: none; }
.drawer-user-footer .user-menu-avatar { background: var(--violet); color: #fff; border-radius: 50%; }
.drawer-user-footer .user-menu-dropdown { position: fixed; left: 12px; right: auto; top: auto; bottom: 66px; width: 252px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: none; }
.user-menu-dropdown { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.user-menu-dropdown a { color: var(--text); }
.user-menu-dropdown a:hover { background: var(--surface-2); }
button, .btn, input[type="submit"], input[type="button"] { border-radius: 13px; box-shadow: none; }
.btn-primary, .btn.primary, button.primary { background: var(--cta); color: var(--cta-fg); border-color: var(--cta); }
.btn-primary:hover, .btn.primary:hover, button.primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); color: var(--cta-fg); }
button.danger:not(.ghost), .btn.danger:not(.ghost) { background: #fae7eb; border-color: transparent; color: #c13853; }
:root[data-design3-theme="dark"] button.danger:not(.ghost), :root[data-design3-theme="dark"] .btn.danger:not(.ghost) { background: #382029; color: #ed7d92; }
button.danger:not(.ghost):hover, .btn.danger:not(.ghost):hover, .modal-footer button.danger:not(.ghost), .modal-footer .btn.danger:not(.ghost) { background: #d2455e; border-color: #d2455e; color: #fff; }
button.ghost.danger, .btn.ghost.danger { color: var(--danger); border-color: var(--danger); }
button.ghost.danger:hover, .btn.ghost.danger:hover { background: #d2455e; border-color: #d2455e; color: #fff; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select { border-radius: 12px; box-shadow: none; }
/* CD-386: background-color, not the shorthand — the shorthand reset background-image and wiped the select chevron in every card. */
.card .field :is(input, textarea, select) { background-color: var(--bg); border-color: transparent; }
:root[data-design3-theme="dark"] .card .field :is(input, textarea, select) { background-color: #232525; }
.field label { font-size: 12px; color: var(--text-2); }
button:active, .btn:active { transform: scale(.97); }
.tabs-underline button.active { color: var(--violet-deep); }
.modal-scrim { background: rgb(30 32 31 / 45%); }
.modal-panel { border: 0; border-radius: 20px; box-shadow: none; }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-panel--confirm { max-width: 420px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #8f73ee; outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--violet); }
table { border-collapse: collapse; }
table th { font: 500 10px/1.3 'Geist Mono', monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
table td { border-top: 1px solid var(--border); }
table tr:hover td { background: var(--surface-2); }
.badge, .chip, .tag { border-radius: 10px; }
/* CD-837: flash banners are not in this list. Their dark grounds (--success-soft, --warning-soft) are
   dark too, so --ink-1 (#1b1d1c) on them was unreadable; they keep --text from globalCss(). */
:root[data-design3-theme="dark"] :is(.chip-enabled, .chip-warning, .chip-global, .badge.done, .badge.discovering, .badge.cancelling, .badge.skipped, .badge.gone, .badge.avail-ready, .role-badge.role-impersonating, .role-badge.role-company-admin) { color: var(--ink-1); }
@media (max-width: 1024px) {
  .design3-theme-toggle { min-width: 44px; min-height: 44px; }
  header.topbar > nav, header.topbar .user-menu { min-width: 0; }
  header.topbar .user-menu-toggle { max-width: 100%; }
  header.topbar .user-menu-name { max-width: 100%; }
  header.topbar .user-menu-avatar { flex-shrink: 0; }
  body:has(.sidebar-settings) > header.topbar { display: flex; background: var(--bg); color: var(--text); border-bottom: 1px solid var(--border); }
  body:has(.sidebar-settings) > header.topbar .logo img:first-child { filter: invert(1); }
  body:has(.sidebar-settings) > header.topbar .logo { display: none; }
  body:has(.sidebar-settings) .topbar-mobile-heading { display: flex; flex-direction: column; gap: 2px; color: var(--text); font-size: 15px; font-weight: 600; }
  .topbar-mobile-heading small { color: var(--muted); font: 500 9px/1.2 'Geist Mono', monospace; letter-spacing: .16em; }
  :root[data-design3-theme="dark"] body:has(.sidebar-settings) > header.topbar .logo img:first-child { filter: none; }
  .shell { grid-template-columns: 1fr; min-height: calc(100vh - 52px); }
  .sidebar-settings { min-height: auto; height: auto; position: static; }
  body:has(#system-health-banner:not([hidden])) .sidebar-settings, body:has(.impersonate-banner) .sidebar-settings { height: auto; }
  html.js-drawer .sidebar-settings { width: min(322px, 88vw); max-width: none; background: var(--bg); }
  .sidebar-settings .drawer-nav { display: flex; }
  .sidebar-settings .drawer-foot { display: block; }
  .sidebar-settings .drawer-user-footer { margin-top: 32px; }
  .content { padding: 24px; }
  .sidebar-settings .side summary, .sidebar-settings .side details a, .sidebar-settings .side a.top { min-height: 48px; }
  .sidebar-settings .drawer-head { padding-bottom: 10px; }
  .sidebar-settings .drawer-close { color: var(--text); }
  .nav-scrim { background: color-mix(in srgb, #1e201f 45%, transparent); }
}
@media (max-width: 640px) {
  .content { padding: 20px 16px 30px; }
  .card { padding: 18px; }
  .content > h2:first-of-type { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
