:root {
  --bg: #0B0D10;
  --surface: #15181D;
  --surface-high: #1C2027;
  --line: #2A2F38;
  --text: #E8EAED;
  --dim: #8A919C;
  --faint: #5A616C;
  --ok: #3DDC97;
  --discharge: #FF8A3D;
  --cold: #4DA3FF;
  --warn: #FFC53D;
  --hot: #FF5D5D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
h2 { font-size: 18px; margin: 16px 0 10px; }

.dim { color: var(--dim); }
.small { font-size: 13px; }
.error { color: var(--hot); margin: 4px 0 0; }
.center { text-align: center; margin: 16px 0; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 16px; padding: 24px; display: grid; gap: 12px;
}
.login-card p { margin: 0; }
.token-input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px; letter-spacing: 1px; text-transform: uppercase;
}

/* ---------------------------------------------------------------- shell */
.brand { font-weight: 700; font-size: 18px; white-space: nowrap; }
.bolt { color: var(--ok); }
.top {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  max-width: 1100px; margin: 0 auto;
}
.status { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--dim); font-size: 13px; }
.status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--ok); }
.tabs {
  display: flex; gap: 4px; padding: 0 16px; max-width: 1100px; margin: 0 auto;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.tab {
  background: none; border: 0; padding: 10px 14px; color: var(--dim); cursor: pointer;
  border-bottom: 2px solid transparent; font-weight: 600; white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--ok); }
main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 24px; }
footer { max-width: 1100px; margin: 0 auto; padding: 0 16px 32px; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--surface-high); font-weight: 600;
}
.btn.primary { background: var(--ok); color: #06140D; }
.btn.ghost { background: transparent; color: var(--ok); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------------------------------------------------------------- tiles */
.section-title {
  color: var(--dim); font-size: 13px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; margin: 20px 0 8px;
}
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border-radius: 14px; padding: 12px 14px; min-height: 84px; }
.tile .label { color: var(--dim); font-size: 12px; font-weight: 500; }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 10px; font-variant-numeric: tabular-nums; }
.tile .unit { color: var(--dim); font-size: 13px; margin-left: 4px; font-weight: 500; }
.tile.stale .value { color: var(--faint); }
.hero { background: var(--surface); border-radius: 16px; padding: 18px; margin-top: 12px; }
.hero .label { color: var(--dim); font-size: 13px; font-weight: 600; letter-spacing: 1px; }
.hero .big { font-size: 56px; font-weight: 700; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.hero .sub { color: var(--text); font-size: 14px; float: right; margin-top: 30px; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-high); overflow: hidden; margin-top: 10px; }
.bar > div { height: 100%; background: var(--ok); }

/* ---------------------------------------------------------------- trips */
.day { color: var(--dim); font-size: 13px; font-weight: 600; margin: 18px 0 6px; }
.trip {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 10px; align-items: center;
  background: var(--surface); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  cursor: pointer; border: 0; width: 100%; text-align: left;
}
.trip:hover { background: var(--surface-high); }
.trip .icon { font-size: 18px; text-align: center; }
.trip .when { font-weight: 600; }
.trip .facts { grid-column: 2 / 4; color: var(--dim); font-size: 13px; }
.trip .dist { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- charts */
.panel { background: var(--surface); border-radius: 14px; padding: 8px 14px; margin-top: 12px; }
.chip {
  background: var(--surface-high); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: 14px;
}
.chip.active { border-color: var(--ok); color: var(--ok); }
.chip .x { margin-left: 6px; color: var(--dim); }
.field { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 14px; }
.field input, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}
.picker { position: relative; margin: 8px 0; }
.picker input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.results {
  position: absolute; z-index: 5; left: 0; right: 0; top: 100%; max-height: 320px; overflow-y: auto;
  background: var(--surface-high); border: 1px solid var(--line); border-radius: 10px; margin-top: 4px;
}
.results button {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; padding: 8px 12px; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
}
.results button:hover { background: var(--line); }
.chart-card { background: var(--surface); border-radius: 14px; padding: 12px 8px 4px; margin-top: 12px; }
.chart-card .title { color: var(--dim); font-size: 13px; font-weight: 600; padding: 0 8px 6px; }
.empty { color: var(--dim); text-align: center; padding: 40px 16px; }
.export { border-top: 1px solid var(--line); padding-top: 8px; }

/* uPlot on a dark background */
.uplot { font-family: inherit; }
.u-legend { color: var(--text); font-size: 12px; }
.u-legend .u-series th { font-weight: 500; }
.u-select { background: rgba(61, 220, 151, .12); }

@media (max-width: 600px) {
  .hero .big { font-size: 46px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .top { flex-wrap: wrap; }
  .status { order: 3; flex-basis: 100%; }
}
