/* Shift Log styles. "Night Clock" theme.
   One narrow column (max 680 px), a header that scrolls away, a bottom tab bar. Components use only the
   tokens in section 2 (tests/design.test.js). */

/* ===== 1. Fonts (self-hosted; every file is in the sw.js SHELL) ===== */
@font-face { font-family: "Big Shoulders Display"; font-weight: 600; font-display: swap; src: url("fonts/big-shoulders-display-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Big Shoulders Display"; font-weight: 800; font-display: swap; src: url("fonts/big-shoulders-display-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 400; font-display: swap; src: url("fonts/public-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 500; font-display: swap; src: url("fonts/public-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 600; font-display: swap; src: url("fonts/public-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-weight: 700; font-display: swap; src: url("fonts/public-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

/* ===== 2. Tokens. Light here; dark in the two blocks below, which must stay identical. ===== */
:root {
  --bg: #e9ecef;
  --surface: #fbfcfd;
  --surface-2: #f0f2f4;
  --ink: #111c27;
  --muted: #4f5d6a;
  --line: #d2d8de;
  --line-strong: #7d8995;
  --accent: #c27a00;
  --on-accent: #1b1305;
  --accent-text: #8a5300;
  --base: #4a5a6b;
  --nightband: #dde2ec;
  --good: #13773a;
  --good-bg: #e3f3e8;
  --bad: #b3261e;
  --bad-bg: #fbe9e6;
  --focus: #2f6db5;
  --hero-bg: #111c27;
  --hero-ink: #fbfcfd;
  --hero-money: #c27a00;
  --hero-line: #111c27;
  --display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-card: 12px;
  --r-ctl: 8px;
  --gutter: 16px;
  --tabbar-h: 57px;
  --t-press: 100ms;
  --t-state: 150ms;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e13; --surface: #121920; --surface-2: #19212a; --ink: #dde4eb; --muted: #8f9ca9;
    --line: #25303b; --line-strong: #627387; --accent: #eea23a; --on-accent: #1b1305; --accent-text: #f0b04a;
    --base: #6b7c8e; --nightband: #1b2436; --good: #5fd08a; --good-bg: #173325; --bad: #ff8a80; --bad-bg: #3a1c1c;
    --focus: #7fb0ff; --hero-bg: #19212a; --hero-ink: #dde4eb; --hero-money: #f0b04a; --hero-line: #25303b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0e13; --surface: #121920; --surface-2: #19212a; --ink: #dde4eb; --muted: #8f9ca9;
  --line: #25303b; --line-strong: #627387; --accent: #eea23a; --on-accent: #1b1305; --accent-text: #f0b04a;
  --base: #6b7c8e; --nightband: #1b2436; --good: #5fd08a; --good-bg: #173325; --bad: #ff8a80; --bad-bg: #3a1c1c;
  --focus: #7fb0ff; --hero-bg: #19212a; --hero-ink: #dde4eb; --hero-money: #f0b04a; --hero-line: #25303b;
  color-scheme: dark;
}

/* ===== 3. Base: type, focus, press feedback ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { background: var(--bg); }
body { color: var(--ink); font: 16px/1.45 var(--body); padding-inline: var(--gutter); padding-block: 0 calc(var(--tabbar-h) + 24px); -webkit-tap-highlight-color: transparent; }
.wrap { max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.wrap .wrap { margin: 0; max-width: none; width: 100%; min-width: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; letter-spacing: .01em; text-wrap: balance; margin: 0; line-height: 1.05; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--muted); }
.kicker { font-size: 12px; font-weight: 700; line-height: 1.3; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn, .chip, .row, .iconbtn, .seg-ctl button, .tabs button { transition: background-color var(--t-state) ease, color var(--t-state) ease, transform var(--t-press) ease-out; }
.btn:active, .chip:active, .row:active, .iconbtn:active, .seg-ctl button:active { transform: scale(.98); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
  .btn:active, .chip:active, .row:active, .iconbtn:active, .seg-ctl button:active { transform: none; }
}

/* ===== 4. Header: scrolls away with the page ===== */
.top { margin-inline: calc(-1 * var(--gutter)); padding: 12px var(--gutter); }
.top-in { max-width: 680px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; row-gap: 2px; }
.brand { flex: 1; min-width: 0; }
.brand h1 { font-size: 26px; }
.brand p { margin: 2px 0 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Own row under the title: at 390 px the German line is wider than the space next to it. */
.status-line { order: 3; flex: 1 0 100%; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-line.warn { color: var(--accent-text); font-weight: 600; }
.iconbtn { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: var(--r-ctl); width: 44px; height: 44px; padding: 0; display: grid; place-items: center; cursor: pointer; }
.iconbtn svg { width: 24px; height: 24px; }

/* ===== 5. Tab bar ===== */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding: 0 8px env(safe-area-inset-bottom, 0px); }
.tabs-in { max-width: 680px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabs button { position: relative; border: 0; background: none; min-height: 56px; padding: 8px 2px 6px; cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.2; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }

/* ===== 6. Cards, fields, buttons, chips, notes, empty states ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 48px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface-2); font-size: 16px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input.time { min-height: 54px; padding-block: 9px; font-family: var(--mono); font-size: 22px; font-weight: 500; letter-spacing: .02em; }
textarea { min-height: 112px; font-family: var(--mono); font-size: 16px; resize: vertical; }
input:disabled, select:disabled, button:disabled { opacity: .45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-family: var(--mono); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip:active { background: var(--surface-2); }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.btn { min-height: 44px; padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface-2); color: var(--ink); font-weight: 600; cursor: pointer; }
.btn:active { background: var(--line); }
.btn.primary { min-height: 48px; border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 700; }
.btnrow .btn.primary { flex: 1 1 160px; }
.btn.primary:active { filter: brightness(.92); }
.btn.danger { color: var(--bad); }
.btn.danger.armed { border-color: var(--bad); background: var(--bad); color: var(--surface); }
.msg { min-height: 1.3em; margin: 0; font-size: 14px; color: var(--muted); }
.msg.err { color: var(--bad); }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.check input { flex: none; width: 22px; height: 22px; min-height: 22px; accent-color: var(--accent); }
.note { margin: 0; max-width: 65ch; font-size: 13px; line-height: 1.45; color: var(--muted); }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }
.empty svg { display: block; width: 32px; height: 32px; margin: 0 auto 8px; }
.empty p { margin: 0; }
/* calc warnings are red-tinted notes: amber only means "act here" and "extra money" */
.warns { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.warns li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--r-ctl); background: var(--bad-bg); color: var(--bad); font-size: 14px; }
.warns svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.flag { display: inline-flex; align-items: center; gap: 3px; color: var(--bad); font-family: var(--body); font-size: 12px; font-weight: 600; }
.flag svg { width: 14px; height: 14px; }

/* ===== 7. Banners ===== */
#banners { display: flex; flex-direction: column; gap: 8px; }
#banners:empty { display: none; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r-card); background: var(--surface); color: var(--ink); font-size: 14px; }
.banner.info { border-left-color: var(--ink); }
.banner.bad { border-left-color: var(--bad); }
.banner.bad p { color: var(--bad); }
.banner p { flex: 1 1 200px; min-width: 0; margin: 0; }
.banner small { display: block; margin-top: 2px; color: var(--muted); }
.banner .btn { min-height: 44px; }
.banner details { flex-basis: 100%; color: var(--muted); }
.banner summary { min-height: 44px; display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-weight: 600; color: var(--ink); }
.banner summary::-webkit-details-marker { display: none; }
.banner summary svg { width: 16px; height: 16px; transition: transform var(--t-state); }
.banner details[open] summary svg { transform: rotate(180deg); }
.banner details p { margin: 0; }

/* ===== 8. Shifts: This week, form, preview ===== */
.week-now { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--hero-line); border-radius: var(--r-card); background: var(--hero-bg); color: var(--hero-ink); }
.week-now .wn-kw { font-family: var(--display); font-size: 24px; font-weight: 800; line-height: 1.05; }
.week-now p { margin: 2px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.week-now .wn-gross { font-family: var(--display); font-size: 32px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--hero-money); }
.form-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.preview { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--surface-2); }
.preview.pv-on { border-left: 4px solid var(--accent); padding-left: 12px; }
.preview .strip { background: var(--surface); }
/* The night-window swatch is --nightband on the panel's --surface-2: almost invisible at night without an edge. */
.preview .legend span:last-child i { box-shadow: inset 0 0 0 1px var(--line-strong); }
.pv-gross { margin-top: -4px; font-family: var(--display); font-size: 48px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.pv-when { margin: 0; font-size: 14px; color: var(--muted); }
.pv-lines { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.pv-line { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.pv-line b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pv-line.bonus { color: var(--accent-text); }
.pv-line.total { padding-top: 6px; border-top: 1px solid var(--line); font-weight: 700; }
.pv-line.total b { font-weight: 700; }
.pv-break { margin: 0; font-size: 13px; color: var(--muted); }
.more { border-block: 1px solid var(--line); }
.more summary { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; font-size: 14px; color: var(--muted); }
.more summary::-webkit-details-marker { display: none; }
.more summary { touch-action: manipulation; transition: color var(--t-state) ease; }
.more summary:active { color: var(--ink); }
.more summary svg { width: 16px; height: 16px; flex: none; transition: transform var(--t-state); }
.more[open] summary svg { transform: rotate(180deg); }
.more .fields { padding-bottom: 12px; align-items: end; } /* German "Pausenbeginn" wraps to two lines; keep both inputs level */

/* ===== 9. The 36-hour shift strip and legends ===== */
.strip { position: relative; height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.strip .nb { position: absolute; top: 0; bottom: 0; background: var(--nightband); }
.strip .seg { position: absolute; top: 3px; bottom: 3px; border-radius: 2px; }
.strip .seg.b { background: var(--base); }
.strip .seg.p { background: var(--accent); }
.strip-axis { display: flex; justify-content: space-between; margin-top: 3px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; }

/* ===== 10. Shifts: week list ===== */
.week { display: flex; flex-direction: column; }
.week-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 0 2px 8px; }
.week-head h3 { font-size: 22px; }
.week-head .num { font-size: 14px; color: var(--muted); }
.rows { overflow: hidden; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.row { width: 100%; min-height: 64px; padding: 12px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink); text-align: left; cursor: pointer; display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.row:first-child { border-top: 0; }
.row:active { background: var(--surface-2); }
@media (hover: hover) { .row:hover { background: var(--surface-2); } }
.row.editing { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.row .d { font-size: 15px; font-weight: 700; line-height: 1.2; }
.row .d small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .times small { font-family: var(--body); font-size: 13px; }
.pv-hint { margin: 0; }
.row .mid { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.row .times { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--mono); font-size: 15px; }
.row .meta { font-size: 13px; color: var(--muted); }
.row .g { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.row .g small { display: block; font-size: 13px; font-weight: 500; color: var(--accent-text); }
.status { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-family: var(--body); font-size: 12px; font-weight: 600; }
.week-head .wk-range { font-family: var(--body); font-size: 13px; font-weight: 500; color: var(--muted); }
#backup-banner { display: flex; flex-direction: column; gap: 8px; }
#backup-banner:empty { display: none; }

/* ===== 11. Summary: filter bar and tiles ===== */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
/* The period select takes its own row on phones: "KW 41 · 05.10.–11.10.2026" doesn't fit beside Week/Month. */
.filterbar select { width: auto; min-width: 0; flex: 1 1 260px; }
.seg-ctl { display: inline-grid; grid-auto-flow: column; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); }
.seg-ctl button { min-height: 44px; padding: 0 18px; border: 0; background: none; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg-ctl button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
/* Two columns at every width: in four columns a 32 px lead value ("€ 9.999,99") never fits, even at the 680 px maximum. */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.tile b { overflow: hidden; font-family: var(--display); font-size: 26px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; text-overflow: ellipsis; }
.tile small { font-size: 13px; color: var(--muted); }
.tile.neg b { color: var(--bad); }
.tile.lead b { font-size: 32px; }
.tile.wide { grid-column: 1 / -1; }
/* After a wide lead tile, an odd last tile takes the whole row instead of leaving a gap beside it. */
.tile.wide:first-child ~ .tile:last-child:nth-child(even) { grid-column: 1 / -1; }
/* 320 px phones: a lead tile is 112 px wide inside, so its value drops to the normal tile size. */
@media (max-width: 359.98px) { .tile.lead b { font-size: 26px; } }

/* ===== 12. Tables ===== */
.tablewrap { min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; text-align: left; }
th { font-size: 13px; font-weight: 600; color: var(--muted); }
td { font-variant-numeric: tabular-nums; }
tr.total td { border-bottom: 0; font-weight: 700; }
tr.cur td { background: var(--surface-2); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pill.ok { background: var(--good-bg); color: var(--good); }
.pill.no { background: var(--bad-bg); color: var(--bad); }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.est { font-size: 12px; font-weight: 600; color: var(--muted); }
td:first-child { white-space: normal; }
td small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
/* Very narrow phones (320 px): tighter cell padding, and a row name may break inside a long word
   ("24.12./31.12."), so the three-column bonus table stays inside the card whatever the font metrics. */
@media (max-width: 359.98px) { th, td { padding-inline: 2px; } td:first-child { overflow-wrap: anywhere; } }
/* Stacked rows on phones: the first cell is the row's title, the other cells sit in equal mini-columns,
   each under its column name (data-label). The header row stays in the page for screen readers.
   Below 640 px, not 520: the German five-column "Earned value" table needs about 585 px, and phones in
   landscape start at 568 px (iPhone SE). */
@media (max-width: 639.98px) {
  table.stack, table.stack tbody, table.stack td { display: block; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  table.stack tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.stack.c2 tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.stack.c4 tr { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  table.stack tr.cur { padding-inline: 8px; border-radius: var(--r-ctl); background: var(--surface-2); }
  table.stack tr.cur td { background: none; }
  table.stack td { padding: 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  table.stack td:first-child { grid-column: 1 / -1; font-weight: 600; }
  table.stack + .note { margin-top: 12px; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--muted); }
}

/* ===== 13. Charts ===== */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--body); font-size: 11px; font-variant-numeric: tabular-nums; fill: var(--muted); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; }
.tip { position: absolute; z-index: 3; pointer-events: none; padding: 6px 10px; border-radius: var(--r-ctl); background: var(--ink); color: var(--surface); font-size: 13px; line-height: 1.35; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.tip b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== 14. Sheets and Settings ===== */
.sheet { position: fixed; inset: 0; z-index: 20; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); padding: calc(12px + env(safe-area-inset-top, 0px)) var(--gutter) calc(32px + env(safe-area-inset-bottom, 0px)); }
.sheet .wrap { gap: 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
fieldset { display: flex; flex-direction: column; gap: 12px; min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
legend { padding: 0 6px; font-family: var(--display); font-size: 20px; font-weight: 800; }
.rp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.csvbox[hidden] { display: none; }
/* Close stays one tap away; the sheet's top padding moves into the sticky header. */
#settings { padding-top: 0; scroll-padding-top: calc(84px + env(safe-area-inset-top, 0px)); }
.sheet-head { position: sticky; top: 0; margin-inline: calc(-1 * var(--gutter)); padding: calc(12px + env(safe-area-inset-top, 0px)) var(--gutter) 12px; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 1; }
/* The legend sits inside the card as its title (a floated legend is an ordinary flex item). */
legend { float: left; width: 100%; margin: 0; padding: 0; line-height: 1.1; }
/* An empty message line takes no room, so Restore is not followed by a blank gap; the text shows after a tap. */
#settings .msg:empty { display: none; }
/* Language fills the card like Theme below it (the two-column .choice is onboarding's). */
#settings .choice { grid-template-columns: 1fr; }
#settings fieldset p { margin: 0; }
#settings a { color: var(--ink); text-underline-offset: 3px; }
/* The GitHub link is a tap target too: 44 × 44 px, like every other control. */
#repo-link { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; }
/* Rate periods: at phone width the date gets half the row (a third cut it to "09/01/20"); Remove sits under the rate. */
.rp + .rp { padding-top: 12px; border-top: 1px solid var(--line); }
@media (max-width: 479px) {
  .rp { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rp-del { grid-column: 2; justify-self: end; }
}

/* ===== 15. Onboarding ===== */
.ob-step { display: flex; flex-direction: column; gap: 16px; min-height: calc(100vh - 44px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); min-height: calc(100dvh - 44px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
.ob-brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-size: 26px; font-weight: 800; }
.ob-brand img { width: 56px; height: 56px; border-radius: var(--r-card); }
.ob-bar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.ob-bar i { height: 4px; border-radius: 2px; background: var(--line); }
.ob-bar i.on { background: var(--accent); }
.ob-step h2 { font-size: 28px; }
.ob-step p { margin: 0; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice .btn[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--surface); }
.ob-lang .btn { min-height: 64px; font-size: 18px; }
.ob-actions { display: flex; flex-direction: column; gap: 8px; }
.ob-actions .btn { width: 100%; }
.ob-nav { display: flex; gap: 8px; margin-top: auto; }
.ob-nav .btn { flex: 1 1 0; min-height: 48px; }
.ob-nav .btn.primary { flex-grow: 2; }

/* ===== 16. Small screens ===== */
@media (max-width: 380px) {
  .row { grid-template-columns: 62px minmax(0, 1fr) auto; }
  .pv-gross { font-size: 40px; }
}
