/* ZoeWeb — dark automotive UI */
:root {
  --bg: #10141b;
  --panel: #1a2029;
  --panel2: #222a36;
  --fg: #dde3ec;
  --dim: #8b95a5;
  --accent: #41b0f5;
  --good: #41d98c;
  --warn: #f5a441;
  --bad: #f0564f;
  --border: #2c3644;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}

/* top bar */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 19px; letter-spacing: .5px; }
.brand b { color: var(--accent); }
#menu-btn { display: none; background: none; border: 0; color: var(--fg); font-size: 22px; cursor: pointer; }
#status-text { flex: 1; color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status-text.warn { color: var(--warn); }
#led { width: 10px; height: 10px; border-radius: 50%; background: #333c48; flex: none; transition: background .1s; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--fg); border-radius: 8px; width: 32px; height: 32px; font-size: 17px; cursor: pointer; flex: none; line-height: 1; }
.icon-btn:hover { background: var(--panel2); }
.icon-btn.active { color: var(--accent); border-color: var(--accent); }
/* flip the entire app for an upside-down mounted screen */
body.flip { transform: rotate(180deg); transform-origin: 50% 50%; }
#led.on { background: var(--good); box-shadow: 0 0 8px var(--good); }

/* layout */
#layout { display: flex; flex: 1; min-height: 0; }
#sidebar {
  width: 210px; flex: none; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
#nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: none; border: 0; border-radius: 8px; color: var(--fg);
  font-size: 15px; cursor: pointer; text-align: left;
}
.nav-btn:hover { background: var(--panel2); }
.nav-btn.active { background: var(--accent); color: #08131c; font-weight: 600; }
.nav-icon { width: 22px; text-align: center; }
#sidebar footer { padding: 10px 14px; font-size: 12px; color: var(--dim); }
#sidebar footer a { color: var(--accent); }

#content { flex: 1; overflow-y: auto; padding: 18px; }

/* cards & grids */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 10px; font-size: 14px; color: var(--dim); text-transform: uppercase; letter-spacing: .8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.tires-layout { display: flex; flex-direction: column; gap: 30px; max-width: 560px; }

.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.tile-label { font-size: 12px; color: var(--dim); }
.tile-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile.big .tile-value { font-size: 38px; color: var(--accent); }
.tile-unit { font-size: 12px; color: var(--dim); }
.tile-value.stale { opacity: .45; }

/* gauges */
.gauges { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.gauge { text-align: center; }
.gauge-label { color: var(--dim); font-size: 13px; margin-top: -8px; }

/* bars */
.hbar { margin: 10px 0; }
.hbar-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--dim); margin-bottom: 4px; }
.hbar-value { color: var(--fg); font-variant-numeric: tabular-nums; }
.hbar-track { position: relative; height: 14px; background: rgba(128,140,160,.15); border-radius: 7px; overflow: hidden; }
.hbar-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--accent); border-radius: 7px; transition: width .15s, left .15s; }

/* heatmap */
.heatmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 4px; }
.heatcell {
  padding: 6px 2px; text-align: center; border-radius: 6px; font-size: 12px;
  background: var(--panel2); font-variant-numeric: tabular-nums;
}

/* forms & buttons */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.toolbar label { color: var(--dim); font-size: 13px; min-width: 110px; }
.input, select.input {
  background: var(--panel2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 130px;
}
.btn {
  background: var(--accent); color: #08131c; border: 0; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.connected { background: var(--good); color: #08131c; }

/* tables */
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.scroll-x { overflow-x: auto; }
.mono { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; }

.cat-chip { background: var(--panel2); color: var(--dim); border: 1px solid var(--border); border-radius: 14px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; }
.cat-chip:hover { color: var(--fg); }
.cat-chip.sel { background: var(--accent); color: #08131c; border-color: var(--accent); font-weight: 600; }

.picker-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px; margin-top: 6px; }
.picker-row { text-align: left; background: none; border: 0; color: var(--fg); padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.picker-row:hover { background: var(--panel2); }
.picker-row.sel { background: var(--accent); color: #08131c; font-weight: 600; }

/* pro console */
.console {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; height: 260px; overflow-y: auto; font-size: 13px;
}
.console .tx { color: var(--accent); }
.console .rx { color: var(--good); }
.console .err { color: var(--bad); }
.console .hint { color: var(--dim); }
.warnbox {
  background: rgba(240,86,79,.12); border: 1px solid var(--bad); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 16px; font-size: 14px;
}
.hint { color: var(--dim); font-size: 13px; }
p.hint { margin: 6px 0; }

/* ===== immersive game-style HUD dashboard ===== */
/* when the dashboard is active, let it fill the screen edge-to-edge */
body:has(.hud) #content { padding: 0; overflow: hidden; }

.hud {
  height: calc(100vh - 48px); height: calc(100dvh - 48px);
  max-width: 100vw; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 0.6vh;
  padding: clamp(4px, 2vh, 18px) 5px clamp(6px, 3vh, 24px);
  background:
    radial-gradient(120% 90% at 50% 30%, rgba(65,176,245,.10), transparent 60%),
    radial-gradient(80% 80% at 50% 120%, rgba(65,217,140,.08), transparent 60%),
    linear-gradient(180deg, #0a0d13, #0e1420 60%, #0a0d13);
  position: relative; overflow: hidden;
}
/* faint HUD grid + vignette */
.hud::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(120,150,190,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,150,190,.05) 1px, transparent 1px);
  background-size: 44px 44px; mask: radial-gradient(80% 70% at 50% 45%, #000, transparent 85%);
}
.hud::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 200px rgba(0,0,0,.7);
}

.dial {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 2.2vh, 30px); width: 100%; max-width: 1200px; margin: 0 auto;
}
.dial-row {
  display: flex; justify-content: center; align-items: flex-start; flex-wrap: wrap;
  gap: clamp(24px, 12vw, 160px); width: 100%;
}
.dial-mid { position: relative; width: clamp(180px, min(42vw, 44vh), 440px); aspect-ratio: 1; }
.dial-ring { width: 100%; height: 100%; position: relative; z-index: 1; }
/* power aura behind the ring */
.dial-aura {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 150%; aspect-ratio: 1; border-radius: 50%; pointer-events: none; z-index: 0;
  transition: background .15s linear;
}

/* ring gauge (responsive, HUD glow) */
.ring { position: relative; width: 100%; height: 100%; z-index: 1; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; text-align: center;
}
.ring-val {
  font-size: clamp(52px, min(18vw, 23vh), 168px); font-weight: 800; line-height: .9;
  font-variant-numeric: tabular-nums; letter-spacing: -2px;
  color: #eef4ff; text-shadow: 0 0 24px rgba(65,176,245,.5);
}
.ring-unit { font-size: clamp(12px, 2.6vw, 20px); color: var(--dim); margin-top: 6px; letter-spacing: 1px; }
.ring-cap { font-size: clamp(10px, 2vw, 14px); color: var(--accent); text-transform: uppercase; letter-spacing: 4px; margin-top: 8px; opacity: .75; }
/* embedded kW power readout under the speed */
.dial-kw {
  margin-top: 8px; font-size: clamp(16px, min(4vw, 4.5vh), 30px); font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
  text-shadow: 0 0 18px currentColor; color: var(--accent);
}

/* embedded readouts */
.ro-cell { display: flex; }
.ro { text-align: center; }
.ro-label { font-size: clamp(11px, 2.2vw, 15px); color: var(--dim); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 4px; }
.ro-row { display: flex; align-items: baseline; gap: 5px; justify-content: center; }
.ro-val { font-size: clamp(30px, min(7vw, 6.6vh), 70px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; color: #eef4ff; text-shadow: 0 0 16px rgba(120,160,210,.3); line-height: 1; }
.ro-val.stale { opacity: .4; }
.ro-unit { font-size: clamp(13px, 2.6vw, 20px); color: var(--dim); }
.ro-stack { display: flex; flex-direction: column; gap: 6px; }
.ro-stack .ro-row { justify-content: center; }
.ro-lineitem .ro-sub { font-size: clamp(9px, 1.8vw, 12px); color: var(--dim); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 1px; }

@media (max-width: 620px) {
  .dial { gap: clamp(6px, 1.6vh, 18px); width: 100%; }
  .dial-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 12px;
    width: 100%;
  }
  .dial-row > .ro-cell { justify-content: center; min-width: 0; overflow: hidden; }
  .ro-val { font-size: clamp(28px, min(10vw, 7vh), 58px); }
  .ro-unit { font-size: clamp(10px, 2.3vw, 14px); }
  .ro-label { font-size: clamp(9px, 2.3vw, 12px); }
  .dial-mid { width: clamp(160px, min(56vw, 38vh), 340px); }
  .dial-aura { width: 120%; }
  /* battery bottom-left, cabin/outside bottom-right; odometer hidden (low priority) */
  .odo-cell { display: none; }
}

/* short screens (phone in landscape on a dash mount): lay readouts to the
   sides of the ring so we use the wide axis, not the short one */
@media (max-height: 560px) and (min-width: 620px) {
  .hud { height: calc(100vh - 48px); height: calc(100dvh - 48px); padding: 2px 1vw; justify-content: center; }
  .dial { flex-direction: row; align-items: center; justify-content: center; gap: clamp(16px, 4vw, 70px); }
  .dial-row { flex-direction: column; align-items: center; gap: clamp(6px, 1.8vh, 16px); width: auto; }
  .dial-mid { width: clamp(140px, 54vh, 300px); }
  .ring-val { font-size: clamp(40px, 26vh, 110px); }
  .dial-kw { margin-top: 3px; font-size: clamp(14px, 5vh, 24px); }
  .ro-val { font-size: clamp(22px, 6.6vh, 44px); }
  .ro-stack { gap: 0; }
  .ro-label { margin-bottom: 1px; }
}

/* mobile */
@media (max-width: 900px) {
  #menu-btn { display: block; }
  #sidebar {
    position: fixed; left: -230px; top: 47px; bottom: 0; z-index: 15; transition: left .2s;
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }
  #sidebar.open { left: 0; }
  #content { padding: 12px; }
  .gauges { gap: 8px; }
}
