:root,
:root[data-theme="night"] {
  color-scheme: dark;
  --theme-bg: #0a0f0d;
  --theme-surface: #111815;
  --theme-surface-2: #18211c;
  --theme-surface-hover: #213428;
  --theme-line: #253129;
  --theme-text: #edf5ef;
  --theme-muted: #93a399;
  --theme-subtle: #bac8bf;
  --theme-accent: #00e5a0;
  --theme-accent-hover: #36efb7;
  --theme-accent-contrast: #032017;
  --theme-warn: #eabd6a;
  --theme-red: #ff8892;
  --theme-selected-bg: #123c2b;
  --theme-selected-text: #00e5a0;
  --theme-sidebar: #101713;
  --theme-topbar: #0e1511ed;
  --theme-code: #0b110d;
  --theme-field: #0c140e;
  --theme-field-border: #304235;
  --theme-focus: #46b27c;
  --theme-focus-ring: #00e5a014;
  --theme-placeholder: #617468;
  --theme-card-start: #151e18;
  --theme-card-end: #101712;
  --theme-table-head: #151f18;
  --theme-row-border: #21302680;
  --theme-row-hover: #1721197a;
  --theme-badge: #213329;
  --theme-badge-text: #bfcec4;
  --theme-success-bg: #123b28;
  --theme-success-text: #68eeb0;
  --theme-danger-bg: #3b2026;
  --theme-danger-text: #ff929a;
  --theme-warning-bg: #392f1a;
  --theme-warning-text: #efc578;
  --theme-info-bg: #1e3038;
  --theme-info-text: #88c9e5;
  --theme-neutral-bg: #262b28;
  --theme-neutral-text: #a3aea7;
  --theme-modal: #131d16;
  --theme-modal-line: #3a5141;
  --theme-backdrop: #020804c7;
  --theme-shadow: #0009;
  --theme-toast: #173b28;
  --theme-toast-line: #398855;
  --theme-toast-text: #dff8e6;
  --theme-toast-error: #3b2028;
  --theme-toast-error-line: #884151;
  --theme-toast-error-text: #ffe1e5;
  --theme-auth-start: #101c13;
  --theme-auth-end: #09100c;
  --theme-auth-glow: #194d2c4a;
}

:root[data-theme="light"] {
  color-scheme: light;
  --theme-bg: #f3f7f4;
  --theme-surface: #ffffff;
  --theme-surface-2: #e8f0eb;
  --theme-surface-hover: #dce9e1;
  --theme-line: #cbd8d0;
  --theme-text: #13241a;
  --theme-muted: #52685a;
  --theme-subtle: #415448;
  --theme-accent: #007a56;
  --theme-accent-hover: #006547;
  --theme-accent-contrast: #ffffff;
  --theme-warn: #8a5a00;
  --theme-red: #b42335;
  --theme-selected-bg: #d7f2e5;
  --theme-selected-text: #006b4a;
  --theme-sidebar: #eaf1ec;
  --theme-topbar: #f8fbf9ee;
  --theme-code: #edf3ef;
  --theme-field: #ffffff;
  --theme-field-border: #aebfb4;
  --theme-focus: #007a56;
  --theme-focus-ring: #007a5626;
  --theme-placeholder: #718279;
  --theme-card-start: #ffffff;
  --theme-card-end: #f7faf8;
  --theme-table-head: #e7efe9;
  --theme-row-border: #dbe5de;
  --theme-row-hover: #edf4ef;
  --theme-badge: #e3ebe6;
  --theme-badge-text: #3e5346;
  --theme-success-bg: #d8f3e5;
  --theme-success-text: #006c49;
  --theme-danger-bg: #fde3e6;
  --theme-danger-text: #a11d2f;
  --theme-warning-bg: #fff0c8;
  --theme-warning-text: #775000;
  --theme-info-bg: #dff1f7;
  --theme-info-text: #205f79;
  --theme-neutral-bg: #e8ece9;
  --theme-neutral-text: #4d5d52;
  --theme-modal: #ffffff;
  --theme-modal-line: #b9c9bf;
  --theme-backdrop: #0b1d1438;
  --theme-shadow: #1f3d2b26;
  --theme-toast: #e0f4e8;
  --theme-toast-line: #2b7f52;
  --theme-toast-text: #164c30;
  --theme-toast-error: #fde7ea;
  --theme-toast-error-line: #b94b5a;
  --theme-toast-error-text: #8c1d2c;
  --theme-auth-start: #e2f3e8;
  --theme-auth-end: #f5faf7;
  --theme-auth-glow: #b8e2c8;
}

:root {
  --bg: var(--theme-bg);
  --surface: var(--theme-surface);
  --surface-2: var(--theme-surface-2);
  --line: var(--theme-line);
  --muted: var(--theme-muted);
  --text: var(--theme-text);
  --accent: var(--theme-accent);
  --warn: var(--theme-warn);
  --red: var(--theme-red);
}

body{background:var(--theme-bg);color:var(--theme-text)}
a,.text-button{color:var(--theme-accent)}
.muted,.loading,.eyebrow,.breadcrumb,.help{color:var(--theme-muted)}
pre{background:var(--theme-code);border-color:var(--theme-line)}
.button{background:var(--theme-surface-2);color:var(--theme-text)}
.button:hover{background:var(--theme-surface-hover)}
.button.primary{background:var(--theme-accent);color:var(--theme-accent-contrast)}
.button.primary:hover{background:var(--theme-accent-hover)}
.button.secondary{border-color:var(--theme-line)}
.button.secondary:hover{border-color:var(--theme-muted);background:var(--theme-surface-2)}
.icon-button{color:var(--theme-muted)}
.icon-button:hover{background:var(--theme-surface-2);color:var(--theme-text)}
.top-link{color:var(--theme-subtle)}
.top-link:hover{color:var(--theme-accent)}
.brand small,.sidebar-bottom small{color:var(--theme-muted)}
.brand-icon{color:var(--theme-accent)}
.sidebar{border-color:var(--theme-line);background:var(--theme-sidebar)}
.nav-caption{color:var(--theme-muted)}
.nav-link{color:var(--theme-muted)}
.nav-link:hover{background:var(--theme-surface-2);color:var(--theme-text)}
.nav-link.selected{background:var(--theme-selected-bg);color:var(--theme-selected-text)}
.sidebar-bottom{border-color:var(--theme-line)}
.avatar{border-color:var(--theme-line);background:var(--theme-selected-bg);color:var(--theme-selected-text)}
.topbar{border-color:var(--theme-line);background:var(--theme-topbar)}
.breadcrumb span{color:var(--theme-muted)}
.context-select,.context-trigger{border-color:var(--theme-line);background:var(--theme-surface);color:var(--theme-text)}
.status-strip{color:var(--theme-subtle)}
.status-dot{background:var(--warn)}
.status-dot.live{background:var(--theme-accent);box-shadow:0 0 0 4px color-mix(in srgb,var(--theme-accent) 12%,transparent)}
.metric,.company-card{background:linear-gradient(140deg,var(--theme-card-start),var(--theme-card-end));border-color:var(--theme-line)}
.metric-top,.metric-top svg{color:var(--theme-muted)}
.metric small{color:var(--theme-muted)}
.panel{background:var(--theme-surface);border-color:var(--theme-line)}
th{color:var(--theme-muted);background:var(--theme-table-head);border-color:var(--theme-line)}
td{border-color:var(--theme-row-border)}
tbody tr:hover{background:var(--theme-row-hover)}
.badge{background:var(--theme-badge);color:var(--theme-badge-text)}
.badge.active,.badge.delivered{background:var(--theme-success-bg);color:var(--theme-success-text)}
.badge.inactive,.badge.dead{background:var(--theme-danger-bg);color:var(--theme-danger-text)}
.badge.retry{background:var(--theme-warning-bg);color:var(--theme-warning-text)}
.badge.pending,.badge.processing{background:var(--theme-info-bg);color:var(--theme-info-text)}
.badge.skipped{background:var(--theme-neutral-bg);color:var(--theme-neutral-text)}
.journey{border-color:var(--theme-line);background:radial-gradient(ellipse at right,color-mix(in srgb,var(--theme-accent) 12%,transparent),transparent 75%)}
.flow>svg{color:var(--theme-muted)}
.flow>span{border-color:var(--theme-line);background:var(--theme-surface-2);color:var(--theme-muted)}
.flow>span.active{color:var(--theme-selected-text);border-color:var(--theme-accent);background:var(--theme-selected-bg)}
.tab{color:var(--theme-muted)}
.tab.active{background:var(--theme-selected-bg);border-color:var(--theme-line);color:var(--theme-selected-text)}
.tab:hover{color:var(--theme-text)}
.company-card:hover{border-color:var(--theme-muted)}
.company-icon,.empty-icon,.logo-square{background:var(--theme-selected-bg);border-color:var(--theme-line);color:var(--theme-selected-text)}
.company-card>p,.card-lines>div>span:first-child,.empty p{color:var(--theme-muted)}
.card-lines{border-color:var(--theme-line)}
.field>span,.check-field{color:var(--theme-subtle)}
input,select,textarea{background:var(--theme-field);border-color:var(--theme-field-border);color:var(--theme-text)}
input:focus,textarea:focus,select:focus{border-color:var(--theme-focus);box-shadow:0 0 0 3px var(--theme-focus-ring)}
input::placeholder,textarea::placeholder{color:var(--theme-placeholder)}
.form-error{color:var(--red)}
.form-actions{border-color:var(--theme-line)}
.notice{background:var(--theme-selected-bg);color:var(--theme-text);border-color:var(--theme-line)}
.notice.warn{background:var(--theme-warning-bg);border-color:var(--theme-warning-text);color:var(--theme-warning-text)}
.modal{background:var(--theme-modal);color:var(--theme-text);border-color:var(--theme-modal-line);box-shadow:0 30px 100px var(--theme-shadow)}
.modal::backdrop{background:var(--theme-backdrop)}
#toast{background:var(--theme-toast);border-color:var(--theme-toast-line);color:var(--theme-toast-text);box-shadow:0 15px 50px var(--theme-shadow)}
#toast.error{border-color:var(--theme-toast-error-line);background:var(--theme-toast-error);color:var(--theme-toast-error-text)}
.auth{position:relative}
.auth-story{border-color:var(--theme-line);background:radial-gradient(ellipse at 15% 45%,var(--theme-auth-glow),transparent 65%),linear-gradient(135deg,var(--theme-auth-start),var(--theme-auth-end))}
.auth-story>.eyebrow{color:var(--theme-selected-text)}
.auth-story h1 span{color:var(--theme-accent)}
.auth-story>p,.auth-footer,.login-note{color:var(--theme-muted)}
.context-trigger:hover,.context-picker[open] .context-trigger{border-color:var(--theme-muted);background:var(--theme-surface-2)}
.context-menu{background:var(--theme-surface);border-color:var(--theme-modal-line);box-shadow:0 24px 70px var(--theme-shadow)}
.context-all,.context-group+.context-group{border-color:var(--theme-line)}
.context-option{color:var(--theme-text)}
.context-option:hover{background:var(--theme-surface-2)}
.context-option.selected{background:var(--theme-selected-bg);color:var(--theme-selected-text)}
.context-option small,.context-caption{color:var(--theme-muted)}
.context-children{border-color:var(--theme-line)}
.theme-toggle svg{pointer-events:none}
.auth-theme-toggle{position:fixed;top:22px;right:22px;z-index:30;width:42px;height:42px;background:var(--theme-surface);border:1px solid var(--theme-line);box-shadow:0 8px 25px var(--theme-shadow)}
@media(max-width:800px){.menu-open .sidebar{box-shadow:30px 0 70px var(--theme-shadow)}.auth-theme-toggle{top:15px;right:15px}}
