/* ===== Design language: "Ledger" =====
   Calm paper and ink, inspired by early-2000s office software (not a copy of it): warm paper neutrals,
   one navy ink accent, dense gridded tables, screen fonts. Light only, by design.

   Colour comes in two layers:
   1. Primitives: the only raw hex values in this file. Nothing below the token block uses hex.
   2. Roles: what components use (surface, text-muted, accent…). Change a role, not a component.
   Tints are never hand-picked: each one is a fixed % of a base colour mixed into the surface,
   so related colours stay related.

   Checked with scripts, not by eye (WCAG 2 contrast + APCA; colour-blind simulation):
   - every text/background pair ≥ 4.5:1, control edges ≥ 3:1;
   - category hues R&D / Maintenance / Marketing are colour-blind separable (ΔE ≥ 16);
   - day states (holiday · vacation · complete) are colour-blind separable (ΔE ≥ 12)
     and always come with text or a ✓, never colour alone. */
:root {
  /* --- primitives --- */
  --paper-0: #ffffff;   --paper-50: #f8f7f3;  --paper-100: #efede7; --paper-200: #e4e1da;
  --paper-300: #cfcbc1; --paper-500: #8f8a7f; --paper-600: #757066; --paper-700: #5f5a51; --paper-900: #1c1a16;
  --ink-100: #dde5f3;   --ink-500: #2c56b8;   --ink-700: #22386b;   --ink-800: #1a2c55;   --ink-900: #111e3b;
  --red-700: #b42318;   --violet-600: #5b47a8; --teal-700: #0e7c86;
  --cat-blue: #3366cc;  --cat-orange: #cc6600; --cat-teal: #009999;

  /* --- roles: surfaces & lines --- */
  --bg-page: var(--paper-100);
  --bg-surface: var(--paper-0);
  --bg-subtle: var(--paper-50);                                              /* zebra rows, weekends */
  --bg-accent: color-mix(in oklab, var(--accent) 14%, var(--bg-surface));     /* table headers */
  --bg-accent-soft: color-mix(in oklab, var(--accent) 6%, var(--bg-surface)); /* hover, total rows */
  --line-soft: var(--paper-200);   /* hairlines inside a card */
  --line: var(--paper-300);        /* grid lines, card edges */
  --line-strong: var(--paper-500); /* control edges (≥ 3:1) */
  --elev-1: 0 2px 6px rgb(20 30 50 / .10);
  --elev-2: 0 12px 32px rgb(20 30 50 / .22);

  /* --- roles: text --- */
  --text: var(--paper-900);
  --text-muted: var(--paper-700);
  --text-faint: var(--paper-600);  /* placeholders, archived, zero dashes */
  --link: var(--ink-500);

  /* --- roles: accent (the one brand colour) --- */
  --accent: var(--ink-700);
  --accent-hover: var(--ink-800);
  --accent-line: var(--ink-900);
  --on-accent: var(--paper-0);
  --on-accent-muted: var(--ink-100);

  /* --- roles: status & special days (always paired with text or an icon) --- */
  --danger: var(--red-700);
  --ok: var(--teal-700);
  --holiday: var(--red-700);
  --holiday-bg: color-mix(in oklab, var(--holiday) 8%, var(--bg-surface));
  --vacation: var(--violet-600);
  --vacation-bg: color-mix(in oklab, var(--vacation) 10%, var(--bg-surface));

  /* --- roles: data categories (charts, dots) --- */
  --rd: var(--cat-blue); --m: var(--cat-orange); --mk: var(--cat-teal);

  /* depth */
  --pressed: inset 0 0 0 1px var(--text-muted), inset 0 1px 2px 1px rgb(0 0 0 / .12);
  --sunken: inset 0 0 0 1px var(--line-strong), inset 0 1px 2px rgb(0 0 0 / .08);

  /* Three font roles, all pre-installed (no downloads, CSP stays 'self'):
     headings in a screen serif, UI in a screen sans, every number in monospace so digits line up. */
  --font-head: Georgia, "Times New Roman", serif;
  --font-ui: Tahoma, Verdana, "Segoe UI", Geneva, sans-serif;
  --font-num: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* One root size that grows with the screen; every font size below is in rem, so it all scales together.
   ~14px on phones, ~15.5px on large desktops. */
html { font-size: clamp(14px, 0.2vw + 12.5px, 15.5px); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg-page); color: var(--text);
  font: 1rem/1.4 var(--font-ui); }
.brand, .month h2, h2, .dlg-title strong, .login h1 { font-family: var(--font-head); letter-spacing: .01em; }
td, .day .num, .day .hrs, .sum-types strong, .sum-total strong, input[type=number], .split-tag, .count {
  font-family: var(--font-num); }
main { max-width: 980px; margin: 0 auto; padding: 8px; }
a { color: var(--link); }
h1 { font-size: 1rem; margin: 0; }
h2 { font-size: 1.077rem; font-weight: bold; margin: 0; }
td { font-variant-numeric: tabular-nums; }
td:first-child { font-family: var(--font-ui); }

/* ---- controls ---- */
/* Buttons by importance — and every button looks pressable (raised face, edge, small shadow;
   it sinks when pressed). Text never looks like a button, and a button never looks like text.
   primary = the one main action on a screen (filled ink) · secondary = default (raised paper)
   icon = small ✕-style controls (no face until hover, but always a visible hover/focus box)
   danger = destructive (red text) · link = inline text action (underlined). */
button { font: inherit; font-weight: 600; color: var(--accent); background: linear-gradient(var(--bg-surface), var(--paper-100));
  border: none; border-radius: 4px; padding: 3px 12px; min-height: 26px; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--text-muted), inset 0 -2px 0 rgb(20 30 50 / .10), 0 1px 2px rgb(20 30 50 / .18); }
button:hover { background: var(--bg-accent); box-shadow: inset 0 0 0 1px var(--accent), inset 0 -2px 0 rgb(20 30 50 / .12), 0 1px 2px rgb(20 30 50 / .2); }
button:active { transform: translateY(1px); box-shadow: inset 0 0 0 1px var(--accent), inset 0 1px 2px rgb(20 30 50 / .2); }
button.primary { font-weight: bold; color: var(--on-accent); background: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-line), 0 1px 2px rgb(20 30 50 / .25); }
button.primary:hover { background: var(--accent-hover); }
button.ghost { background: transparent; box-shadow: none; color: var(--text-muted); }
button.ghost:hover { background: var(--bg-accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }
button.danger { color: var(--danger); font-weight: bold; }
button.link { background: none; box-shadow: none; padding: 0; min-height: 0; color: var(--link); text-decoration: underline; }
button.link:active, button.twisty:active { transform: none; }
button.sm { min-height: 24px; padding: 1px 10px; font-size: 0.923rem; } /* WCAG 2.2 target size ≥ 24px */
input, select { font: inherit; color: var(--text); background: var(--bg-surface); border: none; border-radius: 4px;
  padding: 2px 4px; min-height: 22px; box-shadow: var(--sunken); }
input::placeholder { color: var(--text-faint); }
input[type=checkbox] { box-shadow: none; min-height: 0; width: 13px; height: 13px; margin: 0; }
button:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }
input:focus-visible, select:focus-visible { outline: 1px solid var(--accent); outline-offset: 0; }

/* ---- header: title bar + tab strip ---- */
header { background: var(--accent); color: var(--on-accent); }
.bar { max-width: 980px; margin: 0 auto; padding: 4px 8px 0; display: flex; gap: 12px; align-items: flex-end; }
.brand { font-weight: bold; font-size: 1.154rem; padding-bottom: 4px; }
.tabs { display: flex; gap: 2px; }
.tabs button { background: transparent; color: var(--on-accent-muted); box-shadow: none; min-height: 24px; padding: 2px 12px; border-radius: 3px 3px 0 0; }
.tabs button:hover { color: var(--on-accent); background: rgb(255 255 255 / .1); box-shadow: none; }
.tabs button:active, .day:active { transform: none; }
.tabs button, .day, .picker summary { font-weight: normal; } /* nav and cells are not 'buttons' visually */
.tabs button[aria-current=page] { font-weight: bold; }
.tabs button[aria-current=page] { background: var(--bg-page); color: var(--text); font-weight: bold; }
#logout { margin: 0 0 4px auto; min-height: 22px; padding: 1px 10px; font-size: 0.923rem; color: var(--on-accent); background: transparent; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .55); }
#logout:hover { background: rgb(255 255 255 / .12); box-shadow: inset 0 0 0 1px var(--on-accent); }
.month { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.month h2 { font-size: 1.231rem; min-width: 140px; text-align: center; }
.month button { min-height: 32px; min-width: 40px; padding: 0 10px; font-size: 1.385rem; line-height: 1; font-family: var(--font-ui); }

/* ---- calendar: a gridded month table ---- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line-strong); }
.cal > div:empty { background: var(--bg-subtle); }
.dow { background: var(--bg-page); text-align: center; font-weight: bold; font-size: 0.846rem; padding: 2px; color: var(--text-muted); }
.day { background: var(--bg-surface); box-shadow: none; min-height: 54px; padding: 2px 4px; display: flex; flex-direction: column;
  gap: 2px; align-items: stretch; text-align: left; }
.day:hover { background: var(--bg-accent-soft); }
.day:active { box-shadow: none; }
.day.weekend { background: var(--bg-subtle); }
.day .num { font-size: 1.077rem; font-weight: bold; color: var(--text); align-self: flex-start; padding: 0 4px; }
.day.today .num { background: var(--accent); color: var(--on-accent); font-weight: bold; }
.day .head { display: flex; justify-content: space-between; align-items: center; }
.day .done { color: var(--ok); font-size: 1rem; line-height: 1; }
.day .hrs { font-size: 1rem; color: var(--text-muted); margin-top: auto; }
.day.off { background: var(--vacation-bg); }
.day.holiday { background: var(--holiday-bg); }
.day.weekend .num { color: var(--text-muted); font-weight: normal; }
.day.holiday .num { color: var(--danger); font-weight: bold; }
.note-hol { font-size: 0.769rem; color: var(--holiday); margin-top: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-status.is-hol { color: var(--holiday); }
.note-off { font-size: 0.846rem; color: var(--vacation); margin-top: auto; }
.warn-text { color: var(--danger); }

.t-rd { background: var(--rd); } .t-m { background: var(--m); } .t-mk { background: var(--mk); }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border: 1px solid rgb(0 0 0 / .35); vertical-align: -1px; }
.cal-tasks { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.hint.cal-hint { margin: 14px 0 0; } /* beats the generic .hint margin */
.cal-tasks li { display: contents; }
button.task-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px;
  font-weight: normal; color: var(--text); font-size: 0.923rem; }
button.task-chip[aria-pressed=true] { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--accent-line); }
button.task-chip[aria-pressed=true] .dot { border-color: var(--on-accent); }
/* highlighted days: navy frame + the task's hours; the rest step back */
.day.hl { box-shadow: inset 0 0 0 2px var(--accent); background: var(--bg-accent-soft); padding: 4px 6px; }
.day .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: flex-end; gap: 4px; }
.day .foot .hrs { margin-top: 0; }
.day .hl-hrs { font-family: var(--font-num); font-weight: bold; font-size: 0.923rem; color: var(--on-accent);
  background: var(--accent); border-radius: 99px; padding: 0 7px; line-height: 1.5; }
.day.dim .num, .day.dim .note-hol, .day.dim .note-off { color: var(--text-faint); font-weight: normal; }
.day.dim .done, .day.dim .hrs { opacity: .35; }
.cal-tasks .h { font-family: var(--font-num); font-weight: bold; }
.cal-tasks .dot { margin: 0; }
.cal-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-top: 6px; }
.sum { font-size: 0.923rem; margin: 0; color: var(--text-muted); }
.ok-text { color: var(--ok); }
#nextStep { min-height: 30px; padding: 4px 14px; }
.no-tasks { margin: 0; padding: 10px 12px; color: var(--text-muted); }


/* ---- day editor ---- */
dialog { border: none; padding: 0; width: min(440px, 100vw - 16px); background: var(--bg-surface); color: var(--text);
  border-radius: 8px; box-shadow: 0 0 0 1px var(--line-strong), var(--elev-2); }
dialog::backdrop { background: rgb(20 30 50 / .3); }
.dlg { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.dlg-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dlg-title strong { font-size: 1.154rem; }
.day-status { font-size: 0.923rem; color: var(--text-muted); }
.day-status.is-warn { color: var(--danger); } .day-status.is-ok { color: var(--ok); } .day-status.is-off { color: var(--vacation); }
#toggleOff { color: var(--vacation); }
#toggleOff[aria-pressed=true] { background: var(--vacation-bg); box-shadow: inset 0 0 0 1px var(--vacation); }
#closeDlg { min-height: 26px; width: 28px; padding: 0; color: var(--text-muted); }
.entry { display: grid; grid-template-columns: 10px 1fr 60px 26px; gap: 8px; align-items: center;
  padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line-soft); }
.entry .dot { margin: 0; }
.entry-main { display: flex; flex-direction: column; min-width: 0; }
.entry .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* inline-editable note: reads as a subtitle, becomes a field on focus */
.entry .note { box-shadow: none; padding: 0 2px; min-height: 18px; font-size: 0.923rem; color: var(--text-muted); background: transparent; margin-left: -2px; }
.entry .note:hover, .entry .note:focus { box-shadow: var(--sunken); background: var(--bg-surface); }
.entry input[type=number] { text-align: right; }
.del { min-height: 24px; padding: 0; color: var(--text-muted); }
.del:hover { color: var(--danger); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px 0; }
.quick:empty { display: none; }
.pill { min-height: 22px; padding: 1px 10px; font-size: 0.923rem; border-radius: 99px; }
.add { display: grid; grid-template-columns: 1fr 60px auto; gap: 6px; padding: 8px 8px 10px 12px; }

/* ---- report ---- */
.summary { display: flex; gap: 20px; align-items: center; background: var(--bg-surface); border: 1px solid var(--line-strong); box-shadow: var(--elev-1);
  border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.donut { width: 84px; height: 84px; flex: none; }
.donut .track { stroke: var(--line-soft); }
.donut .seg.t-rd { stroke: var(--rd); } .donut .seg.t-m { stroke: var(--m); } .donut .seg.t-mk { stroke: var(--mk); }
.donut .seg:hover { stroke-width: 19; }
.sum-body { display: flex; flex-wrap: wrap; gap: 8px 32px; align-items: center; flex: 1; min-width: 0; }
.sum-total strong { display: block; font-size: 1.7rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary .sub { font-size: .846rem; color: var(--text-muted); }
.sum-types { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: auto auto auto; gap: 2px 10px; align-items: center; }
.sum-types li { display: contents; }
.sum-types .dot { margin: 0; }
.sum-types strong { text-align: right; font-variant-numeric: tabular-nums; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 0 4px; flex-wrap: wrap; }
.tools { display: flex; gap: 4px; }
.groupby { display: flex; align-items: center; gap: 4px; font-weight: bold; }
.groupby span { margin-right: 4px; }
.groupby [aria-checked=true] { background: var(--accent); color: var(--on-accent); box-shadow: inset 0 0 0 1px var(--accent-line); }
button.twisty { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 0; font-weight: bold; text-align: left; color: var(--text); }
button.twisty:hover { background: none; color: var(--accent); }
.twisty:hover { box-shadow: none; text-decoration: underline; }
.chev { width: 10px; color: var(--text-muted); font-size: .77rem; }
.count { font-size: .77rem; color: var(--text-muted); font-weight: normal; }
.short { display: none; }
.scroll { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--line-strong); border-radius: 6px; margin-bottom: 10px;
  box-shadow: var(--elev-1); }
table { border-collapse: collapse; width: 100%; font-size: 1rem; }
th, td { padding: 4px 8px; text-align: right; white-space: nowrap; background: var(--bg-surface); border-bottom: 1px solid var(--line-soft); }
thead th { background: var(--bg-accent); font-weight: bold; font-size: 0.846rem; color: var(--accent); border-bottom: 2px solid var(--accent); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; z-index: 1; }
.col-total { border-left: 1px solid var(--line); font-weight: bold; }
td.zero { color: var(--text-faint); }
/* hierarchy: type rows are subtotals, task rows sit indented beneath */
tr.group > * { background: var(--bg-subtle); font-weight: bold; border-top: 1px solid var(--line); }
tr.group:first-child > * { border-top: none; }
tr.child td:first-child { padding-left: 30px; }
tr.child > * { color: var(--text); }
tbody tr.child:hover > * { background: var(--bg-accent-soft); }
.split-tag { margin-left: 6px; font-size: 0.769rem; color: var(--text-muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; }
tfoot > tr > * { font-weight: bold; border-top: 3px double var(--accent); border-bottom: none; background: var(--bg-accent-soft); color: var(--accent); }
.empty { background: var(--bg-surface); border: 1px dashed var(--line-strong); border-radius: 6px; padding: 16px; text-align: center; color: var(--text-muted); margin: 0; }

/* ---- settings ---- */
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin: 18px 0 4px; }
#settings .set-head:first-child { margin-top: 0; }
.add-inline { display: flex; gap: 6px; flex: 1; justify-content: flex-end; max-width: 560px; }
.add-inline input { flex: 1; min-width: 0; }
.hint { color: var(--text-muted); font-size: 0.846rem; margin: 0 0 6px; }
/* inline-edit: reads as text, becomes a field on hover/focus */
.inline-edit { box-shadow: none; background: transparent; padding: 2px 4px; margin-left: -4px; min-width: 0; width: 100%; }
.inline-edit:hover, .inline-edit:focus { box-shadow: var(--sunken); background: var(--bg-surface); }

.task-table { background: var(--bg-surface); border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: var(--elev-1); overflow: hidden; }
.task-row { display: grid; grid-template-columns: minmax(9rem, 1fr) 9.5rem minmax(0, 2fr) 5rem; gap: 4px 12px; align-items: start;
  padding: 6px 10px; border-bottom: 1px solid var(--line-soft); }
.task-row:last-child { border-bottom: none; }
.task-row > select, .task-row > button { align-self: start; }
.task-row.head { background: var(--bg-accent); color: var(--accent); font-weight: bold; font-size: 0.846rem; border-bottom: 2px solid var(--accent); padding: 4px 10px; }
.task-row.archived { color: var(--text-faint); background: var(--bg-subtle); }
.archived { color: var(--text-faint); }

.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; box-shadow: var(--elev-1); }
.prod { display: flex; align-items: center; gap: 4px; background: var(--bg-surface); padding: 3px 4px 3px 10px; }
.prod button { display: none; flex: none; }
.prod:hover button, .prod:focus-within button, .editing .prod button { display: inline-flex; }
#editProducts[aria-pressed=true] { background: var(--accent); color: var(--on-accent); }
.set-head h2 { margin-right: auto; }
.report-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin: -2px 0 12px; }
.report-actions .hint { margin: 0 auto 0 0; }
.archived-box { margin-top: 8px; }
.archived-box summary { cursor: pointer; color: var(--text-muted); font-size: 0.923rem; margin-bottom: 4px; }
.archived-box .prod input { color: var(--text-faint); }

/* Product picker: one summary line; opens into aligned columns that add/remove with the width. */
.picker { min-width: 0; }
.picker summary { display: flex; gap: 6px; align-items: baseline; cursor: pointer; padding: 3px 0; min-width: 0; list-style: none; }
.picker summary::-webkit-details-marker { display: none; }
.picker summary::before { content: '▸'; color: var(--text-muted); font-size: .8em; }
.picker[open] summary::before { content: '▾'; }
.pick-label { font-size: 0.846rem; color: var(--text-muted); flex: none; }
.task-row .pick-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); } /* spoken, not shown */
.pick-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0 12px; margin-top: 4px;
  padding: 6px 8px; background: var(--bg-subtle); border: 1px solid var(--line); border-radius: 4px; font-size: 0.923rem; }
.checks label { display: flex; gap: 6px; align-items: center; min-height: 26px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.checks label:has(input:checked) { color: var(--accent); font-weight: bold; }

/* exports: the button, then what you get */
.exports { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }
a.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 4px 14px; border-radius: 4px;
  text-decoration: none; color: var(--accent); background: var(--bg-surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
a.btn:hover { background: var(--bg-accent-soft); }
a.btn.primary { color: var(--on-accent); background: var(--accent); font-weight: bold; box-shadow: inset 0 0 0 1px var(--accent-line); }

/* ---- login: a small window ---- */
.login { max-width: 300px; margin: 14vh auto; padding: 0 0 10px; display: flex; flex-direction: column; gap: 4px;
  background: var(--bg-page); box-shadow: 0 0 0 1px var(--line-strong), var(--elev-2); }
.login h1 { background: var(--accent); color: var(--on-accent); font-size: 0.923rem; padding: 3px 6px; margin-bottom: 6px; }
.login > :not(h1) { margin-left: 10px; margin-right: 10px; }
.login label { font-size: 0.923rem; }
.login .err { color: var(--danger); font-size: 0.923rem; min-height: 1.35em; margin-top: 4px; margin-bottom: 4px; }

/* ---- phone: same palette and density, thumb-friendly layout ---- */
@media (max-width: 640px) {
  main { padding: 6px 6px calc(64px + env(safe-area-inset-bottom)); }
  .bar { padding: 6px 8px; align-items: center; }
  .brand { display: block; padding: 0; }
  #logout { margin: 0 0 0 auto; min-height: 28px; }
  /* tabs become a bottom toolbar, within thumb reach */
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; gap: 0; background: var(--accent);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -1px 0 var(--accent-line); }
  .tabs button { flex: 1; min-height: 44px; border-radius: 3px; font-size: 1rem; }
  .tabs button[aria-current=page] { min-height: 44px; }
  button { min-height: 32px; }
  input, select { font-size: 16px; min-height: 34px; } /* 16px stops iOS zoom-on-focus */
  .month { justify-content: space-between; }
  .month h2 { min-width: 0; }
  .month button { min-height: 34px; min-width: 44px; }
  .cal { margin: 0 -6px; border-left: none; border-right: none; }
  .day { min-height: 44px; padding: 2px; gap: 1px; }
  .day .num { font-size: 0.923rem; }
  .note-off, .note-hol { font-size: 0.714rem; }
  .day .hrs { font-size: 0.923rem; }

  .summary { gap: 12px; padding: 10px; border-radius: 0; margin: 0 -6px 10px; border-left: none; border-right: none; }
  .donut { width: 72px; height: 72px; }
  .sum-body { gap: 6px; }
  .section-head { align-items: stretch; }
  /* tasks: name, then type + archive, then the product picker at full width */
  .task-row { grid-template-columns: 1fr auto; padding: 6px 8px; gap: 4px 8px; }
  .task-row.head { display: none; }
  .task-row > input { grid-column: 1 / -1; }
  .task-row > button { grid-row: 2; grid-column: 2; }
  .task-row > .picker { grid-column: 1 / -1; }
  .task-row .pick-value { white-space: normal; }
  .checks { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }
  .checks label { white-space: normal; } /* wrap long names instead of cutting them */
  /* add task: name on its own line, type + button below, so nothing pushes past the screen */
  #addTask { flex-wrap: wrap; }
  #addTask input { flex-basis: 100%; }
  #addTask select { flex: 1; }
  /* products: a list — one per row, full name, Archive always visible (no hover on touch, no Edit step) */
  .prod-grid, .prod-grid.editing { grid-template-columns: 1fr; }
  .prod { padding: 4px 6px 4px 12px; min-height: 52px; gap: 8px; }
  .prod .inline-edit { font-size: 16px; min-height: 40px; }
  .prod button, .prod:hover button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; }
  #editProducts { display: none; }
  .add-inline { max-width: none; flex-basis: 100%; }
  /* exports: full-width button, its description underneath */
  .exports { grid-template-columns: 1fr; gap: 4px; }
  .exports a.btn { min-height: 44px; }
  .exports > span { margin-bottom: 8px; font-size: 0.923rem; }
  /* report: full-width Product|Task switch; copy actions side by side under the table */
  .groupby { width: 100%; }
  .groupby > span { display: none; }
  .groupby button { flex: 1; min-height: 40px; }
  .report-actions { margin: 0 0 12px; }
  .report-actions .hint { flex-basis: 100%; }
  .report-actions button { flex: 1; min-height: 44px; }
  #matrix th, #matrix td { padding: 5px 5px; }
  .cal-foot { flex-direction: column-reverse; align-items: stretch; }
  #nextStep { min-height: 44px; }
  .long { display: none; } .short { display: inline; }
  #matrix th, #matrix td { padding: 6px 5px; }
  #matrix td:first-child { white-space: normal; padding-left: 8px; }
  #matrix tr.child td:first-child { padding-left: 24px; }
  .scroll { margin-left: -6px; margin-right: -6px; border-left: none; border-right: none; border-radius: 0; }
  th, td { padding: 4px 6px; }
  button.sm { min-height: 28px; }
  .entry { grid-template-columns: 10px 1fr 68px 34px; }
  .entry .note { font-size: 16px; min-height: 24px; } /* iOS zoom guard, like other inputs */
  .add { grid-template-columns: 1fr 68px auto; }
  .pill { min-height: 30px; }
  #closeDlg { min-height: 34px; width: 36px; font-size: 1.077rem; }
  /* day editor: a bottom sheet with a grab handle */
  dialog { width: 100vw; max-width: 100vw; max-height: 88vh; margin: auto 0 0; border-radius: 12px 12px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .dlg-head { padding-top: 14px; position: relative; }
  .dlg-head::before { content: ""; position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
    background: var(--line); border-radius: 2px; }
  .login { margin: 10vh 12px; }
}
.dlg:focus { outline: none; }

/* ---- accessibility ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
h1.brand, h2#monthLabel { margin: 0; }
th[scope=row] { font-weight: normal; text-align: left; position: sticky; left: 0; z-index: 1; }
tr.group th[scope=row], tfoot th[scope=row] { font-weight: bold; }
tr.child th[scope=row] { padding-left: 30px; }
@media (prefers-reduced-motion: reduce) { button:active { transform: none; } }
/* Windows high-contrast: states drawn with backgrounds get a visible edge instead. */
@media (forced-colors: active) {
  .day.today .num, .groupby [aria-checked=true], .tabs button[aria-current=page], #toggleOff[aria-pressed=true] { outline: 2px solid CanvasText; }
  .dot, .donut .seg { forced-color-adjust: none; }
}
