/* TMD Assistant: one stylesheet, every asset local (no CDN). The DM Sans font file sits in static/fonts
   (SIL Open Font Licence, see fonts/OFL.txt); without it the page falls back to Segoe UI. */
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("fonts/dm-sans-latin-wght-normal.woff2") format("woff2");
}

:root {
  --font: "DM Sans", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: Consolas, "Courier New", monospace;

  --bg: #F6F6F7; --surface: #FFFFFF; --soft: #F1F5F9; --faint: #F8FAFC;
  --ink: #0F172A; --body: #334155; --muted: #64748B;
  --line: #E2E8F0; --line-strong: #CBD5E1;
  --accent: #11796B; --accent-hover: #0D6257; --ring: #21A190; --ring-soft: rgba(33, 161, 144, .28);
  --topbar: #1A1A1B; --brand-accent: #45D3B7;

  --ok: #059669; --ok-bg: #ECFDF5; --ok-line: #A7F3D0;
  --warn: #B45309; --warn-bg: #FFFBEB; --warn-line: #FCD34D; --warn-strong: #F59E0B; --warn-ink: #451A03;
  --danger: #EF4444; --danger-hover: #DC2626; --danger-ink: #B91C1C; --danger-bg: #FEF2F2; --danger-line: #FECACA;

  --radius: 8px; --radius-card: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .1);
  --topbar-h: 56px; --sidebar-w: 240px;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
html:has(body.practice) { scroll-padding-top: calc(var(--topbar-h) + 64px); }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; margin: 0 0 16px; }
h2 { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; margin: 32px 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 20px 0 8px; }
h4 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
p { margin: 0 0 12px; }
ul, ol { margin: 0 0 12px; padding-left: 22px; }
strong, b { font-weight: 600; }
.lead { color: var(--muted); margin-bottom: 20px; }
.hint { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ---------- shell: dark top bar, white sidebar, content to the right ---------- */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center;
  gap: 12px; padding: 0 20px; background: var(--topbar); color: #fff; }
.topbar .brand { color: #fff; font-size: 16px; font-weight: 600; letter-spacing: -.01em; text-decoration: none; white-space: nowrap; }
.brand-accent { color: var(--brand-accent); }
.menu-button { display: none; width: 36px; padding: 0; background: transparent; border-color: rgba(255, 255, 255, .22); color: #fff; }
.menu-button:hover { background: rgba(255, 255, 255, .1); }
.practice-switch { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin: 0 0 0 auto; }
.switch-label { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--warn-line); color: var(--warn-ink); font-size: 12px; font-weight: 700; white-space: nowrap; }
.switch-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.topbar button.secondary { background: transparent; color: #E2E8F0; border-color: rgba(255, 255, 255, .22); }
.topbar button.secondary:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.topbar button.secondary.danger { background: transparent; color: #FCA5A5; border-color: rgba(239, 68, 68, .55); }
.topbar button.secondary.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.topbar a:not(.brand) { color: #E2E8F0; font-size: 13px; }
.topbar a:not(.brand):hover { color: #fff; }
.topbar form { margin-top: 0; margin-bottom: 0; }
/* Server mode: who is signed in, with People, Activity and Log out. */
.user-menu { display: flex; align-items: center; gap: 12px; margin-left: 4px; padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, .18); white-space: nowrap; }
.user-menu span { color: #94A3B8; font-size: 13px; }
.user-menu form { display: inline-flex; }
body.practice .topbar { box-shadow: inset 0 -3px 0 var(--warn-strong); }

.sidebar { position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 30; width: var(--sidebar-w); overflow-y: auto;
  padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); }
/* TMD's logo above the menu: small, on the white of the menu (its dark lettering would vanish on the top bar). */
.sidebar-logo { display: block; margin: 0 0 12px; padding: 2px 10px 14px; border-bottom: 1px solid var(--line); }
.sidebar-logo img { display: block; width: 172px; max-width: 100%; height: auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: block; padding: 8px 12px; border-radius: var(--radius); color: var(--body); font-size: 14px; font-weight: 500;
  line-height: 20px; text-decoration: none; }
.sidebar nav a:hover { background: var(--soft); color: var(--ink); }
.sidebar nav a.here { background: var(--soft); color: var(--accent); font-weight: 600; }
.scrim { display: none; }

.page { margin-left: var(--sidebar-w); padding-top: var(--topbar-h); min-height: 100vh; min-width: 0; display: flex; flex-direction: column; }
main { flex: 1 0 auto; width: 100%; max-width: 1100px; min-width: 0; margin: 0 auto; padding: 24px 32px 40px; }
footer { padding: 16px 32px 24px; color: var(--muted); font-size: 12px; text-align: center; }

/* practice mode: an amber banner that stays in view under the top bar */
.practice-banner { position: sticky; top: var(--topbar-h); z-index: 20; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 20px; background: var(--warn-line); color: var(--warn-ink); border-bottom: 1px solid var(--warn-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-size: 14px; font-weight: 700; letter-spacing: .01em; text-align: center; }
.practice-banner::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--warn);
  box-shadow: 0 0 0 4px rgba(180, 83, 9, .22); }
.job-banner { padding: 8px 20px; background: var(--soft); color: var(--body); border-bottom: 1px solid var(--line); font-size: 13px; text-align: center; }

/* ---------- cards ---------- */
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px 20px; margin: 12px 0; }
.note > h3:first-child, .note > h4:first-child { margin-top: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: 24px; margin: 16px 0; }
.card > :first-child, .card > input[type=hidden] + h2, .card > input[type=hidden] + h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
p.card { padding: 14px 20px; }
.card.attention { background: var(--warn-bg); border-color: var(--warn-line); }
.card.note, .flash.note { background: var(--faint); border-color: var(--line); }
.card.status.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.card.status.stopped { background: var(--danger-bg); border-color: var(--danger-line); }

/* the box at the top of each page: calm and compact */
.explain { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px 20px; margin: 0 0 24px;
  font-size: 13px; }
.explain dl { display: grid; grid-template-columns: 200px 1fr; gap: 6px 20px; margin: 0; }
.explain dt { font-weight: 600; color: var(--ink); }
.explain dd { margin: 0; color: var(--body); }
.explain > :last-child { margin-bottom: 0; }

/* ---------- buttons ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius); background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
  line-height: 1.2; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
button:hover, .button:hover { background: var(--accent-hover); color: #fff; }
button.secondary, .button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--soft); color: var(--ink); }
button.danger, .button.danger { background: var(--danger); color: #fff; }
button.danger:hover, .button.danger:hover { background: var(--danger-hover); color: #fff; }
button.secondary.danger, .button.secondary.danger { background: var(--surface); color: var(--danger-ink); border-color: var(--danger-line); }
button.secondary.danger:hover, .button.secondary.danger:hover { background: var(--danger-bg); color: var(--danger-ink); }
button.small, .button.small { height: 32px; padding: 0 12px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
a.small { font-size: 13px; }
button + a.small { margin-left: 12px; }

/* ---------- forms ---------- */
input[type=text], input[type=date], input[type=password], input[type=number], input[type=email], input[type=search], select, textarea {
  height: 36px; max-width: 100%; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background-color: var(--surface);
  color: var(--ink); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
textarea { width: 100%; height: auto; min-height: 64px; padding: 8px 12px; line-height: 1.5; resize: vertical; }
select { min-width: 220px; padding-right: 34px; appearance: none; -webkit-appearance: none; background-repeat: no-repeat; background-position: right 12px center;
  background-size: 12px 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%2364748B' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
input[type=text]:focus, input[type=date]:focus, input[type=password]:focus, input[type=number]:focus, input[type=email]:focus,
input[type=search]:focus, select:focus, textarea:focus, input[type=file]:focus-visible {
  outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px var(--ring-soft); }
input::placeholder, textarea::placeholder { color: #94A3B8; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
input[type=file] { height: 36px; max-width: 100%; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--muted); font-size: 13px; line-height: 34px; }
input[type=file]::file-selector-button { height: 34px; margin: 0 12px 0 0; padding: 0 14px; border: 0; border-right: 1px solid var(--line-strong);
  border-radius: 7px 0 0 7px; background: var(--soft); color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--line); }

.form label { display: block; margin: 16px 0 12px; font-weight: 500; }
.form label input, .form label select, .form label textarea { display: block; width: 100%; max-width: 560px; margin-top: 6px; font-weight: 400; }
.form label input[type=date] { width: auto; }
.form label textarea { max-width: none; }
.form > button, .form > .button { margin: 4px 0 12px; }
.form > .hint { margin-bottom: 12px; }
form.inline + p, .form + p { margin-top: 10px; }
form.inline { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 2px 6px 2px 0; vertical-align: middle; }
.inline-form { margin: 0 0 16px; }
.inline-form label { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 10px; font-weight: 500; }

/* ---------- messages, pills ---------- */
.flash { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 12px; background: var(--soft); color: var(--ink); }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.flash.error { background: var(--danger-bg); color: var(--danger-ink); border-color: var(--danger-line); }
.flash a { color: inherit; font-weight: 600; }

.badge, .status-prepared, .status-sent-to-bank, .status-paid { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  border-radius: 999px; background: var(--soft); color: var(--body); font-size: 12px; font-weight: 500; line-height: 18px; letter-spacing: 0;
  white-space: nowrap; vertical-align: middle; }
.badge.warn::before, .badge.ok::before, .status-prepared::before, .status-sent-to-bank::before, .status-paid::before {
  content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.warn, .status-prepared { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.badge.ok, .status-paid { background: var(--ok-bg); color: var(--ok); }
.status-sent-to-bank { background: var(--soft); color: var(--accent); }

/* ---------- tables: each one is its own card ---------- */
/* The table element is the card and the box that scrolls sideways when its columns do not fit, so the page
   itself never scrolls sideways. The empty caption keeps the rows as wide as the card. */
table.data { display: block; width: 100%; overflow-x: auto; container-type: inline-size; border-collapse: separate; border-spacing: 0;
  margin: 12px 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow);
  font-size: 14px; }
table.data::before { content: ""; display: table-caption; height: 0; min-width: 100cqw; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.data thead th { height: 40px; padding-top: 8px; padding-bottom: 8px; background: var(--faint); color: var(--muted); font-size: 12px; font-weight: 500;
  line-height: 1.35; }
table.data tbody th { font-weight: 600; }
table.data tr > :first-child { padding-left: 16px; }
table.data tr > :last-child { padding-right: 16px; }
table.data tbody > tr > :first-child { min-width: 128px; }
table.data tbody tr:last-child > * { border-bottom: 0; }
table.data tbody tr:hover > * { background: var(--faint); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data tr.total > * { background: var(--faint); font-weight: 600; border-top: 1px solid var(--line-strong); }
table.data tr.late > *, table.data tbody tr.late:hover > * { background: var(--danger-bg); }
table.data input[type=text], table.data input[type=date], table.data select { height: 32px; padding-left: 8px; font-size: 13px; }
table.data input[type=date] { padding-right: 6px; }
table.data select { min-width: 160px; }
table.data td.actions { white-space: normal; }
table.data form.inline { flex-wrap: nowrap; }
table.data button, table.data .button { white-space: nowrap; }
.card table.data, .note table.data, details table.data { box-shadow: none; }
.scroll { overflow-x: auto; margin: 12px 0 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.scroll table.data { display: table; overflow: visible; container-type: normal; margin: 0; border: 0; border-radius: 0; box-shadow: none; font-size: 12px; }
.scroll table.data::before { content: none; }
.scroll table.data th, .scroll table.data td { padding: 8px 10px; }
.scroll table.data tbody > tr > :first-child { min-width: 0; }

/* ---------- home ---------- */
.todo-list { list-style: none; margin: 0; padding: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow); }
.todo-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px 12px 20px;
  border-bottom: 1px solid var(--line); }
.todo-list li:last-child { border-bottom: 0; }
.todo-list li > span { position: relative; padding-left: 18px; }
.todo-list li > span::before { content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.todo-list li.urgent > span { font-weight: 500; }
.todo-list li.urgent > span::before { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.todo-list li:not(.urgent) .button { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.todo-list li:not(.urgent) .button:hover { background: var(--soft); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile { display: block; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.tile:hover { border-color: var(--ring); box-shadow: 0 2px 8px rgba(0, 0, 0, .08); color: var(--ink); }
.tile strong { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; }
.tile span { color: var(--muted); font-size: 13px; }
.empty { margin: 12px 0 16px; padding: 28px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius-card); color: var(--muted);
  text-align: center; }
.empty .button { margin-left: 8px; }

/* ---------- reading: checks, notes to copy, folded detail ---------- */
.readable ul { margin: 4px 0 12px; padding-left: 22px; }
.readable li { margin: 2px 0; }
details { margin: 12px 0; }
details > summary { color: var(--accent); font-weight: 500; cursor: pointer; }
details > summary:hover { color: var(--accent-hover); }
details[open] > summary { margin-bottom: 8px; }
details pre { max-height: 360px; overflow: auto; padding: 12px; background: var(--soft); border-radius: var(--radius); font-family: var(--mono);
  font-size: 12px; white-space: pre-wrap; }
.copybox { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; }
.copybox textarea { background: var(--faint); font-family: var(--mono); font-size: 13px; }

/* ---------- job progress ---------- */
.job-state { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--soft); font-weight: 500; }
.job-state::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.job-state.running { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.job-state.done { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.job-state.failed { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger-ink); }
.job-steps li { margin: 4px 0; }
.job-lines { padding: 16px 20px 16px 40px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow); }
.job-lines li { margin: 2px 0; }
.job-lines:empty { display: none; }

/* ---------- decisions, start here, help ---------- */
ol.questions { padding-left: 22px; }
ul.questions { padding-left: 0; list-style: none; }
.question { border-top: 1px solid var(--line); padding: 16px 0 14px; }
.question.blocking { border-left: 3px solid var(--danger); padding-left: 12px; }
.question.done { opacity: .7; }
.question .ask { margin: 0 0 6px; font-weight: 600; }
.question .why { margin: 0 0 10px; color: var(--body); font-size: 13px; }
.question .answer { display: block; font-size: 13px; font-weight: 500; }
.question .answer textarea { margin-top: 6px; font-weight: 400; }
.question .tick { display: inline-flex; align-items: center; gap: 8px; margin: 8px 12px 0 0; font-weight: 500; }
ul.settled li, ul.defaults li { margin: 6px 0; }
#defaults h3 { margin: 16px 0 4px; font-size: 14px; }
#how p { color: var(--body); }
.steps li { margin: 6px 0; }
.glossary { margin: 12px 0 16px; padding: 4px 20px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow); }
.glossary dt { margin-top: 12px; font-weight: 600; }
.glossary dd { margin: 2px 0 0; color: var(--body); }

/* ---------- rehearsal guide ---------- */
.progress { height: 8px; margin: 8px 0; overflow: hidden; background: var(--line); border-radius: 999px; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 999px; }
.rehearsal-steps { padding-left: 22px; }
.rehearsal-steps li { margin: 6px 0; }
.rehearsal-steps.compact { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; padding: 0; margin: 4px 0 16px; font-size: 13px; }
.rehearsal-steps.compact li { margin: 0; }
.rehearsal-steps.compact li.here a { color: var(--ink); font-weight: 600; }
.rehearsal-steps li.done a::after { content: " \2713"; color: var(--ok); }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.step-nav { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 20px 0; }
.compare h3 { margin-top: 16px; }

/* ---------- the password page (opened from another device) ---------- */
main.login { flex: none; max-width: 400px; margin: 12vh auto 0; padding: 32px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow); }
main.login .login-logo { display: block; width: 230px; max-width: 100%; height: auto; margin: 0 0 22px -2px; }
main.login h1 { font-size: 20px; margin-bottom: 8px; }
main.login p { color: var(--muted); margin-bottom: 20px; }
main.login label { display: block; margin-bottom: 6px; font-weight: 500; }
main.login input { display: block; width: 100%; }
main.login input + label { margin-top: 14px; }
main.login button { width: 100%; margin-top: 16px; }

/* ---------- narrower screens ---------- */
@media (max-width: 800px) {
  html, html:has(body.practice) { scroll-padding-top: 120px; }
  .topbar { position: sticky; height: auto; min-height: var(--topbar-h); flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .menu-button { display: inline-flex; }
  .practice-switch { display: contents; }
  .practice-switch .switch-label, .practice-switch button:first-of-type { margin-left: auto; }
  .user-menu { gap: 8px; margin-left: 0; padding-left: 8px; }
  .user-menu span, .user-menu a { display: none; }
  .sidebar { top: 0; z-index: 60; width: 264px; max-width: 86vw; transform: translateX(-100%); transition: transform .2s ease; visibility: hidden; }
  body.menu-open .sidebar { transform: none; visibility: visible; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45); }
  .page { margin-left: 0; padding-top: 0; min-height: 0; }
  .practice-banner { position: static; padding: 10px 12px; }
  main { padding: 16px 16px 32px; }
  footer { padding: 12px 16px 20px; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
  p.card { padding: 12px 16px; }
  .explain { padding: 14px 16px; }
  .explain dl { grid-template-columns: 1fr; gap: 2px; }
  .explain dd { margin-bottom: 8px; }
  .explain dd:last-child { margin-bottom: 0; }
  button, .button { height: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; white-space: normal; text-align: center; }
  button.small, .button.small { min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
  .menu-button { height: 36px; padding: 0; }
  select { min-width: 0; }
  .form label input, .form label select { max-width: 100%; }
  /* on a phone a table with many columns keeps a readable width and scrolls sideways inside its box */
  table.data:has(thead th:nth-child(4))::before { min-width: max(100cqw, 520px); }
  table.data:has(thead th:nth-child(5))::before { min-width: max(100cqw, 680px); }
  table.data:has(thead th:nth-child(7))::before { min-width: max(100cqw, 900px); }
  .todo-list li { flex-wrap: wrap; gap: 8px 12px; padding: 12px 16px; }
  .tiles { grid-template-columns: 1fr; }
  .side-by-side { grid-template-columns: 1fr; }
  .copybox { flex-direction: column; }
  .empty .button { margin: 8px 0 0; }
  main.login { margin: 24px 16px 0; padding: 24px; max-width: none; width: auto; }
}

/* A tick box with its sentence (the approval form). */
label.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
label.check input { width: 18px; height: 18px; margin-top: 1px; flex: none; }

/* The server's home page: the month as a row of steps. */
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.board-head h1 { margin: 0; }
.board-head form { margin: 0; }
.waiting-card h2 { margin-top: 0; }
.month-board { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.month-board .step { display: flex; align-items: flex-start; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.month-board .step:last-child { border-bottom: 0; }
.month-board .mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--soft); color: var(--muted);
  border: 1px solid var(--line); }
.month-board .step.done .mark { background: #ECFDF5; color: #059669; border-color: #A7F3D0; }
.month-board .step.waiting .mark { background: #FFFBEB; color: #B45309; border-color: #FCD34D; }
.month-board .step-body { flex: 1 1 auto; min-width: 0; }
.month-board .step-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.month-board .step-head strong { font-size: 15px; }
.month-board .step p { margin: 4px 0 0; color: var(--muted); }
.month-board .step.todo strong { color: var(--muted); font-weight: 500; }
.month-board .button { flex: none; align-self: center; }
.pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px;
  font-weight: 600; white-space: nowrap; background: var(--soft); color: var(--muted); }
.pill.state-done { background: #ECFDF5; color: #059669; }
.pill.state-waiting { background: #FFFBEB; color: #B45309; }
.pill.who-person { background: #EFF6FF; color: #1D4ED8; }
.activity { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; }
.activity li { display: flex; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity time { flex: none; width: 124px; color: var(--muted); font-variant-numeric: tabular-nums; }
.other-things { margin-top: 24px; }
.other-things summary { cursor: pointer; font-weight: 600; }
.other-things .todo-list { margin-top: 12px; }
.nav-more { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.nav-more summary { padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.nav-more summary:hover { background: var(--soft); }
.nav-more nav { margin-top: 2px; }
@media (max-width: 800px) {
  .month-board .step { flex-wrap: wrap; padding: 12px 14px; }
  .month-board .button { margin-left: 42px; }
  .activity li { flex-direction: column; gap: 2px; }
}

/* The server's home page, plain: ink and grey, one teal button where something needs doing. No coloured
   circles, boxes or badges. (These rules come last, so they win over the earlier board styles.) */
.plain-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px;
  margin: 0 0 20px; box-shadow: none; }
.plain-card h2 { margin: 0 0 12px; font-size: 16px; }
.quiet { margin: 0; color: var(--muted); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0;
  border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; padding-top: 0; }
.rows li:last-child { padding-bottom: 0; }
.rows li > span { font-weight: 500; }
.month-board { border: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: visible; }
.month-board .step { align-items: center; gap: 20px; padding: 12px 0; border-bottom: 0; border-top: 1px solid var(--line); }
.month-board .step:first-child { border-top: 0; padding-top: 0; }
.month-board .step:last-child { padding-bottom: 0; }
.month-board .step strong { font-size: 14px; font-weight: 600; color: var(--ink); }
.month-board .step p { margin: 2px 0 0; color: var(--muted); }
.month-board .step.todo strong { color: var(--muted); font-weight: 500; }
.month-board .step.done strong { font-weight: 500; }
.step-state { flex: none; width: 92px; text-align: right; font-size: 13px; font-weight: 600; color: var(--ink); }
.step-state small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.step.done .step-state, .step.todo .step-state { color: var(--muted); font-weight: 500; }
.step-link { flex: none; font-size: 13px; color: var(--muted); text-decoration: underline; }
.step-link:hover { color: var(--ink); }
.overdue-fact { margin: 0 0 4px; }
.overdue-more { margin: 12px 0 0; }
.activity { border: 0; border-radius: 0; background: transparent; }
.activity li { padding: 8px 0; border-bottom: 0; border-top: 1px solid var(--line); }
.activity li:first-child { border-top: 0; padding-top: 0; }
.activity li:last-child { padding-bottom: 0; }
.other-things { margin: 0 0 20px; padding: 0 4px; background: transparent; border: 0; box-shadow: none; }
.other-things summary { color: var(--muted); font-size: 13px; font-weight: 500; }
.other-things .rows { margin-top: 12px; }
.other-things .rows li > span { font-weight: 400; }
p.lead { max-width: none; }
@media (max-width: 800px) {
  .month-board .step { flex-wrap: wrap; gap: 8px 16px; }
  .step-state { width: auto; text-align: left; }
  .step-state small { display: inline; margin-left: 6px; }
}

/* Done is green again (the user likes that); still no number circles and no orange boxes. */
.step.done .step-state { color: #059669; font-weight: 600; }
.step.done .step-state::before { content: "\2713\00a0"; }

/* The explanation of a page is folded away until someone asks for it. */
details.explain { padding: 0; border: 0; background: transparent; box-shadow: none; margin: 0 0 16px; }
details.explain > summary { display: inline-block; cursor: pointer; color: var(--muted); font-size: 13px; text-decoration: underline; list-style: none; }
details.explain > summary::-webkit-details-marker { display: none; }
details.explain[open] > summary { margin-bottom: 10px; }
details.explain[open] { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 20px; }

/* Doctor rates and "Not paid yet": names stay on one line; the eleven small rate boxes of a hospital fit the
   page without scrolling sideways. */
table.data td.name { white-space: nowrap; }
table.data.rates-grid th, table.data.rates-grid td { padding: 6px 5px; }
table.data.rates-grid tr > :first-child { padding-left: 14px; }
table.data.rates-grid input[type=text] { width: 54px; padding: 0 6px; }

/* ---------- summary: three small column charts ---------- */
.year-pick { color: var(--muted); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 24px; margin: 4px 0 8px; }
.chart { margin: 0; --chart-col: #0E8F7C; --chart-loss: #C2410C; }
.chart figcaption { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.chart svg { display: block; width: 100%; height: auto; max-width: 480px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick, .chart .month { font-size: 10px; fill: var(--muted); }
.chart .value { font-size: 10.5px; font-weight: 600; fill: var(--ink); }
.chart .hit { fill: transparent; }
.chart .col path { fill: var(--chart-col); }
.chart .col.loss path { fill: var(--chart-loss); }
.chart .col:hover path { opacity: .75; }
.chart .col:hover .month { fill: var(--ink); font-weight: 600; }
table.data td.zero { color: #94A3B8; }
.mini { display: block; }
.mini rect { fill: #0E8F7C; }
.mini line { stroke: var(--line-strong); stroke-width: 1; }
.plain-card > details { margin: 0; }
.plain-card > details > summary.fold-title { color: var(--ink); font-size: 16px; font-weight: 600; }
.month-nav { display: flex; justify-content: space-between; gap: 16px; margin: 0 0 8px; }
