/* Tvoj Novac BiH — stylesheet.
 *
 * Design rules, enforced by the tokens below:
 *   · one accent colour (--color-accent); everything else is neutral, plus one
 *     danger colour used only for errors and destructive actions
 *   · every margin, padding and gap is a --space-* token on an 8px grid
 *     (plus one 4px half step for insets inside small elements)
 *   · density and hierarchy follow product tools such as Linear, Stripe and
 *     Notion: 14px text, 32–40px controls, hairline dividers, lists as rows
 *   · two typefaces: --font-sans for text, --font-mono for numbers and labels
 *   · every digit renders in the monospace face (see "Digits" below)
 *   · layouts are left-aligned; the only gradients are functional
 *     (the match-score ring and the loading shimmer)
 */

/* Digits anywhere in the interface come from the monospace face without
   wrapping each number in markup: this face only covers the characters 0–9. */
@font-face {
  font-family: "Digits";
  src: local("SFMono-Regular"), local("SF Mono"), local("Menlo-Regular"), local("Menlo"), local("Consolas"), local("Roboto Mono"), local("Droid Sans Mono"), local("DejaVu Sans Mono"), local("Liberation Mono"), local("Courier New");
  unicode-range: U+30-39;
}
@font-face {
  font-family: "Digits";
  font-weight: 600 900;
  src: local("SFMono-Bold"), local("SF Mono Bold"), local("Menlo-Bold"), local("Menlo Bold"), local("Consolas Bold"), local("Roboto Mono Bold"), local("DejaVu Sans Mono Bold"), local("Liberation Mono Bold"), local("Courier New Bold");
  unicode-range: U+30-39;
}

:root {
  /* colour */
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-sunken: #f6f6f4;
  --color-ink: #1c1f23;
  --color-ink-muted: #676c73;
  --color-line: #e7e7e4;
  --color-line-strong: #c4c4bf;
  --color-accent: #0b5d4b;
  --color-accent-ink: #ffffff;
  --color-accent-soft: #dcebe4;
  --color-danger: #a3360f;
  --color-danger-soft: #f7e3d9;
  --color-on-danger: #ffffff;
  --color-scrim: rgba(15, 17, 20, .45);
  --color-shadow: rgba(15, 17, 20, .12);
  --color-print-bg: #ffffff;
  --color-print-ink: #000000;

  /* space: 8px grid */
  --space-0: 4px;                     /* half step, for insets inside small elements only */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;
  --space-10: 80px;
  --space-12: 96px;
  --gutter: var(--space-4);          /* page side padding; narrows on phones */

  /* type */
  --font-sans: "Digits", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Roboto Mono", "Droid Sans Mono", monospace;
  --text-xs: .75rem;
  --text-s: .8125rem;
  --text-m: .875rem;
  --text-l: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-display: clamp(2rem, 4.2vw, 3rem);   /* home headline only */
  --text-touch: 1rem;                 /* inputs on touch screens: stops iOS zooming */

  /* shape and size (multiples of 8) */
  --radius: 8px;
  --radius-l: 16px;
  --control: 40px;
  --control-s: 32px;
  --control-xs: 28px;
  --control-touch: 48px;
  --icon: 24px;
  --icon-l: 40px;
  --score: 40px;
  --page: 1040px;
  --measure: 760px;
  --form: 440px;
  --rule: 1px;
  --rule-strong: 2px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f1011;
    --color-surface: #151618;
    --color-sunken: #1c1d20;
    --color-ink: #ededef;
    --color-ink-muted: #9b9ea4;
    --color-line: #26282b;
    --color-line-strong: #41444a;
    --color-accent: #5cc5a5;
    --color-accent-ink: #06231b;
    --color-accent-soft: #1a3129;
    --color-danger: #f0a077;
    --color-danger-soft: #3a2216;
    --color-on-danger: #1b0d05;
    --color-scrim: rgba(0, 0, 0, .65);
    --color-shadow: rgba(0, 0, 0, .5);
  }
}
@media (max-width: 760px) { :root { --gutter: var(--space-2); } }

/* ───────── base ───────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font: var(--text-m)/1.5 var(--font-sans);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 var(--space-2); line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
h1 { font-size: var(--text-2xl); font-weight: 650; letter-spacing: -.02em; }
h2 { font-size: var(--text-l); font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: var(--text-m); font-weight: 600; letter-spacing: -.01em; line-height: 1.25; margin-bottom: var(--space-1); }
p { margin: 0 0 var(--space-2); }
ul { margin: 0; padding-left: var(--space-3); }
a { color: var(--color-accent); text-underline-offset: .2em; }
input, select, textarea, option, optgroup { font-family: inherit; }   /* form controls never fall back to a third typeface */
code, pre { font-family: var(--font-mono); }
mark { background: var(--color-danger-soft); color: var(--color-danger); padding: 0 var(--space-1); border-radius: var(--radius); }
:focus-visible { outline: var(--rule-strong) solid var(--color-accent); outline-offset: var(--rule-strong); border-radius: var(--radius); }
main:focus { outline: none; }
.muted { color: var(--color-ink-muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mt { margin-top: var(--space-4); }
.mt-s { margin-top: var(--space-1); }
.center { justify-content: flex-start; }

/* figures that stand alone are set entirely in the monospace face */
.stat b, .score, .amount, .count, .step-n, input[type=number], input[type=date] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ───────── header and navigation ───────── */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--space-2);
  min-height: var(--space-6);
  padding: max(var(--space-1), env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) var(--space-1) max(var(--gutter), env(safe-area-inset-left));
  background: var(--color-bg);
  border-bottom: var(--rule) solid var(--color-line);
}
.brand { display: flex; align-items: center; gap: var(--space-1); color: var(--color-ink); text-decoration: none; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.brand svg { color: var(--color-accent); flex: none; }
.brand b { font-family: var(--font-mono); font-weight: 500; font-size: var(--text-xs); letter-spacing: .08em; color: var(--color-ink-muted); }
#nav { display: flex; gap: var(--space-3); margin-left: auto; }
#user { display: flex; align-items: center; gap: var(--space-2); padding-left: var(--space-3); border-left: var(--rule) solid var(--color-line); }
#user:empty { display: none; }
#nav a, #user a, button.linklike {
  display: inline-flex; align-items: center; min-height: var(--control-s);
  padding: 0; border: 0; border-radius: 0; background: none;
  color: var(--color-ink-muted); text-decoration: none; font: 500 var(--text-s) var(--font-sans); white-space: nowrap;
  box-shadow: inset 0 calc(-1 * var(--rule-strong)) 0 transparent;
  transition: color .15s, box-shadow .15s;
}
#nav a:hover, #user a:hover, button.linklike:hover { color: var(--color-ink); filter: none; }
#nav a[aria-current="page"], #user a[aria-current="page"] { color: var(--color-ink); box-shadow: inset 0 calc(-1 * var(--rule-strong)) 0 var(--color-accent); }
.count { display: inline-block; min-width: var(--space-3); margin-left: var(--space-1); padding: 0 var(--space-1); border-radius: var(--radius); background: var(--color-accent); color: var(--color-accent-ink); font-size: var(--text-xs); font-weight: 600; text-align: center; }
#lang { min-height: var(--control-s); padding: 0 var(--space-2); flex: none; font: 500 var(--text-xs) var(--font-mono); letter-spacing: .08em; }

main { max-width: calc(var(--page) + 2 * var(--gutter)); margin: 0 auto; padding: var(--space-4) var(--gutter) var(--space-8); min-height: 70vh; }
main > noscript p { margin: 0; }

/* ───────── buttons ───────── */
button, .btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: var(--control); padding: 0 var(--space-2);
  border: var(--rule) solid var(--color-accent); border-radius: var(--radius);
  background: var(--color-accent); color: var(--color-accent-ink);
  font: 550 var(--text-m) var(--font-sans); text-decoration: none; cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s, transform .08s, filter .15s;
}
button:hover, .btn:hover { filter: brightness(1.12); }
button:active, .btn:active { transform: scale(.97); }
button:disabled { cursor: default; opacity: .6; filter: none; transform: none; }
button.ghost, .btn.ghost, .tab, .x { background: transparent; color: var(--color-ink); border-color: var(--color-line-strong); }
button.ghost:hover, .btn.ghost:hover, .tab:hover, .x:hover { border-color: var(--color-ink); filter: none; }
button.small, .btn.small { min-height: var(--control-s); padding: 0 var(--space-1); font-size: var(--text-s); }
button.danger { background: transparent; color: var(--color-danger); border-color: var(--color-line-strong); }
button.danger:hover { background: var(--color-danger-soft); border-color: var(--color-danger); filter: none; }
.tab[aria-pressed="true"] { background: var(--color-ink); color: var(--color-bg); border-color: var(--color-ink); }
.tab[aria-pressed="true"] .count { background: var(--color-bg); color: var(--color-ink); }
.x { min-height: var(--control-s); width: var(--control-s); padding: 0; font-size: var(--text-m); flex: none; }
/* a pressed button shows progress only if the action takes a moment */
button.loading { pointer-events: none; color: transparent; transition-delay: .25s; }
button.loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: var(--space-2); height: var(--space-2); border-radius: 50%; border: var(--rule-strong) solid var(--color-ink-muted); border-right-color: transparent; opacity: 0; animation: spin .7s linear infinite, fade .01s .25s forwards; }
.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* ───────── home ───────── */
.hero { display: grid; grid-template-columns: 7fr 5fr; gap: var(--space-8); align-items: end; padding: var(--space-4) 0 var(--space-6); }
.hero h1 { max-width: 16ch; font-size: var(--text-display); line-height: 1.05; letter-spacing: -.03em; }
.hero p.lead { font-size: var(--text-l); line-height: 1.4; color: var(--color-ink-muted); max-width: 44ch; margin-bottom: var(--space-4); }
.hero .cta { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.eyebrow { font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--color-accent); margin-bottom: var(--space-2); }

/* the four figures read as a ledger, not as tiles */
.stat-card { border-top: var(--rule) solid var(--color-line); }
.stat { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); padding: var(--space-1) 0; border-bottom: var(--rule) solid var(--color-line); }
.stat b { order: 2; font-size: var(--text-l); font-weight: 500; line-height: 1; }
.stat span { color: var(--color-ink-muted); font-size: var(--text-s); }
.stat:first-child b { color: var(--color-accent); }

section.block { margin-top: var(--space-6); padding-top: var(--space-3); border-top: var(--rule) solid var(--color-line); }
.grid { display: grid; gap: var(--space-2); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }

.card { background: var(--color-surface); border: var(--rule) solid var(--color-line); border-radius: var(--radius); padding: var(--space-2); transition: border-color .15s, transform .15s; }
.card > :last-child, .card p:last-child { margin-bottom: 0; }
.step-n { font-size: var(--text-xl); font-weight: 500; line-height: 1; color: var(--color-accent); margin-bottom: var(--space-3); }
.step-n::before { content: "0"; }
.cat { display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-2); min-height: var(--space-12); text-decoration: none; color: inherit; }
.cat h3 { margin: 0; }
.cat small { font-size: var(--text-xs); color: var(--color-ink-muted); }
.cat:hover { border-color: var(--color-accent); transform: translateY(calc(-1 * var(--rule-strong))); }
.note { margin: 0; padding: var(--space-2); border-left: var(--rule-strong) solid var(--color-accent); background: var(--color-sunken); color: var(--color-ink-muted); font-size: var(--text-s); border-radius: 0 var(--radius) var(--radius) 0; }

.price { display: grid; grid-template-columns: 5fr 7fr; gap: var(--space-6); align-items: start; }
.price .amount { font-size: var(--text-display); font-weight: 500; line-height: 1; letter-spacing: -.04em; margin-bottom: var(--space-2); }
.price .amount small { font: 500 var(--text-s) var(--font-sans); letter-spacing: 0; color: var(--color-ink-muted); }
.price ul { list-style: none; padding: 0; border-top: var(--rule) solid var(--color-line); }
.price li { padding: var(--space-2) 0; border-bottom: var(--rule) solid var(--color-line); }
.install { display: flex; gap: var(--space-3); align-items: flex-start; }
.install img { width: var(--space-8); height: var(--space-8); border-radius: var(--radius-l); flex: none; }

/* ───────── forms ───────── */
form.profile { display: grid; gap: var(--space-3); }
.stack { display: grid; gap: var(--space-2); }
.narrow, .narrow-card { max-width: var(--form); }
fieldset { margin: 0; min-width: 0; padding: var(--space-2); background: var(--color-surface); border: var(--rule) solid var(--color-line); border-radius: var(--radius); }
legend { padding: 0 var(--space-1); font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--color-ink-muted); }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.f { display: grid; gap: var(--space-1); align-content: start; font-weight: 600; font-size: var(--text-s); }
.f.wide { grid-column: 1 / -1; }
.f small { font-weight: 400; }
input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], input[type=date], input[type=url], select, textarea {
  width: 100%; max-width: 100%; min-height: var(--control); padding: 0 var(--space-1);
  background: var(--color-bg); color: var(--color-ink);
  border: var(--rule) solid var(--color-line-strong); border-radius: var(--radius);
  font: var(--text-m) var(--font-sans);
  transition: border-color .15s, box-shadow .15s;
}
input[type=number], input[type=date] { font-family: var(--font-mono); }
textarea { padding: var(--space-2); min-height: var(--space-12); resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 var(--rule-strong) var(--color-accent); }
[aria-invalid="true"] { border-color: var(--color-danger) !important; }
.err { color: var(--color-danger); font-size: var(--text-s); font-weight: 600; }
.alert, .ok { margin: 0; padding: var(--space-2); border-radius: var(--radius); font-weight: 600; animation: rise .2s ease-out; }
.alert { background: var(--color-danger-soft); color: var(--color-danger); }
.ok { background: var(--color-accent-soft); color: var(--color-accent); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.chips label { cursor: pointer; }
.chips input { position: absolute; opacity: 0; }
.chips span { display: inline-flex; align-items: center; min-height: var(--control-xs); padding: 0 calc(var(--space-1) * 1.25); border: var(--rule) solid var(--color-line-strong); border-radius: var(--radius); font-size: var(--text-s); font-weight: 500; user-select: none; transition: background-color .15s, color .15s, border-color .15s, transform .08s; }
.chips label:active span { transform: scale(.96); }
.chips input:checked + span { background: var(--color-accent); color: var(--color-accent-ink); border-color: var(--color-accent); }
.chips input:focus-visible + span { outline: var(--rule-strong) solid var(--color-accent); outline-offset: var(--rule-strong); }
label.check { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-s); }
label.check input { width: var(--icon); height: var(--icon); flex: none; margin: 0; accent-color: var(--color-accent); }
label.check .err { display: block; }

/* ───────── programme lists ───────── */
.toolbar { display: flex; gap: var(--space-1); flex-wrap: wrap; margin: var(--space-3) 0; }
.toolbar input[type=search] { flex: 2 1 calc(var(--space-12) * 3); min-width: 0; }
.toolbar select { flex: 1 1 0; min-width: 0; width: auto; }
.list { display: grid; border: var(--rule) solid var(--color-line); border-radius: var(--radius); background: var(--color-surface); overflow: clip; }
.list > .card { border: 0; border-radius: 0; background: transparent; }
.list > .card + .card { border-top: var(--rule) solid var(--color-line); }
.list > .card:hover { background: var(--color-sunken); }
.prog { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; }
.prog h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog .prov { color: var(--color-ink-muted); font-size: var(--text-s); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog .sum { display: none; }                       /* the summary lives in the detail dialog; rows stay scannable */
.prog .tags { margin-top: var(--space-1); }
.prog .side { display: flex; gap: var(--space-1); }
.prog .side button { min-height: var(--control-s); padding: 0 var(--space-1); font-size: var(--text-s); }
.score { position: relative; display: grid; place-items: center; width: var(--score); height: var(--score); border-radius: 50%; font-size: var(--text-s); font-weight: 600; background: conic-gradient(var(--color-accent) calc(var(--v) * 1%), var(--color-line) 0); }
.score::before { content: ""; position: absolute; inset: var(--space-0); border-radius: 50%; background: var(--color-surface); }
.score span { position: relative; }
.tags { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.tag { display: inline-flex; align-items: center; min-height: var(--space-3); padding: 0 var(--space-1); font-weight: 500; border: var(--rule) solid transparent; border-radius: var(--radius); background: var(--color-sunken); color: var(--color-ink-muted); font-size: var(--text-xs); white-space: nowrap; }
.tag.open { background: var(--color-accent); color: var(--color-accent-ink); }
.tag.upcoming { background: var(--color-accent-soft); color: var(--color-accent); }
.tag.why { background: transparent; border-color: var(--color-line-strong); color: var(--color-ink); }
.tag.warn { background: var(--color-danger-soft); color: var(--color-danger); }

/* empty and error states: left-aligned, one sentence, at most one action */
.empty { display: grid; justify-items: start; gap: var(--space-2); padding: var(--space-5) var(--space-4); color: var(--color-ink-muted); border-style: dashed; }
.empty::before { content: ""; width: var(--icon-l); height: var(--icon-l); background: var(--color-accent);
  -webkit-mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m15.5 8.5-2.2 4.8-4.8 2.2 2.2-4.8z'/%3E%3C/svg%3E");
  mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m15.5 8.5-2.2 4.8-4.8 2.2 2.2-4.8z'/%3E%3C/svg%3E"); }
.empty.error::before { background: var(--color-danger);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6M12 16.5v.5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6M12 16.5v.5'/%3E%3C/svg%3E"); }
.empty h1 { font-size: var(--text-xl); margin: 0; color: var(--color-ink); }
.empty p { margin: 0; max-width: 46ch; }

/* ───────── facts, payment, documents ───────── */
.pay dl, dl.facts, .dlg dl { display: grid; grid-template-columns: max-content 1fr; gap: 0 var(--space-3); margin: 0 0 var(--space-2); }
.pay dt, dl.facts dt, .dlg dt { color: var(--color-ink-muted); font-size: var(--text-s); padding: var(--space-1) 0; border-bottom: var(--rule) solid var(--color-line); }
.pay dd, dl.facts dd, .dlg dd { margin: 0; padding: var(--space-1) 0; border-bottom: var(--rule) solid var(--color-line); font-size: var(--text-s); overflow-wrap: anywhere; }
.pay { border-color: var(--color-ink); }
.sub { margin: var(--space-2) 0; }
.row-card { display: flex; gap: var(--space-2); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row-card > div:first-child { flex: 1 1 0; min-width: 0; }
.doc { margin: 0; padding: var(--space-3); background: var(--color-bg); border: var(--rule) solid var(--color-line); border-radius: var(--radius); font: var(--text-s)/1.6 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.doc[contenteditable]:focus { outline: var(--rule-strong) solid var(--color-accent); }
.doclist { list-style: none; padding: 0; margin: 0; border-top: var(--rule) solid var(--color-line); }
.doclist li { display: flex; gap: var(--space-2); justify-content: space-between; align-items: center; padding: var(--space-1) 0; border-bottom: var(--rule) solid var(--color-line); }
.doclist small { display: block; color: var(--color-ink-muted); }
.doclist .doclinks { overflow-wrap: anywhere; }
.codeform { display: flex; gap: var(--space-1); align-items: end; flex-wrap: wrap; margin-top: var(--space-2); }
.codeform .f { flex: 1 1 calc(var(--space-12) * 2); }
.doclist li.tick { flex-direction: row; flex-wrap: wrap; align-items: center; }
.doclist li.tick > input { flex: none; width: var(--space-3); height: var(--space-3); margin: 0; accent-color: var(--color-accent); }
.doclist li.tick > div { flex: 1 1 60%; min-width: 0; }
.stages { display: flex; flex-wrap: wrap; gap: var(--space-1); list-style: none; padding: 0; margin: var(--space-2) 0 var(--space-3); }
.stages button { width: 100%; padding: var(--space-1); font-size: var(--text-s); background: var(--color-surface); color: var(--color-ink-muted); border: var(--rule) solid var(--color-line); border-top: var(--rule-strong) solid var(--color-line-strong); border-radius: var(--radius); white-space: nowrap; }
.stages li { flex: 1 1 auto; }
.stages button.done { border-top-color: var(--color-accent); color: var(--color-ink); }
.stages button[aria-current] { border-top-color: var(--color-accent); background: var(--color-accent); color: var(--color-accent-ink); }
progress { width: 100%; height: var(--space-1); accent-color: var(--color-accent); }
.legal { max-width: var(--measure); }
.legal h2 { font-size: var(--text-l); margin-top: var(--space-5); }

/* ───────── dialog ───────── */
dialog { width: min(var(--measure), calc(100vw - var(--space-4))); max-height: 88vh; padding: 0; background: var(--color-surface); color: var(--color-ink); border: var(--rule) solid var(--color-line); border-radius: var(--radius-l); box-shadow: 0 var(--space-3) var(--space-8) var(--color-shadow); }
dialog::backdrop { background: var(--color-scrim); }
dialog[open] { animation: pop .22s ease-out; }
dialog[open]::backdrop { animation: fade .22s ease-out; }
.dlg { display: grid; gap: var(--space-2); padding: var(--space-3); }
.dlg header { display: flex; gap: var(--space-2); justify-content: space-between; align-items: start; }
.dlg h2 { margin: 0; font-size: var(--text-l); line-height: 1.2; }
.dlg p, .dlg dl { margin: 0; }
.dlg h3 { margin: var(--space-2) 0 var(--space-1); }
.dlg h3 + .tags, .dlg h3 + p { margin-top: 0; }

/* ───────── application board ───────── */
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-2); }
.col { min-width: 0; padding-top: var(--space-2); border-top: var(--rule) solid var(--color-line); }
.col h3 { display: flex; justify-content: space-between; margin: 0; font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--color-ink-muted); }
.item { display: grid; gap: var(--space-1); margin-top: var(--space-2); padding: var(--space-2); background: var(--color-surface); border: var(--rule) solid var(--color-line); border-radius: var(--radius); font-size: var(--text-s); }
.item b { line-height: 1.3; overflow-wrap: anywhere; }
.item select, .item textarea { font-size: var(--text-s); }
.item .row { display: flex; gap: var(--space-1); flex-wrap: wrap; }

/* ───────── tables (admin) ───────── */
.table-wrap { overflow-x: auto; border-top: var(--rule) solid var(--color-line); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-s); }
th, td { text-align: left; padding: var(--space-1) var(--space-2) var(--space-1) 0; border-bottom: var(--rule) solid var(--color-line); vertical-align: middle; }
th { font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--color-ink-muted); white-space: nowrap; }
td.wrap { max-width: calc(var(--form) - var(--space-3)); overflow-wrap: anywhere; }
td select { width: auto; min-height: var(--control-s); font-size: var(--text-s); }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: var(--color-sunken); }
details > summary { cursor: pointer; }

/* ───────── footer ───────── */
.foot { border-top: var(--rule) solid var(--color-line); padding: var(--space-3) var(--gutter) max(var(--space-3), env(safe-area-inset-bottom)); color: var(--color-ink-muted); font-size: var(--text-s); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); justify-content: space-between; }
.foot nav { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.foot a { color: var(--color-ink); }
.foot p { margin: 0; }

/* ───────── motion and feedback ───────── */
@property --v { syntax: "<number>"; inherits: true; initial-value: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(var(--space-1)); } }
@keyframes pop { from { opacity: 0; transform: translateY(var(--space-2)) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fill { from { --v: 0; } }
main.enter > * { animation: rise .28s ease-out both; }
main.enter > *:nth-child(2) { animation-delay: .04s; }
main.enter > *:nth-child(n+3) { animation-delay: .08s; }
main.enter .list > * { animation: rise .3s ease-out both; }
main.enter .list > *:nth-child(2) { animation-delay: .05s; }
main.enter .list > *:nth-child(3) { animation-delay: .1s; }
main.enter .list > *:nth-child(n+4) { animation-delay: .15s; }
main.enter .score { animation: fill .7s ease-out both; }
#admin-body { animation: rise .2s ease-out; }

#toast { position: fixed; left: 50%; bottom: calc(var(--space-3) + env(safe-area-inset-bottom)); translate: -50% var(--space-2); z-index: 20; max-width: calc(100vw - var(--space-4)); padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--color-ink); color: var(--color-bg); font-size: var(--text-s); font-weight: 600; box-shadow: 0 var(--space-1) var(--space-4) var(--color-shadow); opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s; }
#toast.show { opacity: 1; translate: -50% 0; }
#toast.bad { background: var(--color-danger); color: var(--color-on-danger); }

.skel-page { display: grid; gap: var(--space-2); }
.skel { border-radius: var(--radius); background: linear-gradient(90deg, var(--color-line) 25%, var(--color-sunken) 50%, var(--color-line) 75%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
.skel.title { height: var(--space-8); width: min(var(--form), 70%); }
.skel.line { height: var(--space-3); width: min(var(--measure), 90%); margin-bottom: var(--space-2); }
.skel.card { height: var(--space-12); }

/* ───────── touch devices ───────── */
/* ───────── sign-in with outside accounts, authenticator code, home search ───────── */
.social { display: grid; gap: var(--space-1); }
.or { display: flex; align-items: center; gap: var(--space-2); margin: 0; color: var(--color-ink-muted); font-size: var(--text-s); }
.or::before, .or::after { content: ""; flex: 1; border-top: var(--rule) solid var(--color-line); }
.qr { width: calc(var(--space-12) * 2); max-width: 100%; border: var(--rule) solid var(--color-line); border-radius: var(--radius); overflow: hidden; }
.qr svg { display: block; width: 100%; height: auto; }
.hero-search { display: flex; gap: var(--space-1); max-width: 440px; margin-bottom: var(--space-2); }
.hero-search input[type=search] { flex: 1; min-width: 0; }

.invoice { white-space: normal; font-family: var(--font-sans); }
.invoice .parties { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin: var(--space-2) 0; }
.invoice small { color: var(--color-ink-muted); }
.invoice table { width: 100%; margin: var(--space-2) 0; }
.invoice td.num { text-align: right; white-space: nowrap; font-family: var(--font-mono); }
.invoice tr.sum td { font-weight: 700; border-bottom: 0; }
/* an invoice stays a table on phones and on paper */
dialog .invoice table { display: table; }
dialog .invoice tbody { display: table-row-group; }
dialog .invoice tr { display: table-row; padding: 0; margin: 0; border: 0; border-radius: 0; background: none; }
dialog .invoice td { display: table-cell; padding: var(--space-1) 0; border-bottom: var(--rule) solid var(--color-line); }
dialog .invoice td.num { padding-left: var(--space-2); vertical-align: top; }
.profile .check { margin: var(--space-2) 0; }
@media print { .invoice small { color: var(--color-print-ink); } }

@media (pointer: coarse) {
  /* 16px text stops iOS zooming on focus; every control is at least 48px tall */
  input[type=text], input[type=number], input[type=search], input[type=email], input[type=password], input[type=date], input[type=url], select, textarea { font-size: var(--text-touch) !important; min-height: var(--control-touch); }
  button, .btn, button.small, .btn.small, #nav a, #user a, button.linklike, #lang, .x, td select, .prog .side button { min-height: var(--control-touch); }
  .x { width: var(--control-touch); }
  .chips span { min-height: var(--control); }
}

/* ───────── narrower screens ───────── */
@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; gap: var(--space-5); align-items: start; }
  .price { grid-template-columns: 1fr; gap: var(--space-3); }
  .grid.c4, .grid.c3 { grid-template-columns: repeat(2, 1fr); }
  .board { grid-template-columns: 1fr; }
  .table-wrap { overflow: visible; border-top: 0; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr { background: var(--color-surface); border: var(--rule) solid var(--color-line); border-radius: var(--radius); padding: var(--space-2); margin-bottom: var(--space-2); }
  td { border: 0; padding: var(--space-1) 0; max-width: none !important; }
  .fields { grid-template-columns: 1fr; }
  .fields > span:empty { display: none; }
  #nav { gap: var(--space-2); }
}

/* phones: destinations move to a bottom tab bar */
@media (max-width: 760px) {
  main { padding-top: var(--space-4); padding-bottom: calc(var(--space-12) + env(safe-area-inset-bottom)); }
  .top { gap: var(--space-1); min-width: 0; }
  .brand { min-width: 0; flex: 0 1 auto; overflow: hidden; }
  .brand span { overflow: hidden; text-overflow: ellipsis; }
  #user { margin-left: auto; flex: none; padding-left: 0; border-left: 0; }
  #lang { margin-left: auto; }
  #user:not(:empty) + #lang { margin-left: 0; }
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; margin: 0; gap: 0; background: var(--color-bg); border-top: var(--rule) solid var(--color-line);
    padding: 0 max(var(--space-1), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--space-1), env(safe-area-inset-left)); }
  #nav:empty { display: none; }
  #nav a { position: relative; flex: 1 1 0; min-width: 0; min-height: var(--space-8); justify-content: center; text-align: center; white-space: normal; font-size: var(--text-xs); line-height: 1.2; box-shadow: inset 0 var(--rule-strong) 0 transparent; }
  #nav a[aria-current="page"] { color: var(--color-accent); box-shadow: inset 0 var(--rule-strong) 0 var(--color-accent); }
  #nav .count { position: absolute; top: var(--space-1); right: var(--space-1); margin: 0; }
  .foot { padding-bottom: calc(var(--space-10) + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(var(--space-10) + env(safe-area-inset-bottom)); }
  .prog { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
  .prog h3, .prog .prov { white-space: normal; }
  .prog .side { grid-column: 1 / -1; }
  .toolbar > * { flex: 1 1 100%; }
  .toolbar .tab { flex: 1 1 40%; }
  .toolbar select { width: 100%; }
  .grid.c4, .grid.c3, .grid.c2 { grid-template-columns: 1fr; }
  .card, fieldset { padding: var(--space-2); }
  .empty { padding: var(--space-4) var(--space-2); }
  .pay dl, dl.facts, .dlg dl { grid-template-columns: 1fr; }
  .pay dt, dl.facts dt, .dlg dt { border-bottom: 0; padding-bottom: 0; }
  .dlg { padding: var(--space-3) var(--space-2); }
  dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin-bottom: 0; border-radius: var(--radius-l) var(--radius-l) 0 0; border-width: var(--rule) 0 0; }
  .doclist li { flex-direction: column; align-items: stretch; }
  .install { flex-direction: column; }
}
@media (max-width: 420px) { .brand span { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skel { animation: none; }
}

@media print {
  body > *:not(dialog) { display: none !important; }
  /* an open dialog sits in the browser's top layer and is centred there; pin it to the top of the page
     so a document longer than one sheet starts at its first line and flows onto further pages */
  html, html:has(dialog[open]), body { overflow: visible !important; height: auto; }
  dialog, dialog[open] { position: absolute; inset: 0 auto auto 0; margin: 0; width: 100%; max-width: none; height: auto; max-height: none; overflow: visible; border: 0; border-radius: 0; box-shadow: none; animation: none; }
  dialog::backdrop { display: none; }
  .dlg { padding: 0; }
  dialog header, dialog .actions, dialog .note { display: none !important; }
  .doc { border: 0; padding: 0; background: var(--color-print-bg); color: var(--color-print-ink); font-size: 11pt; }
}
.dlg .card { display: grid; gap: var(--space-2); }
.dlg .card > * { margin: 0; }

/* ───────── plan and proposal editor ───────── */
.budget { display: grid; gap: var(--space-1); }
.brow { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1.5fr) auto; gap: var(--space-1); align-items: center; }
.brow.proj { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 2fr); }
.brow.bhead { font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--color-ink-muted); }
.brow.bhead > :last-child:empty { width: var(--control-s); }
.brow.bhead > :nth-child(n+4), .brow.proj.bhead > * { text-align: right; }
.brow output { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-s); text-align: right; white-space: nowrap; }
.brow input[type=number] { text-align: right; }
#plan-totals dd { font-family: var(--font-mono); text-align: right; }
@media (max-width: 760px) {
  .brow.bhead { display: none; }
  .brow, .brow.proj { grid-template-columns: 1fr 1fr; padding-bottom: var(--space-2); border-bottom: var(--rule) solid var(--color-line); }
  .brow > :first-child { grid-column: 1 / -1; }
  .brow > output { align-self: center; }
  .brow.proj > output { grid-column: 1 / -1; }
  #plan-totals dd { text-align: left; }
}

/* ───────── "how to obtain" guides ───────── */
.guide { display: grid; gap: var(--space-1); }
.guide header { margin-bottom: var(--space-1); }
.guide ol, .guide ul:not(.doclist) { display: grid; gap: var(--space-1); }
.guide .hint { margin: 0; padding: var(--space-2); background: var(--color-sunken); border-radius: var(--radius); font-size: var(--text-s); }
.guide .small-print { font-size: var(--text-s); margin-top: var(--space-2); }
.guide .doclist small { overflow-wrap: anywhere; }
.print-only { display: none; }
@media print {
  dialog .guide header { display: block !important; }
  dialog .guide .x, dialog .guide .hint a { display: none !important; }
  dialog .guide .muted, dialog .guide .small-print { display: block !important; }
  .print-only { display: inline; }
  dialog .guide { font-size: 11pt; color: var(--color-print-ink); }
  dialog .guide h3 { margin: var(--space-1) 0 0; break-after: avoid; }
  dialog .guide .hint { padding: 0; background: none; }
  dialog .guide li { break-inside: avoid; }
  dialog .guide a { color: var(--color-print-ink); text-decoration: none; }
}
