:root {
  --rail: #14212e;
  --rail-fg: #8fa5b8;
  --rail-fg-on: #ffffff;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --line: #dde3e9;
  --line-strong: #c3ccd5;
  --ink: #1c2833;
  --ink-soft: #5b6b7a;
  --accent: #1d6fa5;
  --accent-dark: #17567f;
  --bad: #b03030;
  --bad-bg: #fdf1f1;
  --warn: #8a6100;
  --warn-bg: #fdf8ec;
  --good: #1f7a4d;
  --good-bg: #f0f8f3;
}

* { box-sizing: border-box; }

/**
 * The `hidden` attribute must actually hide things.
 *
 * A browser's own rule for [hidden] is `display: none`, but it loses to any
 * class rule that sets `display` — so `.signin { display: grid }` left the
 * sign-in overlay laid out at `position: fixed; inset: 0` while hidden,
 * invisible and swallowing every click in the application behind it. Nothing
 * looked wrong; buttons simply did nothing.
 *
 * One rule, applied to everything, so the next element with a display type
 * cannot reintroduce it.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

/**
 * The application wrapper must not be a box in the layout.
 *
 * The bar and `main` are wrapped in `#app` so the whole application can be
 * hidden behind the sign-in screen. `display: contents` removes the wrapper from
 * the layout without removing it from the document, so those two lay themselves
 * out against the body directly. The `[hidden]` rule above is `!important` and
 * still wins, so hiding the application still hides it.
 */
#app { display: contents; }

/* ── The module bar. Horizontal, across the top. ── */
nav.topbar {
  background: var(--rail);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  min-height: 52px;
  /* Stays put while a long register scrolls underneath it. */
  position: sticky;
  top: 0;
  z-index: 5;
}

nav.topbar .mark {
  color: var(--rail-fg-on);
  font-weight: 700;
  letter-spacing: 0.5px;
  flex: 0 0 auto;
}

/**
 * The modules take the room that is left and scroll sideways if there is not
 * enough of it, rather than wrapping the bar onto a second line or pushing the
 * account controls off the right-hand edge.
 */
nav.topbar .modules {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
nav.topbar .modules::-webkit-scrollbar { display: none; }

nav.topbar button.rail-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--rail-fg);
  font: inherit;
  font-size: 13px;
  /* Nine modules and the account controls share one line at 1280px wide; at
     the payroll app's 12px a side the last one scrolled out of sight. */
  padding: 7px 8px;
  cursor: pointer;
}
nav.topbar button.rail-btn .ico { font-size: 15px; line-height: 1; }

nav.topbar button.rail-btn:hover:not(:disabled) { background: rgba(255,255,255,.08); color: var(--rail-fg-on); }
nav.topbar button.rail-btn[aria-current="true"] { background: rgba(255,255,255,.14); color: var(--rail-fg-on); }
nav.topbar button.rail-btn:disabled { opacity: .35; cursor: default; }

/* ── The account side of the bar ── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  color: var(--rail-fg);
  font-size: 13px;
}
.topbar-right button.link { color: #cfe0ee; padding: 4px 2px; }
.topbar-right button.link:hover { color: #fff; }

main { padding: 22px 28px 60px; min-width: 0; }

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 22px;
}

header.top h1 { font-size: 18px; margin: 0; font-weight: 600; }
.muted { color: var(--ink-soft); }

.entity-switch { display: flex; align-items: center; gap: 8px; }
.entity-switch select {
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 6px;
  padding: 4px 8px;
  background: rgba(255,255,255,.08);
  color: #fff;
  font: inherit;
  font-size: 13px;
  max-width: 230px;
}
/* The options render on the operating system's own menu, which is light. */
.entity-switch select option { color: var(--ink); background: var(--panel); }

/* ── Panels ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 22px;
  max-width: 640px;
}
.panel.wide { max-width: 940px; }

/* The "or" between two ways of doing the same thing — a rule with the word
   sitting in the gap, so neither route reads as the afterthought. */
.or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.or::before,
.or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.panel h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
.panel h3 { font-size: 14px; margin: 22px 0 8px; font-weight: 600; }
.panel > p { margin: 0 0 16px; color: var(--ink-soft); max-width: 60ch; }

.panel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
/* More than one button beside a heading — print it, then leave it. */
.head-actions { display: flex; gap: 8px; align-items: center; }

/**
 * ── A tab bar inside a panel ──
 *
 * The same job the vertical window-nav does on the employee screen, laid out
 * across the top of a form: a long form split into named parts, so somebody
 * adding an employee is not scrolling past twenty fields to reach the bank
 * details. The underline carries the selection rather than a filled block,
 * which keeps it quiet enough to sit directly under a heading.
 */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin: 0 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs .tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--ink); background: #f2f6f9; }
.tabs .tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Panes carry the fieldset's old spacing now that the legend has become a tab. */
.tab-pane { padding-top: 2px; }

/* ── Forms ── */
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0 0 4px; padding: 14px 0 6px; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-weight: 600; font-size: 13px; color: var(--ink-soft); padding: 0 8px 0 0; }

.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row .field { flex: 1 1 200px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 4px; font-weight: 500; }
.field .req { font-style: normal; font-size: 11px; color: var(--ink-soft); font-weight: 400; }
.field input, .field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.field small { display: block; margin-top: 4px; font-size: 12px; color: var(--ink-soft); }
.field.has-error input, .field.has-error select { border-color: var(--bad); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
button.primary, .actions button, .inline-form button, .wizard-actions button {
  border-radius: 6px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
/* The one button that throws an installation's contents away. */
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
#restore-block h3 { margin: 18px 0 8px; font-size: 1rem; }

/**
 * A disabled button has to LOOK disabled.
 *
 * Only the rail had a disabled style, so everywhere else a button that did
 * nothing was indistinguishable from one that worked — the "add a passkey"
 * button sat there in full accent blue on a server where passkeys are switched
 * off, and clicking it was the only way to find out. The explanation next to it
 * is not much use if the control it explains looks live.
 */
button:disabled,
button.primary:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* ── Notices ── */
.notice { border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice.bad { background: var(--bad-bg); color: var(--bad); border: 1px solid #f0d0d0; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #ece0c0; }
.notice.good { background: var(--good-bg); color: var(--good); border: 1px solid #cfe6da; }
/* Information, neither good nor bad news: what a choice will mean. */
.notice.info { background: #eef5fb; color: #1d4f73; border: 1px solid #cfe0ee; }
.notice.info p { margin: 4px 0 0; }

/* ── Tables ── */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-strong);
  padding: 8px 10px;
}
table.grid td { border-bottom: 1px solid var(--line); padding: 9px 10px; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: #f7fafc; }
/**
 * ── Reviewing a run ──
 *
 * The exception list. Several reasons can apply to one person — somebody who
 * left AND had their bank details changed is two facts — so the reasons are a
 * list inside the cell rather than a sentence, and the cell has to stop looking
 * like a bulleted paragraph.
 */
#review-panel { margin: 22px 0; }
#review-panel .panel-head { margin-bottom: 6px; }
#review-table ul.reasons { margin: 0; padding-left: 16px; }
#review-table ul.reasons li { margin: 1px 0; }
/* A moved bank account shows up in no figure on this page — the register is
   identical and the money goes somewhere else. It does not get to look like
   the others. */
#review-table .reason-loud { color: var(--bad); font-weight: 500; }
#review-table tbody tr { cursor: default; }
#review-table tbody tr:hover { background: transparent; }
.reviewed { color: var(--good); font-size: 12px; white-space: nowrap; }

/**
 * ── One-off entries on a run ──
 *
 * The panel sits between the actions and the register, and the two tables are
 * separated deliberately: without the rule below, the entries table's last row
 * and the register's header sat flush against each other and the whole thing
 * read as ONE table with a second set of column headings in the middle of it.
 */
#entries-panel { margin: 22px 0; }
#entries-panel .panel-head { margin-bottom: 6px; }
#entries-panel + .table-scroll > table.grid, #entries-panel + table.grid { margin-top: 24px; border-top: 1px solid var(--line-strong); }
#entries-form { margin: 14px 0 18px; }
#entries-form .muted { font-size: 12px; margin: 4px 0 0; }
/* These rows are not clickable, so they do not offer to be: `table.grid`
   assumes a row opens something, and every other grid in the application
   does. */
/**
 * A checkbox is not a text box, and `.field input { width: 100% }` treats it
 * like one — a stretched checkbox renders centred in its own box, floating
 * above its label with nothing beside it. This puts the box and its words on
 * one line, where a checkbox belongs.
 */
.field.check label { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.field.check input[type="checkbox"] { width: auto; margin: 0; }

#entries-table tbody tr { cursor: default; }
#entries-table tbody tr:hover { background: transparent; }

/* An unfinished record should not read as a finished one at a glance. */
table.grid tbody tr.is-draft { background: var(--warn-bg); }
table.grid tbody tr.is-draft:hover { background: #faf1dc; }

/* Somebody who has left. Red, and only red — no strike-through, because the
   record is still to be read: they were paid this year and they are on the
   TD7. The colour says "not on the next run", not "ignore this line". */
table.grid tbody tr.is-terminated td { color: var(--bad); }

/* ── Detail lists ── */
dl.kv { display: grid; grid-template-columns: 220px 1fr; gap: 7px 18px; margin: 14px 0 0; font-size: 13px; }
dl.kv dt { color: var(--ink-soft); }
dl.kv dd { margin: 0; }

ul.checklist { margin: 0; padding-left: 18px; font-size: 13px; color: var(--warn); }
ul.checklist li { margin-bottom: 3px; }

/* An administrator's bar carries two more links (Add a company, Users), and at
   a laptop's width the last module was being clipped. The word "Company" is
   the first thing to go: the select beside it says which company it is. */
@media (max-width: 1400px) {
  .entity-switch > span:first-child { display: none; }
}

@media (max-width: 860px) {
  /* Names cost more room than a narrow screen has; the icons carry the bar
     alone, and the tooltip that was always there is still on every button. */
  nav.topbar button.rail-btn span:not(.ico) { display: none; }
  nav.topbar button.rail-btn { padding: 7px 10px; }
  nav.topbar { gap: 10px; }
  .topbar-right { gap: 10px; }
  .entity-switch span { display: none; }
  .entity-switch select { max-width: 130px; }
}

/**
 * On a phone the bar takes two rows rather than pushing its right-hand side off
 * the screen.
 *
 * Letting it overflow instead put the language switch 55px past the edge and
 * gave the whole PAGE a sideways scrollbar — every screen in the application
 * slightly draggable, for the sake of one row. Two rows on a 420px screen is
 * the honest answer.
 */
@media (max-width: 560px) {
  nav.topbar { flex-wrap: wrap; padding: 6px 12px; row-gap: 6px; }
  nav.topbar .modules { order: 2; width: 100%; flex: 1 1 100%; }
  .topbar-right { order: 1; margin-left: auto; }
}

@media (max-width: 720px) {
  main { padding: 16px; }
  header.top { flex-wrap: wrap; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 8px; }
}

/* ── The single-employee window: sections down the left, not tabs on top ── */
.window {
  display: grid;
  grid-template-columns: 200px 1fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  max-width: 1040px;
}

.window-nav {
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 12px 0;
}

.window-nav button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 16px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.window-nav button:hover { background: #f2f6f9; color: var(--ink); }
.window-nav button[aria-current="true"] {
  background: var(--panel);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.window-body { padding: 20px 24px; }
.window-body h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.window-body h3 { font-size: 13px; margin: 20px 0 8px; font-weight: 600; color: var(--ink-soft); }

.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 14px; }
.inline-form .field { margin: 0; min-width: 140px; flex: 0 1 auto; }
.inline-form button { align-self: flex-end; }

.pill {
  display: inline-block;
  font-size: 11px;
  border-radius: 10px;
  padding: 1px 8px;
  background: #eef3f7;
  color: var(--ink-soft);
  margin-left: 6px;
}
.pill.a2 { background: #fdf8ec; color: var(--warn); }
.mono { font-variant-numeric: tabular-nums; }
/**
 * Scoped to `table.grid`, and deliberately.
 *
 * A bare `th.num` loses on specificity to `table.grid th { text-align: left }`,
 * so a totals row sat left-aligned beneath right-aligned figures — in a payroll
 * register, which is the one table where the columns have to line up, because
 * lining them up is how anybody checks the addition by eye.
 */
table.grid td.num, table.grid th.num,
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .window { grid-template-columns: 1fr; }
  .window-nav { border-right: 0; border-bottom: 1px solid var(--line); display: flex; overflow-x: auto; }
  .window-nav button { width: auto; white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  .window-nav button[aria-current="true"] { border-left: 0; border-bottom-color: var(--accent); }
}

/* ── Signing in. Its own screen: no rail, no switcher, nothing to click. ── */
.signin {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
  z-index: 10;
}

.signin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 30px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 1px 3px rgba(20, 33, 46, .06);
}

.signin-card h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.signin-card h2 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
.signin-card > p { margin: 0 0 20px; font-size: 13px; }
.signin-card #signin-code p { margin: 0 0 16px; font-size: 13px; }

button.wide { width: 100%; margin-top: 6px; }
button.link {
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 2px;
}
button.link:hover { text-decoration: underline; }

/* Hug the buttons rather than stretching the border across the card. */
.signin-lang { margin: 22px auto 0; width: max-content; }

.setup-key {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  background: #f4f7f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  word-break: break-all;
}

ul.codes {
  list-style: none;
  padding: 0;
  margin: 14px 0;
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 6px 28px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

/* A choice the reader has to make, rather than one already made for them:
   the option and its explanation sit together, and neither is preselected. */
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.choice:hover { background: var(--panel-soft, #fafafa); }
.choice input { margin-top: 3px; }
.choice strong { display: block; font-weight: 600; }
.choice small { display: block; color: var(--ink-soft); margin-top: 3px; max-width: 60ch; }

.week { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 12px 34px; padding: 10px 12px; }
.week label { display: flex; align-items: center; gap: 6px; }

/* A requirement that belongs to a GROUP of fields rather than to any one of
   them — "at least one of these three". Said once, above the row, because
   marking each box "required" would be three lies. */
.group-req {
  margin: 14px 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* An item that has finished. Still listed, because somebody asking why a
   deduction appeared in March needs to see that it ran January to June — but
   quietened, so the ones still running read first. */
table.grid tbody tr.is-ended td { color: var(--ink-soft); }
table.grid td .stop-date { margin-right: 8px; padding: 3px 6px; font-size: 12px; }

/* ── The notes window ────────────────────────────────────────────────────── */

dialog.note-window {
  max-width: 680px;
  width: calc(100% - 32px);
  max-height: 80vh;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}
dialog.note-window::backdrop { background: rgba(16, 32, 45, .45); }
.note-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.note-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.note-body { padding: 4px 20px 20px; overflow-y: auto; max-height: calc(80vh - 64px); }
.note-body h4 { margin: 16px 0 6px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.note-body p { margin: 0 0 10px; font-size: 13px; line-height: 1.55; }

/* A line's notes button sits in its own column. */
table.td59 td.td59-tools { white-space: nowrap; }

/* ── A locked box ─────────────────────────────────────────────────────────── */
/*
 * The read view of a field. The same box as the edit view so the screen does
 * not change shape when Edit is pressed — quieter, and not typeable.
 */
.field.locked input {
  background: #f7fafc;
  border-color: var(--line);
  color: var(--ink);
  cursor: default;
}
.field.locked input:focus { outline: none; border-color: var(--line); }

/* ── Proving it is you again ──────────────────────────────────────────────── */
/*
 * Narrow, and styled from `note-window` rather than `.window` — `.window` sets
 * `display: grid`, which overrides the browser's own
 * `dialog:not([open]) { display: none }` and leaves a closed dialog laid out on
 * the page. A password box rendered behind a prompt nobody opened.
 */
dialog.stepup-window { max-width: 420px; }
dialog.stepup-window h2 { margin: 16px 0 4px; font-size: 15px; font-weight: 600; }
dialog.stepup-window .actions { margin-top: 18px; }

/* ── The unsaved-changes question ─────────────────────────────────────────── */
dialog.unsaved-window { max-width: 480px; }
dialog.unsaved-window .note-body p { margin: 4px 0 0; }
dialog.unsaved-window .actions { margin-top: 20px; flex-wrap: wrap; }

/* The TD59 is a form: its boxes are open from the moment it opens. */
table.td59 td.num input[type="text"],
table.td59 td.num input[type="number"],
table.td59 td.num input[type="date"],
table.td59 td.num select {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
  background: var(--panel);
}
table.td59 td.num input:focus, table.td59 td.num select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

/* ── Users ─────────────────────────────────────────────────────────────── */
#user-form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); max-width: 640px; }
#user-grants-table td { padding: 6px 10px; }
#user-grants-table select { width: auto; min-width: 140px; }
#users-table tr.inactive td { color: var(--ink-soft); }
#users-table td.actions-cell { text-align: right; white-space: nowrap; }
.pill.off { background: #f3eeee; color: var(--bad); }
.pill.warn { background: #fdf8ec; color: var(--warn); }
ul.history { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13px; }
ul.history li { padding: 4px 0; border-bottom: 1px solid var(--line); }

/* A second, quieter line under a table value. */
table.grid td .small { font-size: 12px; margin-top: 2px; }
.history-table td { vertical-align: top; }
.history-table td:first-child { white-space: nowrap; }

/* ─── Phones ───
   Tables slide inside their own box (see wrapTables in app.js), so the page
   never scrolls sideways. Buttons wrap two to a row and are big enough to
   press with a thumb. */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 560px) {
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; gap: 4px 12px; margin-left: 0; width: 100%; flex: 1 1 100%; }
  .entity-switch select { max-width: 170px; }
  main { padding: 12px; }
  .panel, .panel.wide { padding: 16px 14px; }
  .actions button { flex: 1 1 calc(50% - 5px); min-height: 44px; padding: 8px 10px; }
  .panel-head .actions button { flex: 0 0 auto; min-height: 40px; }
  table.grid td, table.grid th { padding: 8px 8px; white-space: nowrap; }
  .steps li { flex: 1 1 calc(50% - 6px); }
  .inline-form .field { flex: 1 1 100%; }
  .inline-form button { flex: 1 1 100%; min-height: 44px; }
}

/* ── A new company: the steps down the left, one question on the right ──
   The QuickBooks interview's shape, which the firm's staff already know. The
   steps not built yet are listed in grey, so the whole is visible from the
   first screen. */
.wizard {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 20px;
  max-width: 1180px;
  align-items: start;
}
.wizard-steps {
  list-style: none;
  margin: 0;
  padding: 14px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  counter-reset: none;
}
.wizard-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
}
.wizard-steps li .n {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--panel);
}
/* Where you are: a filled mark AND bold text, so it is not told by colour alone. */
.wizard-steps li.current { background: #eaf2f8; font-weight: 600; }
.wizard-steps li.current .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-steps li.done .n { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.wizard-steps li.done .n::before { content: "\2713"; }
.wizard-steps li.done .n { font-size: 0; }
.wizard-steps li.done .n::before { font-size: 12px; }
.wizard-steps li.later { color: var(--ink-soft); opacity: .6; }

.wizard-body { max-width: none; }
.wizard-page h3 { border-top: 1px solid var(--line); padding-top: 14px; }
.wizard-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}
.wizard-actions .spacer { flex: 1 1 auto; }

/* The review: what will be saved, one line per answer, the address on its lines. */
dl.review { display: grid; grid-template-columns: 220px 1fr; gap: 6px 18px; margin: 8px 0 14px; }
dl.review dt { color: var(--ink-soft); font-size: 13px; }
dl.review dd { margin: 0; white-space: pre-line; font-weight: 500; }

@media (max-width: 760px) {
  .wizard { grid-template-columns: 1fr; }
  .wizard-steps { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .wizard-steps li { padding: 4px 8px; }
  .wizard-steps li.later span:not(.n) { display: none; }
  dl.review { grid-template-columns: 1fr; }
}

/* A label only a screen reader needs; the page heading already says it. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── A list of choices, one line of explanation under each ──
   The QuickBooks "How is your company organised?" list. The whole row is the
   target, not just the little circle; the chosen row is marked by its border
   and weight as well as its colour. */
fieldset.choices { border: 0; padding: 0; margin: 8px 0 16px; }
/* Two columns where there is room: nine choices one under the other is a list
   nobody reads to the end. Written against .field's own label and input rules,
   which would otherwise stack the circle above the words. */
#legal-form-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
fieldset.choices label.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  cursor: pointer;
  background: var(--panel);
  font-weight: 400;
}
fieldset.choices label.choice:hover { border-color: var(--line-strong); }
fieldset.choices label.choice input { margin: 3px 0 0; flex: 0 0 auto; width: 16px; height: 16px; padding: 0; }
fieldset.choices label.choice span { display: flex; flex-direction: column; gap: 2px; }
fieldset.choices label.choice strong { font-weight: 500; font-size: 13.5px; }
fieldset.choices label.choice small { color: var(--ink-soft); font-size: 12.5px; margin: 0; }
fieldset.choices label.choice:has(input:checked) { border-color: var(--accent); background: #f3f8fc; box-shadow: inset 3px 0 0 var(--accent); }
fieldset.choices label.choice:has(input:checked) strong { font-weight: 600; }
.field.has-error.choices label.choice { border-color: var(--bad); }
