:root {
  --bg: #000;
  --card: #0d0d0d;
  --line: #1c1c1c;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --orange: #ff8a1f;
  --green: #2ee59d;
  --red: #ff4d5e;
  --cyan: #3de0ff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; }
#app { min-height: 100dvh; display: flex; flex-direction: column;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 4px; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.top-right { display: flex; gap: 6px; }
.pill { font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 999px; letter-spacing: .04em; }
.pill.paper { background: var(--orange); color: #000; }
.pill.live { background: var(--red); color: #000; }
.pill.mult { background: #161616; color: var(--text); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pill.mult.up { color: var(--green); }
.pill.mult.down { color: var(--red); }

.odometer-wrap { padding: 4px 18px 6px; }
.odometer { font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums;
  font-size: clamp(66px, 22vw, 100px); line-height: 1; }
.odometer .cents { font-size: .42em; color: var(--muted); letter-spacing: -0.02em; }

.view { padding: 6px 18px 24px; flex: 1; }
.chart-card { margin: 4px -18px 10px; }
canvas.chart { width: 100%; height: 170px; display: block; }

.section-h { font-size: 13px; color: var(--muted); font-weight: 600; margin: 18px 0 8px;
  display: flex; justify-content: space-between; align-items: baseline; }
.section-h a { color: var(--muted); text-decoration: none; font-weight: 500; }

.carousel { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -18px; padding: 2px 18px 6px; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.agent-card { flex: 0 0 62%; scroll-snap-align: start; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px; min-height: 108px; cursor: pointer; }
.agent-card .name { font-weight: 700; text-transform: capitalize; display: flex; align-items: center; gap: 6px; }
.agent-card .stat { color: var(--muted); font-size: 13px; margin-top: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #333; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 10px 0; }
.card h2 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .t { font-weight: 600; }
.row .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row.click { cursor: pointer; }
.muted { color: var(--muted); }
.strike { text-decoration: line-through; color: #555; }
.bad { color: var(--red); }
.good { color: var(--green); }
.btn { display: inline-block; background: #161616; color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; text-decoration: none; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #000; }
.btn.block { display: block; width: 100%; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.error { background: #1a0a0c; color: var(--red); border: 1px solid #3a1418; border-radius: 14px; padding: 14px; margin: 12px 0; }

.login { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 14px 0; }
.login h2 { margin: 0 0 6px; font-size: 17px; }
.login p { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
.login textarea { width: 100%; min-height: 84px; background: #000; color: var(--text); border: 1px solid #2a2a2a;
  border-radius: 12px; padding: 12px; font: 13px/1.35 ui-monospace, Menlo, monospace; resize: vertical; }
.login .err { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 1em; }

.screen-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.back { background: none; border: 0; color: var(--orange); font-size: 15px; font-weight: 600; padding: 6px 0; cursor: pointer; }
.layers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.layer { background: #070707; border-radius: 12px; padding: 10px; border: 1px solid var(--line); min-height: 64px; }
.layer .n { font-size: 11px; color: var(--muted); }
.layer .v { font-size: 12px; margin-top: 4px; }
.layer.ok { border-color: #134a33; }
.layer.bad { border-color: #4a1820; }
.layer.grey { opacity: .5; }
.ring { width: 96px; height: 96px; border-radius: 50%; border: 6px solid #1c1c1c; display: grid; place-items: center; margin: 10px auto; font-size: 26px; font-weight: 800; }
.ring.pass { border-color: var(--green); color: var(--green); }
.risk-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.risk-pills span { font-size: 12px; padding: 5px 10px; border-radius: 999px; }
.risk-pills .stop { background: #1a0a0c; color: var(--red); }
.risk-pills .trail { background: #08180f; color: var(--green); }
.field { margin: 10px 0; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; background: #000; border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 10px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4,1fr);
  background: rgba(0,0,0,.55); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(255,255,255,.08); padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); z-index: 10; }
.tabs button { background: transparent; border: 0; color: var(--muted); padding: 12px 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
.tabs button.active { color: var(--text); }
.toast { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: #161616;
  border: 1px solid var(--line); padding: 10px 14px; border-radius: 999px; z-index: 20; font-size: 13px; }
.hidden { display: none !important; }

/* Terminal */
.term {
  display: flex; flex-direction: column; gap: 10px; min-height: 55dvh;
}
.term-hist {
  background: #050505; border: 1px solid var(--line); border-radius: 16px;
  padding: 12px; max-height: 52dvh; overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.45;
}
.term-hist .cmd { color: var(--orange); margin-top: 10px; white-space: pre-wrap; word-break: break-word; }
.term-hist .cmd:first-child { margin-top: 0; }
.term-hist .cmd::before { content: "› "; opacity: .7; }
.term-hist .reply { color: var(--text); white-space: pre-wrap; word-break: break-word; margin: 4px 0 2px; opacity: .95; }
.term-hist .pending { color: var(--muted); font-style: italic; }
.term-hist .term-err { color: var(--red, #ff4d5e); white-space: pre-wrap; word-break: break-word; margin: 4px 0 2px; font-weight: 600; }
.term-hist .btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.term-hist .btns a {
  display: inline-block; background: var(--orange); color: #000; text-decoration: none;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-weight: 700;
  font-size: 12px; padding: 7px 10px; border-radius: 999px;
}
.term-form { display: flex; gap: 8px; align-items: stretch; }
.term-form input {
  flex: 1; background: #050505; border: 1px solid #2a2a2a; color: var(--text);
  border-radius: 12px; padding: 12px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px;
}
.term-form button {
  background: var(--orange); color: #000; border: 0; border-radius: 12px;
  padding: 0 16px; font-weight: 800; cursor: pointer;
}
.icon-btn {
  background: #161616; border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.top-actions { display: flex; gap: 6px; align-items: center; }

.term-build {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: #666;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.screen-head { display: flex; align-items: center; gap: 8px; }
