:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1d1d1b;
  --muted: #5f5d57;
  --border: #dcd9d0;
  --accent: #1f5f8b;
  --accent-soft: #e3eef6;
  --good: #2c6e49;
  --good-soft: #e3f1e8;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --bad: #9b2c2c;
  --bad-soft: #f8e4e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614;
    --surface: #201f1d;
    --surface-2: #2a2926;
    --text: #ecebe6;
    --muted: #a8a59c;
    --border: #3a3935;
    --accent: #7db4dc;
    --accent-soft: #1e3240;
    --good: #7fc79b;
    --good-soft: #1e3327;
    --warn: #e2b25a;
    --warn-soft: #3a2e17;
    --bad: #ec8f8f;
    --bad-soft: #3d2222;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #161614;
  --surface: #201f1d;
  --surface-2: #2a2926;
  --text: #ecebe6;
  --muted: #a8a59c;
  --border: #3a3935;
  --accent: #7db4dc;
  --accent-soft: #1e3240;
  --good: #7fc79b;
  --good-soft: #1e3327;
  --warn: #e2b25a;
  --warn-soft: #3a2e17;
  --bad: #ec8f8f;
  --bad-soft: #3d2222;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }

.site-header { padding: 32px 0 16px; }
.site-header h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -0.01em; }
.lead { margin: 0 0 8px; max-width: 70ch; font-size: 1.05rem; }
.disclaimer { margin: 0; color: var(--muted); font-size: 0.9rem; }
.jump { display: none; margin-top: 10px; font-weight: 600; }
@media (max-width: 860px) { .jump { display: inline-block; } }
#results { scroll-margin-top: 16px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding-bottom: 32px;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* Form */
.form { display: grid; gap: 12px; }
fieldset, details {
  margin: 0;
  padding: 14px 16px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  min-width: 0;
}
legend { padding: 0 4px; font-weight: 650; }
details summary { cursor: pointer; font-weight: 650; }
details[open] summary { margin-bottom: 4px; }

label { display: grid; gap: 4px; font-size: 0.92rem; }
.label { display: block; font-size: 0.92rem; margin-bottom: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input[type="number"], input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input.invalid { border-color: var(--bad); }
.field-error { margin: 2px 0 0; color: var(--bad); font-size: 0.82rem; }

#municipality-wrap { display: grid; gap: 6px; }
/* Under the student rule the municipality changes nothing, so it steps back. */
#municipality-wrap.inactive .chips, #municipality-wrap.inactive label { opacity: 0.55; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-actions button {
  font: inherit;
  font-size: 0.85rem;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.form-actions button:hover { background: var(--surface-2); }
.form-actions .hint { margin: 0; flex-basis: 100%; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.radio-group { display: grid; gap: 4px; }
.hint { margin: -4px 0 0; color: var(--muted); font-size: 0.82rem; }

.month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.month-grid button, .chips button, .link-button {
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.month-grid button[aria-pressed="true"], .chips button[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}
.month-actions { display: flex; gap: 8px; margin-top: 6px; }
.link-button { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: 0.82rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 10px; }

/* Results */
.results { display: grid; gap: 16px; min-width: 0; }
#results { display: grid; gap: 16px; }
.loading { color: var(--muted); }

.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 620px) { .compare { grid-template-columns: minmax(0, 1fr); } }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card h2, .card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.card .sub { margin: 0 0 12px; color: var(--muted); font-size: 0.85rem; }
/* Room for two lines, so a longer sub in one card does not push its figures
   out of line with the other. */
.compare .card .sub { min-height: 2.6em; }
.card-foot { margin: 10px 0 0; }

.big { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; font-variant-numeric: tabular-nums; }

dl.lines { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; font-size: 0.92rem; }
dl.lines dt { color: var(--muted); }
dl.lines dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
dl.lines .total { font-weight: 650; color: var(--text); border-top: 1px solid var(--border); padding-top: 6px; }
dl.lines dd.total { text-align: right; }
.src { font-size: 0.75rem; margin-left: 4px; white-space: nowrap; }

.card.verdict { border-left: 4px solid var(--accent); }
.card.verdict h2 { font-size: 1.25rem; margin-bottom: 8px; }
.card.verdict p { margin: 0; }

.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; margin-bottom: 8px; }
.badge.neutral { background: var(--surface-2); color: var(--muted); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.note { border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; margin: 0; }
.note.warn { background: var(--warn-soft); color: var(--text); border-left: 3px solid var(--warn); }
.note.info { background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent); }
.notes { display: grid; gap: 8px; }

.hours { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.hour-box { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.hour-box .v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hour-box .k { font-size: 0.78rem; color: var(--muted); }

.meter { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.meter > span { display: block; height: 100%; background: var(--good); }
.meter.over > span { background: var(--bad); }

/* Totals in sight while scrolling a long form on a narrow screen */
.sticky-summary { display: none; }
@media (max-width: 860px) {
  body { padding-bottom: 68px; }
  .sticky-summary {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.82rem;
    text-decoration: none;
    box-shadow: 0 -2px 10px rgb(0 0 0 / 0.12);
    transition: transform 0.15s ease-out;
  }
  .sticky-summary[hidden] { display: none; }
  /* Once the results are on screen the bar has nothing to add. */
  .sticky-summary.out-of-the-way { transform: translateY(110%); }
  .sticky-keep { min-width: 0; }
  .sticky-more { color: var(--accent); font-weight: 600; white-space: nowrap; }
}

/* Sources */
.sources { padding-bottom: 32px; }
.sources h2 { margin-bottom: 4px; }
.sources > p { margin-top: 0; color: var(--muted); }
.source-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.source-table th, .source-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.source-table th { background: var(--surface-2); font-weight: 600; }
.source-table td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
@media (max-width: 620px) {
  .source-table thead { display: none; }
  .source-table tr { display: grid; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .source-table td { border: none; padding: 2px 10px; }
}

.site-footer { border-top: 1px solid var(--border); padding: 20px 0 40px; color: var(--muted); font-size: 0.9rem; }
