/* Stock Radar light/dark palettes. Loaded after site and login styles. */
html[data-theme="light"]{color-scheme:light}
html[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0c1423;
  --ink:#edf4ff;
  --muted:#a0b3cd;
  --line:#293d56;
  --accent:#82adff;
  --navy:#eaf2ff;
  --green:#55ddaa;
  --red:#ff8691;
  --white:#142238;
  --surface:#142238;
  --surface-raised:#1b2b42;
  --surface-hover:#243754;
  --surface-input:#111e32;
  --text-secondary:#a8bcd6;
  --text-heading:#f3f7ff;
  --border-soft:#334a66;
}
.theme-control{
  display:inline-flex;align-items:center;gap:7px;font-weight:700;
  font-size:12px;color:var(--muted);white-space:nowrap
}
.theme-control select{
  font:inherit;min-height:36px;padding:6px 26px 6px 10px;
  color:var(--ink);background:var(--white);
  border:1px solid var(--line);border-radius:9px;max-width:142px;
}
.theme-control select:focus-visible,
.theme-control select:hover{border-color:var(--accent)}
.theme-control select:focus-visible{
  outline:2px solid var(--accent);outline-offset:2px
}
.login-head{display:flex;justify-content:space-between;align-items:center;gap:10px}
.login-head .logo{min-width:0}
.login-head .theme-control{font-size:11px}
.login-head .theme-control select{max-width:120px;font-size:12px}
@media(max-width:640px){
  .topbar{padding:0 14px;gap:10px}
  .topbar .theme-control>span{display:none}
  .topbar .theme-control select{font-size:12px;max-width:114px;min-height:34px}
  .topbar .header-right{gap:8px}
  .topbar .icon-button{margin-left:0}
}
@media(max-width:480px){
  .topbar .brand{font-size:19px;white-space:nowrap;letter-spacing:-.6px}
  .topbar .badge-small{display:none}
  .topbar .header-right #healthLabel{display:none}
}
@media(max-width:380px){
  .topbar .theme-control select{max-width:104px}
  .login-head{align-items:flex-start;flex-wrap:wrap}
}

/* Foundation: surfaces must all be dark, not just the page body. */
html[data-theme="dark"] body{background:var(--bg);color:var(--ink)}
html[data-theme="dark"] ::selection{background:#305d9d;color:#fff}
html[data-theme="dark"] .topbar{background:rgba(15,25,42,.96);border-color:var(--line)}
html[data-theme="dark"] .brand{color:#f2f6ff}
html[data-theme="dark"] .badge-small{color:#a6c2f0;background:#213958}
html[data-theme="dark"] .icon-button{background:var(--surface);color:#d9e7ff;border-color:var(--line)}
html[data-theme="dark"] :is(.metric,.panel,.minute-row){
  background:var(--surface);color:var(--ink);border-color:var(--line);
  box-shadow:0 10px 32px #00000018
}
html[data-theme="dark"] :is(.node-card,.zip-editor,.purchase-mode,.military-verification){
  background:var(--surface-raised);color:var(--ink);border-color:var(--line)
}
html[data-theme="dark"] :is(.metric,.panel,.node-card,.minute-row,.zip-editor,.military-verification,.purchase-mode){
  transition:background-color .15s ease,border-color .15s ease
}

/* Headings, labels and supporting copy (many originally hard-coded in blue-gray). */
html[data-theme="dark"] :is(.lead,.secondary-link,.metric small,.settings-row small,.browser-test small,
 .event-content small,.event time,.node-details,.node-note,
 .zip-editor small,.capacity-region-head small,.capacity-stat small,
 .capacity-stats-note,.purchase-mode-hint,.military-status-row small,.military-verification-note,
 .checkout-note,.test-result,.minute-insights-head p,.minute-column h5 small,.minute-row small,
 .minute-caveat,.minute-empty,.trend-heading p,.trend-summary span,.trend-legend,.footer,footer){
  color:var(--text-secondary)!important
}
html[data-theme="dark"] :is(.node-details b,.capacity-region-head strong,.minute-column h5,
 .minute-insights h4,.trend-summary strong,.military-status-row strong,.minute-row-primary,
 .capacity-stat strong,.zip-editor label,.minute-zip-selector,.trend-zip-selector,
 .minute-scope){
  color:var(--text-heading)
}
html[data-theme="dark"] :is(.node-status,.metric-label,.event time){color:var(--text-secondary)}
html[data-theme="dark"] :is(.node-status.online,.test-result.success){color:#66e6b5!important}
html[data-theme="dark"] :is(.node-status.degraded,.node-error){color:#fbc77b}
html[data-theme="dark"] .test-result.error{color:#ff8e98!important}
html[data-theme="dark"] .hero h1 em{
  background:linear-gradient(98deg,#82a9ff,#66d3ec);
  -webkit-background-clip:text;background-clip:text;color:transparent
}
html[data-theme="dark"] .secondary-link{color:#aec9f8!important}
html[data-theme="dark"] .hero-visual{filter:drop-shadow(0 24px 25px #0006)}
html[data-theme="dark"] .dot.online,
html[data-theme="dark"] .pulse-mini{box-shadow:0 0 0 4px #16523d}

/* Controls: native inputs must never stay bright on a dark screen. */
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea,
 .settings-row select,.zip-editor select,.zip-editor input,.minute-zip-selector select,.trend-zip-selector select){
  background:var(--surface-input);color:var(--ink);border-color:var(--border-soft)
}
html[data-theme="dark"] :is(input,select,textarea)::placeholder{color:#8197b5}
html[data-theme="dark"] :is(input:not([type="checkbox"]),select,textarea):focus-visible{
  border-color:var(--accent);outline:2px solid var(--accent);outline-offset:2px
}
html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"]{accent-color:#82adff}
html[data-theme="dark"] .button.dark{
  color:#0c1a30;background:#97bcff
}
html[data-theme="dark"] .button.light{
  color:#d1e4ff;background:#284467;border:1px solid #3b5d83
}
html[data-theme="dark"] :is(.button.light,.icon-button,.segmented button,.trend-ranges button,.minute-windows button):hover{
  background:var(--surface-hover);color:#fff
}
html[data-theme="dark"] .button.dark:hover{background:#bbd3ff;color:#0c1a30}
html[data-theme="dark"] .primary-link{color:#0c1a30;background:#97bcff;box-shadow:0 9px 22px #223c6380}
html[data-theme="dark"] :is(.segmented,.trend-ranges,.minute-windows){
  background:#202e45
}
html[data-theme="dark"] :is(.segmented button,.trend-ranges button,.minute-windows button){color:#b4c7de}
html[data-theme="dark"] :is(.segmented button.selected,.trend-ranges button.active,.minute-windows button.active){
  background:#38557b;color:#f8fbff;box-shadow:0 2px 8px #0003
}
html[data-theme="dark"] .purchase-mode:has(input:checked){
  background:#233d60;color:#cbe1ff;border-color:#608cce;box-shadow:0 0 0 1px #436a9c
}
html[data-theme="dark"] :is(.chip,.notification-setup,.topic-box code){
  background:#1c2e49;color:#bdd5fb;border-color:var(--line)
}
html[data-theme="dark"] .chip button{color:#b0c1da}
html[data-theme="dark"] .theme-control select{background:var(--surface-input);color:var(--ink)}

/* Inventory states, node statuses and checkout status. */
html[data-theme="dark"] .watch-badge{background:#183e36;color:#83edbf}
html[data-theme="dark"] .node-mark.online{box-shadow:0 0 0 4px #1b5140}
html[data-theme="dark"] .node-mark.degraded{box-shadow:0 0 0 4px #564226}
html[data-theme="dark"] .activity-icon{background:#213b5a;color:#9fcbff}
html[data-theme="dark"] .military-status-badge{background:#614925;color:#ffdf9e}
html[data-theme="dark"] .military-status-badge.confirmed{background:#19533d;color:#95f9cc}
html[data-theme="dark"] .military-status-badge.stale{background:#63382e;color:#ffb19c}
html[data-theme="dark"] .quickbuy-panel{border-color:#367f69}
html[data-theme="dark"] .quickbuy-status{background:#523a24;color:#ffd69b}
html[data-theme="dark"] .quickbuy-status.yes{background:#1c4c39;color:#94ffcc}
html[data-theme="dark"] .error-banner{background:#4a3024;border-color:#926147;color:#ffd5a9}
html[data-theme="dark"] .toast{background:#284467;color:#f7fbff}
html[data-theme="dark"] footer{border-color:var(--line)}

/* Historical inventory cards and dark chart axes. Preserve capacity bar colors. */
html[data-theme="dark"] .capacity-stat{
  background:linear-gradient(135deg,#203755,#18283e);
  border-color:var(--line)
}
html[data-theme="dark"] .capacity-stat span{color:#a4c8fb}
html[data-theme="dark"] .trend-chart-scroll{
  background:linear-gradient(180deg,#15243a,#121f33);
  border-color:var(--line)
}
html[data-theme="dark"] .trend-chart svg line{stroke:#38506d}
html[data-theme="dark"] .trend-chart svg text{fill:#b9cbe4}
html[data-theme="dark"] .minute-insights{background:#101e31;border-color:var(--line)}
html[data-theme="dark"] .minute-row{background:#1a2b43}
html[data-theme="dark"] .minute-meter{background:#2d4866}
html[data-theme="dark"] .minute-rank{color:#9db4d3}
html[data-theme="dark"] .minute-row .minute-stores{color:#91a9c9!important}

/* Login page has inline CSS and uses the same shared theme preference. */
html[data-theme="dark"] body.login-page{
  background:radial-gradient(circle at 80% 20%,#182e4d,transparent 38%),#0c1423;
  color:#f1f6ff
}
html[data-theme="dark"] body.login-page .card{
  background:#142238;border-color:#2c405a;box-shadow:0 22px 65px #0006
}
html[data-theme="dark"] body.login-page p{color:#b1c2d9}
html[data-theme="dark"] body.login-page .foot{color:#91a9c5}
html[data-theme="dark"] body.login-page #error{color:#ff9aab}
html[data-theme="dark"] body.login-page .theme-control{color:#b7c9e1}
html[data-theme="dark"] body.login-page input{
  background:#111e32;color:#f1f6ff;border-color:#354c68
}
html[data-theme="dark"] body.login-page input::placeholder{color:#8da2c0}
@media(prefers-reduced-motion:reduce){
  html[data-theme="dark"] :is(.metric,.panel,.node-card,.minute-row,.zip-editor,.military-verification,.purchase-mode){transition:none}
}


/* Dark-mode treatment for navigation and activity ZIP selector. */
html[data-theme="dark"] .dashboard-tabs-wrap{background:var(--bg)}
html[data-theme="dark"] .dashboard-tabs{background:#19283d;border-color:var(--line)}
html[data-theme="dark"] .dashboard-tabs button{color:#b6c9e4}
html[data-theme="dark"] .dashboard-tabs button[aria-selected="true"]{background:#34557c;color:#f7fbff;box-shadow:0 2px 8px #0004}
html[data-theme="dark"] .dashboard-tabs button:hover:not([aria-selected="true"]){background:#274360}
html[data-theme="dark"] .dashboard-quick-action{background:var(--surface);border-color:var(--line);color:var(--ink)}
html[data-theme="dark"] .activity-zip-selector{color:var(--text-secondary)}
html[data-theme="dark"] .activity-zip-selector select{background:var(--surface-input);border-color:var(--border-soft);color:var(--ink)}
