/* Instrument-panel styling for a benchmark control plane.
 *
 * The chrome and series colours are the validated data-viz palette; both modes
 * are selected, not flipped. Everything is expressed as roles so a chart or a
 * status pill never carries a raw hex value. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-0: #f9f9f7;
  --surface-2: #f2f1ed;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;

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

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-0: #0d0d0d;
    --surface-2: #242422;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --accent: #3987e5;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-0: #0d0d0d;
  --surface-2: #242422;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --accent: #3987e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- shell ------------------------------------------------------------ */

header.top {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 15px;
}
.brand span { color: var(--text-muted); font-weight: 400; }

.top nav { display: flex; gap: 14px; font-family: var(--mono); font-size: 13px; }
.top .spacer { flex: 1; }
.whoami { color: var(--text-muted); font-size: 12px; font-family: var(--mono); }

main { padding: 24px; max-width: 1500px; margin: 0 auto; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px;
}

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 15px; margin: 28px 0 10px; letter-spacing: -0.01em; }
.subtitle { color: var(--text-secondary); margin: 0 0 20px; font-family: var(--mono); font-size: 12px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }

/* --- stat tiles ------------------------------------------------------- */

.stats { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 8px; }
.stat .value { font-family: var(--mono); font-size: 26px; letter-spacing: -0.02em; }
.stat .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- the sweep grid: one cell per parameter combination ---------------- */

.sweep { overflow-x: auto; padding-bottom: 4px; }
.sweep table { border-collapse: separate; border-spacing: 2px; }
.sweep th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: right;
  padding-right: 8px;
  white-space: nowrap;
}
.sweep thead th { text-align: center; padding: 0 0 4px; }

.cell {
  width: 40px;
  height: 26px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-primary);
  border: 1px solid var(--border);
  background: var(--surface-2);
  text-decoration: none;
}
.cell:hover { outline: 2px solid var(--accent); text-decoration: none; }
.cell.succeeded { background: color-mix(in srgb, var(--good) 22%, var(--surface-1)); }
.cell.slo_fail { background: color-mix(in srgb, var(--warning) 32%, var(--surface-1)); }
.cell.failed { background: color-mix(in srgb, var(--critical) 30%, var(--surface-1)); }
.cell.running { background: color-mix(in srgb, var(--accent) 22%, var(--surface-1)); }
.cell.pending { background: var(--surface-2); color: var(--text-muted); }
.cell.skipped {
  background: repeating-linear-gradient(
    135deg, var(--surface-2), var(--surface-2) 3px, var(--surface-1) 3px, var(--surface-1) 6px
  );
  color: var(--text-muted);
}

.legend-cells { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.legend-cells span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend-cells i { width: 12px; height: 12px; border-radius: 2px; border: 1px solid var(--border); display: inline-block; }

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

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-family: var(--mono); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .tick-y { text-anchor: end; }
.chart .tick-x { text-anchor: middle; }
.chart .axis-label { fill: var(--text-secondary); font-family: var(--mono); font-size: 11px; text-anchor: middle; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .marker { stroke: var(--surface-1); stroke-width: 2; }
.chart .series-label { font-family: var(--mono); font-size: 10px; fill: var(--text-secondary); }
.chart .threshold { stroke: var(--critical); stroke-width: 2; stroke-dasharray: 6 4; }
.chart .threshold-label { fill: var(--critical); font-family: var(--mono); font-size: 10px; text-anchor: end; }
.chart .empty { fill: var(--text-muted); font-family: var(--mono); font-size: 12px; text-anchor: middle; }

.chart .s1 .line, .chart .s1 .marker { stroke: var(--series-1); }
.chart .s1 .marker { fill: var(--series-1); }
.chart .s2 .line, .chart .s2 .marker { stroke: var(--series-2); }
.chart .s2 .marker { fill: var(--series-2); }
.chart .s3 .line, .chart .s3 .marker { stroke: var(--series-3); }
.chart .s3 .marker { fill: var(--series-3); }
.chart .s4 .line, .chart .s4 .marker { stroke: var(--series-4); }
.chart .s4 .marker { fill: var(--series-4); }
.chart .s5 .line, .chart .s5 .marker { stroke: var(--series-5); }
.chart .s5 .marker { fill: var(--series-5); }
.chart .s6 .line, .chart .s6 .marker { stroke: var(--series-6); }
.chart .s6 .marker { fill: var(--series-6); }
.chart .s7 .line, .chart .s7 .marker { stroke: var(--series-7); }
.chart .s7 .marker { fill: var(--series-7); }
.chart .s8 .line, .chart .s8 .marker { stroke: var(--series-8); }
.chart .s8 .marker { fill: var(--series-8); }

.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.chart-legend span {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--text-secondary);
}
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-legend .k1 { background: var(--series-1); }
.chart-legend .k2 { background: var(--series-2); }
.chart-legend .k3 { background: var(--series-3); }
.chart-legend .k4 { background: var(--series-4); }
.chart-legend .k5 { background: var(--series-5); }
.chart-legend .k6 { background: var(--series-6); }
.chart-legend .k7 { background: var(--series-7); }
.chart-legend .k8 { background: var(--series-8); }

.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 11px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  z-index: 20;
}

/* --- tables ----------------------------------------------------------- */

table.data { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
table.data th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding: 6px 10px 6px 0;
  white-space: nowrap;
}
table.data td {
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.data tr:hover td { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; }

details.table-view summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 10px;
}

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

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 11px;
  padding: 1px 7px; border-radius: 10px;
  border: 1px solid var(--border); color: var(--text-secondary);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.pill.done::before, .pill.succeeded::before { background: var(--good); }
.pill.running::before { background: var(--accent); }
.pill.failed::before, .pill.done_with_failures::before { background: var(--critical); }
.pill.queued::before { background: var(--warning); }
.pill.cancelled::before, .pill.skipped::before { background: var(--text-muted); }

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

/* --- forms ------------------------------------------------------------ */

textarea {
  width: 100%;
  min-height: 460px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  resize: vertical;
  tab-size: 2;
}

button, .button {
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: transparent; color: #fff; }
button:hover { filter: brightness(1.06); }

.error {
  border-left: 3px solid var(--critical);
  background: color-mix(in srgb, var(--critical) 8%, var(--surface-1));
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.note { color: var(--text-muted); font-size: 12px; }
code, pre {
  font-family: var(--mono);
  background: var(--surface-2);
  border-radius: 3px;
}
code { padding: 1px 5px; font-size: 12px; }
pre { padding: 12px; overflow-x: auto; font-size: 12px; border: 1px solid var(--border); }

.empty-state { color: var(--text-muted); font-family: var(--mono); font-size: 13px; padding: 28px 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
