/* ============================================================
   MyBowser — light dashboard theme (default)
   Fuel-level & datalogger monitoring console.
   ============================================================ */

:root {
  color-scheme: light;

  /* brand */
  --brand:        #2E6BE0;
  --brand-deep:   #1E4FBE;
  --brand-ink:    #163F99;

  /* fuel accent (also doubles as the warning colour) */
  --fuel:         #E0930F;
  --fuel-deep:    #B9740A;

  /* surfaces */
  --page:         #EEF2F9;
  --surface:      #FFFFFF;
  --surface-2:    #F6F9FD;
  --surface-3:    #EAF0F9;
  --border:       rgba(20,40,80,0.11);
  --border-soft:  rgba(20,40,80,0.06);

  /* ink */
  --ink:          #172240;
  --ink-2:        #4C5C78;
  --ink-3:        #8392A9;
  --grid:         rgba(20,40,80,0.08);
  --axis:         rgba(20,40,80,0.32);

  /* categorical series (light-surface steps) */
  --s1: #2E6BE0;
  --s2: #DC8318;
  --s3: #12946A;
  --s4: #7C5CE0;
  --s5: #D9527F;

  /* status (fixed) */
  --good:     #178A45;
  --warning:  #E0930F;
  --serious:  #D96A32;
  --critical: #DC2626;

  --radius: 12px;
  --shadow: 0 10px 28px rgba(20,40,80,0.12);
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* soft brand wash behind the header */
body::before {
  content: "";
  position: fixed;
  top: -360px; left: 50%;
  width: 1200px; height: 640px;
  transform: translateX(-50%);
  background:
    radial-gradient(closest-side, rgba(46,107,224,0.10), transparent 72%);
  pointer-events: none;
  z-index: 0;
}

.wrap { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 0 24px 64px; }

/* ---------------- header ---------------- */

header.top {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 0 14px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand svg.mark { width: 58px; height: 47px; display: block; }
.brand .word { font-size: 1.72rem; font-weight: 700; letter-spacing: -0.5px; line-height: 1; }
.brand .word .c1 { color: var(--brand); }
.brand .word .c2 { color: var(--ink); }
.brand .tag { font-size: 0.74rem; color: var(--ink-3); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 4px; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.conn {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.conn.ok .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(23,138,69,0.5); animation: pulse 2.4s infinite; }
.conn.bad .dot { background: var(--critical); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(23,138,69,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(23,138,69,0); }
  100% { box-shadow: 0 0 0 0 rgba(23,138,69,0); }
}

button.icon-btn, a.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 13px; font: inherit; font-size: 0.84rem;
  cursor: pointer; text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
button.icon-btn:hover, a.icon-btn:hover { background: var(--surface-3); color: var(--ink); border-color: rgba(20,40,80,0.22); }
button.icon-btn svg, a.icon-btn svg { width: 16px; height: 16px; }
button.icon-btn.spin svg { animation: rot 0.9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------------- error banner ---------------- */

#error-banner {
  display: none; align-items: flex-start; gap: 10px;
  background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.35);
  color: #9c1f1f; border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0; font-size: 0.9rem;
}

/* ---------------- KPI strip ---------------- */

.kpi-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin: 18px 0 8px;
}

.kpi {
  background: linear-gradient(180deg, #ffffff, #fafcff);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px 14px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.6;
}
.kpi .k-label { font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.kpi .k-value { font-size: 1.9rem; font-weight: 700; margin-top: 2px; line-height: 1.15; }
.kpi .k-value small { font-size: 1rem; font-weight: 600; color: var(--ink-2); }
.kpi .k-sub { font-size: 0.78rem; color: var(--ink-3); margin-top: 2px; min-height: 1.1em; }
.kpi.alarm .k-value { color: var(--critical); }
.kpi.calm  .k-value { color: var(--good); }

/* ---------------- application sections ---------------- */

.app-section { margin-top: 30px; animation: rise 0.35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.app-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.app-head .app-icon {
  width: 42px; height: 42px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.app-head .app-icon svg { width: 24px; height: 24px; }
.app-head h2 { font-size: 1.06rem; font-weight: 650; }
.app-head .app-sub { font-size: 0.78rem; color: var(--ink-3); }
.app-head .count-pill {
  margin-left: auto; font-size: 0.75rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border);
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}

.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }

/* ---------------- device card ---------------- */

.dev-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px 14px;
  cursor: pointer; text-align: left; color: inherit; font: inherit;
  text-decoration: none;
  display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.16s ease, border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
.dev-card:hover {
  transform: translateY(-3px);
  border-color: rgba(46,107,224,0.45);
  background: #fbfcff;
  box-shadow: var(--shadow);
}

.dev-top { display: flex; align-items: flex-start; gap: 10px; }
.dev-name { font-weight: 650; font-size: 1rem; line-height: 1.25; }
.dev-serial { font-size: 0.76rem; color: var(--ink-3); margin-top: 1px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.pill .pd { width: 6px; height: 6px; border-radius: 50%; }
.pill.online   { background: rgba(23,138,69,0.12);  color: #0f7038; }
.pill.online .pd { background: var(--good); }
.pill.sleep    { background: rgba(76,92,120,0.13); color: #56647d; }
.pill.sleep .pd { background: #8a97ac; }
.pill.offline  { background: rgba(220,38,38,0.11); color: #b32323; }
.pill.offline .pd { background: var(--critical); }
.pill.alarmpill { background: rgba(220,38,38,0.11); color: #b32323; }
.pill.configpill { background: rgba(224,147,15,0.14); color: #8a5c08; }
.pill.configpill .pd { background: var(--fuel); }

.dev-pills { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }

.dev-spark { display: flex; align-items: flex-end; gap: 12px; min-height: 52px; }
.dev-spark svg { flex: 1; height: 46px; display: block; }
.spark-val { text-align: right; }
.spark-val .sv-fill { font-size: 1.3rem; font-weight: 800; color: var(--fuel-deep); line-height: 1.2; margin-bottom: 5px; }
.spark-val .sv-fill small { font-size: 0.72rem; font-weight: 600; color: var(--fuel-deep); opacity: 0.85; margin-left: 3px; text-transform: uppercase; letter-spacing: 0.03em; }
.spark-val .sv { font-size: 1.28rem; font-weight: 700; line-height: 1.05; }
.spark-val .sv small { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.spark-val .sl { font-size: 0.72rem; color: var(--ink-3); }

.dev-meta {
  display: flex; align-items: center; gap: 14px;
  font-size: 0.75rem; color: var(--ink-3);
  border-top: 1px solid var(--border-soft); padding-top: 9px;
  flex-wrap: wrap;
}
.dev-meta .m { display: inline-flex; align-items: center; gap: 5px; }
.dev-meta svg { width: 13px; height: 13px; opacity: 0.85; }

.gsm { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 12px; }
.gsm i { width: 3px; background: rgba(20,40,80,0.16); border-radius: 1px; display: block; }
.gsm i.on { background: var(--brand); }
.gsm i:nth-child(1){height:4px}.gsm i:nth-child(2){height:6px}
.gsm i:nth-child(3){height:9px}.gsm i:nth-child(4){height:12px}

.skeleton {
  background: linear-gradient(90deg, #e9eef7 25%, #f5f8fc 45%, #e9eef7 65%);
  background-size: 300% 100%; animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---------------- detail view ---------------- */

.back-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; flex-wrap: wrap; }
a.back-link {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--ink-2); text-decoration: none; font-size: 0.86rem;
  padding: 7px 13px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface);
  transition: color 0.15s, border-color 0.15s;
}
a.back-link:hover { color: var(--ink); border-color: rgba(20,40,80,0.25); }

.detail-head { display: flex; align-items: center; gap: 14px; margin: 14px 0 4px; flex-wrap: wrap; }
.detail-head .app-icon {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
}
.detail-head .app-icon svg { width: 30px; height: 30px; }
.detail-head h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.detail-head .d-sub { color: var(--ink-3); font-size: 0.84rem; }
.detail-head .d-pills { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.alarm-banner {
  display: flex; align-items: center; gap: 10px;
  background: rgba(220,38,38,0.08); border: 1px solid rgba(220,38,38,0.35);
  border-radius: var(--radius); padding: 11px 16px; margin: 12px 0;
  color: #9c1f1f; font-size: 0.9rem;
}
.alarm-banner svg { width: 18px; height: 18px; flex: none; color: var(--critical); }

.range-row { display: flex; align-items: center; gap: 8px; margin: 16px 0 14px; flex-wrap: wrap; }
.range-row .lbl { font-size: 0.8rem; color: var(--ink-3); margin-right: 4px; }
.chip {
  font: inherit; font-size: 0.9rem; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 15px; cursor: pointer;
  transition: all 0.14s;
}
.chip:hover { color: var(--ink); border-color: rgba(20,40,80,0.25); }
.chip.sel {
  color: #fff; background: linear-gradient(180deg, var(--brand), var(--brand-deep));
  border-color: transparent; font-weight: 600;
}
.range-month {
  font-size: 0.82rem; font-weight: 600; color: var(--brand);
  margin-left: 4px; padding: 6px 4px;
}

.detail-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.dk {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 16px 11px;
}
.dk .k-label { font-size: 0.72rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); }
.dk .k-value { font-size: 1.5rem; font-weight: 700; margin-top: 1px; }
.dk .k-value small { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.dk .k-sub { font-size: 0.74rem; color: var(--ink-3); }
.dk.status-bad .k-value { color: var(--critical); }
.dk.status-good .k-value { color: var(--good); }

/* fuel tank visual (application 044) — MyBowser's headline widget.
   A horizontal above-ground bowser. The card spans the full KPI row so it
   has room to sit beside the other tiles, but shrink-wraps to its own
   content (justify-self: start) instead of stretching into blank space. */
.fuel-card {
  grid-column: 1 / -1;
  justify-self: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 24px; display: flex; flex-direction: column; gap: 12px;
}
.fuel-title { font-size: 0.92rem; font-weight: 650; color: var(--ink); margin: 0; }
.fuel-subtitle { display: flex; align-items: baseline; gap: 8px; font-size: 0.78rem; color: var(--ink-3); margin-top: -8px; }
.fuel-subtitle span::after { content: ":"; }
.fuel-subtitle b { color: var(--ink); font-weight: 600; }
.fuel-body { display: flex; gap: 24px; align-items: center; }
.fuel-svg { width: 374px; flex: 0 0 auto; }
.fuel-wave { animation: fuelwave 3.2s ease-in-out infinite; }
@keyframes fuelwave { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(4px); } }
.fuel-facts { min-width: 235px; flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; }
.ff-row { display: flex; align-items: baseline; gap: 10px; font-size: 0.94rem; color: var(--ink-3); padding: 3.5px 0; border-bottom: 1px solid var(--border-soft); }
.ff-row:last-child { border-bottom: 0; }
.ff-row span { flex: none; min-width: 84px; }
.ff-row span::after { content: ":"; }
.ff-row b { color: var(--ink); font-weight: 650; font-size: 0.94rem; white-space: nowrap; }
@media (max-width: 700px) {
  .fuel-card { justify-self: stretch; }
  .fuel-body { flex-direction: column; align-items: flex-start; }
  .fuel-svg { width: 100%; max-width: 374px; }
}

.chart-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 940px) {
  .chart-grid.two { grid-template-columns: 1fr 1fr; }
  .chart-grid .span2 { grid-column: 1 / -1; }
}

.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px 10px;
  min-width: 0;
}
.chart-card h3 { font-size: 0.92rem; font-weight: 650; }
.chart-card .c-sub { font-size: 0.75rem; color: var(--ink-3); margin-bottom: 8px; }
.chart-card .legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 6px 0 2px; }
.chart-card .legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--ink-2); }
.chart-card .legend .sw { width: 14px; height: 3px; border-radius: 2px; }
.chart-empty { color: var(--ink-3); font-size: 0.85rem; padding: 34px 0; text-align: center; }

.chart-holder { position: relative; }
.chart-holder svg { display: block; width: 100%; height: auto; }
.chart-holder svg text { fill: #7d8da3; }
.chart-holder svg line { stroke: rgba(20,40,80,0.11); }
.chart-holder svg circle { stroke: #ffffff; }
.dev-spark svg rect.skeleton { fill: rgba(20,40,80,0.05); }

.viz-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #ffffff; border: 1px solid rgba(20,40,80,0.16);
  border-radius: 10px; padding: 8px 11px; font-size: 0.76rem;
  box-shadow: 0 8px 24px rgba(20,40,80,0.22);
  white-space: nowrap; display: none;
}
.viz-tip .tt { color: var(--ink-3); margin-bottom: 3px; }
.viz-tip .tr { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.viz-tip .tr b { color: var(--ink); font-weight: 650; margin-left: auto; padding-left: 12px; }
.viz-tip .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ---------------- info + table ---------------- */

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.info-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 18px;
}
.info-card h3 { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.info-card dl .row { display: flex; justify-content: space-between; gap: 14px; padding: 4.5px 0; border-bottom: 1px solid var(--border-soft); }
.info-card dl .row:last-child { border-bottom: 0; }
.info-card dt { color: var(--ink-3); font-size: 0.8rem; }
.info-card dd { font-size: 0.82rem; text-align: right; }
.info-card a { color: var(--brand); text-decoration: none; }
.info-card a:hover { text-decoration: underline; }

.table-card { margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table-card summary {
  cursor: pointer; padding: 14px 18px; font-size: 0.9rem; font-weight: 600;
  color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px;
}
.table-card summary::-webkit-details-marker { display: none; }
.table-card summary::after { content: "▾"; margin-left: auto; color: var(--ink-3); transition: transform 0.2s; }
.table-card[open] summary::after { transform: rotate(180deg); }
.table-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 0 18px 12px; border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.table-tools .tt-note { font-size: 0.76rem; color: var(--ink-3); margin-right: auto; }
.table-scroll { overflow-x: auto; padding: 0 10px 12px; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.79rem; }
table.data th {
  text-align: right; color: var(--ink-3); font-weight: 600; white-space: nowrap;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { padding: 6px 12px; text-align: right; white-space: nowrap; color: var(--ink-2); border-bottom: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }
table.data td:first-child { color: var(--ink); }
table.data tr:hover td { background: rgba(20,40,80,0.025); }

/* ---------------- settings modal ---------------- */

.modal-veil {
  position: fixed; inset: 0; background: rgba(15,26,46,0.42);
  display: none; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal-veil.open { display: flex; }
.modal {
  width: min(440px, calc(100vw - 40px));
  background: #ffffff; border: 1px solid var(--border);
  border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow);
}
.modal h2 { font-size: 1.05rem; margin-bottom: 14px; }
.modal label { display: block; font-size: 0.78rem; color: var(--ink-3); margin: 10px 0 4px; }
.modal input {
  width: 100%; font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px; outline: none;
}
.modal input:focus { border-color: var(--brand); }
.modal .m-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.modal .m-note { font-size: 0.78rem; margin-left: auto; }
.modal .m-note.ok { color: var(--good); }
.modal .m-note.bad { color: var(--critical); }
button.primary {
  font: inherit; font-size: 0.88rem; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--brand), var(--brand-deep));
  border: 0; border-radius: 10px; padding: 10px 20px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }

/* ---------------- footer ---------------- */

footer {
  margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--border-soft);
  color: var(--ink-3); font-size: 0.78rem;
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
}
footer .f-right { margin-left: auto; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .brand .word { font-size: 1.4rem; }
  .kpi .k-value { font-size: 1.5rem; }
}

/* ============================================================
   Shell: topbar + sidebar + login + admin forms
   ============================================================ */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
}
.topbar .brand svg.mark { width: 52px; height: 31px; }
.topbar .brand .word { font-size: 1.35rem; }
.topbar .brand .tag { margin-top: 1px; font-size: 0.64rem; }

.user-box { display: flex; align-items: center; gap: 8px; margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--border); }
#user-chip .uc-name { font-size: 0.84rem; font-weight: 600; line-height: 1.2; }
#user-chip .uc-type { font-size: 0.7rem; color: var(--ink-3); }

.body-row { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 250px; flex: none;
  border-right: 1px solid var(--border-soft);
  padding: 14px 10px 24px;
  background: rgba(255, 255, 255, 0.5);
  overflow-y: auto;
  position: sticky; top: 71px;
  align-self: flex-start;
  max-height: calc(100vh - 71px);
}
.login-mode .sidebar { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none; font-size: 0.86rem;
  margin-bottom: 2px;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.sel { background: rgba(46, 107, 224, 0.12); color: var(--brand); }
.nav-item.sub { padding-left: 30px; font-size: 0.8rem; }
.nav-item .nav-count {
  margin-left: auto; font-size: 0.68rem; color: var(--ink-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 1px 8px;
}
.nav-sep {
  font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 12px 6px;
}
.tree-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.tree-dot.alarm { background: var(--critical); }

/* collapsible zone rows */
.zone-row { padding: 0; gap: 0; background: none; }
.zone-row:hover { background: none; }
.nav-caret {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 24px; align-self: stretch; padding: 0; margin: 0;
  background: none; border: none; cursor: pointer; color: var(--ink-3);
  border-radius: 9px 0 0 9px;
}
.nav-caret svg { width: 14px; height: 14px; transition: transform 0.15s ease; }
.zone-row.open .nav-caret svg { transform: rotate(90deg); }
.nav-caret:hover:not(:disabled) { color: var(--brand); background: var(--surface-3); }
.nav-caret:disabled { opacity: 0; cursor: default; }
.zone-link {
  display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0;
  padding: 8px 12px 8px 3px; border-radius: 0 9px 9px 0;
  color: var(--ink-2); text-decoration: none; font-size: 0.86rem;
}
.zone-link:hover { background: var(--surface-3); color: var(--ink); }
.zone-link.sel { background: rgba(46, 107, 224, 0.12); color: var(--brand); }
.zone-link > span:not(.tree-dot):not(.nav-count) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-link .nav-count {
  margin-left: auto; font-size: 0.68rem; color: var(--ink-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 1px 8px;
}

.content { flex: 1; min-width: 0; }
.content .wrap { padding-top: 18px; }

.page-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.4rem; }
.page-head .page-sub { color: var(--ink-3); font-size: 0.8rem; }
.page-head .primary, .page-head button { margin-left: auto; }
.page-head h1 + .page-sub { margin-left: 0; }
.page-head .page-sub { margin-left: auto; }

.crumb { color: var(--brand); text-decoration: none; }
.crumb:hover { text-decoration: underline; }

.warn-text { color: var(--fuel-deep) !important; }
.icon-btn.sm { padding: 4px 9px; font-size: 0.74rem; border-radius: 7px; }
.icon-btn.danger { color: #b32323; border-color: rgba(220, 38, 38, 0.35); }
.icon-btn.danger:hover { background: rgba(220, 38, 38, 0.1); color: #8f1a1a; }
button.primary.danger { background: linear-gradient(180deg, #e24444, #b92e2e); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------- login ---------------- */

.login-wrap { display: flex; justify-content: center; padding: 9vh 12px 40px; }
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, #ffffff, #fafcff);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 30px 32px 26px; box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo .word { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.5px; }
.login-logo .tag { display: block; font-size: 0.72rem; color: var(--ink-3); letter-spacing: 0.14em; text-transform: uppercase; margin-top: 5px; }
.login-card label { display: block; font-size: 0.76rem; color: var(--ink-3); margin: 12px 0 4px; }
.login-card input {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 13px; outline: none;
}
.login-card input:focus { border-color: var(--brand); }
/* password field with show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 40px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer; color: var(--ink-3);
  padding: 0;
}
.pw-toggle:hover { color: var(--brand); }
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle svg[hidden] { display: none; }
.login-card .primary { width: 100%; margin-top: 18px; padding: 11px; }
.login-msg { min-height: 1.3em; margin-top: 12px; text-align: center; font-size: 0.8rem; color: var(--serious); }

/* ---------------- admin forms ---------------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 6px; }
.form-grid label { font-size: 0.72rem; color: var(--ink-3); display: block; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select {
  width: 100%; margin-top: 3px; font: inherit; font-size: 0.86rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--brand); }
.form-grid input[readonly] { opacity: 0.6; }

.m-intro { font-size: 0.8rem; color: var(--ink-2); margin: 4px 0 8px; line-height: 1.5; }
.danger-box {
  background: rgba(220, 38, 38, 0.07); border: 1px solid rgba(220, 38, 38, 0.35);
  border-radius: 9px; padding: 9px 12px; color: #9c1f1f;
}
#adm-veil .modal { max-height: 86vh; overflow-y: auto; width: min(560px, calc(100vw - 40px)); }
#adm-veil input { font: inherit; font-size: 0.86rem; color: var(--ink); background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; outline: none; }

.ops-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ops-list .icon-btn { justify-content: flex-start; }

.cmd-out {
  margin-top: 12px; background: var(--page); border: 1px solid var(--border);
  border-radius: 9px; padding: 12px; min-height: 70px; max-height: 240px; overflow: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; color: var(--ink-2);
  white-space: pre-wrap;
}

#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #eaf8ee; color: #147a3c; border: 1px solid rgba(23, 138, 69, 0.4);
  border-radius: 99px; padding: 10px 22px; font-size: 0.85rem; z-index: 90;
  opacity: 0; transition: all 0.25s ease; pointer-events: none;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .sidebar { display: none; }
}

/* ---------------- theme toggle ---------------- */

#btn-theme .ic-moon { display: none; }
:root[data-theme="dark"] #btn-theme .ic-sun { display: none; }
:root[data-theme="dark"] #btn-theme .ic-moon { display: inline; }

/* ---------------- sidebar add button ---------------- */

.nav-sep { display: flex; align-items: center; gap: 8px; }
.nav-add {
  margin-left: auto; width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--ink-3);
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; font-size: 0.9rem; line-height: 1; cursor: pointer;
}
.nav-add:hover { color: var(--brand); border-color: rgba(46, 107, 224, 0.5); }

/* ---------------- tank table editor ---------------- */

.tt-layout { display: grid; grid-template-columns: 1fr 230px 320px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .tt-layout { grid-template-columns: 1fr; } }

.tt-grid-scroll { max-height: 420px; overflow-y: auto; border: 1px solid var(--border-soft); border-radius: 8px; }
table.tt-grid { width: 100%; }
table.tt-grid th { position: sticky; top: 0; z-index: 2; }
table.tt-grid tbody tr { cursor: pointer; user-select: none; }
table.tt-grid tr.captured td { color: #1c5cab; font-weight: 600; }
table.tt-grid tr.captured td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
table.tt-grid tr.sel td { background: rgba(46, 107, 224, 0.14) !important; }

.tt-warning {
  background: rgba(224, 147, 15, 0.1); border: 1px solid rgba(224, 147, 15, 0.4);
  color: #8a5c08; border-radius: 8px; padding: 8px 12px; font-size: 0.8rem; margin-bottom: 10px;
}
.tt-dirty {
  font-size: 0.74rem; color: var(--fuel-deep); background: rgba(224, 147, 15, 0.1);
  border: 1px solid rgba(224, 147, 15, 0.35); border-radius: 99px; padding: 3px 12px;
}

.tt-lbl { display: block; font-size: 0.74rem; color: var(--ink-3); margin: 10px 0 4px; }
.tt-input {
  width: 100%; font: inherit; font-size: 0.9rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 11px; outline: none;
}
.tt-input:focus { border-color: var(--brand); }
.tt-act { width: 100%; margin-top: 8px; justify-content: center; }

.tt-shapes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.tt-shape {
  min-width: 0;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 10px 8px;
  cursor: pointer; display: block; background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.tt-shape:hover { border-color: rgba(46, 107, 224, 0.45); }
.tt-shape.sel { border-color: var(--brand); background: rgba(46, 107, 224, 0.06); }
.tt-shape input[type="radio"] { display: none; }
.tt-shape svg { width: 60px; height: 54px; display: block; margin: 0 auto; }
.tt-shape-line { fill: none; stroke: var(--ink-3); stroke-width: 2; }
.tt-shape.sel .tt-shape-line { stroke: var(--brand); }
.tt-shape-fill { fill: rgba(46, 107, 224, 0.3); stroke: none; }
.tt-shape-name { text-align: center; font-size: 0.72rem; color: var(--ink-2); margin: 6px 0 6px; }
.tt-dims { display: flex; flex-direction: column; gap: 4px; }
.tt-dim { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--ink-3); }
.tt-dim b { width: 10px; text-align: center; color: var(--ink-2); }
.tt-dim input {
  flex: 1; min-width: 0; font: inherit; font-size: 0.78rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 7px; outline: none;
}
.tt-dim input:focus { border-color: var(--brand); }
.tt-dim input:disabled { opacity: 0.4; }
.tt-dim i { font-style: normal; }

/* 3D-ish tank shape drawings */
.tt-shape-back { fill: none; stroke: var(--ink-3); stroke-width: 1.6; opacity: 0.45; }
.tt-shape.sel .tt-shape-back { stroke: var(--brand); }
.tt-shape-surface { fill: rgba(46, 107, 224, 0.5); stroke: none; }

/* capsule straight-section band + dimension markings */
.tt-shape-band { fill: rgba(46, 107, 224, 0.13); stroke: none; }
.tt-dim-mark { stroke: var(--ink-2); stroke-width: 1.1; fill: none; opacity: 0.75; }
.tt-dim-arrow { fill: var(--ink-2); stroke: none; opacity: 0.9; }
.tt-dim-text { fill: var(--ink-2); font: italic 700 10.5px Georgia, "Times New Roman", serif; }

/* live comms row selection */
tr.ops-row { cursor: pointer; }
tr.ops-row.sel td { background: rgba(46, 107, 224, 0.12) !important; }

/* login logo mark */
.login-logo .login-mark { width: 170px; height: 102px; display: block; margin: 0 auto 10px; }
.login-logo .word .c1 { color: var(--brand); }
.login-logo .word .c2 { color: var(--ink); }

img.mark, img.login-mark { object-fit: contain; }
.topbar .brand img.mark { width: 52px; height: 31px; }

/* ---------------- logger configuration page ---------------- */

.cf-modebar {
  border-radius: 10px; padding: 10px 16px; font-size: 0.85rem; margin: 4px 0 14px;
}
.cf-modebar.direct { background: rgba(23, 138, 69, 0.09); border: 1px solid rgba(23, 138, 69, 0.32); color: #146b39; }
.cf-modebar.script { background: rgba(224, 147, 15, 0.09); border: 1px solid rgba(224, 147, 15, 0.35); color: #8a5c08; }

.cf-layout { display: grid; grid-template-columns: 1fr 380px; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .cf-layout { grid-template-columns: 1fr; } }

.cf-sect { margin-bottom: 14px; }
.cf-sect h3 { margin-bottom: 10px; }
.cf-pulse-note {
  margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  background: rgba(224, 147, 15, 0.1); border: 1px solid rgba(224, 147, 15, 0.4);
  color: #8a5c08; font-size: 0.82rem;
}
.cf-busy { opacity: 0.55; pointer-events: none; }

.cf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px 14px; }
.cf-field { display: block; min-width: 0; }
.cf-field.wide { grid-column: 1 / -1; }
.cf-field > span { display: block; font-size: 0.71rem; color: var(--ink-3); margin-bottom: 3px; }
.cf-field input, .cf-field select {
  width: 100%; font: inherit; font-size: 0.85rem; color: var(--ink);
  background: var(--page); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; outline: none;
}
.cf-field input:focus, .cf-field select:focus { border-color: var(--brand); }
.cf-field input[readonly] { opacity: 0.65; border-style: dashed; }
.cf-field input:disabled { opacity: 0.4; }

.cf-genrow { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 9px 14px; }

.cf-radios { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 6px; }
.cf-radio { display: inline-flex; align-items: center; gap: 6px; font-size: 0.83rem; color: var(--ink-2); cursor: pointer; }

.cf-side { position: sticky; top: 84px; }
.cf-console {
  background: var(--page); border: 1px solid var(--border); border-radius: 9px;
  height: 380px; overflow-y: auto; padding: 10px 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 0.72rem; line-height: 1.5;
}
.cf-line { white-space: pre-wrap; word-break: break-all; }
.cf-cmd { color: #1e58c9; }
.cf-resp { color: #147a3c; }
.cf-err { color: #b32323; }
.cf-queued { color: #8a5c08; }
.cf-done { color: var(--ink); font-weight: 600; }
.cf-grid-2 { grid-template-columns: 1fr 1fr; }

/* ---------------- map modal (OpenStreetMap) ---------------- */

.map-modal {
  width: min(1000px, calc(100vw - 40px));
  height: min(700px, calc(100vh - 60px));
  background: #ffffff; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.map-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.map-head h2 { font-size: 1.02rem; }
#map-holder { flex: 1; min-height: 0; }


/* branded Leaflet popup bubble */
.leaflet-popup-content-wrapper {
  background: #ffffff; color: var(--ink);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: #ffffff; border: 1px solid var(--border); }
.leaflet-popup-content { margin: 14px 16px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-3); }

.map-pop { font: 0.78rem/1.45 "Inter", "Segoe UI", sans-serif; min-width: 270px; }
.map-pop .mp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.map-pop .mp-icon { width: 32px; height: 32px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; }
.map-pop .mp-icon svg { width: 19px; height: 19px; }
.map-pop .mp-name { font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.map-pop .mp-site { color: var(--ink-3); font-size: 0.7rem; }
.map-pop .mp-head .pill { margin-left: auto; }
.map-pop .mp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px;
  border-top: 1px solid var(--border-soft); padding-top: 8px; }
.map-pop .mp-row { display: flex; flex-direction: column; }
.map-pop .mp-row.wide { grid-column: 1 / -1; }
.map-pop .mp-row span { color: var(--ink-3); font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase; }
.map-pop .mp-row b { font-weight: 600; color: var(--ink-2); }
.map-pop .mp-row.bad b { color: #c22b2b; }
.map-pop .mp-row.good b { color: #178a45; }
.map-pop .mp-row .gsm i { background: rgba(20, 40, 80, 0.18); }
.map-pop .mp-row .gsm i.on { background: var(--brand); }
.map-pop a.mp-link { display: inline-block; margin-top: 10px; color: var(--brand); font-weight: 650; text-decoration: none; }
.map-pop a.mp-link:hover { text-decoration: underline; }

/* dome map markers, coloured by status */
.map-dot {
  display: block; width: 18px; height: 18px; margin: 2px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 6px rgba(20, 40, 80, 0.35);
  background: radial-gradient(circle at 35% 28%, #b7d0ff, #2E6BE0 55%, #163f99);
  cursor: pointer;
}
.map-dot.online { background: radial-gradient(circle at 35% 28%, #96e6ae, #178a45 55%, #0c5c2c); }
.map-dot.sleep  { background: radial-gradient(circle at 35% 28%, #c7d3e3, #7488a0 55%, #48586d); }
.map-dot.offline, .map-dot.alarm {
  background: radial-gradient(circle at 35% 28%, #f3a9a9, #dc2626 55%, #8f1717);
}
.map-dot.alarm { animation: map-dot-pulse 1.6s infinite; }
.map-dot.focus { width: 22px; height: 22px; margin: 0; }
@keyframes map-dot-pulse {
  0%   { box-shadow: 0 2px 6px rgba(20,40,80,0.35), 0 0 0 0 rgba(220, 38, 38, 0.55); }
  70%  { box-shadow: 0 2px 6px rgba(20,40,80,0.35), 0 0 0 11px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 2px 6px rgba(20,40,80,0.35), 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* full lock-up logo (mybowser-logo.jpg) in topbar + login */
.topbar .brand .logo-full {
  height: 50px; width: auto; display: block;
  background: #fff; border: 1px solid var(--border); border-radius: 9px;
  padding: 4px 9px;
}
.login-logo .login-logo-full {
  height: 72px; width: auto; max-width: 100%; display: block; margin: 0 auto 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 11px;
  padding: 8px 16px;
}

/* first-run commissioning notice */
#notice-banner {
  display: none; align-items: flex-start; gap: 8px;
  background: rgba(224, 147, 15, 0.1); border: 1px solid rgba(224, 147, 15, 0.4);
  color: #8a5c08; border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0; font-size: 0.88rem;
}
#notice-banner a { color: var(--brand); font-weight: 600; }

/* update-available banner (managers only) */
.update-banner {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(46, 107, 224, 0.07); border: 1px solid rgba(46, 107, 224, 0.35);
  color: var(--ink-2); border-radius: var(--radius);
  padding: 12px 16px; margin: 10px 0; font-size: 0.88rem;
}
.update-banner svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 2px; color: var(--brand); }
.update-banner b { color: var(--ink); }
.update-banner a { color: var(--brand); font-weight: 600; }
.update-banner.critical { background: rgba(220, 38, 38, 0.08); border-color: rgba(220, 38, 38, 0.4); }
.update-banner.critical svg { color: #c22b2b; }
.update-banner .ub-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--ink-3); font-size: 1.1rem; line-height: 1; padding: 2px 4px;
}
.update-banner .ub-close:hover { color: var(--ink); }

.login-ver { text-align: center; margin-top: 14px; font-size: 0.72rem; color: var(--ink-3); }
.login-msg.info { color: #146b39; }

/* forgot-password link on the sign-in card */
.forgot-link {
  display: block; text-align: center; margin-top: 12px;
  font-size: 0.76rem; color: var(--ink-3); text-decoration: none;
}
.forgot-link:hover { color: var(--brand); text-decoration: underline; }

/* signed-in user chip with initials avatar */
#user-chip { display: flex; align-items: center; gap: 9px; }
.uc-avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--brand), var(--brand-ink));
  color: #fff; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em;
}
#user-chip .uc-name { font-size: 0.88rem; }
