/* Treecode Refresh: the station's look. Dark by design: a deep night ground, glass panels, one cyan-to-violet accent,
   status colors reserved for verdicts. Text stays in ink colors; color marks meaning, never decoration alone. */
:root {
  --bg: #04060c; --bg2: #070b15; --panel: rgba(18, 26, 46, 0.62); --panel2: rgba(24, 34, 60, 0.72); --line: rgba(120, 160, 255, 0.14);
  --line2: rgba(120, 160, 255, 0.26); --ink: #e9eefc; --ink2: #aab6d3; --ink3: #7483a6; --accent: #39e1ff; --accent2: #8b7bff;
  --grad: linear-gradient(120deg, #39e1ff 0%, #6aa8ff 45%, #8b7bff 100%);
  --green: #3ddc97; --amber: #ffb547; --red: #ff5d73; --blue: #4da3ff; --gray: #7c879f;
  --r: 14px; --r2: 10px; --shadow: 0 10px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Inter", ui-sans-serif, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 700px at 85% -10%, rgba(139, 123, 255, 0.16), transparent 60%),
              radial-gradient(900px 600px at -10% 10%, rgba(57, 225, 255, 0.10), transparent 60%), var(--bg);
  color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
}
body::before {   /* the faint grid */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.35;
  background-image: linear-gradient(rgba(120, 160, 255, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(120, 160, 255, 0.05) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 30px; font-weight: 600; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--ink2); }
.faint { color: var(--ink3); }
.small { font-size: 12.5px; }
.label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink3); font-weight: 600; }

/* ---- the frame ---- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; height: 60px;
  padding: 0 max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  background: rgba(4, 6, 12, 0.72); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 600; font-size: 16px; color: var(--ink); white-space: nowrap; }
.brand .mark { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); box-shadow: 0 0 22px rgba(57, 225, 255, 0.45); position: relative; }
.brand .mark::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 2px solid #04060c; }
.brand small { font-family: var(--sans); font-weight: 500; color: var(--ink3); font-size: 12px; margin-left: 2px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav a { color: var(--ink2); padding: 7px 12px; border-radius: 999px; white-space: nowrap; font-weight: 500; }
.nav a:hover { color: var(--ink); background: rgba(120, 160, 255, 0.08); text-decoration: none; }
.nav a.on { color: #04060c; background: var(--grad); }
.who { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.pick { background: var(--panel2); color: var(--ink); border: 1px solid var(--line2); border-radius: 999px; padding: 6px 12px; font: inherit; max-width: 260px; }
.main { position: relative; z-index: 1; max-width: 1320px; margin: 0 auto; padding: 26px max(18px, env(safe-area-inset-right)) 80px max(18px, env(safe-area-inset-left)); display: grid; gap: 18px; }

/* ---- panels ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); backdrop-filter: blur(10px); padding: 18px; min-width: 0; }
.panel.tight { padding: 14px; }
.panel h2 + .sub, .panel h3 + .sub { margin-top: 4px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.side { grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); }
@media (max-width: 960px) { .g3, .g4, .side { grid-template-columns: minmax(0, 1fr); } .g2 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; align-content: start; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---- the answer card: badge, headline, tiles, sentence, action ---- */
.answer { position: relative; overflow: hidden; padding: 22px; border-radius: 18px; border: 1px solid var(--line2);
  background: linear-gradient(180deg, rgba(30, 44, 80, 0.75), rgba(14, 20, 38, 0.75)); box-shadow: var(--shadow); }
.answer::after { content: ""; position: absolute; right: -120px; top: -120px; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(57, 225, 255, 0.18), transparent 70%); pointer-events: none; }
.answer h1 { margin: 10px 0 6px; max-width: 26ch; }
.answer .sentence { color: var(--ink2); max-width: 78ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0 10px; }
.tile { background: rgba(4, 8, 18, 0.55); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.tile .v { font-family: var(--display); font-size: 24px; font-weight: 600; margin-top: 2px; }
.tile .v small { font-size: 13px; color: var(--ink2); font-weight: 500; margin-left: 4px; }

/* ---- badges and chips ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid currentColor; background: rgba(255, 255, 255, 0.03); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.t-green { color: var(--green); } .t-amber { color: var(--amber); } .t-red { color: var(--red); } .t-blue { color: var(--blue); } .t-gray { color: var(--gray); }
.t-accent { color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--line2); color: var(--ink2); background: rgba(120, 160, 255, 0.06); white-space: nowrap; }
.chip.measured { color: var(--green); border-color: rgba(61, 220, 151, 0.4); }
.chip.testing { color: var(--blue); border-color: rgba(77, 163, 255, 0.45); }
.chip.assumed { color: var(--ink3); }
.chip.archived { color: var(--amber); border-color: rgba(255, 181, 71, 0.4); }

/* ---- buttons and forms ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 9px 16px; font: 600 13.5px var(--sans); cursor: pointer;
  border: 1px solid var(--line2); color: var(--ink); background: rgba(120, 160, 255, 0.08); transition: 0.15s; white-space: nowrap; }
.btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57, 225, 255, 0.12); text-decoration: none; }
.btn.primary { color: #04060c; background: var(--grad); border-color: transparent; box-shadow: 0 6px 26px rgba(57, 225, 255, 0.28); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: rgba(4, 8, 18, 0.7); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57, 225, 255, 0.15); }
label.f { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink2); }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink2); font-size: 13px; }
.check input { width: auto; accent-color: var(--accent); }

/* service cards in the request form */
.svc { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.svc label { display: grid; gap: 6px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(4, 8, 18, 0.5); cursor: pointer; transition: 0.15s; }
.svc label:hover { border-color: var(--line2); }
.svc input { display: none; }
.svc label.on { border-color: var(--accent); background: rgba(57, 225, 255, 0.07); box-shadow: inset 0 0 0 1px rgba(57, 225, 255, 0.4); }
.svc .t { font-weight: 600; }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--ink3); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 12px; background: rgba(4, 8, 18, 0.6); position: sticky; top: 0; }
td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: rgba(120, 160, 255, 0.05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- the stage strip ---- */
.stages { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(110px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.stage { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: rgba(4, 8, 18, 0.55); position: relative; overflow: hidden; min-width: 0; }
.stage .n { font-size: 12.5px; font-weight: 600; }
.stage .d { font-size: 11.5px; color: var(--ink3); margin-top: 2px; }
.stage .bar { height: 3px; border-radius: 3px; background: rgba(120, 160, 255, 0.12); margin-top: 10px; overflow: hidden; }
.stage .bar i { display: block; height: 100%; width: 0; background: var(--grad); box-shadow: 0 0 10px rgba(57, 225, 255, 0.7); transition: width 0.4s; }
.stage.done { border-color: rgba(61, 220, 151, 0.35); }
.stage.done .bar i { background: var(--green); box-shadow: none; }
.stage.now { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(57, 225, 255, 0.35), 0 0 30px rgba(57, 225, 255, 0.12); }

/* ---- policy rule chain ---- */
.rules { display: grid; gap: 6px; }
.rule { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(4, 8, 18, 0.45); font-size: 12.5px; }
.rule .i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #04060c; }
.rule.ok .i { background: var(--green); } .rule.hit .i { background: var(--amber); } .rule.skip .i { background: var(--gray); }
.rule.hit { border-color: rgba(255, 181, 71, 0.45); }

/* ---- the exam grid ---- */
.cells { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.cell { height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-family: var(--mono); border: 1px solid var(--line); }
.cell.pass { background: rgba(61, 220, 151, 0.12); color: var(--green); border-color: rgba(61, 220, 151, 0.35); }
.cell.fail { background: rgba(255, 93, 115, 0.14); color: var(--red); border-color: rgba(255, 93, 115, 0.45); }
.cell.close { box-shadow: 0 0 0 2px var(--amber); }

/* ---- charts ---- */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { fill: var(--ink3); font: 11px var(--sans); }
svg.chart .axis { stroke: rgba(120, 160, 255, 0.22); stroke-width: 1; }
svg.chart .grid { stroke: rgba(120, 160, 255, 0.08); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---- customers ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card { cursor: pointer; transition: 0.15s; }
.card:hover { border-color: var(--line2); transform: translateY(-1px); }
.card.on { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(57, 225, 255, 0.4), var(--shadow); }
.quote { font-style: italic; color: var(--ink2); }

/* ---- code ---- */
pre.code { margin: 0; padding: 14px; border-radius: 12px; background: rgba(2, 4, 10, 0.85); border: 1px solid var(--line); overflow-x: auto; font: 12.5px/1.55 var(--mono); color: #cfe6ff; }
pre.code .k { color: var(--accent); } pre.code .s { color: #b9a6ff; } pre.code .c { color: var(--ink3); }

/* ---- the flow diagram ---- */
.flow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(120px, 1fr); gap: 10px; overflow-x: auto; align-items: stretch; }
.flow .step { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: rgba(4, 8, 18, 0.55); position: relative; }
.flow .step::after { content: "→"; position: absolute; right: -11px; top: 50%; transform: translateY(-50%); color: var(--accent); font-weight: 700; }
.flow .step:last-child::after { content: none; }
.flow .who { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent2); font-weight: 700; }

/* ---- toasts and pulse ---- */
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; background: var(--panel2); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 360px; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.spark { display: inline-block; vertical-align: middle; }
.empty { padding: 28px; text-align: center; color: var(--ink3); border: 1px dashed var(--line2); border-radius: 12px; }
.kbd { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line2); color: var(--ink2); }
@media (max-width: 700px) { h1 { font-size: 24px; } .cells { grid-template-columns: repeat(6, minmax(0, 1fr)); } .who .pick { max-width: 150px; } }
