/* Leikkauskone – styles.
   Colours and sizes are variables at the top: change them to restyle everything. */

:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #dddcd6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #6b6a65;
  --accent: #2a78d6;
  --accent-text: #ffffff;
  --track: #e7e6e1;
  --good: #0c7a0c;            /* reached milestone – always paired with an icon and text */
  --notice-bg: #fff4dc;

  /* Category colours (validated categorical palette – the order matters) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --max-width: 1160px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232322;
    --border: #383835;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --accent: #3987e5;
    --accent-text: #ffffff;
    --track: #2c2c2a;
    --good: #3cc43c;
    --notice-bg: #3a2f14;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232322;
  --border: #383835;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #9a998f;
  --accent: #3987e5;
  --accent-text: #ffffff;
  --track: #2c2c2a;
  --good: #3cc43c;
  --notice-bg: #3a2f14;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 30;
  background: var(--surface); color: var(--accent); padding: 8px 12px; border-radius: 6px;
}
.skip-link:focus { top: 8px; }

/* Page width follows the view so that the header, meter and content always line up */
body[data-view="intro"],
body[data-view="questions"] { --max-width: 820px; }
body[data-view="intro"] .meter,
body[data-view="intro"] .wordmark,
body[data-view="intro"] .tabs { display: none; }
body[data-view="intro"] .site-header { background: none; border-bottom: 0; }
/* Hide the empty page shell until the first render */
.loading body > * { visibility: hidden; }
body[data-view="questions"] .milestone-list { display: none; }

.btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 0.45em 1em;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.small { font-size: 0.82rem; padding: 0.35em 0.85em; }
.btn.big { font-size: 1.05rem; padding: 0.7em 1.4em; }
.btn[disabled] { cursor: default; opacity: 0.5; filter: none; }

.link-button {
  font: inherit; font-size: 0.92rem; color: var(--accent); background: none; border: 0; padding: 4px 0;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- Header ---------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; gap: 8px 24px; min-height: 60px; flex-wrap: wrap; }
.wordmark {
  font: inherit; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em; color: var(--text);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.tabs { display: flex; gap: 4px; align-self: stretch; }
.tabs button {
  font: inherit; font-size: 0.95rem; font-weight: 600; color: var(--text-2);
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 0 10px; cursor: pointer;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.lang-select { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--text-2); }
.lang-select select {
  font: inherit; font-size: 0.9rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px;
}

/* ---------- Meter (sticky) ---------- */

.meter {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 0 10px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.04);
}
.meter-inner { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 20px; }
.total { display: flex; flex-direction: column; margin: 0; }
.total-label { font-size: 0.82rem; color: var(--text-2); }
.total-value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.next-goal { margin: 0; font-size: 0.92rem; color: var(--text-2); }
.next-goal strong { color: var(--text); }
.year-note { font-size: 0.8rem; color: var(--text-3); }
.control { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--text-2); }
.control select {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px;
}
.control input { width: 18px; height: 18px; accent-color: var(--accent); }
.settings { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 10px; }

/* Bar: the target band's label sits above it, marker labels below, so nothing overlaps */
.bar-frame { grid-column: 1 / -1; position: relative; padding: 24px 0; }
.bar { display: flex; gap: 2px; height: 22px; background: var(--track); border-radius: 6px; overflow: hidden; }
.bar-segment { height: 100%; min-width: 0; transition: width 0.25s ease; }
.bar-segment:last-child { border-radius: 0 4px 4px 0; }
.bar-marks { position: absolute; inset: 24px 0; pointer-events: none; }
.bar-marks span { position: absolute; font-size: 0.8rem; font-weight: 600; white-space: nowrap; color: var(--text-2); }
.target-band { position: absolute; top: -4px; bottom: -4px; border: 2px solid var(--text); border-radius: 7px; }
.target-band span { bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; color: var(--text); font-weight: 700; }
.marker { position: absolute; top: -4px; bottom: -4px; border-left: 2px solid var(--text-2); }
.marker span { top: 100%; margin-top: 4px; transform: translateX(-50%); }
.marker.at-end span { transform: translateX(-100%); }
.target-band.reached, .marker.reached { border-color: var(--good); }
.target-band.reached span, .marker.reached span { color: var(--good); }

.milestone-list {
  grid-column: 1 / -1;
  list-style: none; margin: 6px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 4px 18px;
  font-size: 0.8rem; color: var(--text-2);
}
.milestone-list li { display: flex; align-items: center; gap: 5px; }
.milestone-list .icon {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--text-3); font-size: 0.65rem; line-height: 1;
}
.milestone-list .reached { color: var(--text); }
.milestone-list .reached .icon { background: var(--good); border-color: var(--good); color: #fff; }

/* ---------- Start page ---------- */

.intro { padding-top: clamp(32px, 7vw, 72px); padding-bottom: 56px; }
.eyebrow { margin: 0 0 8px; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.intro h1 { font-size: clamp(2.6rem, 9vw, 4rem); letter-spacing: -0.02em; margin-bottom: 16px; }
.intro-lead { font-size: clamp(1.1rem, 2.6vw, 1.3rem); color: var(--text-2); margin: 0 0 8px; max-width: 34em; }
.intro-lead strong { color: var(--text); }
.intro-bar { margin: 8px 0 28px; }
.intro-question { font-size: clamp(1.3rem, 3.5vw, 1.6rem); margin-bottom: 4px; }
.intro-meta { margin: 0 0 16px; color: var(--text-2); }
.intro-browse { margin: 18px 0 0; }

/* ---------- Questions ---------- */
/* Both layouts use the same markup; [data-layout] on #questions switches between them. */

.questions { padding-top: 20px; padding-bottom: 40px; }
.questions-toolbar { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.progress-text { margin: 0; font-weight: 600; }
.progress-text[hidden] + .link-button { margin-left: auto; }
.progress { height: 8px; margin: 8px 0 16px; background: var(--track); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }

.question-section { margin-top: 20px; }
.question-section > h2 { font-size: 1.35rem; margin-bottom: 12px; }

.question {
  margin: 0 0 14px;
  padding: 16px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.question.answered { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.question legend { float: left; width: 100%; padding: 0; }
.question legend + * { clear: both; }
.question h3 { font-size: 1.08rem; margin-bottom: 6px; }
.question-description { margin: 0 0 12px; font-size: 0.9rem; color: var(--text-2); }
.notice-text { background: var(--notice-bg); padding: 8px 12px; border-radius: 8px; font-size: 0.92rem; }

.options { display: grid; gap: 8px; }
.option {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  padding: 12px 14px;
  background: var(--surface-2); border: 2px solid var(--border); border-radius: 10px; cursor: pointer;
}
.option:hover { border-color: var(--accent); }
.option:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.option input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.option-text { display: flex; flex-direction: column; gap: 2px; }
.option-head { display: flex; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; }
.option-name { font-weight: 700; }
.option-description { color: var(--text-2); font-size: 0.95rem; }
.option-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chosen-description { margin: 10px 0 0; font-size: 0.88rem; }
.chosen-description:empty { display: none; }

.card-details { margin-top: 10px; font-size: 0.82rem; }
.card-details summary { cursor: pointer; color: var(--accent); width: fit-content; }
.card-details-body { color: var(--text-2); padding-top: 6px; }
.card-details-body ul { list-style: none; margin: 0 0 8px; padding: 0; }
.card-details-body li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--surface-2); }
.card-details-body .num { white-space: nowrap; }
.details-title { margin: 6px 0 2px; font-weight: 600; color: var(--text); }

/* One at a time: one large question with generous text */
[data-layout="single"] .question-section { margin-top: 0; }
[data-layout="single"] .question-section > h2 { display: none; }
[data-layout="single"] .question { padding: 22px 22px 16px; }
[data-layout="single"] .question h3 { font-size: clamp(1.35rem, 3.2vw, 1.7rem); margin-bottom: 8px; }
[data-layout="single"] .question-description { font-size: 1.05rem; margin-bottom: 18px; }
[data-layout="single"] .option { padding: 14px 16px; }
[data-layout="single"] .option-name { font-size: 1.15rem; }
[data-layout="single"] .option-amount { font-size: 1.05rem; }
[data-layout="single"] .chosen-description { display: none; }
.step-nav { display: flex; justify-content: space-between; gap: 12px; }

/* All at once: compact questions, descriptions shown only for the chosen option */
[data-layout="all"] .options { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
[data-layout="all"] .option { gap: 8px; padding: 8px 10px; }
[data-layout="all"] .option-head { flex-direction: column; }
[data-layout="all"] .option-description { display: none; }
[data-layout="all"] .option-amount { font-size: 0.82rem; color: var(--text-2); font-weight: 400; }

.result {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
[data-layout="all"] .result { margin-top: 28px; }
.result h2 { font-size: 1.4rem; margin-bottom: 8px; }
.result-text { font-size: 1.05rem; margin: 0 0 14px; max-width: 70ch; }
.answers-title { font-size: 1.05rem; margin: 22px 0 2px; }
.answers-hint { margin: 0 0 8px; font-size: 0.88rem; }
.answers { list-style: none; margin: 0 0 16px; padding: 0; }
.answers li + li { border-top: 1px solid var(--surface-2); }
.answer {
  font: inherit; color: var(--text); text-align: left; width: 100%;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: none; border: 0; padding: 10px 4px; cursor: pointer; border-radius: 6px;
}
.answer:hover { background: var(--surface-2); }
.answer-question { flex: 1 1 260px; }
.answer-choice { font-weight: 600; white-space: nowrap; }

/* ---------- Measures ---------- */

.measures { padding-top: 28px; padding-bottom: 40px; }
.measures > h1 { font-size: 1.8rem; }
.lead { font-size: 1.05rem; max-width: 70ch; margin: 8px 0 14px; color: var(--text-2); }
.help {
  max-width: 75ch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
}
.help summary { cursor: pointer; font-weight: 600; }
.help ul { margin: 10px 0 4px; padding-left: 1.2em; color: var(--text-2); }
.help li { margin-bottom: 6px; }


.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: start;
  margin-top: 20px;
}
.search input {
  width: 100%; font: inherit; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.jump-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.jump-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem; text-decoration: none; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
}
.jump-nav a:hover { color: var(--text); }
.no-results { color: var(--text-2); padding: 20px 0; }

.category { margin-top: 28px; scroll-margin-top: 190px; }
.category-header {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding-bottom: 8px; margin-bottom: 10px; border-bottom: 2px solid var(--border);
}
.category-header h2 { font-size: 1.25rem; display: flex; align-items: center; gap: 10px; }
.category-total { margin-left: auto; font-size: 0.9rem; color: var(--text-2); }
.category-total strong { color: var(--text); }
.category-description { margin: -4px 0 10px; font-size: 0.88rem; color: var(--text-2); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }

.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.group.has-selection { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.group-header { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 10px 12px 10px 6px; }
.group-toggle {
  flex: 1 1 220px; display: flex; align-items: center; gap: 8px; text-align: left;
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.group-toggle:hover { background: var(--surface-2); }
.chevron {
  flex: none; width: 8px; height: 8px; margin: 0 4px;
  border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.group-toggle[aria-expanded="true"] .chevron { transform: rotate(45deg); }
.group-name { font-weight: 600; }
.group-status { font-size: 0.8rem; color: var(--text-2); }
.group-figures { text-align: right; font-size: 0.82rem; color: var(--text-2); line-height: 1.3; }
.group-figures strong { display: block; font-size: 1rem; color: var(--text); }

.measure-list { list-style: none; margin: 0; padding: 0 12px 8px; border-top: 1px solid var(--border); }
.measure { padding: 10px 0 8px; border-bottom: 1px solid var(--surface-2); }
.measure:last-child { border-bottom: 0; }
.measure-row { display: flex; gap: 12px; align-items: flex-start; }
.measure-select { display: flex; gap: 10px; align-items: flex-start; flex: 1; cursor: pointer; }
.measure-select input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.measure-name { font-size: 0.95rem; }
.measure.selected .measure-name { font-weight: 600; }
.measure.blocked .measure-name { color: var(--text-2); }
.measure-amount { white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 0.92rem; text-align: right; min-width: 92px; }
.measure-amount.negative { color: var(--text-2); }
.measure-amount.empty { color: var(--text-3); font-size: 0.8rem; }
.measure-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin: 4px 0 0 28px; font-size: 0.78rem; color: var(--text-3); }
.measure-conflict { margin: 4px 0 0 28px; font-size: 0.78rem; color: var(--text-2); }
.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); background: var(--surface-2);
}
.badge.notice { background: var(--notice-bg); border-color: transparent; color: var(--text); }

.measure-unit .measure-select { cursor: default; padding-left: 28px; }
.measure-unit .measure-row { align-items: center; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; flex: none; }
.stepper button {
  font: inherit; font-weight: 700; width: 32px; height: 30px; border: 0; background: none;
  color: var(--accent); cursor: pointer; border-radius: 999px;
}
.stepper button:disabled { color: var(--text-3); cursor: default; }
.stepper output { min-width: 64px; text-align: center; font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.measure-details { margin: 4px 0 0 28px; font-size: 0.85rem; }
.measure-details summary { cursor: pointer; color: var(--accent); font-size: 0.8rem; width: fit-content; }
.measure-details-body { padding: 8px 0 4px; color: var(--text-2); }
.measure-details-body p { margin: 0 0 8px; white-space: pre-line; }
.table-scroll { overflow-x: auto; }
.year-table { border-collapse: collapse; font-size: 0.78rem; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.year-table th, .year-table td { padding: 2px 8px 2px 0; text-align: right; }
.year-table th[scope="row"] { text-align: left; font-weight: 400; }
.year-table thead th { color: var(--text-3); font-weight: 600; }
.year-table .current { color: var(--text); font-weight: 700; }

.summary { position: sticky; top: 196px; }
.summary-body {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; max-height: calc(100vh - 216px); overflow-y: auto;
}
.summary h2 { font-size: 1.1rem; margin-bottom: 4px; }
.summary p { margin: 0 0 10px; font-size: 0.88rem; }
.breakdown { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 12px; }
.breakdown td { padding: 4px 0; border-bottom: 1px solid var(--surface-2); vertical-align: top; }
.breakdown td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 8px; }
.breakdown .swatch { margin-right: 6px; vertical-align: -1px; }
.selected-list-title { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.selected-list { list-style: none; margin: 0 0 14px; padding: 0; font-size: 0.82rem; }
.selected-list li { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; border-bottom: 1px solid var(--surface-2); }
.selected-list .name { flex: 1; }
.selected-list .amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.selected-list button {
  border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 1.1rem; line-height: 1;
  min-width: 24px; min-height: 24px;
}
.selected-list button:hover { color: var(--text); }

/* ---------- Share image dialog ---------- */

.image-dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 20px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.image-dialog::backdrop { background: rgb(0 0 0 / 0.55); }
.image-dialog h2 { font-size: 1.1rem; margin-bottom: 12px; }
.image-dialog img {
  display: block; width: 100%; height: auto; max-height: calc(100vh - 200px); object-fit: contain;
  border-radius: 8px; background: var(--surface-2); margin-bottom: 14px;
}

/* ---------- Footer & toast ---------- */

.site-footer { padding-top: 14px; padding-bottom: 40px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--text-2); }
.site-footer p { margin: 0 0 6px; }
.site-footer summary { cursor: pointer; width: fit-content; }
.site-footer ul { padding-left: 1.2em; margin: 8px 0; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--text); color: var(--surface);
  padding: 10px 16px; border-radius: 8px; font-size: 0.88rem;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 20;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Narrow screens ---------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
  .summary-body { max-height: none; }
  .category { scroll-margin-top: 150px; }
}
@media (max-width: 640px) {
  .header-inner { gap: 0 12px; padding-top: 8px; }
  .tabs { order: 3; width: 100%; margin: 0 -10px; }
  .tabs button { padding: 10px; }
  .meter { padding-top: 8px; }
  .meter-inner { grid-template-columns: 1fr auto; gap: 4px 12px; }
  .next-goal { grid-column: 1 / -1; grid-row: 2; font-size: 0.85rem; }
  .total-value { font-size: 1.5rem; }
  .milestone-list { display: none; }
  .bar-marks span { font-size: 0.72rem; }
  [data-layout="all"] .option { padding: 8px; gap: 6px; }
  .group-header { padding-right: 10px; }
  .group-figures { text-align: left; }
  .measure-amount { min-width: 0; }
  .measure-unit .measure-row { flex-wrap: wrap; }
  .measure-unit .measure-select { flex-basis: 100%; }
  .measure-unit .stepper { margin-left: 28px; }
  .measure-unit .measure-amount { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
