/* One stylesheet for every surface.
 *
 * Dense and quiet on purpose: these are operations screens, read for hours
 * by people who need to find one wrong number among three hundred right
 * ones. Colour is reserved for state, never for decoration, so that when
 * something IS coloured it means something.
 */

:root {
  --bg: #0e1116;
  --panel: #161a22;
  --panel-2: #1c212b;
  --line: #262c38;
  --ink: #e6e9ef;
  --ink-dim: #9aa4b5;
  --ink-faint: #6b7489;

  --accent: #5b9dff;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --policy: #a371f7;

  /* Validated categorical slots 1 and 3, plus a status threshold and a
   * second-panel hue. The pair that was here before (amber vs green)
   * failed CVD separation at ΔE 5.1 for protanopia. */
  --series-held: #3987e5;
  --series-serving: #199e70;
  --series-load: #d95926;
  --series-ceiling: #e66767;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --radius: 10px;
}

:root:not([data-theme="dark"]) {
  @media (prefers-color-scheme: light) {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --panel-2: #f1f3f6;
    --line: #dfe3ea;
    --ink: #11151c;
    --ink-dim: #5b6472;
    --ink-faint: #878f9d;
    --accent: #1f6feb;
    --ok: #1a7f37;
    --warn: #9a6700;
    --bad: #cf222e;
    --policy: #8250df;
  --series-held: #2a78d6;
  --series-serving: #1baf7a;
  --series-load: #eb6834;
  --series-ceiling: #e34948;
  }
}

:root[data-theme="light"] {
  --series-held: #2a78d6;
  --series-serving: #1baf7a;
  --series-load: #eb6834;
  --series-ceiling: #e34948;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --line: #dfe3ea;
  --ink: #11151c;
  --ink-dim: #5b6472;
  --ink-faint: #878f9d;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --policy: #8250df;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* ------------------------------------------------------------- chrome */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.top nav { display: flex; gap: 2px; flex-wrap: wrap; }

.top nav a {
  padding: 6px 11px;
  border-radius: 7px;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.top nav a:hover { background: var(--panel-2); color: var(--ink); }
.top nav a.on { background: var(--panel-2); color: var(--ink); font-weight: 600; }

.spacer { flex: 1; }

.demo-tag {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  cursor: help;
}

.persona {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  font: 13px var(--sans);
  max-width: 320px;
}

/* -------------------------------------------------------------- layout */

.page-head { margin: 20px 0 18px; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -0.02em; }
.page-head .sub { margin: 0; color: var(--ink-dim); max-width: 78ch; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  font-weight: 650;
}

.cols { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .cols.two { grid-template-columns: 1fr 1fr; }
  .cols.three { grid-template-columns: repeat(3, 1fr); }
  .cols.side { grid-template-columns: 1.6fr 1fr; }
}

/* --------------------------------------------------------------- stats */

.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
}
.stat .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-faint); margin-bottom: 6px;
}
.stat .v { font: 600 24px/1.1 var(--mono); letter-spacing: -0.02em; }
.stat .n { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }
.stat.ok .v { color: var(--ok); }
.stat.warn .v { color: var(--warn); }
.stat.bad .v { color: var(--bad); }

/* --------------------------------------------------------------- table */

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left; padding: 7px 10px;
  color: var(--ink-faint); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td {
  padding: 8px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  vertical-align: top;
}
table.grid tbody tr:hover { background: var(--panel-2); }
table.grid td.num, table.grid th.num { text-align: right; font-family: var(--mono); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--ink-faint); }
.wrap { white-space: normal; max-width: 52ch; }

/* --------------------------------------------------------------- pills */

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font: 500 11px/1.7 var(--mono);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.policy { color: var(--policy); border-color: color-mix(in srgb, var(--policy) 40%, transparent); }

/* ------------------------------------------------------------ refusals */

/* A refusal gets a panel of its own rather than an empty table, because
 * "you may not see this" and "there is nothing here" are different facts
 * and a customer who confuses them files a support ticket. */
.refusal {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--policy) 7%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--policy) 28%, transparent);
  border-radius: 9px;
  margin-bottom: 10px;
}
.refusal strong { display: block; font-size: 13px; margin-bottom: 2px; }
.refusal p { margin: 0; color: var(--ink-dim); font-size: 13px; }

/* -------------------------------------------------------------- buttons */

button, .btn {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 13px;
  font: 500 13px var(--sans);
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { filter: brightness(1.08); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input[type=text], input[type=number], select {
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; font: 13px var(--sans);
}

/* ----------------------------------------------------------- the ladder */

/* Replica cards for the serving page: one per NPU. The product is that
 * these appear and disappear, so they animate in. */
.replicas { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.replica {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  background: var(--panel-2);
  animation: pop 220ms ease-out;
}
.replica.ready { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.replica.pending { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.replica .card-id { font: 600 13px var(--mono); margin-bottom: 4px; }
.replica .pod { font: 11px var(--mono); color: var(--ink-faint); word-break: break-all; }

@keyframes pop { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.slot {
  border: 1px dashed var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  color: var(--ink-faint);
  font: 12px var(--mono);
  display: flex; align-items: center; justify-content: center;
  min-height: 62px;
}

/* ---------------------------------------------------------------- chart */

.chart { width: 100%; height: 230px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-dim); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 5px; }

/* ----------------------------------------------------------------- logs */

.logs {
  background: #0a0c10;
  color: #c9d1d9;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  font: 11.5px/1.65 var(--mono);
  max-height: 440px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
:root[data-theme="light"] .logs { background: #0d1117; }

/* ----------------------------------------------------------------- tree */

.tree { font: 13px var(--mono); }
.tree .node { padding: 5px 0 5px 0; display: flex; gap: 8px; align-items: center; }
.tree .depth-1 { padding-left: 22px; }
.tree .depth-2 { padding-left: 44px; }
.tree .depth-3 { padding-left: 66px; }
.tree .you { outline: 1px solid var(--accent); border-radius: 6px; padding-left: 6px; }

/* ----------------------------------------------------------------- misc */

.note {
  font-size: 12.5px; color: var(--ink-dim);
  border-left: 2px solid var(--line);
  padding-left: 11px; margin: 10px 0;
}
.gap {
  font-size: 12.5px;
  background: color-mix(in srgb, var(--warn) 8%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: 8px; padding: 9px 12px; margin: 10px 0;
}
.gap strong { color: var(--warn); }

a { color: var(--accent); }

.persona-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.persona-card {
  display: block; text-decoration: none; color: inherit;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 14px;
}
.persona-card:hover { border-color: var(--accent); }
.persona-card h3 { margin: 0 0 3px; font-size: 14px; }
.persona-card .role { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.persona-card p { margin: 7px 0 0; font-size: 12.5px; color: var(--ink-dim); }

/* ---------------------------------------------------------------- charts */

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: 11.5px/1.7 var(--mono);
  color: var(--ink);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.28);
  min-width: 170px;
  z-index: 3;
}
.chart-tip strong { display: block; margin-bottom: 4px; color: var(--ink-dim); }
.chart-tip span { display: flex; align-items: center; gap: 6px; }
.chart-tip i { width: 9px; height: 2px; border-radius: 1px; flex: none; }
.chart-tip b { margin-left: auto; font-weight: 600; }

/* The table view. Identity is never colour alone, and a reader who cannot
 * use the chart still gets the numbers. */
details.table-view { margin-top: 12px; }
details.table-view summary { color: var(--ink-dim); font-size: 12.5px; cursor: pointer; }
details.table-view table { margin-top: 9px; }
