:root {
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);

  --status-good: #0ca30c;
  --status-critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
  }
}

* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  margin: 0;
  padding: 32px 20px 64px;
}
.wrap { max-width: 1080px; margin: 0 auto; }

h1 { font-size: 22px; font-weight: 650; margin: 0 0 4px; }
.sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 28px; }

section { margin-bottom: 40px; }
h2 {
  font-size: 13px; font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--text-muted); margin: 0 0 14px;
}

.meter-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
}
.meter-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.meter-label { font-size: 14px; color: var(--text-secondary); }
.meter-value { font-size: 14px; font-weight: 650; color: var(--text-primary); }
.meter-track { height: 8px; border-radius: 4px; background: color-mix(in srgb, #2a78d6 18%, var(--surface-1)); overflow: hidden; }
.meter-fill { height: 100%; background: #2a78d6; border-radius: 4px; }
.meter-caption { font-size: 12.5px; color: var(--text-muted); margin-top: 10px; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
@media (max-width: 720px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px;
}
.tile .label { font-size: 12.5px; color: var(--text-secondary); margin-bottom: 8px; }
.tile .value { font-size: 26px; font-weight: 650; line-height: 1.1; }
.tile .value .unit { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.tile .delta { font-size: 12.5px; margin-top: 6px; color: var(--text-muted); }

.card-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 820px) { .card-row { grid-template-columns: 1fr; } }
.tcard {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 18px 16px; position: relative; overflow: hidden;
}
.tcard::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--accent);
}
.tcard .name { font-size: 15px; font-weight: 650; margin: 6px 0 2px; }
.tcard .meta { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.tcard .result-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 650; padding: 3px 9px; border-radius: 20px;
  margin-bottom: 14px;
}
.badge-gold { background: color-mix(in srgb, #eda100 20%, var(--surface-1)); color: #8a6400; }
.badge-silver { background: color-mix(in srgb, var(--text-muted) 20%, var(--surface-1)); color: var(--text-secondary); }
.badge-neutral { background: color-mix(in srgb, var(--status-critical) 14%, var(--surface-1)); color: var(--status-critical); }
@media (prefers-color-scheme: dark) { .badge-gold { color: #eda100; } }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.stat-grid .k { font-size: 12px; color: var(--text-secondary); }
.stat-grid .v { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }

.chart-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 22px 16px;
}
.legend { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

.bar-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar-row .rlabel { font-size: 13px; color: var(--text-secondary); text-align: right; }
.bar-track { position: relative; height: 24px; background: var(--grid); border-radius: 4px; }
.bar-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 4px; }
.bar-fill .bval {
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  font-size: 12.5px; font-weight: 650; color: var(--text-primary); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.grouped-row { margin-bottom: 16px; }
.grouped-row .glabel { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.grouped-bars { display: flex; flex-direction: column; gap: 5px; }
.gbar-track { position: relative; height: 16px; background: var(--grid); border-radius: 3px; }
.gbar-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 3px; }
.gbar-fill .gbval {
  position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
  font-size: 11.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chart-caption { font-size: 12px; color: var(--text-muted); margin-top: 12px; }

.callout {
  background: color-mix(in srgb, #2a78d6 8%, var(--surface-1));
  border: 1px solid var(--border); border-left: 3px solid #2a78d6;
  border-radius: 8px; padding: 14px 18px; font-size: 13.5px; color: var(--text-secondary);
  line-height: 1.55;
}
.callout strong { color: var(--text-primary); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-1); }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
tbody td { padding: 9px 14px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
.name-cell { font-variant-numeric: normal; }
.t-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.t-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.res-tag { display: inline-flex; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 650; }
.res-win { background: color-mix(in srgb, var(--status-good) 16%, var(--surface-1)); color: var(--status-good); }
.res-loss { background: color-mix(in srgb, var(--status-critical) 14%, var(--surface-1)); color: var(--status-critical); }

.oppo-record { font-weight: 650; font-variant-numeric: tabular-nums; }
.oppo-good { color: var(--status-good); }
.oppo-bad { color: var(--status-critical); }
.oppo-even { color: var(--text-secondary); }

.empty { color: var(--text-muted); font-size: 13px; padding: 18px; text-align: center; }
.loading { color: var(--text-muted); font-size: 13px; padding: 18px; }

/* Statistik-sidan */
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px;
  color: var(--text-secondary); text-decoration: none; margin-bottom: 18px;
}
.nav-link:hover { color: var(--text-primary); }
.medal-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.medal-tile { text-align: center; }
.medal-tile .medal-icon { font-size: 28px; margin-bottom: 4px; }
.medal-tile .value { font-size: 22px; font-weight: 650; }
.medal-tile .label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .two-col, .medal-row { grid-template-columns: 1fr; } }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .three-col { grid-template-columns: 1fr; } }
