/* ============================================================
   MyBowser — DARK THEME (opt-in)
   Loaded only when the saved preference or ?theme= URL param is
   "dark" (see index.html); light is the default theme. Mostly
   token overrides, plus targeted fixes for chart chrome, the
   logo and a handful of hand-tuned colours.
   ============================================================ */

:root {
  color-scheme: dark;

  /* surfaces */
  --page:         #0B1526;
  --surface:      #101E33;
  --surface-2:    #16273F;
  --surface-3:    #1C3049;
  --border:       rgba(255,255,255,0.09);
  --border-soft:  rgba(255,255,255,0.05);

  /* ink */
  --ink:          #EAF1FB;
  --ink-2:        #B7C4DA;
  --ink-3:        #7C8FAE;
  --grid:         rgba(255,255,255,0.07);
  --axis:         rgba(255,255,255,0.2);

  /* categorical series (dark-surface steps) */
  --s1: #5B9BFF;
  --s2: #FFB454;
  --s3: #3FD1A5;
  --s4: #C99BFF;
  --s5: #FF8FB3;

  /* fuel accent, brightened to stay legible on navy surfaces */
  --fuel:      #FFB454;
  --fuel-deep: #F0C987;

  --shadow: 0 12px 32px rgba(0,0,0,0.5);
}

/* ambient glow: stronger on dark */
body::before { background: radial-gradient(closest-side, rgba(91,155,255,0.16), transparent 70%); }

/* ---------------- shell ---------------- */

.topbar {
  background: rgba(11, 21, 38, 0.85);
  border-bottom: 1px solid var(--border);
}

.sidebar { background: rgba(9, 17, 30, 0.6); }
.nav-item.sel, .zone-link.sel { background: rgba(91, 155, 255, 0.14); color: var(--brand); }

/* ---------------- cards & chrome ---------------- */

.kpi { background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.dev-card:hover { background: var(--surface-2); border-color: rgba(91, 155, 255, 0.5); }

.pill.online   { background: rgba(63, 209, 165, 0.14);  color: #6fe0bc; }
.pill.online .pd { background: #3FD1A5; }
.pill.sleep    { background: rgba(124, 143, 174, 0.18); color: var(--ink-2); }
.pill.sleep .pd { background: var(--ink-3); }
.pill.offline  { background: rgba(255, 107, 107, 0.16); color: #ff9d9d; }
.pill.offline .pd { background: #ff6b6b; }
.pill.alarmpill { background: rgba(255, 107, 107, 0.16); color: #ffa8a8; }
.pill.configpill { background: rgba(255, 180, 84, 0.16); color: #ffb454; }
.pill.configpill .pd { background: #ffb454; }

#error-banner, .alarm-banner {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.4);
  color: #ffd3d3;
}
.danger-box { background: rgba(255, 107, 107, 0.1); border-color: rgba(255, 107, 107, 0.4); color: #ffd3d3; }
.icon-btn.danger { color: #ff9d9d; border-color: rgba(255, 107, 107, 0.4); }
.icon-btn.danger:hover { background: rgba(255, 107, 107, 0.15); color: #ffc9c9; }

.gsm i { background: rgba(255, 255, 255, 0.16); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 45%, var(--surface-2) 65%);
}

/* ---------------- chart chrome ---------------- */

.chart-holder svg text { fill: #7c8fae; }
.chart-holder svg line { stroke: rgba(255,255,255,0.08); }
.chart-holder svg circle { stroke: var(--surface); }
.dev-spark svg rect.skeleton { fill: rgba(255,255,255,0.05); }

.viz-tip {
  background: #0c1526;
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 8px 24px rgba(0,0,0,0.55);
}

/* ---------------- misc ---------------- */

#toast { background: #12301d; color: #7fe0a4; border-color: rgba(63, 209, 165, 0.45); }

.chip.sel { color: #fff; }

.cmd-out { color: var(--ink-2); }
.cf-cmd { color: #82b4ff; }
.cf-resp { color: #6fe0bc; }
.cf-err { color: #ff9d9d; }
.cf-queued { color: #ffb454; }

.modal, #adm-veil .modal { background: var(--surface-2); }
.modal-veil { background: rgba(2, 6, 14, 0.65); }
.map-modal { background: var(--surface-2); }

.login-card { background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.kpi::after { opacity: 0.5; }
.login-msg.info { color: #7fe0a4; }

/* tank table editor */
table.tt-grid tr.captured td { color: #8fb8f5; }
.tt-warning { color: #f0c987; }
.tt-dirty { color: #f0c987; }
.tt-shape-fill { fill: rgba(91, 155, 255, 0.35); }
.tt-shape-surface { fill: rgba(91, 155, 255, 0.55); }
.cf-modebar.direct { background: rgba(63, 209, 165, 0.1); border-color: rgba(63, 209, 165, 0.35); color: #7fe0a4; }
.cf-modebar.script { background: rgba(255, 180, 84, 0.09); border-color: rgba(255, 180, 84, 0.35); color: #f0c987; }
.tt-warning, .cf-pulse-note { background: rgba(255, 180, 84, 0.1); border-color: rgba(255, 180, 84, 0.4); color: #f0c987; }

/* logo chip stays a light badge so the artwork keeps its own contrast */
.topbar .brand .logo-full,
.login-logo .login-logo-full { background: #fff; }

/* leaflet popup + map dots */
.leaflet-popup-content-wrapper { background: var(--surface-2); color: var(--ink); }
.leaflet-popup-tip { background: var(--surface-2); border-color: var(--border); }
.map-pop .mp-row.bad b { color: #ff8f8f; }
.map-pop .mp-row.good b { color: #7fe0a4; }

#notice-banner { background: rgba(255, 180, 84, 0.1); border-color: rgba(255, 180, 84, 0.4); color: #f0c987; }
