:root {
  --bg: #0a0d0d;
  --panel: #111616;
  --panel-2: #171e1d;
  --ink: #eef4ed;
  --muted: #8c9a97;
  --line: #2b3735;
  --accent: #2de1c2;
  --hazard: #ffb400;
  --danger: #ff6b55;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --body: "Barlow", system-ui, sans-serif;
  --display: "Archivo Black", Impact, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font-family: var(--body); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 82% 0%, rgba(45, 225, 194, .12), transparent 28%), var(--bg); }
button, input, select { font: inherit; }
button:disabled { cursor: not-allowed; opacity: .35; transform: none !important; }
code { color: var(--accent); font-family: var(--mono); }
.grain { position: fixed; inset: 0; pointer-events: none; z-index: 10; opacity: .3; background: repeating-linear-gradient(135deg, rgba(255,255,255,.018) 0 1px, transparent 1px 5px); }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 20; background: var(--accent); color: #04110e; padding: 10px 14px; }
.skip-link:focus { top: 16px; }

.masthead { max-width: 1600px; margin: auto; padding: 48px clamp(20px, 5vw, 78px) 30px; display: flex; justify-content: space-between; align-items: end; border-bottom: 1px solid var(--line); }
.eyebrow, .metric-tag, .section-heading span, .filter-grid label > span, .result-band article > span, .rows-field > span, footer { font: 600 11px/1.4 var(--mono); letter-spacing: .14em; color: var(--accent); }
h1 { margin: 8px 0 0; font: 400 clamp(3.5rem, 9vw, 8.8rem)/.78 var(--display); letter-spacing: -.065em; }
h1 span { color: transparent; -webkit-text-stroke: 1.5px var(--ink); }
.run-state { min-width: 190px; padding: 16px; display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); background: rgba(17,22,22,.8); }
.run-state small { display: block; color: var(--muted); font: 10px var(--mono); letter-spacing: .16em; }
.run-state strong { display: block; margin-top: 5px; text-transform: uppercase; }
.pulse { width: 12px; height: 12px; border: 2px solid var(--muted); transform: rotate(45deg); }
.pulse.complete, .pulse.running { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 18px rgba(45,225,194,.7); }
.pulse.running { animation: pulse 1.4s ease-in-out infinite; }
.pulse.paused { border-color: var(--hazard); background: var(--hazard); }
.pulse.error { border-color: var(--danger); background: var(--danger); }

main { max-width: 1600px; margin: auto; padding: 24px clamp(20px, 5vw, 78px) 70px; }
.explorer-panel, .results-panel, .scope-panel, .event-panel, .method-panel { margin-top: 28px; border: 1px solid var(--line); background: rgba(17,22,22,.82); }
.section-heading { padding: 22px; display: flex; justify-content: space-between; align-items: end; gap: 30px; border-bottom: 1px solid var(--line); }
.section-heading.compact { border-bottom: 0; }
.section-heading h2 { margin: 7px 0 0; font: 400 clamp(1.4rem, 2.5vw, 2.3rem) var(--display); letter-spacing: -.035em; }
.section-heading p { max-width: 630px; margin: 0; color: var(--muted); font: 12px/1.6 var(--mono); }
.hero-heading { background: linear-gradient(105deg, rgba(45,225,194,.08), transparent 55%); }

.filter-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)) auto; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.filter-grid label, .rows-field { display: flex; flex-direction: column; gap: 9px; padding: 18px; background: #0d1211; }
.filter-grid select, .rows-field select { min-height: 46px; width: 100%; padding: 0 38px 0 12px; border: 1px solid #41504e; border-radius: 0; background: #080b0b; color: var(--ink); outline: none; }
.filter-grid select:focus, .rows-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(45,225,194,.12); }
button { min-height: 44px; padding: 0 18px; border: 1px solid var(--accent); background: var(--accent); color: #04110e; font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; cursor: pointer; transition: transform .2s ease, background .2s ease; }
button:hover { transform: translateY(-2px); }
button:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--hazard); outline-offset: 3px; }
button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.reset-button { min-height: 100%; border: 0; background: #111716 !important; padding-inline: 22px; }

.result-band { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); position: relative; }
.result-band[aria-busy="true"] article { opacity: .45; }
.result-band article { min-height: 166px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); transition: opacity .18s ease; }
.result-band article strong { font: 400 clamp(2.25rem, 4.3vw, 4.3rem)/1 var(--display); letter-spacing: -.055em; }
.result-band article small { color: var(--muted); font: 10px/1.5 var(--mono); }
.result-primary { background: var(--accent); color: #061310; }
.result-primary > span, .result-primary small { color: #16453c !important; }
.result-primary .drop-positive { color: #681d13; }
.result-primary .drop-negative { color: #06483c; }
.result-note { grid-column: 1 / -1; padding: 12px 20px; color: var(--muted); background: #0b0f0f; font: 11px/1.5 var(--mono); }

.evidence-actions { display: flex; align-items: end; gap: 10px; }
.rows-field { min-width: 100px; padding: 0; background: transparent; }
.rows-field select { min-height: 44px; }
.export-button { white-space: nowrap; }
.table-wrap { overflow: auto; max-height: 720px; }
table { width: 100%; border-collapse: collapse; min-width: 1450px; }
thead { position: sticky; top: 0; z-index: 2; background: #0b0f0f; }
th, td { padding: 14px 15px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font: 600 10px var(--mono); letter-spacing: .1em; }
td { font-size: 13px; }
td small, .position-cell small, .match-date { display: block; margin-top: 5px; color: var(--muted); font: 9px/1.4 var(--mono); }
td.mono { font-family: var(--mono); font-size: 11px; }
.match-teams { display: block; max-width: 180px; margin-top: 5px; font-size: 12px; }
.match-date { margin-top: 0; color: var(--accent); }
.energy-drop { font-weight: 700; white-space: nowrap; }
.drop-positive { color: var(--danger); }
.drop-negative { color: var(--accent); }
.retirement-badge { display: inline-flex; min-width: 64px; padding: 5px 7px; justify-content: center; border: 1px solid var(--line); color: var(--muted); font: 600 9px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.retirement-badge.yellow { border-color: #e4cb43; color: #f2df76; background: rgba(228,203,67,.1); }
.retirement-badge.orange { border-color: #ff8a32; color: #ffad70; background: rgba(255,138,50,.1); }
.retirement-badge.red { border-color: var(--danger); color: #ff9685; background: rgba(255,107,85,.1); }
.retirement-badge.none { color: var(--muted); }
.pagination { min-height: 70px; padding: 13px 18px; display: flex; justify-content: center; align-items: center; gap: 18px; border-top: 1px solid var(--line); }
.pagination span { min-width: 190px; text-align: center; color: var(--muted); font: 11px var(--mono); }
.empty { color: var(--muted); font-style: italic; }

.scope-panel { padding-bottom: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.metric { min-height: 156px; padding: 20px; border-right: 1px solid var(--line); background: rgba(17,22,22,.7); display: flex; flex-direction: column; justify-content: space-between; }
.metric:last-child { border: 0; }
.metric strong { font: 400 clamp(2rem, 4vw, 3.9rem)/1 var(--display); letter-spacing: -.05em; }
.metric small { font: 500 10px var(--mono); color: var(--muted); letter-spacing: .08em; }
.metric.accent { background: var(--accent); color: #061310; }
.metric.accent .metric-tag, .metric.accent small { color: #153e37; }
.pipeline { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); }
.pipe-step { padding: 20px; border-right: 1px solid var(--line); }
.pipe-step:last-child { border: 0; }
.pipe-step strong { display: block; margin-bottom: 8px; font: 600 12px var(--mono); }
.pipe-step span { color: var(--muted); font: 10px var(--mono); }
.pipe-step.done { box-shadow: inset 0 -4px var(--accent); }
.pipe-step.active { box-shadow: inset 0 -4px var(--hazard); }

.method-panel { padding: 0; }
.method-panel summary { padding: 19px 22px; cursor: pointer; color: var(--accent); font: 600 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.method-panel > div { padding: 0 22px 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; border-top: 1px solid var(--line); }
.method-panel p { margin: 18px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.method-panel strong { color: var(--ink); }
.event-panel ol { margin: 0; padding: 0; list-style: none; }
.event-panel li { display: grid; grid-template-columns: 150px 70px 1fr; gap: 12px; padding: 12px 22px; border-top: 1px solid var(--line); font: 10px/1.5 var(--mono); }
.event-panel li span:first-child { color: var(--muted); }
.level-warn { color: var(--hazard); }
.level-error { color: var(--danger); }
.level-info { color: var(--accent); }

footer { max-width: 1600px; margin: auto; padding: 22px clamp(20px, 5vw, 78px) 38px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: 380px; padding: 14px 18px; background: var(--ink); color: var(--bg); font: 12px var(--mono); transform: translateY(130%); transition: transform .25s ease; }
.toast.visible { transform: translateY(0); }

@keyframes pulse { 50% { opacity: .4; transform: rotate(45deg) scale(.75); } }
@media (max-width: 1400px) {
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .result-band { grid-template-columns: repeat(2, 1fr); }
  .result-band article:nth-child(2) { border-right: 0; }
  .result-band article { border-bottom: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .masthead { align-items: start; flex-direction: column; gap: 28px; }
  .run-state { width: 100%; }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric { border-bottom: 1px solid var(--line); }
  .method-panel > div { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 580px) {
  .section-heading { align-items: start; flex-direction: column; }
  .filter-grid, .result-band, .metric-grid, .pipeline { grid-template-columns: 1fr; }
  .result-band article, .metric, .pipe-step { border-right: 0; border-bottom: 1px solid var(--line); }
  .result-band article { min-height: 135px; }
  .result-note { grid-column: auto; }
  .evidence-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .rows-field { width: 100%; }
  .pagination { justify-content: space-between; gap: 8px; }
  .pagination span { min-width: auto; }
  .event-panel li { grid-template-columns: 1fr; }
  footer { flex-direction: column; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
