/* MiMo RL dashboard — design tokens, layout, components. Light and dark are both selected palettes. */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e2e1dc;
  --line-strong: #cfcec8;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8984;
  --accent: #2a78d6;
  --accent-soft: #e3eefb;
  /* categorical series (validated order: blue, orange, aqua, yellow, magenta, green, violet, red) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  /* status (fixed, never themed) */
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px -12px rgba(0,0,0,.12);
  --font: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #232322; --line: #2c2c2a; --line-strong: #3a3a37;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8c8b84; --accent: #3987e5; --accent-soft: #1b2a3d;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232322; --line: #2c2c2a; --line-strong: #3a3a37;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8c8b84; --accent: #3987e5; --accent-soft: #1b2a3d;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -14px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; font-feature-settings: "tnum" 1, "cv11" 1; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--text); }
a { color: var(--accent); }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 10px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--s1), var(--s7)); display: inline-block; }
.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 15px; }
.brand-run { color: var(--text-3); font-family: var(--mono); font-size: 12px; }
.progress { display: grid; gap: 4px; min-width: 0; }
.progress-track { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .6s ease; }
.progress-text { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 12.5px; }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.pill[data-state="running"] .pill-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.pill[data-state="update"] .pill-dot { background: var(--accent); }
.pill[data-state="quiet"] .pill-dot, .pill[data-state="starting"] .pill-dot { background: var(--warn); }
.pill[data-state="attention"] .pill-dot, .pill[data-state="down"] .pill-dot { background: var(--critical); }
.updated { font-size: 12px; color: var(--text-3); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--surface-2); }

/* ---------- page ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 28px; }
.banner { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--critical) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--critical) 40%, var(--line)); color: var(--text); }
.section { display: grid; gap: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head .muted { font-size: 12px; }
.grid { display: grid; gap: 14px; }
.multiples { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.envs { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.foot-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 14px; box-shadow: var(--shadow); display: grid; gap: 4px; align-content: start; }
.stat-label { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-value { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat-value small { font-size: 16px; color: var(--text-2); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.stat-note { font-size: 12.5px; color: var(--text-2); }
.delta-up { color: var(--good); } .delta-down { color: var(--serious); }
.split { display: flex; height: 6px; border-radius: 999px; overflow: hidden; margin-top: 8px; background: var(--surface-2); }
.split span { height: 100%; }
.split .gen { background: var(--s1); } .split .upd { background: var(--s7); } .split .oth { background: var(--line-strong); }

/* ---------- mix ---------- */
.mixbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.mixbar span { height: 100%; min-width: 2px; }
.mix-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.mix-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.chip:hover { background: var(--surface-2); }
.chip.is-on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--text); font-weight: 600; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .last-label { font-size: 11px; font-weight: 600; fill: var(--text-2); font-family: var(--font); }
.chart .crosshair { stroke: var(--text-3); stroke-dasharray: 3 3; stroke-width: 1; }
.chart .hover-target { fill: transparent; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.legend li { list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.legend ul { display: contents; }
.empty { color: var(--text-3); font-size: 12.5px; padding: 18px 0; text-align: center; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); max-width: 260px; }
.tooltip b { font-weight: 600; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; }
.tooltip .row span:last-child { font-family: var(--mono); font-size: 11.5px; }

/* mini multiples */
.mini { display: grid; gap: 6px; }
.mini-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mini-head .name { font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; }
.mini-head .val { font-family: var(--mono); font-size: 13px; color: var(--text); }
.mini-head .sub { font-size: 11.5px; color: var(--text-3); }

/* ---------- environment cards ---------- */
.env { display: grid; gap: 10px; align-content: start; }
.env-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.env-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.env-badge { font-size: 11px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.env-hero { display: flex; align-items: baseline; gap: 10px; }
.env-hero .big { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.env-hero .trend { font-size: 12px; color: var(--text-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px 12px; }
.tile { display: grid; gap: 2px; }
.tile .k { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.tile .v { font-size: 15px; font-weight: 600; font-family: var(--mono); }
.tile .v.warn { color: var(--serious); }
.env-note { font-size: 12px; color: var(--text-2); }
.env table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.env th { text-align: right; padding: 4px 8px 4px 0; font-weight: 600; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 4px 0; border-bottom: 1px solid var(--line); }
.env td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); font-family: var(--mono); text-align: right; white-space: nowrap; }
.env th:first-child, .env td:first-child { text-align: left; }
.env td:first-child { font-family: var(--font); }
.env tr:last-child td { border-bottom: 0; }
.spark svg { height: 48px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: right; font-weight: 600; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
table.data td:first-child { font-family: var(--font); font-size: 13px; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.best { font-weight: 700; color: var(--text); }
table.data td.delta-up { color: var(--good); } table.data td.delta-down { color: var(--serious); }

/* ---------- samples ---------- */
.samples { display: grid; gap: 10px; }
.sample { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.sample summary { list-style: none; cursor: pointer; padding: 12px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.sample summary::-webkit-details-marker { display: none; }
.sample summary:hover { background: var(--surface-2); border-radius: var(--radius); }
.sample .score { font-family: var(--mono); font-weight: 700; font-size: 15px; min-width: 52px; }
.sample .score.hi { color: var(--good); } .sample .score.mid { color: var(--text); } .sample .score.lo { color: var(--serious); }
.sample .title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample .meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.sample .body { padding: 0 16px 14px; display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.sample .body h4 { margin: 0 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.sample pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; line-height: 1.5; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; max-height: 360px; overflow: auto; }
.sample .facts { font-size: 12px; }

/* ---------- facts ---------- */
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.facts dt { color: var(--text-3); }
.facts dd { margin: 0; font-family: var(--mono); font-size: 12.5px; }
.foot { display: grid; gap: 12px; }

@media (max-width: 760px) {
  .topbar-inner { grid-template-columns: 1fr auto; }
  .progress { grid-column: 1 / -1; }
  .brand-run { display: none; }
  .updated { display: none; }
  .stat-value { font-size: 28px; }
  .sample summary { grid-template-columns: auto 1fr; }
  .sample .meta { grid-column: 1 / -1; white-space: normal; }
}

/* ---------- trajectory turns ---------- */
.turns { display: grid; gap: 8px; }
.turn { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; display: grid; gap: 6px; background: var(--surface); }
.turn-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; }
.turn-think { font-size: 12.5px; color: var(--text-2); font-style: italic; white-space: pre-wrap; }
.turn-text { font-size: 13px; white-space: pre-wrap; }
.turn-call { font-family: var(--mono); font-size: 12px; background: var(--accent-soft); border-radius: 6px; padding: 4px 8px; white-space: pre-wrap; word-break: break-word; }
.turn-call .fn { font-weight: 700; color: var(--accent); }
.turn-call .args { color: var(--text-2); }
.sample pre.turn-result { max-height: 160px; font-size: 11.5px; }
.turn-skip { text-align: center; color: var(--text-3); font-size: 12px; padding: 4px; }
.malformed { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--serious) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--serious) 45%, var(--line)); font-size: 12.5px; }
