:root {
  --bg: #f6f9ff;
  --panel: #ffffff;
  --panel-2: #eef4ff;
  --line: #dbe5f2;
  --text: #10213a;
  --muted: #667892;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eaf1ff;
  --danger: #c2413a;
  --radius: 18px;
  --shadow: 0 18px 55px rgba(30, 64, 175, .09);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 82% 2%, rgba(37, 99, 235, .12), transparent 30rem),
    linear-gradient(180deg, #fbfdff 0, var(--bg) 42rem);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .92em; color: var(--accent-dark); }

.page-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; }
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.brand { text-decoration: none; font-weight: 900; letter-spacing: -.04em; font-size: 1.35rem; }
.brand span { color: var(--accent); }
.header-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-family: var(--mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; }
.live-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 0 5px rgba(37, 99, 235, .12); }

.hero { min-height: 600px; padding: 88px 0 70px; align-items: end; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr); gap: 40px; }
.eyebrow { margin: 0 0 15px; color: var(--accent); font-family: var(--mono); font-size: .75rem; letter-spacing: .12em; font-weight: 800; }
.hero h1 { margin: 0; max-width: 900px; font-size: clamp(4.4rem, 10vw, 9.7rem); line-height: .84; letter-spacing: -.075em; text-transform: uppercase; }
.hero h1 em { color: var(--accent); font-style: normal; }
.hero-description { color: var(--muted); max-width: 620px; margin: 36px 0 0; font-size: 1.08rem; line-height: 1.7; }
.latest-card {
  min-height: 320px;
  padding: 26px;
  background: linear-gradient(145deg, #2f6ff2, #1848b8);
  color: #ffffff;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: rotate(1deg);
  box-shadow: 0 30px 75px rgba(29, 78, 216, .24);
}
.card-label { font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; font-weight: 800; }
.latest-title { margin: auto 0 20px; font-size: clamp(2rem, 4vw, 4.4rem); line-height: .92; letter-spacing: -.06em; text-transform: uppercase; }
.latest-date { font-family: var(--mono); font-size: .8rem; opacity: .75; }
.latest-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; border-top: 1px solid rgba(255,255,255,.28); padding-top: 18px; }
.latest-metrics span { display: block; font-size: .64rem; font-family: var(--mono); letter-spacing: .07em; opacity: .72; }
.latest-metrics strong { font-size: 1.15rem; }
.latest-loading { margin: auto 0; font-weight: 700; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card {
  min-height: 245px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 34px rgba(30, 64, 175, .045);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.kpi-label, .kpi-unit { color: var(--muted); font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; }
.kpi-value { font-size: clamp(2.8rem, 5vw, 6.2rem); line-height: .9; letter-spacing: -.07em; }
.accent-card { background: var(--accent-soft); border-color: #bfd2ff; }
.accent-card .kpi-value { color: var(--accent-dark); }

.content-section { padding: 120px 0; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; gap: 40px; align-items: end; margin-bottom: 46px; }
.section-heading h2 { margin: 0; font-size: clamp(2.8rem, 5vw, 5.8rem); line-height: .9; letter-spacing: -.06em; text-transform: uppercase; }
.section-heading > p { color: var(--muted); max-width: 380px; margin: 0; line-height: 1.6; }
.record-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.record-card {
  background: var(--panel);
  border: 1px solid var(--line);
  min-height: 270px;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: 0 10px 34px rgba(30, 64, 175, .045);
  display: flex;
  flex-direction: column;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.record-card:hover { transform: translateY(-4px); border-color: #94b5ff; box-shadow: var(--shadow); }
.record-name { color: var(--muted); font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; }
.record-value { margin: auto 0 8px; font-size: clamp(2.4rem, 4vw, 4.6rem); line-height: .92; letter-spacing: -.06em; }
.record-sub { color: var(--accent-dark); font-family: var(--mono); font-size: .8rem; }
.record-date { color: var(--muted); margin-top: 18px; font-size: .82rem; }

.year-section { position: relative; }
.year-section::before {
  content: "";
  position: absolute;
  inset: 38px -24px;
  z-index: -1;
  border-radius: 34px;
  background: linear-gradient(135deg, rgba(37, 99, 235, .09), rgba(255,255,255,.2));
}
.year-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.year-stat {
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.year-stat span { color: var(--muted); font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.year-stat strong { font-size: clamp(2rem, 4vw, 4.4rem); letter-spacing: -.06em; }

.charts-section { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
.chart-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 10px 34px rgba(30, 64, 175, .045); padding: 26px; min-height: 440px; overflow: hidden; }
.chart-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 34px; }
.chart-heading h3 { margin: 0; font-size: 2rem; letter-spacing: -.04em; }
.chart-heading select, .history-controls select, .history-controls input { background: #ffffff; color: var(--text); border: 1px solid #cbd8e8; border-radius: 10px; padding: 11px 13px; outline: none; }
.chart-heading select:focus, .history-controls select:focus, .history-controls input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.chart-note { color: var(--muted); font-family: var(--mono); font-size: .7rem; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px 14px; color: var(--muted); font-family: var(--mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .04em; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend small { flex-basis: 100%; text-align: right; color: var(--muted); font: inherit; }
.legend-line { width: 18px; height: 3px; border-radius: 99px; background: var(--accent); }
.legend-bar { width: 9px; height: 13px; border-radius: 2px; background: rgba(37, 99, 235, .2); border: 1px solid rgba(37, 99, 235, .35); }
.bar-chart { height: 320px; display: flex; align-items: end; gap: 9px; padding-top: 15px; }
.bar-column { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 9px; }
.bar-value { font-family: var(--mono); font-size: .62rem; color: var(--muted); min-height: 15px; }
.bar { width: 100%; background: linear-gradient(180deg, #4d83f6, var(--accent-dark)); min-height: 2px; border-radius: 5px 5px 1px 1px; opacity: .9; transition: height .4s ease, opacity .2s ease; }
.bar-column:hover .bar { opacity: 1; }
.bar-label { color: var(--muted); font-family: var(--mono); font-size: .63rem; }
.trend-chart-wrap { width: 100%; min-height: 300px; display: flex; align-items: center; }
.trend-chart { width: 100%; overflow: visible; }
.chart-grid-line { stroke: #dfe7f2; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#paceGradient); pointer-events: none; }
.distance-bar { fill: rgba(37, 99, 235, .14); stroke: rgba(37, 99, 235, .22); stroke-width: 1; transition: fill .15s ease; }
.distance-bar:hover { fill: rgba(37, 99, 235, .28); }
.chart-dot { fill: #ffffff; stroke: var(--accent); stroke-width: 3; }
.chart-axis-label { fill: var(--muted); font: 11px var(--mono); }

.recent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.run-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 10px 34px rgba(30, 64, 175, .045); padding: 24px; min-height: 230px; display: flex; flex-direction: column; }
.run-date { color: var(--accent-dark); font-family: var(--mono); font-size: .72rem; letter-spacing: .06em; }
.run-card h3 { margin: 20px 0 auto; font-size: 1.6rem; line-height: 1.05; letter-spacing: -.035em; }
.run-primary { display: flex; align-items: baseline; gap: 8px; margin: 25px 0 15px; }
.run-primary strong { font-size: 2.4rem; letter-spacing: -.06em; }
.run-primary span { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.run-meta { display: flex; gap: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: .72rem; }

.history-heading { align-items: center; }
.history-controls { display: flex; gap: 10px; }
.history-controls input { min-width: 260px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 10px 34px rgba(30, 64, 175, .04); }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 18px 20px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); background: var(--panel-2); font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .9rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f4f7fd; }
.table-title { font-weight: 750; }
.table-muted { color: var(--muted); font-family: var(--mono); font-size: .78rem; }
.history-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 18px; color: var(--muted); font-family: var(--mono); font-size: .74rem; }
.text-button, .text-link { color: var(--accent-dark); border: 0; background: transparent; text-decoration: none; cursor: pointer; font-weight: 800; }
.text-button:hover, .text-link:hover { color: var(--accent); }
.site-footer { display: flex; justify-content: space-between; padding: 30px 0 48px; color: var(--muted); font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; }
.error-state { padding: 100px 0; }
.error-state h2 { font-size: 3rem; margin: 0 0 15px; }
.error-state p { color: var(--muted); }

/* Import page */
.admin-page { min-height: 100vh; }
.admin-shell { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 55px 0 100px; }
.admin-header { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 38px; }
.admin-header h1 { margin: 0; font-size: clamp(2.8rem, 7vw, 5.8rem); letter-spacing: -.065em; line-height: .9; text-transform: uppercase; }
.admin-warning { border: 1px solid #f3c8c4; background: #fff4f2; padding: 18px 20px; border-radius: 14px; margin-bottom: 18px; }
.admin-warning strong { color: var(--danger); }
.admin-warning p { color: var(--muted); margin: 7px 0 0; line-height: 1.5; }
.admin-card { display: grid; grid-template-columns: 80px 1fr; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 10px 34px rgba(30, 64, 175, .045); margin-top: 16px; overflow: hidden; }
.step-number { border-right: 1px solid var(--line); padding: 26px 20px; color: var(--accent); background: var(--accent-soft); font: 800 1rem var(--mono); }
.admin-card-content { padding: 30px; }
.admin-card h2 { margin: 0 0 10px; font-size: 1.8rem; letter-spacing: -.04em; }
.admin-card p { color: var(--muted); line-height: 1.55; }
.status-row { display: flex; align-items: center; gap: 14px; margin: 22px 0; }
.status-pill { display: inline-flex; border-radius: 999px; padding: 8px 11px; font: 700 .7rem var(--mono); letter-spacing: .05em; text-transform: uppercase; }
.status-pill.pending { background: #eef2f7; color: var(--muted); }
.status-pill.ready { background: var(--accent-soft); color: var(--accent-dark); }
.status-pill.missing { background: #fff0ef; color: var(--danger); }
.file-drop { margin: 20px 0; min-height: 150px; border: 1px dashed #8fb1fb; border-radius: 14px; background: #f7faff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; cursor: pointer; transition: background .2s ease, border-color .2s ease; }
.file-drop:hover { background: var(--accent-soft); border-color: var(--accent); }
.file-drop input { position: absolute; opacity: 0; pointer-events: none; }
.file-drop span { font-weight: 800; }
.file-drop small { color: var(--muted); margin-top: 7px; }
.small-drop { min-height: 90px; border-color: var(--line); }
.primary-button, .secondary-button { border: 0; border-radius: 10px; padding: 13px 18px; font-weight: 800; cursor: pointer; }
.primary-button { background: var(--accent); color: #ffffff; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { opacity: .35; cursor: not-allowed; }
.secondary-button { background: #ffffff; color: var(--text); border: 1px solid #cbd8e8; }
.secondary-button:hover { background: var(--panel-2); }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px 0; }
.result-grid div { background: var(--accent-soft); border: 1px solid #d3e0fb; border-radius: 12px; padding: 18px; }
.result-grid span { display: block; color: var(--muted); font: .68rem var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.result-grid strong { display: block; margin-top: 13px; font-size: 2rem; }
.result-actions { display: flex; gap: 10px; }
.save-note { font-size: .84rem; }
.compact-table table { min-width: 680px; }
.compact-table th, .compact-table td { padding: 13px 15px; }

@media (max-width: 1000px) {
  .section-grid, .charts-section { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
  .latest-card { transform: none; min-height: 280px; }
  .kpi-grid, .record-grid { grid-template-columns: repeat(2, 1fr); }
  .recent-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .page-shell { width: min(100% - 28px, 1440px); }
  .site-header { padding: 20px 0; }
  .header-meta { font-size: .62rem; }
  .hero { padding: 62px 0 50px; }
  .hero h1 { font-size: clamp(3.6rem, 19vw, 6rem); }
  .hero-description { font-size: .95rem; }
  .kpi-grid, .record-grid, .year-grid, .recent-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 195px; }
  .content-section { padding: 80px 0; }
  .section-heading, .history-heading { align-items: start; flex-direction: column; }
  .section-heading h2 { font-size: 3.3rem; }
  .history-controls { width: 100%; flex-direction: column; }
  .history-controls input { min-width: 0; width: 100%; }
  .chart-card { padding: 20px; min-height: 400px; }
  .chart-heading { flex-direction: column; }
  .chart-legend { justify-content: flex-start; }
  .chart-legend small { flex-basis: auto; text-align: left; }
  .bar-chart { gap: 4px; }
  .bar-value { display: none; }
  .site-footer { flex-direction: column; gap: 8px; }
  .admin-header { flex-direction: column; align-items: start; }
  .admin-card { grid-template-columns: 54px 1fr; }
  .step-number { padding: 24px 12px; }
  .admin-card-content { padding: 24px 18px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .result-actions { flex-direction: column; }
}
