/* Design 3 app layer. Kept after the legacy page CSS so existing forms and routes retain their behavior. */
:root {
  color-scheme: light;
  --paper-0: #f4f5f3;
  --paper-1: #fff;
  --paper-2: #eaebe9;
  --paper-3: #e2e3e0;
  --ink-0: #1e201f;
  --ink-1: #1d1f1e;
  --ink-2: #545756;
  --ink-3: #868988;
  --violet: #7f5dea;
  --violet-deep: #5c3fc0;
  --violet-wash: #efeafb;
  --neon: #7f5dea;
  --neon-deep: #5c3fc0;
  --surface-page: #fff;
  --surface-card: #f4f5f3;
  --surface-sunken: #eaebe9;
  --text-body: #1e201f;
  --text-muted: #545756;
  --text-faint: #868988;
  --border-soft: #e2e3e0;
  --border-hard: #d5d7d4;
  --bg: #fff;
  --surface: #f4f5f3;
  --surface-2: #eaebe9;
  --surface-3: #e2e3e0;
  --text: #1e201f;
  --text-2: #545756;
  --muted: #868988;
  --border: #e2e3e0;
  --border-strong: #d5d7d4;
  --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;
  --paper-0: #1d1f1e;
  --paper-1: #141615;
  --paper-2: #232525;
  --paper-3: #262828;
  --ink-0: #f2f3f1;
  --ink-1: #1d1f1e;
  --ink-2: #adafae;
  --ink-3: #6e7170;
  --violet: #7f5dea;
  --violet-deep: #9678f0;
  --violet-wash: #2c2543;
  --neon: #7f5dea;
  --neon-deep: #9678f0;
  --surface-page: #141615;
  --surface-card: #1d1f1e;
  --surface-sunken: #232525;
  --text-body: #f2f3f1;
  --text-muted: #adafae;
  --text-faint: #6e7170;
  --border-soft: #262828;
  --border-hard: #2e3130;
  --bg: #141615;
  --surface: #1d1f1e;
  --surface-2: #232525;
  --surface-3: #262828;
  --text: #f2f3f1;
  --text-2: #adafae;
  --muted: #6e7170;
  --border: #262828;
  --border-strong: #2e3130;
  --accent: #7f5dea;
  --accent-hover: #9678f0;
  --accent-soft: #2c2543;
  --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: #232525;
  --text-on-invert: #f2f3f1;
  --text-on-invert-muted: #adafae;
  --fill-on-ink: #232525;
  --fill-on-ink-strong: #2c2543;
  --border-on-ink: #262828;
}
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); }
.design3-theme-toggle .design3-theme-sun { display: none; }
:root[data-design3-theme="dark"] .design3-theme-toggle .design3-theme-moon { display: none; }
:root[data-design3-theme="dark"] .design3-theme-toggle .design3-theme-sun { display: inline; }
.design3-theme-toggle :is(.design3-theme-moon, .design3-theme-sun) { font-size: 20px; line-height: 1; }
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: 236px 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 12px 12px; background: var(--bg); border-right: 1px solid var(--border); color: var(--text); }
body:has(#system-health-banner:not([hidden])) .sidebar-settings { height: calc(100vh - 56px); top: 56px; }
.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: block; padding: 9px 12px; margin-bottom: 16px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-size: 13px; }
.drawer-back:hover { background: var(--surface-2); 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(--violet-wash); color: var(--violet-deep); font-weight: 500; }
.sidebar-settings .side :is(a.active, a.top.active, a.top-sub.active)::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--violet); display: inline-block; margin-left: 6px; vertical-align: middle; }
.drawer-user-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 0 0; }
.drawer-user-footer .design3-theme-toggle { justify-content: flex-start; width: 100%; height: 42px; padding: 0 12px; margin-bottom: 6px; border: 0; background: transparent; }
.drawer-user-footer .design3-theme-toggle:hover { background: var(--surface-2); }
.drawer-user-footer .design3-theme-label { font-size: 13px; }
.drawer-user-footer .user-menu { width: 100%; }
.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: 11px; }
.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-theme { display: block; width: 100%; padding: 10px 14px; background: transparent; border: 0; border-radius: 10px; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.user-menu-theme:hover { background: var(--surface-2); }
.user-menu-theme[aria-pressed="true"]::after { content: '✓'; float: right; color: var(--violet); }
.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(--violet); color: #fff; border-color: var(--violet); }
.btn-primary:hover, .btn.primary:hover, button.primary:hover { background: var(--violet-deep); border-color: var(--violet-deep); color: #fff; }
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; }
:root[data-design3-theme="dark"] :is(.flash-banner.flash-warning, .flash-banner.flash-success, .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 { 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; } }
