/* ═══════════════════════════════════════════════════════════════
   SKOLKOLL — Design System v2
   A calm, professional data-tool aesthetic.
   Inspired by Linear, Notion, and Scandinavian design principles.
   ═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  /* Palette — calmer, more professional greens + warm neutrals */
  --bg: #f6f7f4;
  --bg-deep: #eef0ea;
  --surface: #ffffff;
  --surface-dim: #f9faf8;
  --ink: #1a2024;
  --ink-secondary: #3d4f54;
  --muted: #64787e;
  --faint: #9aacb0;
  --line: #dfe5e2;
  --line-soft: #edf0ed;

  /* Brand — deeper, more authoritative teal */
  --brand: #0a6b56;
  --brand-strong: #064d3e;
  --brand-soft: #e0f3ed;
  --brand-muted: #b2ddd0;

  /* Accent — warm gold for metrics and highlights */
  --accent: #c5851e;
  --accent-soft: #fdf3e4;
  --accent-border: #e8c98a;

  /* Status colours */
  --warn: #9e4a0f;
  --warn-bg: #fef7f0;
  --warn-border: #f0c9a0;
  --error: #b52534;
  --error-bg: #fef1f3;
  --error-border: #f0a0aa;
  --success: #0a6b56;
  --success-bg: #e0f3ed;

  /* Geometry */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Shadows — layered for depth */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.05), 0 1px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.12), 0 8px 20px rgba(0, 0, 0, 0.06);

  /* Timing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.15s;
  --duration: 0.25s;
  --duration-slow: 0.4s;
}

/* ── Reset & base ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: "Sora", "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

::selection {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

/* ── Skip link ─────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -50px;
  left: 1rem;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  z-index: 200;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: top var(--duration) var(--ease-out);
}

.skip-link:focus {
  top: 1rem;
}

/* ── Layout ────────────────────────────────────────────────── */
.layout {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
  display: grid;
  gap: 1.25rem;
}

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, summary {
  font-family: "Literata", "Iowan Old Style", Georgia, serif;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 { font-size: clamp(1.6rem, 2.5vw, 2.4rem); }
h2 { font-size: clamp(1.15rem, 1.5vw, 1.4rem); margin-bottom: 0.5rem; }
h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ── Panel system ──────────────────────────────────────────── */
.panel,
.results-head {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  animation: rise-in var(--duration-slow) var(--ease-out) both;
}

.panel-elevated {
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.panel-head {
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin-bottom: 0.25rem;
}

.panel-head p {
  margin-bottom: 0;
}

/* ── Hero (consolidated: branding + search + quick searches) ── */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0a6b56 0%, #064d3e 50%, #043830 100%);
  color: #f0faf6;
  padding: 2rem;
}

.hero::before {
  content: "";
  position: absolute;
  top: -60%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(255, 220, 160, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  bottom: -40%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(180, 240, 220, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: rgba(180, 230, 210, 0.7);
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  color: #fff;
  font-weight: 700;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
}

.hero h1 img.chalk-logo {
  display: block;
  width: clamp(180px, 30vw, 320px);
  height: auto;
}

.lead {
  margin: 0.3rem 0 0;
  max-width: 55ch;
  color: rgba(220, 245, 235, 0.75);
  line-height: 1.5;
  font-size: 0.88rem;
}

.hero-nav {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.hero-nav a {
  color: rgba(240, 255, 248, 0.9);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-spring);
}

.hero-nav a:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.hero-nav a:active {
  transform: translateY(0);
}

/* ── Hero search bar ───────────────────────────────────────── */
.hero-search {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.65rem;
}

.search-row {
  display: flex;
  gap: 0;
}

.search-field {
  flex: 1;
  display: block;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.search-field input {
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.search-field input::placeholder {
  color: rgba(200, 230, 220, 0.6);
}

.search-field input:focus {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
  outline: none;
}

.search-submit {
  padding: 0.7rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
}

.search-submit:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: none;
  box-shadow: none;
}

/* Quick searches (inside hero) */
.quick-searches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.quick-label {
  font-size: 0.78rem;
  color: rgba(200, 230, 220, 0.6);
  margin-right: 0.15rem;
}

.hero .chip {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(240, 255, 248, 0.9);
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
}

.hero .chip:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  box-shadow: none;
}

/* Advanced filter toggle */
.advanced-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.1rem;
  border: none;
  background: none;
  color: rgba(200, 230, 220, 0.7);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--duration-fast) ease;
}

.advanced-toggle:hover {
  color: rgba(240, 255, 248, 0.95);
  transform: none;
  box-shadow: none;
}

.advanced-toggle:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.advanced-toggle-icon {
  font-size: 0.6rem;
  transition: transform var(--duration) var(--ease-out);
}

.advanced-toggle[aria-expanded="true"] .advanced-toggle-icon {
  transform: rotate(180deg);
}

.hero-actions {
  display: flex;
  gap: 0.35rem;
}

.hero-ghost {
  padding: 0.3rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(220, 245, 235, 0.75);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--duration-fast) ease,
    color var(--duration-fast) ease;
}

.hero-ghost:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transform: none;
  box-shadow: none;
}

.hero-ghost:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Advanced filters grid */
.advanced-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
  max-height: 300px;
  opacity: 1;
  overflow: hidden;
  transition:
    max-height var(--duration-slow) var(--ease-out),
    opacity var(--duration) ease,
    margin var(--duration-slow) var(--ease-out);
}

.advanced-filters label {
  color: rgba(200, 230, 220, 0.7);
  font-size: 0.8rem;
}

.advanced-filters select,
.advanced-filters input {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.85rem;
}

.advanced-filters select:focus,
.advanced-filters input:focus {
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
  outline: none;
}

.advanced-filters select option {
  background: var(--brand-strong);
  color: #fff;
}

.advanced-hidden {
  max-height: 0;
  opacity: 0;
  margin-top: 0 !important;
  pointer-events: none;
}

/* Hero meta & hint */
.hero-meta {
  font-size: 0.8rem;
  color: rgba(200, 230, 220, 0.6);
  margin-top: 0.25rem;
}

.hero-meta a {
  color: rgba(200, 230, 220, 0.85);
}

.hero-meta strong {
  color: rgba(240, 255, 248, 0.9);
}

.hero-hint {
  font-size: 0.72rem;
  color: rgba(200, 230, 220, 0.45);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── Chips ─────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface-dim);
  color: var(--ink-secondary);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) ease;
  user-select: none;
}

.chip:hover {
  background: var(--brand-soft);
  border-color: var(--brand-muted);
  color: var(--brand-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.chip:active {
  transform: translateY(0);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--brand-muted);
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.filter-chip.metric {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: #7a5010;
  font-weight: 600;
}

/* ── Form elements ─────────────────────────────────────────── */
label,
fieldset {
  display: grid;
  gap: 0.35rem;
  color: var(--ink-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

.hint {
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 400;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
}

fieldset label {
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  transition:
    border-color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

input:hover,
select:hover {
  border-color: var(--brand-muted);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 107, 86, 0.12);
}

button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

input::placeholder {
  color: var(--faint);
}

/* ── Controls grid ─────────────────────────────────────────── */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.table-tools-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.column-filters-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 0.6rem;
}

.column-filters-grid label {
  font-size: 0.8rem;
  color: var(--muted);
}

.column-filters-grid input {
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
}

/* ── View toggle ───────────────────────────────────────────── */
.view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 0;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}

.view-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--line);
}

.view-toggle-btn:hover {
  background: var(--surface-dim);
  color: var(--ink-secondary);
  transform: none;
  box-shadow: none;
}

.view-toggle-btn.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.view-toggle-btn svg {
  flex-shrink: 0;
}

/* ── Buttons ───────────────────────────────────────────────── */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

button[type="submit"] {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-strong);
}

button[type="submit"]:hover {
  background: var(--brand-strong);
}

.secondary {
  background: var(--brand-soft);
  color: var(--brand-strong);
  border-color: var(--brand-muted);
}

.secondary:hover {
  background: #d0ede4;
}

.link-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.ghost {
  background: var(--surface);
  color: var(--ink-secondary);
  border-color: var(--line);
}

.ghost:hover {
  background: var(--surface-dim);
  border-color: var(--brand-muted);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Active filters & settings summary ─────────────────────── */
.active-filters {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.settings-summary {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.inline-link {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--brand-muted);
  transition: color var(--duration-fast) ease;
}

.inline-link:hover {
  color: var(--brand-strong);
  text-decoration-color: var(--brand);
}

/* ── Messages / notices ────────────────────────────────────── */
#messages {
  display: grid;
  gap: 0.5rem;
}

.notice,
.warning {
  margin: 0;
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  border-left: 3px solid transparent;
  font-size: 0.875rem;
  line-height: 1.55;
}

.notice-warning,
.warning {
  border-left-color: var(--warn);
  color: #6d2f10;
  background: var(--warn-bg);
}

.notice-error {
  border-left-color: var(--error);
  color: #8a1a28;
  background: var(--error-bg);
}

/* ── Summary KPIs ──────────────────────────────────────────── */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.75rem;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: var(--surface);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.kpi:hover {
  border-color: var(--brand-muted);
  box-shadow: var(--shadow-sm);
}

.kpi .label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi .value {
  margin-top: 0.35rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* ── Results section ───────────────────────────────────────── */
.results-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.results-head h2 {
  margin-bottom: 0;
}

.results-head p {
  margin-bottom: 0;
}

.results {
  display: grid;
  gap: 1rem;
}

/* ── Empty & loading states ────────────────────────────────── */
.empty-state {
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  background: var(--surface);
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 0.4rem;
  color: var(--ink-secondary);
}

.loading-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  background: var(--surface);
}

.shimmer {
  height: 0.75rem;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    100deg,
    var(--line-soft) 25%,
    var(--line) 50%,
    var(--line-soft) 75%
  );
  background-size: 300% 100%;
  animation: shimmer 1.5s ease infinite;
  margin-bottom: 0.65rem;
}

.shimmer:nth-child(1) { width: 42%; }
.shimmer:nth-child(2) { width: 85%; }
.shimmer:nth-child(3) { width: 60%; }

/* ── Data tables ───────────────────────────────────────────── */
details {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow var(--duration) ease;
}

details[open] {
  box-shadow: var(--shadow-sm);
}

summary {
  cursor: pointer;
  padding: 0.85rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--surface-dim);
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--duration-fast) ease;
  list-style: none;
}

summary::-webkit-details-marker { display: none; }

summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  transition: transform var(--duration) var(--ease-out);
}

details[open] > summary::before {
  transform: rotate(90deg);
}

summary:hover {
  background: var(--brand-soft);
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  /* Smooth scrollbar appearance */
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.table-wrap::-webkit-scrollbar {
  height: 6px;
}

.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

table {
  width: 100%;
  min-width: 1400px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.5;
  border-bottom: 1px solid var(--line-soft);
}

th {
  background: var(--surface-dim);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  font-weight: 600;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Sort header buttons */
.sort-header {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0.2rem 0.35rem;
  font-weight: 600;
  font-size: 0.73rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}

.sort-header:hover {
  background: rgba(10, 107, 86, 0.06);
  color: var(--brand);
  transform: none;
  box-shadow: none;
}

.sort-header.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

/* Data rows */
tr.data-row {
  cursor: pointer;
  transition:
    background var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

tr.data-row:nth-child(even) {
  background: var(--surface-dim);
}

tr.data-row:hover {
  background: var(--brand-soft);
}

tr.data-row:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: var(--brand-soft);
}

tr.data-row td.col-school {
  font-weight: 600;
  color: var(--ink);
}

td.col-code,
td.col-orgnr {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

/* Column widths */
th.col-school,  td.col-school    { min-width: 260px; }
th.col-code,    td.col-code      { width: 110px; }
th.col-types,   td.col-types     { min-width: 165px; }
th.col-status,  td.col-status    { width: 110px; }
th.col-organizer, td.col-organizer { min-width: 250px; }
th.col-orgnr,   td.col-orgnr     { width: 130px; }
th.col-municipality, td.col-municipality { min-width: 130px; }
th.col-county,  td.col-county    { min-width: 150px; }
th.col-concern, td.col-concern   { min-width: 170px; }
th.col-legal,   td.col-legal     { min-width: 160px; }

/* Statistics columns */
th.col-pupils, td.col-pupils           { width: 90px; }
th.col-teacher-ratio, td.col-teacher-ratio { width: 100px; }
th.col-certified, td.col-certified     { width: 110px; }
th.col-merit, td.col-merit             { width: 100px; }

td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Statistics grid (detail modal) ───────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-block: 0.75rem 1.25rem;
}

.stat-card {
  background: var(--surface-dim);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.detail-panel h4 {
  margin: 1.25rem 0 0.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-secondary);
  letter-spacing: 0.01em;
}

/* Company data extras */
.sni-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sni-list li {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  padding: 0.3rem 0.5rem;
  background: var(--surface-dim);
  border-radius: var(--radius-sm);
}
.sni-list li strong {
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.company-description {
  font-size: 0.85rem;
  color: var(--ink-secondary);
  line-height: 1.55;
  margin: 0.35rem 0;
}

/* ── Horizontal bar charts (kommun/DeSO detail panels) ───── */
.hbar-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.5rem 0 1rem;
}

.hbar-row,
.party-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 4rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
}

.hbar-label,
.party-label {
  font-size: 0.78rem;
  color: var(--ink-secondary);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.party-label {
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.hbar-track {
  height: 18px;
  background: var(--surface-dim);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}

.hbar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width var(--duration-slow) var(--ease-out);
  min-width: 2px;
}

.hbar-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Election blocks ──────────────────────────────────────── */
.election-block {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-soft);
}

.election-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.election-turnout {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin: 0.25rem 0 0.5rem;
}

.election-turnout strong {
  color: var(--brand);
}

.party-bars {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.party-row {
  grid-template-columns: 3.5rem 1fr 4rem;
}

/* ── Comparison badges (DeSO vs kommun) ──────────────────── */
.cmp-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15em 0.5em;
  border-radius: var(--radius-pill);
  vertical-align: middle;
  margin-left: 0.4rem;
}

.cmp-higher {
  background: var(--success-bg);
  color: var(--success);
}

.cmp-lower {
  background: var(--warn-bg);
  color: var(--warn);
}

.cmp-neutral {
  background: var(--surface-dim);
  color: var(--muted);
}

/* ── DeSO intro text ─────────────────────────────────────── */
.deso-intro {
  font-size: 0.82rem;
  margin-bottom: 0.75rem;
}

.deso-intro strong {
  font-family: var(--font-heading);
  color: var(--brand);
}

/* ── Per-program GY table (detail view) ──────────────────── */
.program-details-table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.program-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.program-details-table th,
.program-details-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.program-details-table th {
  background: var(--surface-dim);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--ink-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.program-details-table td.numeric,
.program-details-table th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.program-details-table tbody tr:last-child td {
  border-bottom: none;
}

/* ── Status badges ─────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-ok {
  background: color-mix(in oklab, var(--brand) 15%, transparent);
  color: var(--brand);
}

.badge-off {
  background: var(--surface-dim);
  color: var(--ink-secondary);
}

/* ── Detail modal ──────────────────────────────────────────── */
.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 18, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in var(--duration) var(--ease-out);
}

.detail-modal-panel {
  position: relative;
  width: min(1100px, 100%);
  max-height: calc(100vh - 3rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  background: var(--surface);
  animation: modal-in var(--duration-slow) var(--ease-out);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.detail-modal-content {
  padding: 0;
}

body.detail-open {
  overflow: hidden;
}

/* Detail header */
.detail-header {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.detail-overline {
  margin: 0 0 0.2rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
  font-weight: 700;
}

#school-detail h2 {
  margin: 0;
  font-size: clamp(1.2rem, 1.6vw, 1.6rem);
}

.detail-chip-row {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* Detail tabs */
.detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-dim);
}

.detail-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  transition:
    background var(--duration-fast) ease,
    color var(--duration-fast) ease,
    border-color var(--duration-fast) ease;
}

.detail-tab:hover {
  background: rgba(10, 107, 86, 0.06);
  color: var(--brand);
  transform: none;
  box-shadow: none;
}

.detail-tab.active {
  background: var(--brand-soft);
  border-color: var(--brand-muted);
  color: var(--brand-strong);
}

.detail-tab:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Detail panels — stacked layout to prevent height jumps on tab switch */
.detail-panels {
  position: relative;
  padding: 1.5rem;
  /* Grid stacking: all children occupy the same cell */
  display: grid;
  overflow: hidden;
}

.detail-panel {
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition:
    opacity var(--duration) var(--ease-out),
    visibility var(--duration);
}

.detail-panel.panel-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}

.detail-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--surface-dim);
}

.detail-card--wide {
  width: 100%;
}

.detail-card h3 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  color: var(--ink);
}

/* Key-value list */
.kv-list {
  display: grid;
  gap: 0;
}

.kv-row {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.kv-value {
  color: var(--ink);
  line-height: 1.5;
  word-break: break-word;
}

/* Address grid */
.address-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
}

.address-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--surface);
  transition: border-color var(--duration-fast) ease;
}

.address-card:hover {
  border-color: var(--brand-muted);
}

.address-card h4 {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-strong);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.address-card p {
  margin: 0;
  line-height: 1.55;
  color: var(--ink-secondary);
}

/* ── Settings page ─────────────────────────────────────────── */
.settings-form {
  display: grid;
  gap: 1rem;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

.toggle-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: var(--surface-dim);
  display: flex;
  gap: 0.85rem;
  justify-content: space-between;
  align-items: flex-start;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.toggle-card:hover {
  border-color: var(--brand-muted);
}

.toggle-copy {
  display: grid;
  gap: 0.3rem;
}

.toggle-copy strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.toggle-copy small {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.82rem;
}

.toggle-card input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--brand);
  margin-top: 0.1rem;
  cursor: pointer;
}

/* ── FAQ / pedagogy ────────────────────────────────────────── */
.pedagogy .faq-grid {
  display: grid;
  gap: 0.6rem;
}

.pedagogy details {
  background: var(--surface);
  border-color: var(--line);
}

.pedagogy details summary {
  font-size: 0.92rem;
  background: var(--surface);
  border-bottom-color: var(--line-soft);
}

.pedagogy details[open] summary {
  background: var(--surface-dim);
}

.pedagogy p {
  color: var(--ink-secondary);
  margin: 0;
  padding: 0.75rem 1.25rem 1rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

/* ── Results head ──────────────────────────────────────────── */
.results-head h2 {
  margin-bottom: 0;
}

/* ── Utility ───────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes detail-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Staggered entrance for panels ─────────────────────────── */
.layout > :nth-child(1) { animation-delay: 0ms; }
.layout > :nth-child(2) { animation-delay: 40ms; }
.layout > :nth-child(3) { animation-delay: 80ms; }
.layout > :nth-child(4) { animation-delay: 120ms; }
.layout > :nth-child(5) { animation-delay: 160ms; }
.layout > :nth-child(6) { animation-delay: 200ms; }
.layout > :nth-child(7) { animation-delay: 240ms; }
.layout > :nth-child(8) { animation-delay: 280ms; }

/* ── Table tools collapse toggle ───────────────────────────── */
#table-tools {
  overflow: hidden;
}

#table-tools .panel-head {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -1.5rem -1.5rem 0;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transition: background var(--duration-fast) ease;
}

#table-tools .panel-head:hover {
  background: var(--surface-dim);
}

#table-tools.collapsed .panel-head {
  margin-bottom: -1.5rem;
  border-radius: var(--radius-lg);
}

#table-tools .panel-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

#table-tools .panel-head p {
  margin: 0;
}

.panel-toggle-icon {
  font-size: 0.75rem;
  color: var(--muted);
  transition: transform var(--duration) var(--ease-out);
}

#table-tools.collapsed .panel-toggle-icon {
  transform: rotate(-90deg);
}

#table-tools .table-tools-body {
  transition: opacity var(--duration) ease;
}

#table-tools.collapsed .table-tools-body {
  display: none;
}

/* ── Scroll to top button ──────────────────────────────────── */
.scroll-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity var(--duration) ease,
    transform var(--duration) var(--ease-spring);
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.scroll-top:hover {
  background: var(--brand-strong);
  transform: translateY(-2px);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 860px) {
  .layout {
    padding: 1rem;
  }

  .hero {
    padding: 1.5rem;
  }

  .panel,
  .results-head {
    padding: 1.25rem;
  }

  .panel-elevated {
    padding: 1.5rem;
  }

  .hero-nav {
    gap: 0.35rem;
  }

  .hero-nav a {
    font-size: 0.78rem;
    padding: 0.35rem 0.7rem;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .table-tools-top {
    grid-template-columns: 1fr;
  }

  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .detail-modal {
    padding: 0.5rem;
  }

  .detail-modal-panel {
    max-height: calc(100vh - 1rem);
    border-radius: var(--radius-lg);
  }

  .detail-header {
    padding: 1rem;
  }

  .detail-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.65rem 1rem;
    -webkit-overflow-scrolling: touch;
  }

  .detail-panels {
    padding: 1rem;
  }

  .kv-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .kv-label {
    font-weight: 700;
  }

  .address-grid {
    grid-template-columns: 1fr;
  }

  .hbar-row,
  .party-row {
    grid-template-columns: 5.5rem 1fr 3.5rem;
    gap: 0.35rem;
  }

  .party-row {
    grid-template-columns: 2.5rem 1fr 3.5rem;
  }

  .hbar-label {
    font-size: 0.72rem;
  }

  .summary {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .kpi .value {
    font-size: 1.25rem;
  }

  #table-tools .panel-head {
    margin: -1.25rem -1.25rem 0;
    padding: 0.85rem 1.25rem;
  }

  #table-tools.collapsed .panel-head {
    margin-bottom: -1.25rem;
  }

  /* ── Responsive table: hide secondary columns on mobile ── */
  table {
    min-width: 0;
  }

  .col-code,
  .col-status,
  .col-organizer,
  .col-orgnr,
  .col-county,
  .col-concern,
  .col-legal,
  .col-teacher-ratio,
  .col-certified,
  .col-merit {
    display: none;
  }

  th.col-school, td.col-school { min-width: 0; }
  th.col-types, td.col-types { min-width: 0; }
  th.col-municipality, td.col-municipality { min-width: 0; }

  th, td {
    padding: 0.5rem 0.4rem;
    font-size: 0.8rem;
  }

  th {
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .layout {
    padding: 0.75rem;
  }

  .hero {
    padding: 1.25rem;
  }

  .panel,
  .results-head {
    padding: 1rem;
  }

  .summary {
    grid-template-columns: 1fr 1fr;
  }

  .hero h1 {
    font-size: 1.35rem;
  }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  .hero-nav,
  .actions,
  .scroll-top,
  #table-tools,
  #guide,
  #faq,
  .detail-modal,
  .view-toggle,
  .map-view {
    display: none !important;
  }

  .panel, .results-head {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  body {
    background: #fff;
    font-size: 10pt;
  }
}

/* ═══════════════════════════════════════════════════════════════
   CAREER PATHWAYS — Karriar tab
   ═══════════════════════════════════════════════════════════════ */

.karriar-program-section { margin-bottom: 1.5rem; }
.karriar-program-section h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }

.karriar-occ-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.karriar-occ-card {
  background: var(--surface, #f8f8f8);
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  overflow-wrap: break-word;
}

.karriar-occ-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.karriar-score {
  font-size: 0.75rem;
  color: var(--muted, #888);
  background: var(--surface-dim, #f0f0f0);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  white-space: nowrap;
}

.karriar-demand { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }

.karriar-demand-badge {
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}
.demand-high { background: #d4edda; color: #155724; }
.demand-med  { background: #fff3cd; color: #856404; }
.demand-low  { background: #f8d7da; color: #721c24; }

.karriar-jobs-section { margin-top: 1.5rem; border-top: 1px solid var(--border, #e5e5e5); padding-top: 1rem; }
.karriar-jobs-section h4 { margin: 0 0 0.25rem; }

.karriar-jobs-list { display: flex; flex-direction: column; gap: 0.5rem; }

.karriar-job-card {
  background: var(--surface, #f8f8f8);
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* ═══════════════════════════════════════════════════════════════
   COMMUTE PLANNING — Pendling tab
   ═══════════════════════════════════════════════════════════════ */

.pendling-stops { margin-bottom: 1.5rem; }
.pendling-stops h4 { margin: 0 0 0.5rem; }

.pendling-stops-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pendling-stop-card {
  background: var(--surface, #f8f8f8);
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pendling-trips { margin-bottom: 1rem; }
.pendling-trips h4 { margin: 0 0 0.5rem; }

.pendling-trips-list { display: flex; flex-direction: column; gap: 0.5rem; }

.pendling-trip-card {
  background: var(--surface, #f8f8f8);
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pendling-trip-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.pendling-trip-time { font-weight: 600; }
.pendling-trip-duration { font-size: 0.85rem; color: var(--muted, #888); }

.pendling-trip-legs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.pendling-leg {
  font-size: 0.8rem;
  background: var(--brand, #0a6b56);
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.pendling-leg-walk {
  background: var(--surface-dim, #e0e0e0);
  color: var(--text, #333);
}

.pendling-leg-sep {
  color: var(--muted, #888);
  font-size: 0.75rem;
}

.pendling-location-prompt {
  text-align: center;
  padding: 1rem;
}

/* ── Home location picker ──────────────────────────────────── */

.pendling-home { margin-bottom: 1.5rem; }
.pendling-home h4 { margin: 0 0 0.5rem; }

.pendling-home-current {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pendling-home-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pendling-home-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pendling-home-search input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line, #ddd);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--surface, #fff);
  color: var(--ink, #333);
}

.pendling-home-search input:focus {
  outline: none;
  border-color: var(--brand, #0a6b56);
  box-shadow: 0 0 0 2px rgba(10, 107, 86, 0.15);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line, #ddd);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: var(--ink, #333);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-sm:hover { background: var(--bg-deep, #f0f0f0); }
.btn-sm:disabled { opacity: 0.5; cursor: default; }

.btn-link {
  background: none;
  border: none;
  color: var(--brand, #0a6b56);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover { opacity: 0.7; }
.btn-link:disabled { opacity: 0.4; cursor: default; }

.pendling-address-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.pendling-address-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line, #ddd);
  border-radius: 6px;
  background: var(--surface, #fff);
  color: var(--ink, #333);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.1s;
}

.pendling-address-option:hover {
  background: var(--bg-deep, #f0f0f0);
  border-color: var(--brand, #0a6b56);
}

/* ═══════════════════════════════════════════════════════════════
   SYNC BADGE
   ═══════════════════════════════════════════════════════════════ */

.sync-badge {
  font-size: 0.78rem;
  color: rgba(240, 255, 248, 0.88);
}

/* ═══════════════════════════════════════════════════════════════
   SEARCH HIGHLIGHTING
   ═══════════════════════════════════════════════════════════════ */

mark {
  background: #fef3cd;
  color: inherit;
  padding: 0.05em 0.15em;
  border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   COMPARE COLUMN & BAR
   ═══════════════════════════════════════════════════════════════ */

th.col-compare,
td.col-compare {
  width: 2rem;
  min-width: 2rem;
  max-width: 2rem;
  text-align: center;
  padding: 0.3rem !important;
}

.compare-check {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--brand);
}

.compare-bar {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink, #1a1a2e);
  color: #fff;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-lg, 12px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  z-index: 900;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity var(--duration) ease, transform var(--duration) ease;
}

.compare-bar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(1rem);
}

.compare-bar .primary {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius, 6px);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.compare-bar .ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius, 6px);
  cursor: pointer;
  font-size: 0.8rem;
}

.compare-table th {
  font-size: 0.8rem;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════
   GROUP CONTROLS (expand / collapse all)
   ═══════════════════════════════════════════════════════════════ */

.group-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.group-controls .ghost {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════
   BENCHMARKING
   ═══════════════════════════════════════════════════════════════ */

.bench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.bench-card {
  background: var(--surface-dim, #f8f9fa);
  border: 1px solid var(--line-soft, #e8e8ec);
  border-radius: var(--radius, 6px);
  padding: 0.75rem;
}

.bench-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary, #666);
  margin-bottom: 0.25rem;
}

.bench-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink, #1a1a2e);
  margin-bottom: 0.35rem;
}

.bench-compare {
  font-size: 0.78rem;
  color: var(--ink-secondary, #666);
  display: flex;
  gap: 0.35rem;
  align-items: baseline;
}

.bench-good {
  color: #15803d;
  font-weight: 600;
}

.bench-warn {
  color: #b45309;
  font-weight: 600;
}

.bench-neutral {
  color: var(--ink-secondary, #888);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════
   DETAIL HEADER ACTIONS
   ═══════════════════════════════════════════════════════════════ */

.detail-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  flex-shrink: 0;
}

.copy-detail {
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE CARD VIEW (≤ 480px)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  /* Hide compare column and table header on small mobile */
  th.col-compare { display: none; }

  /* Transform table rows into cards */
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr.data-row {
    border: 1px solid var(--line-soft, #e8e8ec);
    border-radius: var(--radius, 6px);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--surface, #fff);
  }

  .table-wrap td {
    padding: 0.2rem 0;
    font-size: 0.82rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .table-wrap td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ink-secondary, #666);
    flex-shrink: 0;
    font-size: 0.75rem;
  }

  .table-wrap td.col-compare {
    display: flex;
    justify-content: flex-end;
    border-bottom: 1px solid var(--line-soft, #eee);
    padding-bottom: 0.4rem;
    margin-bottom: 0.3rem;
  }

  .table-wrap td.col-compare::before {
    content: "Jämför";
  }

  .table-wrap td.col-school {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--brand, #0a6b56);
  }

  /* Show all columns in card view */
  .col-code,
  .col-status,
  .col-organizer,
  .col-orgnr,
  .col-county,
  .col-concern,
  .col-legal,
  .col-teacher-ratio,
  .col-certified,
  .col-merit {
    display: flex !important;
  }

  /* Hide empty-value rows in card */
  .table-wrap td:empty { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   SITE FOOTER
   ═══════════════════════════════════════════════════════════════ */

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.82rem;
  color: var(--ink-secondary, #666);
}

.site-footer a {
  color: var(--brand, #0a6b56);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* ── School detail page (SSG) ───────────────────────────────── */
.school-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem 2rem;
  margin: 0;
}
.school-meta > div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.school-meta dt {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #64787e);
}
.school-meta dd {
  margin: 0;
  font-size: 1rem;
  color: var(--ink, #1a2024);
}

/* ── SEO link grids (kommun/län navigation) ─────────────────── */
.seo-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.seo-link-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 1rem;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #dfe5e2);
  border-radius: var(--radius-sm, 8px);
  text-decoration: none;
  color: var(--ink, #1a2024);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.seo-link-card:hover {
  border-color: var(--brand, #0a6b56);
  box-shadow: var(--shadow-sm);
}
.seo-link-card strong {
  font-size: 0.92rem;
}
.seo-link-card .muted {
  font-size: 0.78rem;
}

/* ── SEO tables (kommun/län pages) ──────────────────────────── */
.seo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.seo-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #64787e);
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--line, #dfe5e2);
  white-space: nowrap;
}
.seo-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--line-soft, #edf0ed);
  vertical-align: top;
}
.seo-table a {
  color: var(--brand, #0a6b56);
  text-decoration: none;
}
.seo-table a:hover {
  text-decoration: underline;
}
.seo-table tr:hover td {
  background: var(--surface-dim, #f9faf8);
}
