:root {
  --bg: #141414;
  --chrome: #1d1d1f;
  --elevated: #242427;
  --fill: rgba(240, 240, 240, 0.08);
  --fill-strong: rgba(240, 240, 240, 0.14);
  --stroke: rgba(240, 240, 240, 0.12);
  --stroke-soft: rgba(240, 240, 240, 0.07);
  --text: #f0f0f0;
  --text-2: rgba(240, 240, 240, 0.74);
  --text-3: rgba(240, 240, 240, 0.55);
  --text-4: rgba(240, 240, 240, 0.36);
  --green: #3fb68b;
  --orange: #e0a43c;
  --red: #e05d55;
  --accent: #529add;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
  height: 100%;
  overscroll-behavior: none;
}

#app {
  padding: calc(env(safe-area-inset-top) + 14px) 16px 90px;
  max-width: 480px;
  margin: 0 auto;
}

.num { font-variant-numeric: tabular-nums; }

/* ---- tab bar ---- */
#tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: color-mix(in srgb, var(--chrome) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--stroke-soft);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 8px);
}
#tabbar button {
  flex: 1; background: none; border: none;
  color: var(--text-4); font-size: 10px; line-height: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-family: inherit; cursor: pointer;
}
#tabbar button .glyph { font-size: 15px; }
#tabbar button.active { color: var(--accent); }

/* ---- status banner ---- */
.banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--fill);
  border: 1px solid var(--stroke-soft);
  border-left: 3px solid var(--green);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 18px;
}
.banner.warn { border-left-color: var(--orange); }
.banner.bad { border-left-color: var(--red); }
.banner .title { font-size: 14px; font-weight: 590; }
.banner .sub { font-size: 11px; color: var(--text-3); }

.dot {
  width: 9px; height: 9px; border-radius: 999px; flex-shrink: 0;
  background: var(--green);
}
.dot.warn { background: var(--orange); }
.dot.bad { background: var(--red); }
.dot.off { background: var(--text-4); }

/* ---- headline stats ---- */
.hero-label { font-size: 12px; color: var(--text-3); }
.hero-value { font-size: 34px; font-weight: 590; line-height: 42px; }
.hero-value.pos { color: var(--green); }
.hero-value.neg { color: var(--red); }
.hero-sub { font-size: 12px; color: var(--text-3); margin-bottom: 16px; }

.statrow { display: flex; gap: 26px; margin-bottom: 18px; }
.statrow .label { font-size: 11px; color: var(--text-3); }
.statrow .value { font-size: 19px; font-weight: 590; }

/* ---- gauges ---- */
.gauge { margin-bottom: 14px; }
.gauge .head {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 4px;
}
.gauge .head .l { color: var(--text-2); }
.gauge .track {
  height: 5px; border-radius: 3px; background: var(--fill); overflow: hidden;
}
.gauge .bar { height: 100%; background: var(--accent); }
.gauge .note { font-size: 10px; color: var(--text-4); margin-top: 3px; }

/* ---- sections & rows ---- */
.section-title { font-size: 12px; color: var(--text-3); margin: 18px 0 6px; }
h1.page { font-size: 19px; font-weight: 590; margin-bottom: 14px; }

.row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--stroke-soft);
  font-size: 13px;
}
.row .k { color: var(--text-2); }
.row .k small { color: var(--text-4); font-size: 10px; }
.row .v { color: var(--text); }

/* ---- book cards ---- */
.card {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.card.dim { opacity: 0.7; }
.card .head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.card .head .sym { font-size: 15px; font-weight: 590; }
.card .head .status { margin-left: auto; font-size: 10px; color: var(--text-4); }
.card .metrics { display: flex; gap: 18px; margin-bottom: 10px; }
.card .metrics .label { font-size: 9px; color: var(--text-4); }
.card .metrics .value { font-size: 13px; }
.invband { position: relative; height: 5px; border-radius: 3px; background: var(--fill); }
.invband .mid {
  position: absolute; left: 50%; top: -2px; width: 1px; height: 9px;
  background: var(--stroke);
}
.invband .pin {
  position: absolute; top: -1px; width: 7px; height: 7px; border-radius: 4px;
  background: var(--accent); transform: translateX(-50%);
}
.card .bandlabel { font-size: 9px; color: var(--text-4); margin: 8px 0 3px; }

/* ---- detail ---- */
.backlink { color: var(--text-3); font-size: 14px; background: none; border: none; font-family: inherit; padding: 4px 8px 4px 0; }
.detail-head { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.detail-head .sym { font-size: 18px; font-weight: 590; }
.detail-head .status { margin-left: auto; font-size: 11px; color: var(--text-4); }

.controls { display: flex; gap: 10px; margin: 10px 0; }
.btn {
  flex: 1; text-align: center; padding: 11px 10px; border-radius: 9px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  background: var(--fill-strong); color: var(--text); border: none; cursor: pointer;
}
.btn:active { background: var(--fill); }
.btn.accent { background: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.45; }

.presets { display: flex; gap: 10px; margin-bottom: 8px; }
.presets button {
  flex: 1; text-align: center; padding: 9px 0; border-radius: 8px;
  font-size: 13px; font-family: inherit; cursor: pointer;
  background: none; border: 1px solid var(--stroke); color: var(--text-2);
}
.presets button.active { border-color: var(--accent); color: var(--accent); }
.hint { font-size: 10px; color: var(--text-4); }

/* ---- slide to confirm ---- */
.slide {
  position: relative; height: 46px; border-radius: 10px;
  border: 1px solid var(--red);
  color: var(--red); font-size: 13px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; user-select: none; -webkit-user-select: none;
  touch-action: pan-y;
  margin-top: 8px;
}
.slide.green { border-color: var(--green); color: var(--green); }
.slide .knob {
  position: absolute; left: 3px; top: 3px; bottom: 3px; width: 46px;
  border-radius: 8px; background: var(--fill-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-2);
}
.slide .fillbar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: rgba(224, 93, 85, 0.15);
}
.slide.green .fillbar { background: rgba(63, 182, 139, 0.15); }

/* ---- alerts ---- */
.alerts { font-size: 12px; line-height: 20px; color: var(--text-2); }
.alerts .t { font-variant-numeric: tabular-nums; margin-right: 6px; }
.alerts .kill .t { color: var(--red); }
.alerts .warn .t { color: var(--orange); }
.alerts .info .t { color: var(--green); }

/* ---- setup ---- */
.setup { padding-top: 60px; text-align: center; }
.setup input {
  width: 100%; padding: 12px; margin: 18px 0 12px;
  background: var(--elevated); color: var(--text);
  border: 1px solid var(--stroke); border-radius: 9px;
  font-size: 14px; font-family: inherit;
}
.toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 76px);
  left: 50%; transform: translateX(-50%);
  background: var(--elevated); border: 1px solid var(--stroke);
  border-radius: 9px; padding: 9px 16px; font-size: 12px;
  z-index: 10; white-space: nowrap;
}
.updated { font-size: 10px; color: var(--text-4); text-align: center; margin-top: 18px; }
svg text.axis { font-size: 8.5px; fill: var(--text-4); font-family: inherit; font-variant-numeric: tabular-nums; }

.daynav {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 18px 0 6px;
}
.daynav .dlabel { font-size: 12px; color: var(--text-3); }
.daynav .dlabel small { color: var(--text-4); font-size: 9px; }
.daynav input[type="date"] {
  background: var(--fill); border: 1px solid var(--stroke-soft);
  color: var(--text-2); border-radius: 7px; padding: 4px 8px;
  font-size: 12px; font-family: inherit; color-scheme: dark;
  -webkit-appearance: none; appearance: none;
}
