/* RLX Leaderboard, OptRL brand theme (matches optrl.com dark) */

:root {
  /* Default = dark, matching optrl.com homepage */
  --paper: #0A0A0A;
  --paper-2: #141414;
  --ink: #FAFAF9;
  --ink-2: #D6D3D1;
  --ink-3: #A8A29E;
  --ink-4: #78716C;
  --rule: #2a2724;
  --rule-soft: #1c1a18;
  --grid: rgba(197, 156, 109, 0.05);
  --grid-major: rgba(197, 156, 109, 0.10);
  --accent: #C59C6D;   /* warm tan-gold */
  --accent-2: #E3C79A; /* lighter gold */
  --accent-3: #8a6a3f; /* deep gold */
  --accent-4: #C59C6D;
  --flag: #d68a55;
  --ok: #6db48a;
  --bad: #c87060;
  --chip: #1a1816;
  --chip-border: #2e2a26;
  --shadow: 0 1px 0 rgba(0,0,0,0.6);
  --on-accent: #1A1A1A;

  /* Typography. Inter is the optrl.com font. */
  --serif: 'Crimson Pro', 'Libre Caslon Text', Georgia, serif;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --sans: 'Inter', 'Helvetica Neue', system-ui, sans-serif;
}

:root[data-theme="light"] {
  /* Cream paper / navy ink alt */
  --paper: #f4ecdb;
  --paper-2: #ebe1c8;
  --ink: #0B2545;
  --ink-2: #1f3a5f;
  --ink-3: #5a6b85;
  --ink-4: #8a96a8;
  --rule: #b6b09e;
  --rule-soft: #cfc7b2;
  --grid: rgba(11, 37, 69, 0.07);
  --grid-major: rgba(11, 37, 69, 0.13);
  --accent: #C59C6D;
  --accent-2: #0B2545;
  --accent-3: #8a6a3f;
  --accent-4: #C59C6D;
  --chip: #e6dcc1;
  --chip-border: #b6ad94;
  --on-accent: #1A1A1A;
}

:root[data-theme="accent"] {
  --paper: #0A0A0A;
  --paper-2: #141414;
  --ink: #FAFAF9;
  --accent: #C59C6D;
  --accent-2: #E3C79A;
  --accent-3: #8a6a3f;
  --accent-4: #C59C6D;
  --grid: rgba(197, 156, 109, 0.06);
  --grid-major: rgba(197, 156, 109, 0.11);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px, -1px -1px, -1px -1px, -1px -1px;
  min-height: 100vh;
}

/* ---------- Typography primitives ---------- */
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); }
.sans { font-family: var(--sans); }
.small-caps { font-variant: all-small-caps; letter-spacing: 0.06em; }
.tabular { font-variant-numeric: tabular-nums; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 44px; line-height: 1.05; }
h2 { font-size: 28px; line-height: 1.1; }
h3 { font-size: 20px; line-height: 1.2; }

.kicker {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

/* ---------- Header / Nav ---------- */
.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-square {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand .logo-mark {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand .logo-mark .lm-light { color: var(--ink); }
.brand .logo-mark .lm-gold  { color: var(--accent); }
.brand .logo-mark .sub { font-size: 15px; color: var(--ink-3); font-weight: 500; margin-left: 6px; }
.brand .tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-3);
}

.topbar-meta {
  display: flex;
  gap: 20px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}
.topbar-meta .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
  display: inline-block; margin-right: 6px;
  box-shadow: 0 0 0 3px rgba(63, 107, 74, 0.15);
}

/* Primary nav (tabs) */
.nav {
  display: flex;
  gap: 0;
  margin-top: 0;
  border-bottom: 1px solid var(--rule);
}
.nav-item {
  padding: 14px 20px 14px 0;
  margin-right: 28px;
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  position: relative;
  transition: color 120ms;
}
.nav-item:hover { color: var(--ink); }
.nav-item.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.nav-item .idx {
  color: var(--ink-4);
  margin-right: 8px;
  font-weight: 500;
}
.nav-item.active .idx { color: var(--accent); }

/* ---------- Page title band ---------- */
.page-header {
  padding: 32px 0 20px;
  border-bottom: 1px solid var(--rule-soft);
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 32px;
  align-items: end;
}
.page-header .lede {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--ink-2);
  max-width: 56ch;
  line-height: 1.45;
}
.page-header h1 .annot {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
  margin-left: 10px;
  vertical-align: middle;
  letter-spacing: 0.08em;
}

/* ---------- Leaderboard selector ---------- */
.board-selector {
  display: flex;
  gap: 0;
  margin: 24px 0 8px;
  border: 1px solid var(--ink);
  background: var(--paper-2);
  width: fit-content;
}
.board-tab {
  padding: 10px 18px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: transparent;
  border: none;
  border-right: 1px solid var(--ink);
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
}
.board-tab:last-child { border-right: none; }
.board-tab.active {
  background: var(--ink);
  color: var(--paper);
}
.board-tab .count {
  margin-left: 8px;
  opacity: 0.6;
  font-size: 10px;
}

/* ---------- Filter row ---------- */
.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  flex-wrap: wrap;
}
.filter-row .label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-right: 4px;
}
.chip {
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--chip);
  border: 1px solid var(--chip-border);
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  border-radius: 2px;
  transition: all 100ms;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.chip.accent {
  border-color: var(--accent);
  color: var(--accent);
}
.chip.accent.active {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

/* ---------- Table ---------- */
.tbl-wrap {
  border: 1px solid var(--ink);
  background: var(--paper);
  margin-top: 8px;
  /* The board carries all 11 CSV columns; scroll rather than clip the
     rightmost one on narrow viewports. */
  overflow-x: auto;
  overflow-y: hidden;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 13px;
}
.tbl thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--paper-2);
  border-bottom: 1.5px solid var(--ink);
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tbl thead th:hover { color: var(--ink); }
.tbl thead th.sorted { color: var(--accent); }
.tbl thead th .sort-arrow { margin-left: 4px; opacity: 0.6; font-size: 9px; }
.tbl thead th.num { text-align: right; }

.tbl tbody tr {
  border-bottom: 1px dotted var(--rule);
  transition: background 80ms;
}
.tbl tbody tr:hover { background: var(--paper-2); }
.tbl tbody tr:last-child { border-bottom: none; }

.tbl td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--ink-2);
}
.tbl td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--ink);
}
.tbl td.rank {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  width: 46px;
  text-align: center;
}
.tbl td.rank.gold { color: var(--accent-4); }
.tbl td.rank.medal { color: var(--accent); }

.tbl .algo-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.tbl .algo-cite {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* Class badges */
.cls-badge {
  display: inline-block;
  padding: 2px 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  border: 1px solid currentColor;
  border-radius: 2px;
  text-transform: uppercase;
  background: transparent;
  white-space: nowrap;
}
.cls-policy { color: var(--accent); }
.cls-value { color: var(--accent-3); }
.cls-irl { color: var(--accent-4); }
.cls-offline { color: var(--accent-2); }
.cls-hybrid { color: #7a3ba0; }
.cls-modelbased { color: #2e6d7a; }

/* Tiny NN indicator */
.nn-indicator {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}
.nn-dot {
  width: 6px; height: 6px;
  border: 1px solid var(--ink-3);
  border-radius: 50%;
}
.nn-dot.filled { background: var(--ink-2); border-color: var(--ink-2); }

/* Sparkline cell */
.spark {
  display: inline-block;
  vertical-align: middle;
}

/* Stability bar */
.stab-bar {
  display: inline-block;
  position: relative;
  width: 70px;
  height: 14px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  vertical-align: middle;
}
.stab-bar .fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  background: var(--accent-2);
  opacity: 0.5;
}
.stab-bar .val {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink);
}

/* Metric delta */
.delta-up { color: var(--ok); }
.delta-down { color: var(--bad); }
.delta-pill {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 2px;
  background: var(--paper-2);
  margin-left: 6px;
}

/* ---------- Sections / cards ---------- */
.section { padding: 32px 0; border-bottom: 1px solid var(--rule-soft); }
.section:last-child { border-bottom: none; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-head h2 .num {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-3);
  margin-right: 10px;
  vertical-align: middle;
  letter-spacing: 0.08em;
}

.card {
  border: 1px solid var(--rule);
  background: var(--paper);
  padding: 20px;
  position: relative;
}
.card.ink { border-color: var(--ink); }
.card .corner {
  position: absolute;
  width: 8px; height: 8px;
  border: 1px solid var(--ink);
}
.card .corner.tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.card .corner.tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.card .corner.bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.card .corner.br { bottom: -1px; right: -1px; border-left: none; border-top: none; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 9px 16px;
  background: var(--paper);
  border: 1px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
  transition: all 100ms;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--accent); color: var(--on-accent, var(--paper)); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent, var(--paper)); }
.btn.accent { background: var(--accent); color: var(--on-accent, var(--paper)); border-color: var(--accent); font-weight: 600; }
.btn.ghost { border-color: var(--rule); color: var(--ink-2); }
.btn.ghost:hover { border-color: var(--ink); background: var(--paper-2); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 10px; }

/* ---------- Playground ---------- */
.pg-grid {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 20px;
  margin-top: 20px;
}

.env-card {
  border: 1px solid var(--rule);
  background: var(--paper);
  padding: 14px;
  cursor: pointer;
  transition: all 120ms;
  margin-bottom: 10px;
  position: relative;
}
.env-card:hover { border-color: var(--ink-3); }
.env-card.active {
  border-color: var(--ink);
  background: var(--paper-2);
  box-shadow: 3px 3px 0 var(--ink);
}
.env-card .env-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 2px;
}
.env-card .env-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.env-stage {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  min-height: 480px;
  position: relative;
  overflow: hidden;
}
.env-stage .stage-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ink);
  background: var(--paper-2);
  font-family: var(--mono);
  font-size: 11px;
}
.env-stage .stage-canvas {
  position: relative;
  height: 440px;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
}

.pg-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.control-group {
  border: 1px solid var(--rule);
  padding: 12px 14px;
  background: var(--paper);
}
.control-group .label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 8px;
  display: block;
}
.control-group select, .control-group input[type=text] {
  width: 100%;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  color: var(--ink);
  outline: none;
}
.control-group select:focus, .control-group input:focus { border-color: var(--ink); }

/* ---------- Configure & Train ---------- */
.train-grid {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  gap: 22px;
  align-items: start;
}
.train-select {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  color: var(--ink);
  outline: none;
  margin-top: 6px;
}
.train-select:focus { border-color: var(--ink); }
.class-chip-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

.fit-readout {
  margin-top: 16px;
  padding: 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
}

.hp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.train-launch {
  padding: 14px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--accent);
}
.train-progress {
  height: 6px;
  background: var(--paper);
  border: 1px solid var(--rule);
  margin-top: 12px;
  position: relative;
  overflow: hidden;
}
.train-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 120ms linear;
}

/* ---- Configure & Train v2 layout ---- */
.train-v2-grid {
  display: grid;
  grid-template-columns: minmax(380px, 440px) 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1180px) {
  .train-v2-grid { grid-template-columns: 1fr; }
}
.train-v2-left { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.train-v2-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.hp-section {
  border: 1px solid var(--rule);
  background: var(--paper-2);
  padding: 14px 16px;
}
.hp-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px dotted var(--rule);
}
.hp-section-head .kicker { letter-spacing: 0.08em; }

.hp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 580px) {
  .hp-grid { grid-template-columns: 1fr; }
}
.hp-field {
  display: block;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.4;
}
.hp-field:hover { border-color: var(--ink-3); }
.hp-field input[type=range] {
  width: 100%;
  accent-color: var(--accent);
  margin: 8px 0 6px;
}
.hp-field input[type=number], .hp-field select {
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  color: var(--ink);
  outline: none;
}
.hp-field input[type=number]:focus, .hp-field select:focus { border-color: var(--ink); }
.hp-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  line-height: 1.25;
}
.hp-head > span:first-child {
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-weight: 500;
  font-size: 12px;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: none;
}
.hp-head > span:last-child {
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}
.hp-help {
  margin-top: 6px;
  font-family: var(--serif);
  font-size: 11px;
  font-style: italic;
  color: var(--ink-3);
  line-height: 1.4;
}

.train-launch-v2 {
  padding: 16px 18px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  position: sticky;
  top: 16px;
}
.launch-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.launch-progress-num {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--mono);
  line-height: 1;
}

.train-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 900px) {
  .train-metrics-row { grid-template-columns: repeat(2, 1fr); }
}
.metric-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 12px 14px;
  border-left: 2px solid var(--accent);
  min-width: 0;
}
.mc-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.mc-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 4px;
  line-height: 1;
  overflow-wrap: anywhere;
}
.mc-delta {
  font-family: var(--mono);
  font-size: 10px;
  margin-top: 6px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 900px) {
  .charts-row { grid-template-columns: 1fr; }
}
.chart-box {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 12px 14px;
  min-width: 0;
}
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dotted var(--rule);
}
.chart-head .kicker { flex-shrink: 0; }

/* Algorithm picker block at top of Configure & Train */
.algo-picker {
  padding: 14px 16px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
}
.algo-picker select {
  width: 100%;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
  outline: none;
  margin-top: 6px;
}
.algo-picker select:focus { border-color: var(--ink); }
.algo-picker .class-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dotted var(--rule);
}
.algo-picker .class-chip-row .grow { flex: 1; }

/* compact env-stage in PgTrain: smaller than overview */
.train-v2-right .env-stage { min-height: auto; }
.train-v2-right .stage-canvas svg { max-height: 320px; }

.metric-stack { display: flex; flex-direction: column; gap: 10px; }
.metric-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px dotted var(--rule);
}
.metric-item:last-child { border-bottom: none; }
.metric-item .m-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.metric-item .m-value {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 15, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  width: 480px;
  max-width: 92vw;
  position: relative;
}
.modal .modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink);
  background: var(--paper-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal .modal-body { padding: 22px 20px; }
.modal .modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--paper-2);
}

/* ---------- Tweaks panel ---------- */
.tweaks-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 280px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  z-index: 80;
  font-family: var(--sans);
}
.tweaks-panel .tp-head {
  padding: 10px 14px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.tweaks-panel .tp-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.tweaks-panel.collapsed .tp-body { display: none; }

.tp-group .tp-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 6px;
  display: block;
}
.tp-pills { display: flex; flex-wrap: wrap; gap: 4px; }
.tp-pills .chip { font-size: 10px; padding: 4px 8px; }

/* ---------- Admin ---------- */
.admin-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  margin-top: 20px;
}
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-item {
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-nav-item:hover { color: var(--ink); background: var(--paper-2); }
.admin-nav-item.active {
  color: var(--ink);
  background: var(--paper-2);
  border-left-color: var(--accent);
}
.admin-nav-item .badge {
  background: var(--accent);
  color: var(--paper);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
}

/* Sparkline default color */
.spark path { stroke: var(--accent); fill: none; stroke-width: 1.3; }
.spark .area { fill: var(--accent); opacity: 0.1; stroke: none; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--rule);
  padding: 40px;
  text-align: center;
  background: var(--paper-2);
  transition: all 120ms;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--ink); background: var(--paper); }
.dropzone.drag { border-color: var(--accent); background: rgba(183, 71, 42, 0.05); }

/* Status dots */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
}
.status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
}
.status.ok::before { background: var(--ok); }
.status.warn::before { background: var(--accent-4); }
.status.bad::before { background: var(--bad); }
.status.flag::before { background: var(--accent); }

/* Utility */
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.sep { flex: 1; height: 1px; background: var(--rule); }
.mono-tiny { font-family: var(--mono); font-size: 10px; color: var(--ink-3); letter-spacing: 0.05em; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--ink);
  background: var(--paper);
}
.stat-cell {
  padding: 18px;
  border-right: 1px solid var(--rule);
}
.stat-cell:last-child { border-right: none; }
.stat-cell .k {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.stat-cell .v {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}
.stat-cell .d {
  font-family: var(--mono);
  font-size: 10px;
  margin-top: 6px;
  color: var(--ink-3);
}

/* Footer */
.footer {
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1.5px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* Animations */
@keyframes dashmove {
  to { stroke-dashoffset: -40; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.pulse { animation: pulse 1.6s ease-in-out infinite; }

@keyframes tick {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}
.tick-in { animation: tick 200ms ease-out; }

/* Admin UI Extensions */
.admin-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(18, 18, 18, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.admin-modal {
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 0 12px 36px rgba(0,0,0,0.25);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.admin-modal-head {
  padding: 14px 18px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-modal-body {
  padding: 18px;
}
.admin-json-box {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}
.admin-batch-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--paper-2);
  border: 1px solid var(--accent);
  margin-bottom: 12px;
}
.admin-batch-bar .count {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--accent);
}

