/* Atlas demo suite — shared visual shell.
   Tuned for a projector in a lit training room: high contrast, large base
   type, no thin greys, no colour-only encoding. Light by default; the dark
   toggle exists because some rooms have a good screen and low light. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d6dae1;
  --border-strong: #b6bcc7;
  --text: #14181f;
  --text-dim: #4a5262;
  --text-faint: #6b7383;

  --accent: #1c5fd6;
  --accent-weak: #e6eefc;
  --good: #0f7a45;
  --good-weak: #e2f4ea;
  --warn: #9a5b00;
  --warn-weak: #fdf0dc;
  --bad: #b3261e;
  --bad-weak: #fbe6e5;
  --violet: #6b3fa0;
  --violet-weak: #f0e9f8;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 4px 12px rgba(16, 24, 40, .08), 0 12px 32px rgba(16, 24, 40, .10);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f1218;
  --surface: #171b23;
  --surface-2: #1e232d;
  --border: #2b323e;
  --border-strong: #3d4654;
  --text: #eef1f6;
  --text-dim: #a8b1c1;
  --text-faint: #7c8698;
  --accent: #6ea3ff;
  --accent-weak: #16233d;
  --good: #4ade80;
  --good-weak: #10241a;
  --warn: #fbbf24;
  --warn-weak: #2a2110;
  --bad: #f87171;
  --bad-weak: #2c1517;
  --violet: #c4a3f0;
  --violet-weak: #221a30;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -.01em; font-size: 15px;
  text-decoration: none; color: var(--text); white-space: nowrap;
}
.topbar .brand .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
.topbar .demo-no {
  font: 600 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-weak);
  padding: 5px 8px; border-radius: 5px;
}
.topbar nav { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; }
.topbar nav a {
  padding: 7px 11px; border-radius: var(--radius-sm);
  color: var(--text-dim); text-decoration: none; font-weight: 550; font-size: 14px;
  white-space: nowrap;
}
.topbar nav a:hover { background: var(--surface-2); color: var(--text); }
.topbar nav a.active { background: var(--accent-weak); color: var(--accent); }
.topbar .spacer { flex: 1; }

.page { max-width: 1400px; margin: 0 auto; padding: 22px 20px 80px; }
.page.wide { max-width: 1680px; }

h1 { font-size: 25px; letter-spacing: -.022em; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 18px; letter-spacing: -.014em; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14.5px; margin: 0 0 8px; font-weight: 650; }
p  { margin: 0 0 12px; color: var(--text-dim); }
a  { color: var(--accent); }

.lede { font-size: 15.5px; color: var(--text-dim); max-width: 78ch; margin-bottom: 20px; }

/* ---------- primitives ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px)  { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: 600 14px var(--sans); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.lg { padding: 11px 20px; font-size: 15px; }

input[type=text], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; font: 15px var(--sans);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { font: 14px/1.5 var(--sans); resize: vertical; }
label { display: block; font-size: 12.5px; font-weight: 620; color: var(--text-dim); margin-bottom: 5px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font: 600 12px var(--sans); white-space: nowrap;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
}
.pill.good   { background: var(--good-weak);   color: var(--good);   border-color: transparent; }
.pill.bad    { background: var(--bad-weak);    color: var(--bad);    border-color: transparent; }
.pill.warn   { background: var(--warn-weak);   color: var(--warn);   border-color: transparent; }
.pill.accent { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.pill.violet { background: var(--violet-weak); color: var(--violet); border-color: transparent; }

code, .mono { font-family: var(--mono); font-size: .92em; }
code:not(pre code) {
  background: var(--surface-2); padding: 1.5px 5px; border-radius: 4px;
  border: 1px solid var(--border);
}
pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px; overflow: auto;
  font: 12.8px/1.5 var(--mono); margin: 0 0 12px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 11px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  font: 620 11.5px var(--sans); text-transform: uppercase; letter-spacing: .045em;
  color: var(--text-faint); background: var(--surface-2);
  position: sticky; top: 0; z-index: 1;
}
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; }

/* ---------- metric tiles ---------- */

.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.tile .k {
  font: 620 11px var(--sans); text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); margin-bottom: 6px;
}
.tile .v { font: 700 26px/1.1 var(--sans); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 5px; }
.tile .v.good { color: var(--good); }
.tile .v.bad  { color: var(--bad); }
.tile .v.warn { color: var(--warn); }
.delta { font: 620 13px var(--mono); }
.delta.up   { color: var(--good); }
.delta.down { color: var(--bad); }

/* ---------- callouts ---------- */

.note {
  border-left: 3px solid var(--accent); background: var(--accent-weak);
  padding: 11px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px; color: var(--text); margin: 0 0 14px;
}
.note.warn { border-color: var(--warn); background: var(--warn-weak); }
.note.bad  { border-color: var(--bad);  background: var(--bad-weak); }
.note.good { border-color: var(--good); background: var(--good-weak); }
.note strong { font-weight: 680; }

/* The teaching beat: what the room should notice, and when. */
.beat {
  border: 1px dashed var(--violet); background: var(--violet-weak);
  border-radius: var(--radius-sm); padding: 11px 14px; margin: 0 0 14px;
  font-size: 14px;
}
.beat .lbl {
  font: 700 10.5px var(--sans); letter-spacing: .09em; text-transform: uppercase;
  color: var(--violet); display: block; margin-bottom: 4px;
}

/* ---------- tabs / steps ---------- */

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  padding: 9px 14px; border: none; background: none; cursor: pointer;
  font: 600 14px var(--sans); color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.steps { counter-reset: step; }
.step {
  position: relative; padding-left: 38px; padding-bottom: 18px;
  border-left: 2px solid var(--border); margin-left: 12px;
}
.step:last-child { border-left-color: transparent; padding-bottom: 0; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: -13px; top: -2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  font: 700 12px var(--mono); color: var(--text-dim);
}
.step.done::before { background: var(--good); border-color: var(--good); color: #fff; content: "\2713"; }
.step.active::before { background: var(--accent); border-color: var(--accent); color: #fff; }

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

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--text-faint); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.nowrap { white-space: nowrap; }
.scroll-y { overflow-y: auto; }
.hidden { display: none !important; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }

.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar > i.good { background: var(--good); }
.bar > i.bad  { background: var(--bad); }
.bar > i.warn { background: var(--warn); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-faint); font-weight: 600; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.8px; word-break: break-word; }

mark { background: #fde68a; color: #14181f; padding: 0 2px; border-radius: 2px; }
[data-theme="dark"] mark { background: #7c5c00; color: #fff; }

.cite {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 5px; margin: 0 2px;
  border-radius: 4px; background: var(--accent-weak); color: var(--accent);
  font: 700 11px var(--mono); cursor: pointer; vertical-align: baseline;
  border: 1px solid transparent;
}
.cite:hover { border-color: var(--accent); }
.cite.bad { background: var(--bad-weak); color: var(--bad); }

/* Trace tree */
.trace-row {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer;
}
.trace-row:hover { background: var(--surface-2); border-color: var(--border); }
.trace-row .nm { font-family: var(--mono); font-size: 12.6px; }
.trace-row .dur { font-family: var(--mono); font-size: 12.3px; color: var(--text-faint); }
.trace-row.kind-llm       { border-left: 3px solid var(--violet); }
.trace-row.kind-retrieval { border-left: 3px solid var(--accent); }
.trace-row.kind-tool      { border-left: 3px solid var(--warn); }
.trace-row.kind-guardrail { border-left: 3px solid var(--bad); }
.trace-row.err { background: var(--bad-weak); }

/* ---------- visualization tokens ----------
   Categorical slots, the sequential ramp and the diverging pair below are the
   validated default palette, checked with the palette validator against THIS
   file's two surfaces (#ffffff light, #171b23 dark): all gates pass in both
   modes. Light mode raises a sub-3:1 contrast warning on slots 3/4/5, which
   obliges relief -- every chart in this suite ships a legend, selective direct
   labels and a table view, which satisfies it. Do not re-order these slots:
   the ordering is the colour-vision-deficiency safety mechanism, not taste. */

:root {
  --s1: #2a78d6;  /* blue    */
  --s2: #eb6834;  /* orange  */
  --s3: #1baf7a;  /* aqua    */
  --s4: #eda100;  /* yellow  */
  --s5: #e87ba4;  /* magenta */
  --s6: #008300;  /* green   */
  --s7: #4a3aa7;  /* violet  */
  --s8: #e34948;  /* red     */

  /* Sequential ramp (one hue, light -> dark) for heatmaps and magnitude. */
  --q1: #cde2fb; --q2: #9ec5f4; --q3: #6da7ec; --q4: #3987e5;
  --q5: #256abf; --q6: #184f95; --q7: #0d366b;

  /* Diverging: blue <-> red with a NEUTRAL GREY midpoint (never a hue). */
  --d-neg: #2a78d6; --d-mid: #f0efec; --d-pos: #d03b3b;

  /* Status marks. Distinct from the categorical slots so a status colour can
     never impersonate a series. Always shipped with an icon or a label. */
  --st-good: #0ca30c; --st-warn: #fab219; --st-serious: #ec835a; --st-crit: #d03b3b;

  /* Chart chrome. */
  --viz-surface: #ffffff;
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --viz-ink: #0b0b0b;
  --viz-ink-2: #52514e;
  --viz-muted: #898781;
}

[data-theme="dark"] {
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --q1: #0d366b; --q2: #184f95; --q3: #256abf; --q4: #3987e5;
  --q5: #6da7ec; --q6: #9ec5f4; --q7: #cde2fb;
  --d-neg: #3987e5; --d-mid: #383835; --d-pos: #d03b3b;
  --viz-surface: #171b23;
  --viz-grid: #2c2c2a;
  --viz-axis: #383835;
  --viz-ink: #ffffff;
  --viz-ink-2: #c3c2b7;
  --viz-muted: #898781;
}

.viz { position: relative; }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz .viz-title { font: 650 14px var(--sans); color: var(--text); margin-bottom: 2px; }
.viz .viz-sub { font: 13px var(--sans); color: var(--text-faint); margin-bottom: 10px; }

/* Legend: always present for two or more series. Identity is the swatch, not
   the text colour -- the label itself stays in an ink token. */
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 0; padding: 0; list-style: none; }
.viz-legend li { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
.viz-legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.viz-legend .sw.line { height: 3px; width: 15px; border-radius: 2px; }
.viz-legend li.off { opacity: .38; }
.viz-legend li[role=button] { cursor: pointer; }

.viz-tip {
  position: absolute; pointer-events: none; z-index: 30;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 8px 10px; font-size: 12.8px; color: var(--text);
  min-width: 120px; transform: translate(-50%, -100%);
  transition: opacity .08s;
}
.viz-tip .t-hd { font-weight: 650; margin-bottom: 5px; font-size: 12.5px; }
.viz-tip .t-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.viz-tip .t-row .nm { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); }
.viz-tip .t-row .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.viz-tip .t-row .v { font-family: var(--mono); font-size: 12.3px; font-variant-numeric: tabular-nums; }

.viz-tools { display: flex; gap: 6px; align-items: center; }
.viz-table { max-height: 320px; overflow: auto; margin-top: 12px; }
.viz-table table { font-size: 13px; }

/* Print / export */
@media print {
  .topbar, .btn, .tabs { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}
