/* Genuine Invoice application interface. Document styles live in document.css. */

:root {
  /* The page says, up front, that it dresses itself in both light and dark. Without this a browser with
     its own "dark mode" — Samsung Internet, and Chrome's automatic one on Android — decides the page
     cannot cope and inverts the colours itself, which is why switching the theme appeared to do nothing
     there. Saying it here hands the decision back to the page. */
  color-scheme: light;

  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --line: #e6e1d4;
  --line-strong: #d4ccb8;
  --text: #262b33;
  --muted: #6b7482;
  /* Genuine Invoice's colours: the logo's slate and brushed gold. The bright gold (#d9b862) is too light to
     carry text on white, so links and accents use a deeper gold, #8a6a2a, at 5.1:1. */
  --brand: #8a6a2a;
  --brand-dark: #6f5420;
  /* A filled button writes white on this, so it is the logo's slate: 14:1. The dark theme turns it gold,
     because slate on a near-black page would disappear, and writes dark text on it instead. */
  --brand-solid: #262b33;
  --brand-solid-hover: #14171c;
  --brand-tint: #f5ecd6;
  --success: #17794f;
  --success-tint: #e3f4ec;
  --warning: #8a5a00;
  --warning-tint: #fff4dc;
  --danger: #b3261e;
  --danger-tint: #fdeceb;
  /* Pill and panel edges, and the two extra hues the statuses use. Tokens so the dark theme can carry
     them without every rule being written twice. */
  --label: #3d4450;
  --edge-warning: #f1d9a3;
  --success-ink: #0f5537;
  --danger-ink: #8c1d17;
  --warning-ink: #6b4500;
  --inverse: #262b33;
  --inverse-ink: #ffffff;
  --edge-brand: #e6d3a3;
  --edge-success: #b9e2cf;
  --edge-danger: #f2c4c0;
  --edge-info: #c6dcf4;
  --edge-plum: #ddd0ef;
  --info: #1d5fa8;
  --info-tint: #eef6ff;
  --plum: #5b3a8a;
  --plum-tint: #f3eefa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(38, 43, 51, 0.06), 0 4px 16px rgba(38, 43, 51, 0.05);
  --focus: 0 0 0 3px rgba(195, 156, 76, 0.38);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { min-height: 100vh; display: flex; flex-direction: column; font-size: 15px; line-height: 1.5; background: var(--bg); }
main { flex: 1; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 0.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0 0; }
.mt { margin-top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Hidden by clipping, not by being pushed off the side: a left: -9999px element makes a right-to-left
   page scrollable by 11,000px, which opens it on blank space. */
.skip-link { position: absolute; top: 0.5rem; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; background: var(--surface); padding: 0; z-index: 100; }
.skip-link:focus { inset-inline-start: 0.5rem; width: auto; height: auto; overflow: visible; clip: auto;
  padding: 0.5rem 1rem; }

/* ---------------------------------------------------------------- top bar */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 0 1.25rem; height: 60px; display: flex; align-items: center; gap: 1.5rem; }
/* With a side panel, the bar spans the same measure as the shell below it, and the logo is nudged in by
   the width of a nav item's own padding, so the L sits directly above the menu icons. */
body.has-appbar .topbar-inner, body.has-rootbar .topbar-inner { max-width: 1480px; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.1rem; }
/* The wordmark itself — icon and lettering in one piece, as drawn. It carries its own colours, so the
   same file sits on the light header and the dark footer. The width shrinks on a narrow phone so it
   never crowds the menu button; height follows, because the aspect ratio is fixed. */
.brand-logo { height: 56px; width: auto; max-width: min(300px, 52vw); display: block; object-fit: contain; }
/* Genuine Invoice: the wordmark's grey "genuine" is redrawn light for dark backgrounds */
.brand-logo--dark { display: none; }
:root[data-theme="dark"] .brand-logo--light, .is-root-login .brand-logo--light { display: none; }
:root[data-theme="dark"] .brand-logo--dark, .is-root-login .brand-logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo--light { display: none; }
  :root:not([data-theme="light"]) .brand-logo--dark { display: block; }
}
.mainnav { display: flex; gap: 0.25rem; }
.mainnav a { text-decoration: none; color: var(--muted); padding: 0.45rem 0.75rem; border-radius: 8px; font-weight: 500; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a.is-active { color: var(--brand); background: var(--brand-tint); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.plan-badge { font-size: 0.8rem; text-decoration: none; padding: 0.25rem 0.6rem; border-radius: 999px; background: var(--brand-tint); color: var(--brand-dark); white-space: nowrap; }
.plan-badge.plan-expired, .plan-badge.plan-none { background: var(--warning-tint); color: var(--warning); }
.plan-badge.plan-active { background: var(--success-tint); color: var(--success); }
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--text); color: #fff; display: grid; place-items: center; font-weight: 600; }
.usermenu summary:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 50%; }
.usermenu-panel { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.9rem 1rem; min-width: 230px; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
.usermenu-panel a, .usermenu-panel .linklike { margin-top: 0.35rem; }

/* ---------------------------------------------------------------- layout */

.page { max-width: 1320px; width: 100%; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.page.narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1.25rem; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.85rem 1rem; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
.row-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.row-actions form { margin: 0; }
.sitefoot { display: flex; justify-content: space-between; gap: 1rem; max-width: 1320px; width: 100%; margin: 0 auto; padding: 1.25rem; color: var(--muted); font-size: 0.8rem; }

/* ---------------------------------------------------------------- forms */

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; color: var(--label); }
/* A label stacks its caption above its field, so a caption written as loose text beside a span —
   "Button text" and "(optional)" — would become two stacked rows. Wrapped in this, it is one row. */
.label-text { display: block; }
label.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
label.checkbox-row { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; align-self: end; padding-bottom: 0.55rem; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--label); margin-bottom: 0.4rem; }
input, select, textarea {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  width: 100%;
  min-width: 0;
}
textarea { resize: vertical; }
/* flex: none, or a tick box put in a flex row gets squashed to a sliver and becomes hard to hit. */
input[type="checkbox"], input[type="radio"] { width: auto; flex: none; accent-color: var(--brand);
  inline-size: 1rem; block-size: 1rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input.upper { text-transform: uppercase; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-size: 0.92rem; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 0.5rem 0.95rem; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brand-solid); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-solid-hover); border-color: var(--brand-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #efc2bf; }
.btn-danger:hover { background: var(--danger-tint); color: var(--danger); }
.btn-sm { font-size: 0.83rem; padding: 0.35rem 0.7rem; }
.btn-block { width: 100%; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; width: 32px; height: 32px; font-size: 1.2rem; line-height: 1; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--danger-tint); color: var(--danger); }

/* ---------------------------------------------------------------- alerts, pills, toast */

.alert { border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem; border: 1px solid; font-size: 0.92rem; }
.alert-success { background: var(--success-tint); border-color: var(--edge-success); color: var(--success-ink); }
.alert-error { background: var(--danger-tint); border-color: var(--edge-danger); color: var(--danger-ink); }
.alert-warning { background: var(--warning-tint); border-color: var(--edge-warning); color: var(--warning-ink); }
.alert-info { background: var(--brand-tint); border-color: var(--edge-brand); color: var(--brand-dark); }
.pill { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--success-tint); color: var(--success); vertical-align: middle; }
.status { display: inline-block; font-size: 0.76rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.status-sent, .status-issued, .status-trial { background: var(--brand-tint); color: var(--brand-dark); border-color: var(--edge-brand); }
.status-paid, .status-accepted, .status-active, .status-refunded { background: var(--success-tint); color: var(--success); border-color: var(--edge-success); }
.status-part { background: var(--info-tint); color: var(--info); border-color: var(--edge-info); }
.status-overdue, .status-declined, .status-expired, .status-used-up { background: var(--danger-tint); color: var(--danger); border-color: var(--edge-danger); }
.status-converted, .status-paused { background: var(--plum-tint); color: var(--plum); border-color: var(--edge-plum); }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--inverse); color: var(--inverse-ink); padding: 0.75rem 1.1rem; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); z-index: 50; max-width: min(92vw, 560px); font-size: 0.92rem; }
.toast-error { background: var(--danger); }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th { text-align: left; font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .select { width: 36px; }
.table .empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.table td.actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.table td.actions form { margin: 0; }
.docs-table tbody tr { cursor: pointer; }
.docs-table tbody tr:hover td { background: var(--surface-2); }
.docs-table tbody tr.is-selected td { background: var(--brand-tint); }
.doc-link { font-weight: 600; text-decoration: none; }
.edit-table input { padding: 0.35rem 0.5rem; }
.edit-table .w-code { width: 5rem; text-transform: uppercase; }
.edit-table td.num input { text-align: right; max-width: 8rem; }
.edit-table .new-row td { background: var(--surface-2); }
.summary-table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.summary-table th { text-align: left; font-weight: 400; padding: 0.5rem 0; }
.summary-table td { text-align: right; padding: 0.5rem 0; font-variant-numeric: tabular-nums; }
.summary-table .total th, .summary-table .total td { font-weight: 700; font-size: 1.1rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }

/* ---------------------------------------------------------------- workspace */

/* Why a tile reads zero when there is work in progress: drafts are not counted. */
.stat-drafts { display: block; margin-top: 0.15rem; font-size: 0.78rem; color: var(--muted); font-style: italic; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.15rem; box-shadow: var(--shadow); }
.stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-note { font-size: 0.8rem; color: var(--muted); }

/* The tiles are the first thing read on My documents, and five grey ones say nothing at a glance. A
   rule along the top carries the colour across the room; the label repeats it for anyone who needs the
   word rather than the hue, since colour on its own is no use to a reader who cannot see it. The rule
   replaces the tile's own top border rather than adding to it, so nothing shifts or changes height. */
.stat.tone-success  { border-top: 3px solid var(--success); }
.stat.tone-warning  { border-top: 3px solid var(--warning); }
.stat.tone-danger   { border-top: 3px solid var(--danger); }
.stat.tone-info     { border-top: 3px solid var(--info); }
.stat.tone-plum     { border-top: 3px solid var(--plum); }
.stat.tone-success .stat-label { color: var(--success); }
.stat.tone-warning .stat-label { color: var(--warning); }
.stat.tone-danger  .stat-label { color: var(--danger); }
.stat.tone-info    .stat-label { color: var(--info); }
.stat.tone-plum    .stat-label { color: var(--plum); }
/* The 2px the thicker rule adds is taken off the padding, so a toned tile is exactly as tall as a
   plain one and a row of them lines up whatever each is reporting. */
.stat[class*="tone-"], .stat-profit { padding-top: calc(1rem - 2px); }
/* Profit colours its figure rather than its label, because the figure is the news. Its label follows the
   rule above it so the tile matches the ones beside it. */
.stat-profit.is-gain .stat-label { color: var(--success); }
.stat-profit.is-loss .stat-label { color: var(--danger); }
.list-tools { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; flex-wrap: wrap; }
.segmented button { font: inherit; font-size: 0.85rem; font-weight: 600; border: 0; background: none; color: var(--muted); padding: 0.35rem 0.8rem; border-radius: 7px; cursor: pointer; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.search { flex: 1; max-width: 360px; }
.action-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.6rem 0.75rem; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--line-strong); margin-bottom: 0.75rem; }
.action-bar.is-active { background: var(--brand-tint); border-style: solid; border-color: var(--edge-brand); }
.action-label { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.action-bar.is-active .action-label { color: var(--brand-dark); }
.action-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.back-link { text-decoration: none; font-size: 0.88rem; font-weight: 500; }

.modal { border: 0; border-radius: 12px; padding: 0; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); width: min(92vw, 440px); }
.modal::backdrop { background: rgba(20, 26, 40, 0.45); }
.modal-body { padding: 1.4rem; display: flex; flex-direction: column; gap: 0.9rem; }
.modal-body h2 { margin: 0; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ---------------------------------------------------------------- home */

.home { max-width: 1180px; width: 100%; margin: 0 auto; padding: 3rem 1.25rem; }
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(320px, 440px); gap: 3.5rem; align-items: start; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; font-weight: 700; color: var(--brand); margin: 0 0 0.75rem; }
.hero h1 { font-size: clamp(2rem, 4vw, 2.9rem); line-height: 1.12; letter-spacing: -0.025em; margin-bottom: 1rem; }
.lede { font-size: 1.1rem; color: #414a5c; margin: 0 0 1.5rem; max-width: 36em; }
.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.ticks li { padding-left: 1.8rem; position: relative; }
.ticks li::before { content: ""; position: absolute; left: 0; top: 0.2em; width: 1.15rem; height: 1.15rem; border-radius: 50%; background: var(--success-tint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%2317794f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 0.8rem no-repeat; }
.ticks.compact { margin: 1.25rem 0; font-size: 0.92rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.5rem; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 9px; padding: 3px; margin-bottom: 1.25rem; border: 1px solid var(--line); }
.tabs button { font: inherit; font-weight: 600; border: 0; background: none; padding: 0.5rem; border-radius: 7px; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; }

/* ---------------------------------------------------------------- subscription */

.status-card h2 { margin-bottom: 0.35rem; }
.status-card p { margin: 0; }
.status-card form { margin-top: 0.9rem; }
.status-card.status-trial { border-left: 4px solid var(--brand); }
.status-card.status-active { border-left: 4px solid var(--success); }
.status-card.status-expired, .status-card.status-none { border-left: 4px solid var(--warning); }
.plans-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.plan-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.plan-head h2 { margin: 0; }
.plan-head select { width: auto; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.plan { position: relative; cursor: pointer; font-weight: 400; }
.plan input { position: absolute; opacity: 0; }
.plan-body { display: flex; flex-direction: column; gap: 0.3rem; border: 2px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem; height: 100%; }
.plan input:checked + .plan-body { border-color: var(--brand); background: var(--brand-tint); }
.plan input:focus-visible + .plan-body { box-shadow: var(--focus); }
.plan-name { font-weight: 700; font-size: 1rem; color: var(--text); display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.plan-name .pill { font-size: 0.68rem; padding: 0.1rem 0.4rem; }
.plan-price { font-size: 1.6rem; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.plan-price small { font-size: 0.9rem; font-weight: 500; color: var(--muted); }
.promo-row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.promo-row label { flex: 1; min-width: 200px; }
.notice { background: var(--warning-tint); color: var(--warning-ink); padding: 0.6rem 0.85rem; border-radius: 8px; font-size: 0.9rem; }

/* ---------------------------------------------------------------- editor */

.editor-page { width: 100%; max-width: 1480px; margin: 0 auto; padding: 0 1.25rem 3rem; }
.editor-toolbar { position: sticky; top: 60px; z-index: 10; background: var(--bg); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.editor-title { display: flex; align-items: baseline; gap: 0.9rem; flex-wrap: wrap; }
.editor-title h1 { font-size: 1.35rem; margin: 0; }
.save-state { font-size: 0.82rem; color: var(--muted); }
.editor-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.editor { display: grid; grid-template-columns: minmax(360px, 520px) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.editor-form { display: flex; flex-direction: column; gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.15rem 1.2rem; box-shadow: var(--shadow); }
.panel legend { float: left; width: 100%; font-weight: 700; font-size: 0.98rem; margin-bottom: 0.85rem; padding: 0; }
.panel legend ~ * { clear: both; }
.panel > label + label { margin-top: 0.85rem; }

/* The track list is set by the editor, because the serial number, part number and HSN columns are
   switched on per company. The value here is the fallback while the page is still starting. */
.items-head, .item-row { display: grid; grid-template-columns: var(--item-grid, minmax(0, 1fr) 64px 96px 132px 32px); gap: 0.45rem; align-items: start; }
.items-head { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; margin-bottom: 0.35rem; }
.items { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.75rem; }
.item-row textarea { min-height: 38px; field-sizing: content; }
.item-row input, .item-row select, .item-row textarea { font-size: 0.88rem; padding: 0.45rem 0.5rem; }
.item-row input[type="number"] { text-align: right; }
/* Prices include VAT, under the items in the new editor layout (editor.js moves it there). */
.prices-tax-slot { margin: 0.5rem 0 0; }
.prices-tax-slot .checkbox-row { font-size: 0.9rem; }
/* The last column: the microphone (where the browser can listen) and the remove button. */
.line-acts { display: flex; gap: 4px; justify-content: flex-end; }
.mic-btn { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.mic-btn:hover { background: var(--brand-tint); color: var(--brand-dark); }
.mic-btn.is-listening { background: var(--brand-tint); color: var(--brand-dark); border-color: var(--brand); animation: mic-pulse 1.4s ease-in-out infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 4px var(--brand-tint); } }
@media (prefers-reduced-motion: reduce) { .mic-btn.is-listening { animation: none; } }
/* What was heard, under the line, to check before it is added. */
.voice-card { border: 1px solid var(--brand); border-radius: 10px; background: var(--brand-tint); padding: 0.75rem 0.85rem; }
.voice-card p { margin: 0 0 0.35rem; }
.voice-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.voice-problem { color: var(--danger); }
.voice-live, .voice-heard { font-size: 0.95rem; min-height: 1.3em; }
.voice-heard { font-style: italic; }
.voice-note { font-size: 0.78rem; color: var(--muted); }
.voice-fields { display: grid; grid-template-columns: minmax(0, 1fr) 80px 110px; gap: 0.45rem; margin: 0.35rem 0; }
.voice-field { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.75rem; color: var(--muted); }
.voice-field input { font-size: 0.9rem; padding: 0.45rem 0.5rem; }
.voice-field input[type="number"] { text-align: right; }
.voice-sum { font-size: 0.85rem; font-weight: 600; }
.voice-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 0.35rem; }
@media (max-width: 520px) {
  .voice-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .voice-field:first-child { grid-column: 1 / -1; }
  .voice-actions .btn { flex: 1; }
}
.item-sn { padding-top: 0.55rem; text-align: right; font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Not enough width for one line: the fields stack instead of being squashed. The editor measures the
   real space and sets this class, because the items area sits beside the preview. */
/* Tax sets in Business details */
.tax-set { border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.7rem 0.8rem; margin-bottom: 0.6rem; background: #fbfcfe; }
.tax-set-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.tax-set-head input { flex: 1; font-weight: 600; }
.tax-parts { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.4rem; }
.tax-part { display: grid; grid-template-columns: minmax(0, 1fr) 150px 84px auto 32px; gap: 0.4rem; align-items: center; }
.tax-part .tax-pc { color: var(--muted); font-size: 0.85rem; }
.rate-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 32px; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.rate-input { display: flex; align-items: center; gap: 0.35rem; }
.rate-input input { text-align: right; }
.rate-input .tax-pc { color: var(--muted); font-size: 0.85rem; }
.tax-part input[type="number"] { text-align: right; }
@media (max-width: 720px) {
  .tax-part { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px; }
  .tax-part select { grid-column: 1 / 2; }
  .tax-part input[type="number"] { grid-column: 2 / 3; }
  .tax-part .tax-pc { display: none; }
}

.items-head.stacked { display: none; }
.items.stacked .item-row { grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1fr) auto; row-gap: 0.35rem; }
.items.stacked .item-sn { grid-column: 1; grid-row: 1; }
.items.stacked .item-row textarea { grid-column: 2 / 4; }
.items.stacked .item-row .line-acts { grid-column: 4; grid-row: 1; }
.items.stacked .item-row input[data-f="sku"] { grid-column: 2 / 3; }
.items.stacked .item-row input[data-f="hsn"] { grid-column: 3 / 5; }
.items.stacked .item-row input[data-f="qty"] { grid-column: 2 / 3; }
.items.stacked .item-row input[data-f="unitPrice"] { grid-column: 3 / 5; }
.items.stacked .item-row select { grid-column: 2 / 4; }
.items.stacked .item-row select[data-f="taxSet"] { grid-column: 2 / 4; }
/* The line's own amount: a figure, not a field, so it is right-aligned and sits with the inputs. */
.item-amount { padding-top: 0.55rem; text-align: right; font-size: 0.88rem; font-weight: 600;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.items.stacked .item-amount { grid-column: 2 / 5; text-align: left; padding-top: 0; color: var(--muted); }
.items.stacked .item-amount::before { content: 'Amount: '; }

/* What the lines come to, under the Add line buttons. */
.item-totals { margin-top: 0.8rem; margin-left: auto; width: min(22rem, 100%); display: grid; gap: 0.2rem; }
.item-totals div { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.88rem; }
.item-totals .num { font-variant-numeric: tabular-nums; }
.item-totals .is-total { border-top: 1px solid var(--line); margin-top: 0.25rem; padding-top: 0.3rem; font-weight: 700; }
.item-totals:empty { display: none; }

/* Payments received: what has come in, when, and what is still owed. */
/* Its own section now, so it needs no rule above it to separate it from the items it used to end. */
.payrec-block { margin-top: 0; }
.payrec-list { width: min(26rem, 100%); display: grid; gap: 0.15rem; margin-bottom: 0.6rem; }
.payrec-list:empty { display: none; }
/* In the Record payment dialog the rows are read-only, so there is no remove button to leave room for. */
.payrec-list .payrec-row:not(:has(> .icon-btn)) { grid-template-columns: 1fr auto; }
.payrec-row { display: grid; grid-template-columns: 1fr auto 28px; align-items: center; gap: 0.6rem;
  padding: 0.3rem 0.1rem 0.3rem 0.5rem; border-radius: 7px; background: var(--surface-2); font-size: 0.88rem; }
.payrec-row .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.payrec-row.is-total { background: none; border-top: 1px solid var(--line); border-radius: 0;
  grid-template-columns: 1fr auto 28px; margin-top: 0.2rem; padding-top: 0.4rem; font-weight: 700; }
.payrec-when { color: var(--muted); display: flex; align-items: baseline; gap: 0.45rem; flex-wrap: wrap; }
/* How the money came in, beside the date it arrived. */
.payrec-mode { font-size: 0.78rem; padding: 0.05rem 0.4rem; border-radius: 99px;
  background: var(--brand-tint); color: var(--brand); white-space: nowrap; }
.payrec-add { display: flex; align-items: flex-end; gap: 0.6rem; flex-wrap: wrap; }
.payrec-add label { display: grid; gap: 0.2rem; }
.payrec-add input { width: 11rem; }
@media (max-width: 560px) {
  .payrec-add { gap: 0.5rem; }
  .payrec-add label, .payrec-add input { width: 100%; }
  .payrec-add label { flex: 1 1 100%; }
}

.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
.choice { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 0.15rem; padding: 0.55rem; border: 2px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; }
.choice > strong { font-size: 0.85rem; }
.choice > small { font-size: 0.72rem; color: var(--muted); line-height: 1.25; }
.choice[aria-checked="true"] { border-color: var(--brand); background: var(--brand-tint); }
.choice:focus-visible, .swatch:focus-visible { outline: none; box-shadow: var(--focus); }
.thumb { display: block; height: 46px; border-radius: 4px; background: #fff; border: 1px solid var(--line); position: relative; overflow: hidden; margin-bottom: 0.3rem; }
.thumb i { position: absolute; left: 12%; right: 12%; height: 4px; border-radius: 2px; background: #d7dbe2; }
.thumb i:nth-child(1) { top: 9px; right: 50%; background: var(--brand); }
.thumb i:nth-child(2) { top: 22px; }
.thumb i:nth-child(3) { top: 32px; left: 55%; }
.layout-thumb-modern .thumb { background: linear-gradient(var(--brand) 0 16px, #fff 16px); }
.layout-thumb-modern .thumb i:nth-child(1) { background: #fff; top: 6px; }
.layout-thumb-minimal .thumb i:nth-child(1) { height: 2px; background: #9aa1ad; }
.layout-thumb-bold .thumb { border-left: 7px solid var(--brand); }
.layout-thumb-bold .thumb i:nth-child(3) { background: var(--brand); height: 7px; }
.layout-thumb-corporate .thumb { border-top: 5px solid var(--brand); }
.layout-thumb-corporate .thumb i:nth-child(1) { top: 7px; }
.layout-thumb-corporate .thumb i:nth-child(3) { background: var(--brand-dark); height: 6px; }
.layout-thumb-executive .thumb i { left: 30%; right: 30%; }
.layout-thumb-executive .thumb i:nth-child(1) { right: 30%; top: 8px; }
.layout-thumb-executive .thumb i:nth-child(2) { top: 18px; height: 3px; left: 12%; right: 12%; border-top: 1px solid var(--brand); border-bottom: 1px solid var(--brand); background: transparent; }
.layout-thumb-executive .thumb i:nth-child(3) { left: 20%; right: 20%; }
.layout-thumb-elegant .thumb i:nth-child(3) { left: 58%; right: 8%; top: 8px; height: 14px; border-radius: 4px; background: var(--brand-tint); }
.layout-thumb-compact .thumb { background: repeating-linear-gradient(#fff 0 4px, #eef0f3 4px 7px); }
.layout-thumb-split .thumb { background: linear-gradient(90deg, var(--brand) 0 50%, var(--brand-tint) 50%) top / 100% 20px no-repeat, #fff; }
.layout-thumb-split .thumb i:nth-child(1) { background: #fff; top: 7px; }
.swatches { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; background: var(--sw); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--text); }
.upload { display: flex; flex-direction: column; align-items: flex-start; gap: 0.45rem; }
.upload-preview { width: 100%; height: 64px; border: 1px dashed var(--line-strong); border-radius: 8px; display: grid; place-items: center; background: repeating-conic-gradient(#f3f4f6 0 25%, #fff 0 50%) 50% / 14px 14px; font-size: 0.82rem; }
.upload-preview img { max-width: 90%; max-height: 54px; }
.file-btn { flex-direction: row; font-weight: 600; }

.preview-pane { position: sticky; top: 140px; }

/* The wide editor (version 3): a small preview on the left, the document itself on the right.
   Both layouts share the same markup, so switching between them changes nothing but the view. */
.editor.editor-wide { grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); }
.editor.editor-wide .preview-pane { order: 0; }
.editor.editor-wide .editor-form { order: 1; }
.editor-layout-switch { flex-basis: 100%; text-align: left; font-size: 0.82rem; }
.btn-short { display: none; }
.bank-pick { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; }

/* Bank accounts in Business details */

@media (max-width: 720px) {
}
.preview-meta { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.5rem; }
.preview-meta #preview-total { font-weight: 700; color: var(--text); }
.preview-stage { position: relative; overflow: hidden; }
.preview-scaler { transform-origin: top left; }
.preview-scaler .doc { box-shadow: 0 2px 6px rgba(20, 28, 45, 0.08), 0 12px 40px rgba(20, 28, 45, 0.1); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .editor, .editor.editor-wide { grid-template-columns: minmax(0, 1fr); }
  /* Stacked on a narrow screen, the document comes first and the preview follows it. */
  .editor.editor-wide .editor-form { order: 0; }
  .editor.editor-wide .preview-pane { order: 1; }
  .preview-pane { position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .mainnav { display: none; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .plans { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .plan-badge { display: none; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .items-head { display: none; }
  .sitefoot { flex-direction: column; }
}

/* ---------------------------------------------------------------- saved items */

.item-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.btn.btn-on { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-tint); font-weight: 600; }

/* ---------------------------------------------------------------- platform administration (Root) */

.rootbar-title { font-size: 0.9rem; font-weight: 700; color: var(--muted); letter-spacing: 0.01em; }
/* The body is a column flex container, so the shell has to claim the full width itself. Without this it
   shrinks to fit whatever the page happens to contain, and the sidebar moves from page to page. */
.rootshell { display: grid; grid-template-columns: 232px minmax(0, 1fr); align-items: start; gap: 1.75rem;
  width: 100%; max-width: 1480px; margin: 0 auto; padding: 0 1.25rem; }
/* The column is fixed; the page fills it and stays left, so nothing shifts as content changes. */
.rootshell > main.page, .rootshell > main.page.narrow { width: 100%; max-width: none; margin: 0; padding-left: 0; padding-right: 0; }
/* Pages that want a narrower measure cap their own blocks rather than the column. */
.rootshell > main.narrow > * { max-width: 880px; }
.rootbar { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 1rem; padding: 1rem 0 1.5rem; }
.rootnav { display: flex; flex-direction: column; gap: 0.15rem; }
.rootnav a { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.75rem; border-radius: 0.6rem;
  color: var(--text); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.rootnav a:hover { background: var(--surface); }
.rootnav a.is-active { background: var(--brand-tint); color: var(--brand); }
.rootnav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.rootnav a.is-active .rootnav-dot { background: var(--brand); }
.rootnav-foot { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.9rem 0.75rem 0; border-top: 1px solid var(--line);
  font-size: 0.88rem; }
.rootnav-foot a, .rootnav-foot button { color: var(--muted); text-decoration: none; text-align: left; font: inherit; }
.rootnav-foot a:hover, .rootnav-foot button:hover { color: var(--brand); }

@media (max-width: 900px) {
  /* Not enough width for a column, so the menu runs across the top and scrolls sideways. */
  .rootshell { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .rootbar { position: static; padding-bottom: 0.5rem; }
  .rootnav { flex-direction: row; overflow-x: auto; gap: 0.35rem; padding-bottom: 0.35rem; }
  .rootnav a { white-space: nowrap; }
  .rootnav-dot { display: none; }
  .rootnav-foot { flex-direction: row; gap: 1rem; padding-top: 0.6rem; }
}

/* ---------------------------------------------------------------- first-run setup and advanced settings */

.setup-head .setup-step { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand); margin-bottom: 0.3rem; }
.setup-head h1 { margin-bottom: 0.35rem; }

.advanced-toggle { display: flex; align-items: center; gap: 0.7rem; width: 100%; margin: 0.4rem 0; padding: 0.8rem 1rem; font: inherit;
  text-align: left; color: var(--brand); background: var(--brand-tint); border: 1px dashed #b7c9e6; border-radius: 0.75rem; cursor: pointer; }
.advanced-toggle:hover { background: #dce6f5; }
.advanced-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
.advanced-arrow { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--brand); color: #fff; transition: transform 0.2s ease; }
.advanced-toggle[aria-expanded="true"] .advanced-arrow { transform: rotate(180deg); }
.advanced-text { font-weight: 700; }
.advanced-note { color: var(--muted); font-size: 0.85rem; }
@media (max-width: 560px) { .advanced-note { display: none; } }
.biz-advanced { gap: inherit; }

/* ---------------------------------------------------------------- help assistant */
.help-fab { position: fixed; inset-inline-end: 1.25rem; bottom: 1.25rem; z-index: 40; width: 52px; height: 52px;
  border: 0; border-radius: 50%; padding: 0; background: var(--brand); color: #fff; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(20, 28, 45, 0.28);
  transition: background 0.18s ease, transform 0.18s ease; }
.help-fab:hover { background: var(--brand-dark); transform: translateY(-1px); }
.help-fab:focus-visible { outline: none; box-shadow: var(--focus), 0 6px 20px rgba(20, 28, 45, 0.28); }
.help-fab[aria-expanded="true"] { background: var(--text); }
.help-panel { position: fixed; inset-inline-end: 1.25rem; bottom: 1.25rem; z-index: 41; width: min(380px, calc(100vw - 2.5rem));
  max-height: min(560px, calc(100vh - 6rem)); display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 50px rgba(20, 28, 45, 0.25); overflow: hidden; }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); }
.help-log { flex: 1; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.7rem; }
.help-msg { display: flex; flex-direction: column; gap: 0.4rem; }
.help-you { align-items: flex-end; }
.help-bubble { max-width: 90%; padding: 0.55rem 0.75rem; border-radius: 0.75rem; font-size: 0.88rem; line-height: 1.5; }
.help-you .help-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 0.2rem; }
.help-bot .help-bubble { background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 0.2rem; }
.help-bubble ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.help-bubble li { margin-bottom: 0.25rem; }
.help-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.help-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0.3rem 0.65rem;
  font: inherit; font-size: 0.78rem; color: var(--brand-dark); cursor: pointer; }
.help-chip:hover { border-color: var(--brand); }
.help-ask { display: flex; gap: 0.4rem; padding: 0.7rem 0.9rem; border-top: 1px solid var(--line); }
.help-ask input { flex: 1; }
@media print { .help-fab, .help-panel { display: none; } }
.modal-wide { width: min(94vw, 560px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.saved-list { list-style: none; margin: 0; padding: 0; max-height: min(55vh, 420px); overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.saved-row { display: flex; align-items: center; gap: 0.25rem; border-bottom: 1px solid var(--line); padding-right: 0.4rem; }
.saved-row:last-child { border-bottom: 0; }
.saved-add { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; font: inherit; text-align: left; background: none; border: 0; padding: 0.7rem 0.85rem; cursor: pointer; border-radius: 6px; }
.saved-add:hover { background: var(--brand-tint); }
.saved-add:focus-visible { outline: none; box-shadow: inset var(--focus); }
.saved-desc { font-weight: 600; overflow-wrap: anywhere; }
.saved-meta { font-size: 0.82rem; color: var(--muted); }
.saved-meta em { font-style: normal; color: var(--warning); }
.saved-badge { font-size: 0.72rem; font-weight: 600; color: var(--success); }
.saved-empty { padding: 1.5rem 1rem; text-align: center; color: var(--muted); font-size: 0.9rem; }

/* ---------------------------------------------------------------- checkout and payments */

.checkout-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.checkout-head h2 { margin: 0; }
.test-badge { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; background: var(--warning-tint); color: var(--warning); border: 1px solid #f1d9a3; padding: 0.2rem 0.6rem; border-radius: 999px; }
.pay-title { font-size: 1rem; margin: 1.25rem 0 0.6rem; }
.pay-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 1rem; }
.pay-tabs button { display: flex; align-items: center; gap: 0.6rem; font: inherit; font-weight: 600; text-align: left; padding: 0.8rem 0.9rem; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.pay-tabs button[aria-selected="true"] { border-color: var(--brand); background: var(--brand-tint); }
.pay-tabs button:focus-visible { outline: none; box-shadow: var(--focus); }
.pay-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--surface-2); color: var(--brand); flex: none; }
.pay-icon-paypal { background: #003087; color: #fff; font-weight: 800; font-style: italic; font-family: Verdana, sans-serif; }
.pay-panel { margin-bottom: 0.5rem; }
.card-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem 1rem; }
.card-number-wrap { position: relative; display: block; }
.card-number-wrap input { padding-right: 6.5rem; font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.card-brand { position: absolute; right: 0.7rem; top: 50%; transform: translateY(-50%); font-size: 0.78rem; font-weight: 700; color: var(--brand); }
input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { font-size: 0.8rem; font-weight: 500; color: var(--danger); }
.test-cards { font-size: 0.88rem; border: 1px dashed var(--line-strong); border-radius: 8px; padding: 0.6rem 0.85rem; }
.test-cards summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.test-cards p { margin: 0.5rem 0; color: var(--muted); }
.test-cards .table td { padding: 0.4rem 0.5rem; }
.btn-paypal { background: #ffc439; border-color: #ffc439; color: #111; }
.btn-paypal:hover { background: #f2b61f; border-color: #f2b61f; color: #111; }
/* Stripe's own purple, so the two buttons are told apart at a glance rather than by reading them. */
/* The administration address, shown as the literal thing to type. */
.root-path { font-size: 0.95rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.3rem 0.6rem; }
.root-path-form { margin-top: 0.75rem; }

/* A field you can empty in one tap. The button sits beside the input rather than on top of it, so it
   never collides with the browser's own dropdown arrow, and it is a full finger-sized target. */
.field-with-clear { display: flex; align-items: stretch; gap: 0.4rem; }
.field-with-clear > input { flex: 1; min-width: 0; }
.field-clear { flex: none; width: 2.6rem; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.field-clear:hover { color: var(--text); border-color: var(--text); }
@media (pointer: coarse) { .field-clear { width: 3rem; min-height: 44px; } }

/* The six-digit code: big, spaced, and unmistakably a code rather than a password. */
.code-input { font-size: 1.6rem; letter-spacing: 0.45em; text-align: center; font-variant-numeric: tabular-nums; padding-left: 0.45em; }
.auth-card { max-width: 30rem; margin-inline: auto; }

/* A message shown exactly as it will arrive, so what you check is what they get. */
.mail-preview { white-space: pre-wrap; word-break: break-word; font-size: 0.86rem; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; margin: 0.5rem 0 0; }
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats-4 { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- announcements and the bell */
.notice-banner { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.8rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--edge-info); background: var(--info-tint); color: var(--text); margin-bottom: 1rem; }
.notice-banner.notice-warning { border-color: var(--edge-warning); background: var(--warning-tint); }
.notice-banner.notice-urgent { border-color: var(--edge-danger); background: var(--danger-tint); }
.notice-text { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.92rem; }
.notice-text a { font-weight: 600; }
.notice-close { flex: none; border: 0; background: none; font-size: 1.4rem; line-height: 1; cursor: pointer;
  color: var(--muted); padding: 0 0.2rem; min-width: 32px; min-height: 32px; }
.notice-close:hover { color: var(--text); }

.bell { position: relative; }
.bell > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); position: relative; }
.bell > summary::-webkit-details-marker { display: none; }
.bell > summary:hover { border-color: var(--line-strong); }
.bell-dot { position: absolute; top: 7px; right: 8px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface); }
.bell-panel { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 40; width: min(22rem, calc(100vw - 2rem));
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.bell-head { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.bell-item { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.bell-item:last-child { border-bottom: 0; }
.bell-item.is-unread { background: var(--brand-tint); }
.bell-empty { padding: 0.9rem; margin: 0; font-size: 0.88rem; }
@media (pointer: coarse) { .bell-panel { width: min(20rem, calc(100vw - 1.5rem)); } }

.btn-stripe { background: #635bff; border-color: #635bff; color: #fff; }
.btn-stripe:hover { background: #544de0; border-color: #544de0; color: #fff; }
/* The provider's mark sits in the button beside its wording, and never on its own: the words are what
   a screen reader announces, and the mark is hidden from it. */
.pay-mark { flex: none; }
.pay-choice .btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.secure-note { font-size: 0.82rem; color: var(--muted); margin: 1rem 0 0; }
.sandbox-page { max-width: 460px; }
.sandbox-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.5rem; margin-top: 1rem; }
.sandbox-banner { background: var(--warning-tint); color: var(--warning); font-size: 0.8rem; font-weight: 700; text-align: center; padding: 0.4rem; border-radius: 6px; margin-bottom: 1.25rem; }
.sandbox-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; font-size: 1.15rem; color: #003087; }
.sandbox-merchant { margin: 1rem 0 0; color: var(--muted); }
.sandbox-amount { font-size: 2rem; font-weight: 700; margin: 0.2rem 0; letter-spacing: -0.01em; }
@media (max-width: 560px) {
  .pay-tabs, .card-form { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- security */

.captcha { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.85rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.captcha .field-label { margin: 0; }
.captcha-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.captcha-img { display: block; border-radius: 6px; border: 1px solid var(--line-strong); background: #f4f6fa; max-width: 100%; height: auto; }
.captcha input { text-transform: uppercase; letter-spacing: 0.2em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.captcha .hint { margin: 0; }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.inline-form { margin: 0; }
.inline-form select { width: auto; }
.nowrap { white-space: nowrap; }
.small { font-size: 0.82rem; }

/* ---------------------------------------------------------------- contact messages (Root) */

.message.is-unread { border-left: 4px solid var(--brand); }
.message-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.message-head h2 { margin: 0 0 0.2rem; }
.message-head p { margin: 0; font-size: 0.88rem; }
.message-body { margin: 1rem 0 0; white-space: normal; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- custom layouts */

.layout-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.choice.is-custom { border-style: dashed; }
.choice.is-custom[aria-checked="true"] { border-style: solid; }

.layout-section { margin-bottom: 2rem; }
.layout-section > h2 { margin-bottom: 0.35rem; }
.layout-section > .muted { margin: 0 0 1rem; }
.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1.1rem; margin-top: 0.85rem; }
.layout-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.layout-card-body { padding: 0.85rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.layout-card-body h3 { margin: 0; font-size: 1rem; }
.layout-card-body p { margin: 0; }
.layout-card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.6rem; }
.mini-doc { background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 14px 14px 0; height: 250px; overflow: hidden; pointer-events: none; }
.mini-doc-inner { width: 794px; transform: scale(0.26); transform-origin: top left; box-shadow: 0 4px 18px rgba(20, 28, 45, 0.18); }
.empty-card { text-align: center; padding: 2rem; }
.empty-card p { margin: 0 0 1rem; color: var(--muted); }

.preview-as { font-weight: 600; font-size: 0.85rem; }
.preview-as select { width: auto; padding: 0.35rem 0.5rem; }
.le-tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.le-tabs button { font: inherit; font-size: 0.88rem; font-weight: 600; border: 0; background: none; color: var(--muted); padding: 0.55rem 0.4rem; border-radius: 8px; cursor: pointer; }
.le-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.le-panel { display: flex; flex-direction: column; gap: 1rem; }
.le-hint-top { margin: 0 0 0.85rem; }
.count-badge { display: inline-grid; place-items: center; min-width: 1.3rem; height: 1.3rem; border-radius: 999px; background: var(--brand); color: #fff; font-size: 0.72rem; padding: 0 0.3rem; margin-left: 0.2rem; }
.radio-row { flex-direction: row; align-items: center; gap: 0.55rem; font-weight: 500; }
.colour-row { display: flex; gap: 0.6rem; align-items: center; padding-left: 1.6rem; }
.colour-row input[type="color"] { width: 3rem; height: 2.4rem; padding: 0.15rem; cursor: pointer; }
.colour-row input[type="text"] { width: 7.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-transform: lowercase; }

.field-group + .field-group { margin-top: 1.1rem; }
.field-group h3 { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 0.4rem; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) 4.2rem minmax(0, 1.2fr); gap: 0.6rem; align-items: center; padding: 0.35rem 0; border-top: 1px solid var(--line); }
.field-row .field-name { font-size: 0.9rem; font-weight: 500; }
.field-row.is-hidden .field-name { color: var(--muted); text-decoration: line-through; }
.field-row input[type="text"] { padding: 0.4rem 0.55rem; font-size: 0.88rem; }
.always { font-size: 0.75rem; color: var(--muted); }
.switch { flex-direction: row; }
.switch input { width: 2.4rem; height: 1.35rem; appearance: none; -webkit-appearance: none; background: var(--line-strong); border-radius: 999px; position: relative; cursor: pointer; border: 0; padding: 0; transition: background 0.15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: calc(1.35rem - 6px); height: calc(1.35rem - 6px); border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(1.05rem); }
.switch input:focus-visible { box-shadow: var(--focus); }

.custom-field-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.85rem; }
.custom-field { border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 0.85rem 0.9rem; background: var(--surface-2); }
.custom-field-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.custom-field-tools { display: flex; gap: 0.15rem; }
.custom-field-tools .icon-btn { font-size: 1rem; }
.custom-field-tools .icon-btn:disabled { opacity: 0.35; cursor: default; background: none; }
.empty-note { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.85rem; }
@media (max-width: 560px) {
  .field-row { grid-template-columns: minmax(0, 1fr) 4.2rem; }
  .field-row input[type="text"], .field-row .muted.small { grid-column: 1 / -1; }
}

/* ---------------------------------------------------------------- layout designer (drag and drop) */

#preview.design-mode .el { cursor: grab; outline: 1.5px dashed rgba(31, 78, 140, 0.55); outline-offset: 2px; touch-action: none; user-select: none; }
#preview.design-mode .el:hover { outline-color: var(--brand); outline-style: solid; background-color: rgba(31, 78, 140, 0.05); }
#preview.design-mode .el-contents > * { cursor: grab; }
#preview.design-mode .el.is-dragging { opacity: 0.35; }
#preview.design-mode .doc-free { outline-color: #b4502d; }
.drag-ghost { position: fixed; z-index: 100; border: 2px solid var(--brand); background: rgba(31, 78, 140, 0.12); border-radius: 3px; pointer-events: none; }
.drag-ghost span { position: absolute; top: -1.6rem; left: 0; background: var(--brand); color: #fff; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.45rem; border-radius: 4px; white-space: nowrap; }

.element-list { display: flex; flex-direction: column; }
.element-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.element-row:first-child { border-top: 0; }
.element-row.is-placed .element-name strong::after { content: "Placed"; margin-left: 0.4rem; font-size: 0.68rem; font-weight: 700; color: #b4502d; background: #f9ece6; padding: 0.05rem 0.4rem; border-radius: 999px; vertical-align: middle; }
.element-name { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.element-name strong { font-size: 0.9rem; }
.pos-inputs { display: flex; align-items: flex-end; gap: 0.4rem; flex-wrap: wrap; }
.pos-inputs label { font-size: 0.72rem; gap: 0.15rem; }
.pos-inputs input[type="number"] { width: 4.3rem; padding: 0.3rem 0.4rem; font-size: 0.85rem; }
.pos-inputs .unit { font-size: 0.8rem; color: var(--muted); padding-bottom: 0.45rem; }
.inline-check { padding-bottom: 0.35rem; margin-left: 0.4rem; font-size: 0.85rem; }
.mt-sm { margin-top: 0.6rem; }

.section-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.section-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0.5rem 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: grab; font-size: 0.9rem; }
.section-item .section-name { flex: 1; }
.section-item .grip { color: var(--muted); letter-spacing: -0.2em; font-weight: 700; }
.section-item.is-dragging { opacity: 0.4; }
.section-item.drop-before { box-shadow: 0 -3px 0 var(--brand); }
.section-item.drop-after { box-shadow: 0 3px 0 var(--brand); }

.bg-row { display: flex; gap: 1rem; align-items: center; }
.bg-preview { width: 84px; height: 118px; flex: none; }
.bg-preview img { max-width: 100%; max-height: 100%; }
#le-logo-size button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.clear-top { margin-top: 0.85rem; align-items: flex-start; font-size: 0.88rem; }
.overlap-warn { font-size: 0.78rem; font-weight: 600; color: var(--warning); }
.overlap-warn::before { content: "⚠ "; }

/* ---------------------------------------------------------------- USD pricing and Root admin */

.local-est { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.price-card .local-est { margin: -0.2rem 0 0.6rem; }
.plan-body .local-est { margin-top: -0.15rem; }
.usd-note { font-size: 0.85rem; color: var(--muted); margin: 0.85rem 0 0; }
.promo-banner { background: var(--success-tint); color: var(--success-ink); border: 1px solid var(--edge-success); border-radius: 8px; padding: 0.6rem 0.9rem; font-size: 0.92rem; margin: 0 0 1rem; }
s.was { color: var(--muted); font-weight: 500; font-size: 0.7em; margin-right: 0.25rem; }
.price-hint { margin: -0.3rem 0 0; font-size: 0.85rem; color: var(--success-ink); background: var(--success-tint); border-radius: 8px; padding: 0.55rem 0.75rem; }
.price-hint:empty { display: none; }
.price-country { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; margin: -1rem 0 1.75rem; }
.price-country select { width: auto; }
.price-country .promo-banner { margin: 0; }

.stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.75rem; }
.card-head h2 { margin: 0; }
.card-head a { font-size: 0.88rem; font-weight: 600; text-decoration: none; }
.card-head form { margin: 0; }
.stack-cards { display: flex; flex-direction: column; }
.big-price { font-size: 1.3rem; font-weight: 700; margin: 0 0 0.3rem; }
.big-price small { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.mini-head { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 1rem 0 0.4rem; }
.plain-list { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; display: flex; flex-direction: column; gap: 0.25rem; }
.filter-bar { display: flex; gap: 0.85rem; align-items: flex-end; flex-wrap: wrap; }
.filter-bar .grow { flex: 1; min-width: 220px; }
.filter-bar select { width: auto; min-width: 150px; }
.filter-actions { display: flex; gap: 0.5rem; }
.detail-list { display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 0.5rem 1rem; margin: 0; font-size: 0.92rem; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.money-input { display: flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); overflow: hidden; }
.money-input span { padding: 0 0.6rem; color: var(--muted); font-weight: 600; }
.money-input input { border: 0; border-radius: 0; }
.money-input:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
.hint-box { align-self: end; background: var(--surface-2); border-radius: 8px; padding: 0.65rem 0.8rem; }
.edit-table .w-pct { width: 5rem; }
.rates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.75rem; }
.country-picks { border: 0; padding: 0; margin: 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.3rem 1rem; margin-top: 0.4rem; }
.status-suspended { background: var(--text); color: var(--bg); border-color: var(--text); }
.status-closed { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
@media (max-width: 1100px) { .stats-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats-6 { grid-template-columns: minmax(0, 1fr); } .detail-list { grid-template-columns: minmax(0, 1fr); } .detail-list dd { margin-bottom: 0.4rem; } }

/* ---------------------------------------------------------------- Root sign-in page */

.is-root-login { background: linear-gradient(160deg, #1d2127 0%, #262b33 55%, #3a3324 100%); }
.is-root-login .topbar { background: transparent; border-bottom-color: rgba(255, 255, 255, 0.08); }
.is-root-login .brand { color: #fff; }
.is-root-login .sitefoot { color: #9aa3b5; }
.root-login { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 2.5rem 1.25rem; }
.root-card { margin: auto 0; width: min(100%, 420px); background: var(--surface); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); padding: 1.9rem 1.75rem 1.5rem; }
.root-card h1 { font-size: 1.45rem; margin: 0.8rem 0 0.3rem; }
.root-card > .muted { margin: 0 0 1.25rem; font-size: 0.92rem; }
.root-card .alert { margin-bottom: 1rem; }
.root-badge { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--inverse); color: var(--inverse-ink); }

/* ---------------------------------------------------------------- payment gateways */

.gateway-card { scroll-margin-top: 80px; }
.gateway-head { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.gateway-head form { margin: 0 0 0 auto; }
.gateway-title { flex: 1; min-width: 0; }
.gateway-title h2 { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.25rem; }
.gateway-title p { margin: 0; }
.gateway-logo { flex: none; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; color: #fff; background: var(--muted); }
.gateway-logo-stripe { background: #635bff; }
.gateway-logo-paypal { background: #003087; font-style: italic; }
.gateway-logo-test { background: #8a5a00; }
.mode-badge { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--brand-tint); color: var(--brand-dark); }
.mode-badge.is-live { background: var(--danger); color: #fff; }
.switch-row { align-self: end; padding-bottom: 0.5rem; font-weight: 600; }
.switch-row .switch { display: inline-flex; }
.live-warning { background: var(--danger-tint); border: 1px solid var(--edge-danger); color: var(--danger-ink); border-radius: 8px; padding: 0.75rem 0.9rem; font-size: 0.9rem; display: flex; flex-direction: column; gap: 0.5rem; }
.live-warning .checkbox-row { color: var(--danger-ink); font-weight: 600; }
.country-select summary { cursor: pointer; font-size: 0.88rem; font-weight: 600; color: var(--brand); }
.country-select .check-grid { margin-top: 0.6rem; }
.gateway-mini { list-style: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.9rem; }
.gateway-mini li { display: flex; justify-content: space-between; align-items: center; }
.test-tag { font-size: 0.68rem; font-weight: 700; color: var(--warning); background: var(--warning-tint); padding: 0.05rem 0.4rem; border-radius: 999px; margin-left: 0.2rem; vertical-align: middle; }
.pay-tabs button > span:last-child { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.2rem; }

/* ---------------------------------------------------------------- locked fields (payment details) */

.locked-field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.field-head label { display: inline-flex; flex-direction: row; align-items: center; gap: 0.35rem; font-size: 0.85rem; font-weight: 600; color: var(--label); }
.field-actions { display: flex; gap: 0.35rem; }
.locked-field.is-locked textarea { background: var(--surface-2); color: var(--label); cursor: default; border-style: dashed; }
.locked-field.is-locked .field-head label::after { content: "🔒"; font-size: 0.75rem; }
.locked-field .hint { margin: 0; }
.locked-field .hint.warn { color: var(--warning); font-weight: 600; }
.panel > .locked-field + label { margin-top: 0.85rem; }

/* ---------------------------------------------------------------- layout picker with live miniatures */

/* Six designs to a row where there is room, fewer as the panel narrows. The picker measures itself, so
   it works the same in the wide editor, the classic one and on the Layouts page. */
.layout-picker { container-type: inline-size; }
.layout-picker .choice-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.5rem; }
@container (max-width: 900px) { .layout-picker .choice-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@container (max-width: 640px) { .layout-picker .choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (max-width: 420px) { .layout-picker .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice-live { padding: 0.45rem; gap: 0.2rem; }
.choice-live .thumb-live { display: block; width: 100%; height: 110px; overflow: hidden; border-radius: 5px; border: 1px solid var(--line); background: #fff; position: relative; margin-bottom: 0.35rem; pointer-events: none; }
.choice-live .thumb-doc { display: block; width: 793.7px; transform-origin: top left; }
.choice-live .thumb-doc .doc { margin: 0; box-shadow: none; }
.choice-live[aria-checked="true"] .thumb-live { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint); }
.set-toggle { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; margin: 0.75rem 0; padding: 0.55rem 0.8rem; font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--brand); background: var(--brand-tint); border: 1px dashed #b7c9e6; border-radius: 999px; cursor: pointer; }
.set-toggle:hover { background: #dce6f5; }
.set-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
.set-toggle-arrow { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; transition: transform 0.2s ease; }
.set-toggle[aria-expanded="true"] .set-toggle-arrow { transform: rotate(180deg); }
.layout-set-head { margin: 1rem 0 0.5rem; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }


/* ---------------------------------------------------------------- company default design */

.default-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.9rem; padding: 0.6rem 0.75rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.86rem; }
.default-row .btn:disabled { opacity: 1; color: var(--success); border-color: var(--edge-success); background: var(--success-tint); cursor: default; }
.choice { position: relative; }
.default-badge { position: absolute; top: 0.55rem; right: 0.55rem; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: #fff; background: var(--success); padding: 0.1rem 0.45rem; border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.swatch.is-default { outline: 2px dashed var(--success); outline-offset: 3px; }
.default-design { border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem 1rem; }
.default-design legend { font-weight: 700; font-size: 0.92rem; padding: 0 0.35rem; }

/* Revisions (version control) */
.list-tools-right { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.check-inline { display: inline-flex; flex-direction: row; align-items: center; gap: 0.4rem; font-size: 0.88rem; color: var(--muted, #5b6475); font-weight: 500; white-space: nowrap; }
.check-inline input { width: auto; margin: 0; }
.ver-tag { display: inline-block; margin-left: 0.35rem; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; vertical-align: 1px; background: var(--brand-tint); color: var(--brand-dark); border: 1px solid var(--edge-brand); white-space: nowrap; }
.ver-tag.ver-old { background: #f1f2f5; color: #5b6475; border-color: #dfe2e8; }
.docs-table tr.is-superseded td { color: #7a8394; }
.docs-table tr.is-superseded .doc-link { color: #5b6475; }
.status-revised { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.version-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1.25rem; margin: 0 0 1rem; padding: 0.7rem 0.9rem; border-radius: 8px; background: var(--brand-tint); border: 1px solid var(--edge-brand); color: var(--brand-dark); font-size: 0.9rem; }
.version-bar.is-old { background: var(--warning-tint); border-color: #f0d9a8; color: var(--warning-ink); }
.version-bar .ver-msg .btn { margin-left: 0.4rem; }
.version-bar .ver-list { font-size: 0.85rem; }
.version-bar .ver-sep { margin: 0 0.35rem; opacity: 0.6; }
.editor-form.is-read-only { opacity: 0.75; }

/* Annual sales tile */
.stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1200px) { .stats-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .stats-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stats-5 { grid-template-columns: minmax(0, 1fr); } }
.stat-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: -0.2rem; }
.year-select { display: block; }
.year-select select { width: auto; padding: 0.15rem 1.6rem 0.15rem 0.5rem; font-size: 0.8rem; font-weight: 600; min-height: 0; height: auto; border-radius: 6px; }
.stat-sales { border-top: 3px solid var(--brand); }

/* Multiple companies */
.company-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.company-tab, .company-add { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.8rem 0.45rem 0.5rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 600; font-size: 0.92rem; text-decoration: none; }
.company-tab:hover { border-color: var(--line-strong); text-decoration: none; }
.company-tab.is-on { border-color: var(--brand); background: var(--brand-tint); color: var(--brand-dark); box-shadow: inset 0 0 0 1px var(--brand); }
.company-tab.is-new { padding-left: 0.8rem; }
.company-tab img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
.company-initial { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 700; font-size: 0.85rem; }
.main-badge { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.1rem 0.4rem; border-radius: 999px; background: var(--success-tint); color: var(--success); }
.company-add { border-style: dashed; color: var(--brand); padding-left: 0.8rem; }
.company-add:hover { background: var(--brand-tint); text-decoration: none; }
.company-add.is-disabled { color: var(--muted); cursor: not-allowed; }
.biz-uploads { gap: 1rem; }
.biz-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.company-field .hint { font-weight: 400; }

/* Company add-ons and numbering */
.plan-companies { margin: 0.9rem 0; padding: 0.8rem 0.9rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.plan-companies p { margin: 0 0 0.5rem; }
.addon-form { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.companies-row { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin: 1rem 0 0.5rem; padding: 0.8rem 0.9rem; border: 1px dashed var(--line-strong); border-radius: 8px; }
.companies-row label { flex: none; }
.companies-row .hint { flex: 1; min-width: 240px; margin: 0; }
.plan-note { margin-top: -0.4rem; }

/* Licences on My team: one card for each kind of licence the plan covers */
.lic-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin: 0.4rem 0 1rem; }
.lic-card { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.lic-card.is-out { border-color: var(--line-strong); }
.lic-card h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.lic-card > p { margin: 0 0 0.6rem; }
.lic-left { display: flex; align-items: baseline; gap: 0.4rem; }
.lic-left strong { font-size: 1.9rem; line-height: 1.1; font-weight: 700; }
.lic-left span { color: var(--muted); }
.lic-card.is-out .lic-left strong { color: var(--danger); }
.lic-figures { margin: 0.7rem 0 0; padding: 0.6rem 0 0; border-top: 1px solid var(--line); display: grid; gap: 0.3rem; }
.lic-figures > div { display: flex; justify-content: space-between; gap: 1rem; }
.lic-figures dt { color: var(--muted); font-size: 0.86rem; }
.lic-figures dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
.lic-card .notice { margin: 0.7rem 0 0; }
.lic-card .addon-form { margin: 0.8rem 0 0; }
.lic-card .addon-form .w-pct { width: 5rem; }
.numbering .num-table input, .numbering .num-table select { min-width: 0; width: 100%; }
.numbering .num-table td { vertical-align: middle; }
.numbering .num-table th[scope="row"] { white-space: nowrap; font-weight: 600; }
.num-next code { font-weight: 700; color: var(--brand-dark); white-space: nowrap; }
.num-table input[name="num-prefix"] { min-width: 8rem; }
.num-table input[name="num-suffix"] { min-width: 6rem; }
.num-table input[name="num-start"] { min-width: 6rem; max-width: 8rem; }
.num-table select[name="num-digits"] { min-width: 4.2rem; }
/* It holds only "None" or "mm/yy", so it is kept narrow and the row still fits without scrolling. */
.num-table select[name="num-date"] { min-width: 5.6rem; max-width: 7rem; }
.num-table th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 0.88rem; color: var(--text); }
.hint.warn, #num-warning.warn { color: #8a5a00; }
.stat-split { list-style: none; margin: 0.35rem 0 0; padding: 0.35rem 0 0; border-top: 1px dashed var(--line); font-size: 0.78rem; color: var(--muted); display: grid; gap: 0.1rem; }
.stat-split li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; }
.stat-split li span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat { min-width: 0; }
.stat-split li span:last-child { font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.company-filter select { width: auto; }
.page-head-actions { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Pro plan and Projects */
.pro-badge { display: inline-block; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.06em; padding: 0.1rem 0.45rem; border-radius: 999px; color: #2a2110; background: linear-gradient(100deg, #9a7630, #d9b862 50%, #a98336); vertical-align: middle; margin-left: 0.35rem; }
.pro-badge-sm { font-size: 0.58rem; padding: 0.05rem 0.35rem; margin-left: 0.2rem; vertical-align: 1px; }
.mainnav a .pro-badge { margin-left: 0.25rem; }

.tier-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0.5rem 0 1rem; }
.tier { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem 1rem; margin: 0; background: var(--surface); }
.tier legend { font-weight: 800; font-size: 1.05rem; padding: 0 0.35rem; }
.tier-pro { border-color: #c9b8ee; background: linear-gradient(180deg, #faf7ff, var(--surface) 40%); }
.tier .plans { grid-template-columns: minmax(0, 1fr); margin-top: 0.6rem; }
.tier .ticks { margin: 0.2rem 0 0; }
@media (max-width: 820px) { .tier-grid, .tier .plans { grid-template-columns: minmax(0, 1fr); } }

.upgrade-box { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: 0.9rem 0; padding: 0.9rem 1rem; border-radius: 8px; border: 1px solid #c9b8ee; background: #faf7ff; }
.upgrade-box p { margin: 0.25rem 0 0; }
.tier-change { margin: 0.5rem 0; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.tier-change p { margin: 0; }

.pro-upsell { max-width: 760px; margin: 1rem auto; padding: 2rem; }
.pro-upsell h1 { margin: 0.6rem 0 0.4rem; }
.pro-upsell .lede { font-size: 1.05rem; color: var(--muted); }
.pro-list { margin: 1rem 0; }

/* Sections within a page, as a segmented control: a thin underline is easy to miss on a pale card,
   while a filled pill says plainly which section you are on. */
.subnav-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.subnav-row .subnav { margin-bottom: 0; }
.subnav { display: inline-flex; gap: 0.2rem; align-items: center; margin-bottom: 1.35rem; padding: 0.3rem;
  border: 1px solid var(--line-strong); border-radius: 13px; background: var(--surface-2); max-width: 100%;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.05); }
.subnav a { padding: 0.6rem 1.15rem; border-radius: 10px; text-decoration: none; color: var(--muted);
  font-weight: 700; font-size: 1rem; white-space: nowrap; line-height: 1.35; }
.subnav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.subnav a.is-active { background: var(--brand-solid); color: #fff;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.subnav a.is-active:hover { background: var(--brand-solid-hover); color: #fff; }
.subnav a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.subnav-export { font-weight: 600; font-size: 0.88rem; margin-inline-start: auto; }

.neg { color: var(--danger); }
.pos { color: var(--success); }
td.neg, td.pos { font-weight: 700; }
.pstatus-quoted { background: #f3eefa; color: #5b3a8a; border-color: #ddd0ef; }
.pstatus-active { background: var(--brand-tint); color: var(--brand-dark); border-color: var(--edge-brand); }
.pstatus-completed { background: var(--success-tint); color: var(--success); border-color: var(--edge-success); }
.pstatus-closed { background: #eef0f3; color: #4b5363; border-color: #dfe2e8; }
.pstatus-cancelled { background: var(--danger-tint); color: var(--danger); border-color: var(--edge-danger); }
.stat-profit.is-gain { border-top: 3px solid var(--success); }
.stat-profit.is-gain .stat-value { color: var(--success); }
.stat-profit.is-loss { border-top: 3px solid var(--danger); }
.stat-profit.is-loss .stat-value { color: var(--danger); }
.proj-table tbody tr, .click-rows tbody tr { cursor: pointer; }
.proj-table tbody tr:hover, .click-rows tbody tr:hover { background: var(--surface-2); }

.cost-bars { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.cost-bars li { display: grid; grid-template-columns: minmax(6rem, 9rem) 1fr auto; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.cb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.cb-track { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.cb-track.big { height: 14px; margin-top: 0.4rem; }
.cb-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #262b33, #c39c4c); transition: width 0.3s ease; }
.cb-fill.over { background: var(--danger); }
.budget-card .card-head { margin-bottom: 0; }
.link-row { display: flex; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap; margin-top: 0.8rem; }
.link-row label { flex: 1; min-width: 220px; }
.rc-count { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.cat-chip { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
tfoot th { text-align: left; }
tfoot th.num { text-align: right; }

.modal-form { width: min(96vw, 760px); max-height: 92vh; }
.modal-form .modal-body { overflow: auto; max-height: 92vh; }
.modal-form .modal-body > * { flex-shrink: 0; }
.modal-actions .spacer { flex: 1; }
.form-error { color: var(--danger); background: var(--danger-tint); padding: 0.5rem 0.7rem; border-radius: 8px; font-size: 0.9rem; }
.pu-items input, .pu-items select { width: 100%; min-width: 0; }
.pu-items td:nth-child(1) { min-width: 12rem; }
.pu-items td:nth-child(2) { width: 5rem; }
.pu-items td:nth-child(3) { width: 7rem; }
.pu-items td:nth-child(4) { width: 6.5rem; }
.pu-items td:nth-child(6) { width: 1.5rem; }
.pu-totals { margin: 0; text-align: right; font-size: 0.92rem; }
.paid-row, .vat-row { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; align-items: end; }
.vat-row { grid-template-columns: 1fr 1fr; }
.receipts-field { display: flex; flex-direction: column; gap: 0.5rem; }
.rc-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.rc-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.6rem 0.35rem 0.35rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); font-size: 0.85rem; max-width: 100%; }
.rc-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: #fff; }
.rc-item a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.rc-pdf { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 6px; background: #d33a2c; color: #fff; font-size: 0.7rem; font-weight: 800; }
.rc-uploading { margin: 0; }
.receipts-field .file-btn { align-self: flex-start; }

.pro-settings { margin-top: 1rem; align-items: start; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.8rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.inline-form label.inline input { width: auto; }
.danger-zone { margin-top: 1rem; border: 1px solid var(--edge-danger); border-radius: 8px; padding: 0.6rem 0.8rem; }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; }
.pro-delete-warning a { font-weight: 700; }
.vat-reclaim span { font-weight: 400; }

/* Document checking settings and the public check page */
.verify-settings .hint { margin: 0.2rem 0 0.6rem; }
.verify-page .verify-card { max-width: 640px; margin: 1rem auto; padding: 1.75rem; }
.verify-eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brand); margin: 0; }
.verify-card h1 { margin: 0.35rem 0 0.5rem; }
.verify-card .lede { color: var(--muted); margin-top: 0; }
.verify-list { margin: 1.25rem 0; }
.check-code { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.08em; background: var(--brand-tint); color: var(--brand-dark); padding: 0.15rem 0.5rem; border-radius: 6px; }
.verify-warn { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; background: var(--surface-2); }
.verify-warn h2 { margin: 0 0 0.6rem; font-size: 1rem; }

/* Settings: email gateway */
.smtp-test { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.smtp-help { margin-top: 1.1rem; }
.smtp-help summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.smtp-help .table { margin-top: 0.75rem; font-size: 0.88rem; }
.smtp-help code { font-size: 0.85rem; }

/* Teams */
.invite-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin-bottom: 0.5rem; }
.invite-form .span-2 { grid-column: 1 / -1; }
.company-picks { border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.8rem; display: grid; gap: 0.35rem; }
.company-picks legend { padding: 0 0.3rem; }
.member-edit summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 0.9rem; }
.member-edit .stack { margin-top: 0.6rem; display: grid; gap: 0.6rem; max-width: 320px; }
.member-edit form + form { margin-top: 0.5rem; }
.danger-link { color: var(--danger); }
.role-help { list-style: none; padding: 0; margin: 0.75rem 0 0; display: grid; gap: 0.3rem; font-size: 0.88rem; color: var(--muted); }
.invite-link { margin-bottom: 1rem; padding: 0.8rem 0.9rem; border-radius: 8px; background: var(--brand-tint); border: 1px solid var(--edge-brand); }
.invite-link p { margin: 0 0 0.4rem; }
.copy-field { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
tr.is-pending td { background: var(--surface-2); }
@media (max-width: 700px) { .invite-form { grid-template-columns: minmax(0, 1fr); } }
.status-member { background: var(--plum-tint); color: var(--plum); border-color: var(--edge-plum); }

/* CSV import and export */
.export-picks { display: flex; gap: 0.6rem; flex-wrap: wrap; }
/* My customers: eight columns, so a little tighter than other tables. Long names and addresses wrap to
   at most two lines; the full address shows on hover and on the customer's own page. */
.cust-table { font-size: 0.87rem; }
.cust-table th, .cust-table td { padding-left: 0.5rem; padding-right: 0.5rem; }
.cust-table th { white-space: normal; }
.cust-table td.c-phone, .cust-table td.c-tax { white-space: nowrap; }
.cust-table td.c-email { overflow-wrap: anywhere; min-width: 12.5rem; }
.cust-table td.c-addr { min-width: 10rem; }
.cust-table .cell-clip { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.cust-table td.is-empty { color: var(--muted); }
.cust-table .c-name a { color: var(--text); }

/* Import: matching a file's own columns to ours. */
.csv-file { margin: 0.9rem 0 0.2rem; }
.csv-map-title { font-size: 0.95rem; margin: 0.9rem 0 0.4rem; }
.csv-map th[scope="row"] { text-transform: none; letter-spacing: 0; font-size: 0.9rem; color: var(--text); white-space: nowrap; vertical-align: middle; }
.csv-map select { width: 100%; min-width: 11rem; }
.csv-pick { display: grid; gap: 0.35rem; }
.csv-pick .linklike { justify-self: start; font-size: 0.85rem; }
.csv-req { font-size: 0.68rem; font-weight: 700; color: var(--danger); text-transform: uppercase; letter-spacing: 0.04em; margin-left: 0.25rem; }
.csv-sample { color: var(--muted); font-size: 0.88rem; max-width: 16rem; overflow-wrap: anywhere; }
.modal .csv-import { max-width: 46rem; }
.csv-report { list-style: none; margin: 0.9rem 0 0; padding: 0.8rem 0.9rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 0.3rem; font-size: 0.92rem; }
#csv-report .form-error { margin-top: 0.9rem; }
.modal-form .file-btn { align-self: flex-start; }

/* ------------------------------------------------------ Root dashboard */

.dash-head { align-items: flex-start; margin-bottom: 1.5rem; }
.dash-head .muted { max-width: 58ch; }
.eyebrow { margin: 0 0 0.2rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--brand); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.15rem 1.05rem; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--line-strong); }
.kpi-money::before { background: linear-gradient(90deg, var(--brand), #d9b862); }
.kpi-label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; color: var(--muted); text-transform: uppercase; }
.kpi-value { font-size: 1.9rem; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-money .kpi-value { color: var(--brand-dark); }
.kpi-foot { font-size: 0.82rem; color: var(--muted); }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }

.chip-stats { list-style: none; margin: 0 0 1.5rem; padding: 0.35rem 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chip-stats li { padding: 0.65rem 1.1rem; display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; border-left: 1px solid var(--line); }
.chip-stats li:first-child { border-left: 0; }
.chip-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.chip-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-note { font-size: 0.76rem; color: var(--muted); }

.dash-cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); gap: 1.25rem; align-items: start; }
.dash-main, .dash-side { min-width: 0; }
.dash-main > .card:last-child, .dash-side > .card:last-child { margin-bottom: 0; }

.trend-card .legend { font-size: 0.78rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-key + span, .legend-rev { margin-left: 0; }
.legend-sign { margin-left: 0.6rem; }
.legend-rev { background: #c39c4c; }
.legend-sign { background: #9db7dc; }
.trend-rows { display: grid; gap: 0.5rem; }
.trend-row { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr) auto; align-items: center; gap: 0.85rem; }
.trend-month { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.trend-bars { display: block; min-width: 0; }
.trend-svg { display: block; width: 100%; height: 26px; }
.trend-figs { display: grid; justify-items: end; gap: 0; font-size: 0.8rem; line-height: 1.35; font-variant-numeric: tabular-nums; }
.trend-figs strong { font-size: 0.9rem; }

.todo-card { border-left: 3px solid var(--warning); }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.todo-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.8rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.todo-list li > div { display: grid; gap: 0.1rem; min-width: 0; }
.todo-list strong { font-size: 0.92rem; }
.todo-bad { background: var(--danger-tint); border-color: var(--edge-danger); }
.todo-bad strong { color: var(--danger); }
.todo-warn { background: var(--warning-tint); border-color: #f0dcae; }
.all-clear { margin: 0; font-size: 0.92rem; color: var(--muted); }
.todo-card:has(.all-clear) { border-left-color: var(--success); }

.plan-rows { display: grid; gap: 0.5rem; margin-bottom: 0.8rem; }
.plan-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.75rem; align-items: baseline;
  padding: 0.6rem 0.8rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.plan-name { font-weight: 600; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.plan-price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan-price small { font-size: 0.76rem; font-weight: 500; color: var(--muted); }
.plan-price.alt { grid-column: 2; font-weight: 600; font-size: 0.88rem; color: var(--muted); }

.setup-list { list-style: none; margin: 0 0 0.8rem; padding: 0; display: grid; gap: 0.1rem; font-size: 0.9rem; }
.setup-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.6rem; padding: 0.5rem 0; border-top: 1px solid var(--line); }
.setup-list li:first-child { border-top: 0; }
.setup-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-list a { font-size: 0.85rem; font-weight: 600; text-decoration: none; white-space: nowrap; }

@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chip-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chip-stats li:nth-child(4) { border-left: 0; }
}
@media (max-width: 1000px) {
  .dash-cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .chip-stats { grid-template-columns: minmax(0, 1fr); }
  .chip-stats li { border-left: 0; border-top: 1px solid var(--line); }
  .chip-stats li:first-child { border-top: 0; }
  .trend-row { grid-template-columns: 2.4rem minmax(0, 1fr); }
  .trend-figs { grid-column: 2; justify-items: start; }
}

/* ------------------------------------ document list, compact (phone) layout */

/* Pieces the wide table has no room for: they only appear once the table becomes a list. */
.row-type, .row-when, .year-row, .row-docs { display: none; }

@media (max-width: 640px) {
  .docs-table { display: block; }
  .docs-table thead { display: none; }
  .docs-table tbody { display: block; }
  .table-wrap:has(.docs-table) { overflow-x: visible; }

  /* Each document becomes a two-line row: who and what on the left, how much and when on the right. */
  /* Each document is its own card with air around it, rather than a row in a ruled table. It reads
     better at arm's length and gives the whole document a tap target instead of a line of text. */
  .docs-table tbody tr[data-id] { display: grid; grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.75rem; row-gap: 0.1rem; padding: 0.75rem 0.85rem; margin-bottom: 0.5rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
  .docs-table tbody tr[data-id] td { display: block; padding: 0; border: 0; }
  .docs-table tbody tr[data-id]:last-child { margin-bottom: 0; }
  /* The card is the surface now, so the card it sits in gives up its own padding and lines. */
  .workspace .card:has(.docs-table) { background: none; border: 0; box-shadow: none; padding-inline: 0; }
  /* Nothing can be selected here, so the bar the selection drives has nothing to say. */
  .workspace .action-bar { display: none; }
  .docs-table tbody tr.is-selected td { background: none; }

  .docs-table tbody tr[data-id] td.c-select, .docs-table tbody tr[data-id] td.c-type,
  .docs-table tbody tr[data-id] td.c-status, .docs-table tbody tr[data-id] td.c-issued,
  .docs-table tbody tr[data-id] td.c-balance, .docs-table tbody tr[data-id] td.c-company { display: none; }

  /* The number is what somebody looks for, so it leads, with the amount beside it; the customer and
     where the document stands read underneath. The right-hand cell spans both lines and spaces itself,
     which is what keeps the two columns level — the old version let the amount cell grow to two lines
     and pushed everything below it out of line. */
  .docs-table tbody tr[data-id] td.c-number { grid-column: 1; grid-row: 1; font-size: 1.02rem; font-weight: 700;
    line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .docs-table .c-number .doc-link { color: var(--text); text-decoration: none; font-weight: 700; }
  .docs-table tbody tr[data-id] td.c-customer { grid-column: 1; grid-row: 2; font-size: 0.88rem; color: var(--muted);
    line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .docs-table tbody tr[data-id] td.c-total { grid-column: 2; grid-row: 1 / span 2; display: flex;
    flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 0.1rem;
    text-align: right; font-size: 1.02rem; font-weight: 700; line-height: 1.3; }

  /* The number line carries the type, since the type column is gone. */
  .docs-table .row-type { display: inline; }
  .docs-table .row-type::before { content: " · "; }
  .docs-table .ver-tag { font-size: 0.72rem; }

  /* Where it stands, in the same colour as the dot beside the number, so the two agree. */
  .docs-table .row-when { display: block; font-size: 0.88rem; font-weight: 600; color: var(--muted); text-align: right;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .docs-table .when-late { color: var(--danger); }
  .docs-table .when-paid { color: var(--success); }
  .docs-table .when-part { color: var(--warning); }
  .docs-table .when-old { color: var(--line-strong); }
  .docs-table tbody tr[data-id] { row-gap: 0.15rem; padding: 0.75rem 0.15rem; }

  /* A quiet band at the start of each year, with that year's total. Also on a customer's own page,
     where the same rows are listed under Previous documents. */
  .docs-table .year-row, .stack-table .year-row { display: block; }
  .docs-table .year-row > td, .stack-table .year-row > td { display: flex; justify-content: space-between;
    gap: 1rem; align-items: baseline; padding: 0.35rem 0.2rem 0.5rem; margin: 0.4rem 0 0.1rem; border: 0;
    background: none; font-size: 0.95rem; font-weight: 400; }
  .docs-table .year-row > td::before, .stack-table .year-row > td::before { content: none; }
  .docs-table tbody tr.year-row:first-child > td,
  .stack-table tbody tr.year-row:first-child > td { border-top: 0; }
  .stack-table tbody tr.year-row { padding: 0; border-bottom: 0; }
  .year-name { font-weight: 600; color: var(--muted); }
  .year-total { font-weight: 700; font-variant-numeric: tabular-nums; }

  /* Room for the list: the tools stop competing for the width. */
  /* My customers reads the same way: who and how to reach them, against what they owe. */
  .cust-table { display: block; }
  .cust-table thead { display: none; }
  .cust-table tbody { display: block; }
  .cust-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 0.75rem;
    row-gap: 0.1rem; padding: 0.8rem 0.15rem; border-bottom: 1px solid var(--line); }
  .cust-table tbody tr:last-child { border-bottom: 0; }
  .cust-table tbody tr td { display: block; padding: 0; border: 0; }
  .cust-table tbody tr td.c-name { grid-column: 1; grid-row: 1; font-size: 1.02rem; line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cust-table .c-name a { text-decoration: none; color: var(--text); }
  .cust-table tbody tr td.c-contact,
  .cust-table tbody tr td.c-email,
  .cust-table tbody tr td.c-phone,
  .cust-table tbody tr td.c-tax,
  .cust-table tbody tr td.c-addr { grid-column: 1; font-size: 0.86rem; color: var(--muted); max-width: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cust-table tbody tr td.c-contact { grid-row: 2; color: var(--text); }
  .cust-table tbody tr td.c-email { grid-row: 3; }
  .cust-table tbody tr td.c-phone { grid-row: 4; }
  .cust-table tbody tr td.c-tax { grid-row: 5; }
  .cust-table tbody tr td.c-addr { grid-row: 6; white-space: normal; }
  .cust-table tbody tr td.is-empty { display: none; }
  .csv-map thead { display: none; }
  .csv-map, .csv-map tbody, .csv-map tr, .csv-map th, .csv-map td { display: block; }
  .csv-map tr { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
  .csv-map th, .csv-map td { border: 0; padding: 0.15rem 0; max-width: none; }
  .cust-table tbody tr td.c-owed { grid-column: 2; grid-row: 1; text-align: right; font-size: 1.02rem; font-weight: 600; }
  .cust-table tbody tr td.c-docs { grid-column: 2; grid-row: 2; text-align: right; font-size: 0.86rem;
    color: var(--muted); font-weight: 500; }
  /* The bare count belongs under a column heading; with the heading gone it needs the word too. */
  .cust-table tbody tr td.c-docs { font-size: 0; }
  .cust-table .row-docs { display: inline; font-size: 0.86rem; white-space: nowrap; }
  .cust-table tbody tr td.empty { display: block; grid-column: 1 / -1; font-size: 0.92rem; }

  /* Stacked tiles would push the list itself off the screen, so they become one swipeable row. */
  .stats { display: flex; grid-template-columns: none; gap: 0.6rem; overflow-x: auto;
    scroll-snap-type: x proximity; padding-bottom: 0.25rem; margin-bottom: 1rem; }
  .stats .stat { flex: 0 0 66%; scroll-snap-align: start; padding: 0.75rem 0.85rem; }
  .stats .stat-value { font-size: 1.25rem; }

  /* The Projects sub-menu scrolls sideways rather than falling onto a second line. */
  /* Narrow screens scroll the track sideways rather than stacking the tabs. */
  .subnav { display: flex; overflow-x: auto; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav a { flex: none; }

  .list-tools { flex-direction: column; align-items: stretch; gap: 0.6rem; min-width: 0; }
  /* An explicit width pins these to the column, so the tab strip scrolls inside itself instead of
     stretching the page. min-width alone is not enough: the strip is sized by its own content. */
  .list-tools > * { width: 100%; }
  .segmented { flex-wrap: nowrap; overflow-x: auto; min-width: 0; width: 100%; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { white-space: nowrap; flex: none; }
  .list-tools-right { flex-direction: column; align-items: stretch; gap: 0.5rem; min-width: 0; }
  .list-tools-right .search { max-width: none; min-width: 0; }
  .list-tools-right .search input { width: 100%; }
}

/* ------------------------------------------- bottom tab bar (phone and tablet) */

/* Off on a wide screen, where the same five places sit in the top bar. */
.tabbar { display: none; }

@media (max-width: 820px) {
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    box-shadow: 0 -2px 12px rgba(20, 28, 45, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabbar a, .tabbar button { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
    align-items: center; gap: 0.15rem; padding: 0.5rem 0.2rem 0.45rem; text-decoration: none; color: var(--muted);
    background: none; border: 0; font: inherit; cursor: pointer; }
  .tabbar a.is-active, .tabbar button.is-active { color: var(--brand); }
  .tabbar-icon { position: relative; display: block; line-height: 0; }
  .tabbar-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a.is-active .tabbar-label, .tabbar button.is-active .tabbar-label { font-weight: 700; }
  /* The selected tab is marked above the icon as well as by colour, for anyone who cannot see the colour. */
  .tabbar a.is-active::before, .tabbar button.is-active::before { content: ""; position: absolute; top: 0; width: 34px; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--brand); }
  .tabbar-pro { position: absolute; top: -5px; left: 13px; font-size: 0.5rem; font-weight: 800; letter-spacing: 0.04em;
    color: #2a2110; background: linear-gradient(100deg, #9a7630, #d9b862 50%, #a98336); border-radius: 999px; padding: 0.05rem 0.25rem;
    line-height: 1.3; }

  /* Room for the bar, so it never covers the end of a page. */
  body.has-tabbar { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  body.has-tabbar .sitefoot { margin-bottom: 0.25rem; }
}

/* --------------------------------------- any other table, folded up on a phone */

@media (max-width: 640px) {
  .stack-table, .stack-table tbody, .stack-table tbody > tr { display: block; }
  .stack-table thead { display: none; }
  .stack-table tbody > tr:not(.year-row) { padding: 0.75rem 0.15rem; border-bottom: 1px solid var(--line); }
  .stack-table tbody > tr:last-child { border-bottom: 0; }
  /* Heading on the left, the value (or values) gathered on the right. */
  .stack-table tbody > tr:not(.year-row) > td { padding: 0.15rem 0; border: 0; display: flex; flex-wrap: wrap;
    align-items: baseline; justify-content: flex-end; gap: 0 0.7rem; text-align: left; }
  .stack-table tbody > tr:not(.year-row) > td::before { content: attr(data-label); flex: none; margin-right: auto;
    color: var(--muted); font-size: 0.82rem; font-weight: 600; }
  .stack-table tbody > tr:not(.year-row) > td:not([data-label])::before { content: none; }
  /* The first column names the row, so it reads as a heading instead of another label and value. */
  .stack-table tbody > tr:not(.year-row) > td:first-child { display: block; font-size: 1rem; font-weight: 600;
    margin-bottom: 0.3rem; line-height: 1.35; }
  .stack-table tbody > tr:not(.year-row) > td:first-child::before { content: none; }
  .stack-table tbody > tr:not(.year-row) > td.num { font-variant-numeric: tabular-nums; }
  /* A cell of buttons goes full width underneath rather than squeezing in beside a label. */
  .stack-table tbody > tr:not(.year-row) > td.actions { justify-content: flex-start; margin-top: 0.45rem; }
  .stack-table tbody > tr > td.empty { display: block; text-align: center; padding: 1.5rem 0.5rem; }
  .stack-table tbody > tr > td.select { display: none; }
  .table-wrap:has(.stack-table) { overflow-x: visible; }
}

/* ------------------------------------- the round + (phone and tablet only) */

.fab-wrap { display: none; }

@media (max-width: 820px) {
  /* Comfortable to hit with a thumb: bigger tick boxes, and text buttons with some height to them. */
  input[type="checkbox"], input[type="radio"] { inline-size: 1.15rem; block-size: 1.15rem; }
  .linklike { padding-block: 0.3rem; }
  .row-actions .linklike, td .linklike { padding-block: 0.4rem; }

  /* The + button does this on a phone, so the top bar keeps only what is not already elsewhere.
     Not the public pair, though: on the home page those two buttons are the way in. */
  .topbar-actions > .btn-primary:not(.btn-public) { display: none; }

  .fab-wrap { display: block; position: fixed; inset-inline-end: 16px; z-index: 31;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }   /* clear of the tab bar */
  .fab { width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
    background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(31, 78, 140, 0.4);
    transition: transform 0.18s ease, background 0.18s ease; }
  .fab:hover { background: var(--brand-dark); }
  .fab:focus-visible { outline: none; box-shadow: var(--focus), 0 4px 14px rgba(31, 78, 140, 0.4); }
  .fab[aria-expanded="true"] { transform: rotate(45deg); background: var(--text); }

  .fab-menu { position: absolute; right: 0; bottom: 68px; display: flex; flex-direction: column;
    align-items: flex-end; gap: 0.6rem; }
  .fab-item { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); }
  .fab-item-label { background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    padding: 0.3rem 0.6rem; font-size: 0.86rem; font-weight: 600; box-shadow: var(--shadow); white-space: nowrap; }
  .fab-item-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--surface); color: var(--brand);
    border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; flex: none; }
  .fab-item:hover .fab-item-icon { background: var(--brand-tint); }
  .fab-item:focus-visible { outline: none; }
  .fab-item:focus-visible .fab-item-icon { box-shadow: var(--focus); }

  /* A quiet layer behind the open menu, so a tap anywhere closes it and the page recedes. */
  .fab-veil { position: fixed; inset: 0; z-index: 30; background: rgba(20, 28, 45, 0.28); border: 0; }

  /* With the + there, New document on the page itself is a second button for one job. */
  .workspace .page-head-actions .btn-primary[href^="create-document"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .fab { transition: none; }
}

/* The help button keeps out of the way of the + and the tab bar on a small screen. */
@media (max-width: 820px) {
  .help-fab { right: auto; left: 16px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); width: 48px; height: 48px; }
  .help-panel { right: 12px; left: 12px; width: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    max-height: min(70vh, calc(100vh - 12rem)); }
}
@media (prefers-reduced-motion: reduce) { .help-fab { transition: none; } }

/* ------------------------------- the sheets behind Search and More (phone and tablet) */

.tabsheet { display: none; }

@media (max-width: 820px) {
  .tabsheet { display: flex; position: fixed; inset: 0; z-index: 45; flex-direction: column;
    background: var(--bg); padding-bottom: calc(57px + env(safe-area-inset-bottom, 0px)); }
  .tabsheet[hidden] { display: none; }
  .tabsheet-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
    padding: 0.75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
  .tabsheet-head strong { font-size: 1.05rem; }
  .tabsheet-body { flex: 1; overflow-y: auto; padding: 0.9rem 1rem 1.5rem; -webkit-overflow-scrolling: touch; }
  .tabsheet-heading { margin: 0.4rem 0 0.5rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted); }
  .tabsheet-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; margin-bottom: 1.1rem; }
  .tabsheet-list a { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 0.9rem;
    text-decoration: none; color: var(--text); border-top: 1px solid var(--line); }
  .tabsheet-list a:first-child { border-top: 0; }
  .tabsheet-list a.is-here { background: var(--brand-tint); }
  .tabsheet-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); color: var(--brand);
    border: 1px solid var(--line); display: grid; place-items: center; flex: none; }
  .tabsheet-list a.is-here .tabsheet-icon { background: var(--surface); border-color: var(--edge-brand); }
  .tabsheet-text { display: grid; gap: 0.05rem; min-width: 0; }
  .tabsheet-text strong { font-size: 0.95rem; }
  .tabsheet-text .muted { font-size: 0.8rem; }
  .tabsheet-signout .btn-block { width: 100%; }

  /* Search */
  /* label is a column elsewhere in the app, so this one says so explicitly. */
  .search-field { flex: 1; min-width: 0; display: flex; flex-direction: row; align-items: center; gap: 0.5rem;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 0.15rem 0.65rem;
    color: var(--muted); }
  .search-field svg { flex: none; }
  .search-field input { flex: 1; border: 0; background: none; padding: 0.55rem 0; font-size: 1rem; min-width: 0; }
  .search-field input:focus { outline: none; }
  .search-field:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
  .search-hint, .search-empty { margin: 0.6rem 0.2rem; color: var(--muted); font-size: 0.9rem; }
  .search-group { margin-bottom: 1.1rem; }
  .search-group h3 { margin: 0 0 0.5rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted); }
  .search-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .search-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 0.75rem; align-items: baseline;
    padding: 0.7rem 0.9rem; text-decoration: none; color: var(--text); border-top: 1px solid var(--line); }
  .search-list a:first-child { border-top: 0; }
  .search-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .search-badge { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .search-sub { grid-column: 1 / -1; font-size: 0.82rem; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* While a sheet is up, the buttons that float over the page would sit on top of it. */
  body.sheet-open .fab-wrap, body.sheet-open .help-fab, body.sheet-open .help-panel { display: none; }
}

/* ---------------------------------------------------------------- saved items */

.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stats-3 { grid-template-columns: minmax(0, 1fr); } }

.item-group { margin-top: 1.1rem; }
.item-group:first-of-type { margin-top: 0.4rem; }
.item-group-head { font-size: 0.76rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 0.5rem; }
.item-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem 1rem; align-items: start;
  padding: 0.75rem 0.9rem; border-top: 1px solid var(--line); cursor: pointer; }
.item-list li:first-child { border-top: 0; }
.item-list li:hover { background: var(--surface-2); }
.item-main { display: grid; gap: 0.2rem; min-width: 0; }
.item-main strong { font-size: 0.95rem; line-height: 1.35; }
/* The body is the whole description, kept to a few lines so a long specification does not fill the page. */
.item-body { font-size: 0.85rem; color: var(--muted); line-height: 1.5; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item-meta { font-size: 0.8rem; color: var(--muted); }
.item-price { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
  display: grid; gap: 0.1rem; justify-items: end; }

/* Saved items panel: categories, and a glimpse of a long description. */
.saved-cat { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); padding: 0.7rem 0.1rem 0.25rem; list-style: none; }
.saved-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-line; font-size: 0.8rem; color: var(--muted); line-height: 1.45; margin-top: 0.15rem; }

/* Terms library */
.terms-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem 0.75rem; align-items: start;
  padding: 0.85rem; margin-bottom: 0.6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.terms-row .terms-name { grid-column: 1; }
.terms-row .terms-types { grid-column: 1 / -1; border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.terms-row .terms-types legend { font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 0.2rem; }
.terms-row .terms-types .checkbox-row { font-weight: 500; }
.terms-row .terms-text { grid-column: 1 / -1; }
.terms-row .icon-btn { grid-column: 2; grid-row: 1; }
.terms-defaults { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px dashed var(--line); }
@media (max-width: 560px) { .terms-row .terms-types { flex-direction: column; gap: 0.15rem; } }

/* ------------------------------- global search from the top bar (wide screens) */

.topbar-search { display: none; }

@media (min-width: 821px) {
  .topbar-search { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
    border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
  .topbar-search:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
  .topbar-search:focus-visible { outline: none; box-shadow: var(--focus); }
  .topbar-search[aria-expanded="true"] { background: var(--brand-tint); border-color: var(--edge-brand); color: var(--brand); }

  /* On a wide screen the search is a panel over the page rather than a full screen, and the More sheet
     is not offered at all: those places are all in the top bar already. */
  .tabsheet-search { display: flex; position: fixed; inset: 0; z-index: 45; flex-direction: column;
    align-items: center; padding: 10vh 1rem 2rem; background: rgba(20, 28, 45, 0.35); }
  .tabsheet-search[hidden] { display: none; }
  /* The head's flex rule lives in the narrow-screen block, so it is stated again here. */
  .tabsheet-search .tabsheet-head { display: flex; align-items: center; gap: 0.75rem;
    width: 100%; max-width: 640px; background: var(--surface);
    border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
    padding: 0.75rem 0.9rem; box-shadow: 0 24px 60px rgba(20, 28, 45, 0.3); }
  .tabsheet-search .tabsheet-body { width: 100%; max-width: 640px; background: var(--surface);
    border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius);
    padding: 0.9rem; max-height: 60vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(20, 28, 45, 0.3); }
  .tabsheet-search .search-field { flex: 1; min-width: 0; display: flex; flex-direction: row; align-items: center;
    gap: 0.5rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 0.15rem 0.65rem; color: var(--muted); }
  .tabsheet-search .search-field svg { flex: none; }
  .tabsheet-search .search-field input { flex: 1; border: 0; background: none; padding: 0.55rem 0; font-size: 1rem; min-width: 0; }
  .tabsheet-search .search-field input:focus { outline: none; }
  .tabsheet-search .search-field:focus-within { border-color: var(--brand); box-shadow: var(--focus); }
  .tabsheet-search .search-hint, .tabsheet-search .search-empty { margin: 0.5rem 0.2rem; color: var(--muted); font-size: 0.9rem; }
  .tabsheet-search .search-group { margin-bottom: 1rem; }
  .tabsheet-search .search-group:last-child { margin-bottom: 0; }
  .tabsheet-search .search-group h3 { margin: 0 0 0.45rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted); }
  .tabsheet-search .search-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .tabsheet-search .search-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 0.75rem;
    align-items: baseline; padding: 0.6rem 0.8rem; text-decoration: none; color: var(--text); border-top: 1px solid var(--line); }
  .tabsheet-search .search-list a:first-child { border-top: 0; }
  .tabsheet-search .search-list a:hover { background: var(--surface-2); }
  .tabsheet-search .search-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabsheet-search .search-badge { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .tabsheet-search .search-sub { grid-column: 1 / -1; font-size: 0.82rem; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---------------------------------------------------------------- reports */

.report-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.85rem 1rem; align-items: end; }
.report-go { grid-column: 1 / -1; }
@media (max-width: 1100px) { .report-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.report-banner { margin: 0 0 1rem; padding: 0.8rem 1rem; border-radius: var(--radius); font-weight: 500;
  background: var(--brand-tint); color: var(--brand-dark); border: 1px solid var(--edge-brand); }
.report-banner-ok { background: var(--success-tint); color: var(--success); border-color: var(--edge-success); }
.report-banner-bad { background: var(--danger-tint); color: var(--danger); border-color: var(--edge-danger); }

/* Tabs above the table: the periods, then what you can do with what is showing. */
.report-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: -1px; }
.rtab { display: inline-flex; align-items: center; gap: 0.4rem; font: inherit; font-size: 0.88rem; font-weight: 600;
  padding: 0.55rem 0.9rem; border: 1px solid var(--line); border-bottom-color: transparent;
  border-radius: 9px 9px 0 0; background: var(--surface-2); color: var(--text); cursor: pointer; }
.rtab:hover { background: var(--surface); }
.rtab.is-on { background: var(--surface); border-bottom-color: var(--surface); box-shadow: inset 0 2px 0 var(--brand); }
.rtab:disabled { opacity: 0.55; cursor: default; }
.rtab-count { font-size: 0.74rem; font-weight: 700; background: var(--brand); color: #fff; border-radius: 999px; padding: 0.05rem 0.4rem; }
.rtab-clear { margin-left: 0.15rem; font-size: 1rem; line-height: 1; color: var(--muted); }
.rtab-clear:hover { color: var(--danger); }
.rtab-ico { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.03em; padding: 0.1rem 0.28rem; border-radius: 4px; color: #fff; }
.rtab-pdf { background: #b3261e; }
.rtab-xls { background: #17794f; }

.report-results { border-top-left-radius: 0; }
.report-what { margin: 0 0 0.9rem; font-size: 0.9rem; color: var(--muted); }
.report-clear { margin: 0 0 0.6rem; text-align: center; }
.report-clear .linklike { color: var(--danger); font-weight: 600; }
.report-table .rtype { display: block; font-size: 0.78rem; color: var(--muted); }
.rsort { font: inherit; font-size: inherit; font-weight: inherit; letter-spacing: inherit; text-transform: inherit;
  color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem; }
.rsort-mark { font-size: 0.7rem; color: var(--line-strong); }
.rsort.is-on { color: var(--brand); }
.rsort.is-on .rsort-mark { color: var(--brand); }

.past-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.past-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 0.75rem; align-items: center;
  padding: 0.7rem 0.9rem; border-top: 1px solid var(--line); }
.past-list li:first-child { border-top: 0; }
.past-kind { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.03em; padding: 0.2rem 0.35rem; border-radius: 4px; color: #fff; }
.past-pdf { background: #b3261e; }
.past-xlsx { background: #17794f; }
.past-main { display: grid; gap: 0.1rem; min-width: 0; }
.past-main .muted { font-size: 0.8rem; }

@media print {
  .topbar, .report-filters, .report-tabs, .report-banner, .sitefoot, .help-fab, .fab-wrap, .tabbar { display: none !important; }
  .report-results { border: 0; box-shadow: none; padding: 0; }
}
@media (max-width: 640px) {
  .past-list li { grid-template-columns: auto minmax(0, 1fr) auto; }
  .past-list li .icon-btn { grid-column: 3; }
}

/* ------------------------------------------------- the client sidebar (wide screens) */

/* Seven places to go is more than a row of links can carry without wrapping, so they stand in a column
   beside the page, the way the platform administration side of the app already does. Below 820px the
   bar along the bottom takes over and this disappears entirely. */
.appshell { display: block; width: 100%; }
.appbar { display: none; }

@media (min-width: 821px) {
  .appshell { display: grid; grid-template-columns: 216px minmax(0, 1fr); align-items: start; gap: 1.5rem;
    width: 100%; max-width: 1480px; margin: 0 auto; padding: 0 1.25rem; }
  .appshell > main.page, .appshell > main.page.narrow { width: 100%; max-width: none; margin: 0;
    padding-left: 0; padding-right: 0; }
  .appshell > main.narrow > * { max-width: 880px; }

  body.has-appbar .brand, body.has-rootbar .brand { margin-inline-start: 0.75rem; }
  .appbar { display: block; position: sticky; top: 76px; padding: 1.25rem 0 1.5rem; }
  .appnav { display: flex; flex-direction: column; gap: 0.15rem; }
  .appnav a { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.75rem; border-radius: 0.6rem;
    text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.92rem; }
  .appnav a:hover { background: var(--surface); color: var(--text); }
  .appnav a.is-active { background: var(--brand-tint); color: var(--brand); }
  /* Each section has its own colour: the icon sits on a soft tile of it, and the page you are on
     fills its tile solid. --ic is the colour, --ic-bg the tint behind it. */
  .appnav-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 9px;
    color: var(--ic, var(--muted)); background: var(--ic-bg, transparent); transition: background .15s, color .15s; }
  .appnav-icon svg { width: 19px; height: 19px; }
  .appnav a.is-active .appnav-icon { background: var(--ic, var(--brand)); color: #fff; }
  .appnav-icon--documents { --ic: #a8842f; --ic-bg: #c39c4c24; }
  .appnav-icon--customers { --ic: #7556d4; --ic-bg: #7556d41f; }
  .appnav-icon--projects  { --ic: #e2731b; --ic-bg: #e2731b1f; }
  .appnav-icon--reports   { --ic: #2d6be0; --ic-bg: #2d6be01f; }
  .appnav-icon--items     { --ic: #d8447f; --ic-bg: #d8447f1f; }
  .appnav-icon--layouts   { --ic: #0b8fc4; --ic-bg: #0b8fc41f; }
  .appnav-icon--business  { --ic: #e05a43; --ic-bg: #e05a431f; }
  .appnav-icon--getpaid   { --ic: #179c55; --ic-bg: #179c551f; }
  .appnav-icon--settings  { --ic: #b47b07; --ic-bg: #b47b071f; }
  .appnav-icon--team      { --ic: #4f57d6; --ic-bg: #4f57d61f; }
  .appnav-icon--account   { --ic: #5b6b80; --ic-bg: #5b6b801f; }
  .appnav-icon--help      { --ic: #0e7480; --ic-bg: #0e74801f; }
  .appnav-label { min-width: 0; }

  /* The document editor needs its width for the form and the A4 preview, so there it is icons only. */
  body.rail-only .appshell { grid-template-columns: 60px minmax(0, 1fr); gap: 1rem; }
  body.rail-only .appnav a { justify-content: center; padding: 0.65rem 0; }
  body.rail-only .appnav-label { display: none; }
}

/* Between 821 and 1180 the labels would squeeze the page, so the rail is used there too. */
@media (min-width: 821px) and (max-width: 1180px) {
  .appshell { grid-template-columns: 60px minmax(0, 1fr); gap: 1rem; }
  .appnav a { justify-content: center; padding: 0.65rem 0; }
  .appnav-label { display: none; }
}

/* ---------------------------------------------------------------- dark theme
 *
 * The palette is almost entirely tokens, so the dark theme is a second set of them and nothing else has
 * to be written twice. The same set is declared in two places: once for the system preference, which
 * applies on its own, and once for an explicit choice, which overrides the system either way.
 *
 * What stays light on purpose: anything standing in for paper. A layout thumbnail, a logo preview and
 * the A4 document itself are pictures of a printed page, and a printed page is white in any theme.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #1c2026;
    --surface-2: #232831;
    --line: #303640;
    --line-strong: #414955;
    --text: #eceef1;
    --muted: #a0a8b4;
    --label: #c9cfd8;
    --brand: #d9b862;
    --brand-dark: #ecd48b;
    /* Gold, so a filled button stands out on the dark page. It is too light for white text, so every
       surface filled with it writes dark ink instead (see "Text on gold" below the dark theme). */
    --brand-solid: #c9a24f;
    --brand-solid-hover: #ddb95f;
    --brand-tint: #2b2618;
    --success: #5fd3a0;
    --success-tint: #16302a;
    --success-ink: #8fe3bd;
    --warning: #e0b061;
    --warning-tint: #33290f;
    --warning-ink: #f0cd92;
    --danger: #ff8d85;
    --danger-tint: #3a1e1f;
    --danger-ink: #ffb4ad;
    --info: #8fbaf0;
    --info-tint: #1b2a3f;
    --plum: #c3a8ef;
    --plum-tint: #2a2140;
    --edge-brand: #5a4a26;
    --edge-success: #245c47;
    --edge-danger: #6b3733;
    --edge-warning: #5a4620;
    --edge-info: #2d4a70;
    --edge-plum: #46356b;
    --inverse: #eceef1;
    --inverse-ink: #14171c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    --focus: 0 0 0 3px rgba(217, 184, 98, 0.4);
    color-scheme: dark;
  }
}

/* Chosen by hand, either way, overriding whatever the system prefers. */
:root[data-theme="light"] { color-scheme: light; }

:root[data-theme="dark"] {
  --bg: #14171c;
  --surface: #1c2026;
  --surface-2: #232831;
  --line: #303640;
  --line-strong: #414955;
  --text: #eceef1;
  --muted: #a0a8b4;
  --label: #c9cfd8;
  --brand: #d9b862;
  --brand-dark: #ecd48b;
  /* Set here as well as in the automatic dark theme above: without it this block falls back to
     the light theme's near-black button, which on a near-black page cannot be seen at all. */
  --brand-solid: #c9a24f;
  --brand-solid-hover: #ddb95f;
  --brand-tint: #2b2618;
  --success: #5fd3a0;
  --success-tint: #16302a;
  --success-ink: #8fe3bd;
  --warning: #e0b061;
  --warning-tint: #33290f;
  --warning-ink: #f0cd92;
  --danger: #ff8d85;
  --danger-tint: #3a1e1f;
  --danger-ink: #ffb4ad;
  --info: #8fbaf0;
  --info-tint: #1b2a3f;
  --plum: #c3a8ef;
  --plum-tint: #2a2140;
  --edge-brand: #5a4a26;
  --edge-success: #245c47;
  --edge-danger: #6b3733;
  --edge-warning: #5a4620;
  --edge-info: #2d4a70;
  --edge-plum: #46356b;
  --inverse: #eceef1;
  --inverse-ink: #14171c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  --focus: 0 0 0 3px rgba(217, 184, 98, 0.4);
  color-scheme: dark;
}

/* Text on gold. In the dark theme the brand colours are gold, which is too light for white text, so
   everything filled with them writes dark ink instead. */
:root[data-theme="dark"] :is(.btn-primary, .btn-primary:hover, .subnav a.is-active, .advanced-arrow, .help-fab, .help-you .help-bubble,
  .count-badge, .drag-ghost span, .set-toggle-arrow, .company-initial, .fab, .rtab-count, .money-chip.is-on) { color: #1d1606; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.btn-primary, .btn-primary:hover, .subnav a.is-active, .advanced-arrow, .help-fab, .help-you .help-bubble,
    .count-badge, .drag-ghost span, .set-toggle-arrow, .company-initial, .fab, .rtab-count, .money-chip.is-on) { color: #1d1606; }
}
/* a faint gold rule under the top bar, as on the home page */
.topbar { box-shadow: inset 0 -2px 0 -1px rgba(195, 156, 76, 0.35); }

/* The light/dark switch. One button showing the theme you would move to. */
.topbar-theme { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; flex: none; }
.topbar-theme:hover { background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.topbar-theme:focus-visible { outline: none; box-shadow: var(--focus); }
.topbar-theme .theme-moon { display: none; }
.topbar-theme[aria-pressed="true"] .theme-sun { display: none; }
.topbar-theme[aria-pressed="true"] .theme-moon { display: block; }

/* Paper stays paper. A layout thumbnail, a logo preview and the A4 document are pictures of a printed
   page, so they keep their white whichever theme is on. */
:root[data-theme="dark"] .thumb,
:root[data-theme="dark"] .thumb-live,
:root[data-theme="dark"] .upload-preview,
:root[data-theme="dark"] .company-tab img,
:root[data-theme="dark"] .preview-stage { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .thumb,
  :root:not([data-theme="light"]) .thumb-live,
  :root:not([data-theme="light"]) .upload-preview,
  :root:not([data-theme="light"]) .company-tab img,
  :root:not([data-theme="light"]) .preview-stage { color-scheme: light; }
}

/* Business details tabs: the same strip the Projects page uses. */
.biz-tabs { margin-bottom: 1rem; }
.biz-tabs a { cursor: pointer; }

/* ---------------------------------------------------------------- my account */

.acct-tabs { margin-bottom: 1.2rem; flex-wrap: wrap; }
.theme-picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.theme-pick { display: grid; gap: 0.5rem; padding: 0.9rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); cursor: pointer; font-weight: 500; }
.theme-pick.is-on { border-color: var(--brand); background: var(--brand-tint); box-shadow: inset 0 0 0 1px var(--brand); }
.theme-pick input { justify-self: start; }
.theme-swatch { display: grid; gap: 3px; padding: 7px; border-radius: 7px; border: 1px solid var(--line); }
.theme-swatch i { display: block; height: 7px; border-radius: 2px; }
.theme-swatch-light { background: #ffffff; }
.theme-swatch-light i { background: #d7dce4; }
.theme-swatch-light i:first-child { background: #262b33; }
.theme-swatch-dark { background: #14171c; border-color: #303640; }
.theme-swatch-dark i { background: #39434f; }
.theme-swatch-dark i:first-child { background: #d9b862; }
.theme-swatch-system { background: linear-gradient(110deg, #ffffff 0 50%, #14171c 50% 100%); }
.theme-swatch-system i { background: linear-gradient(110deg, #d7dce4 0 50%, #39434f 50% 100%); }
.theme-swatch-system i:first-child { background: linear-gradient(110deg, #262b33 0 50%, #d9b862 50% 100%); }
.theme-text { display: grid; gap: 0.1rem; }
.theme-text .muted { font-size: 0.82rem; font-weight: 400; }
.biz-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.35rem; }
.biz-list li { display: flex; align-items: center; gap: 0.5rem; }
@media (max-width: 700px) { .theme-picks { grid-template-columns: minmax(0, 1fr); } }

/* My account: two columns, so a name field is not the width of the screen. */
.acct-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.acct-cols > .card { margin-bottom: 0; }
.acct-rule { border: 0; border-top: 1px solid var(--line); margin: 1.4rem 0 1.2rem; }
@media (max-width: 980px) { .acct-cols { grid-template-columns: minmax(0, 1fr); } }

/* Terms and conditions, and the consent boxes that go with them */
.foot-links { display: flex; gap: 1rem; flex-wrap: wrap; }
.foot-links a { color: inherit; }
.terms-page .page-head { margin-bottom: 0.75rem; }
.terms-country { display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap; margin: 0 0 1.25rem;
  padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.terms-country .hint { flex-basis: 100%; margin: 0; }
.terms-toc { margin: 0 0 1.25rem; padding: 0.9rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.terms-toc h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 0.5rem; }
.terms-toc ol { margin: 0; padding-left: 1.2rem; columns: 2; column-gap: 2rem; }
.terms-toc li { margin: 0 0 0.25rem; break-inside: avoid; }
.terms-section { scroll-margin-top: 5rem; }
.terms-section h2 { display: flex; align-items: baseline; gap: 0.6rem; font-size: 1.1rem; margin: 0 0 0.75rem; }
.terms-no { flex: none; min-width: 1.6rem; height: 1.6rem; display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }
.terms-section p { margin: 0 0 0.75rem; line-height: 1.6; }
.terms-section p:last-child { margin-bottom: 0; }
.terms-rows { margin: 0 0 1rem; display: grid; gap: 0.5rem; }
.terms-rows > div { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--line); }
.terms-rows > div:last-child { border-bottom: 0; padding-bottom: 0; }
.terms-rows dt { font-weight: 600; }
.terms-rows dd { margin: 0; color: var(--muted); }
@media (max-width: 700px) {
  .terms-toc ol { columns: 1; }
  .terms-rows > div { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
}

/* The tick boxes: the text wraps, so it lines up with the top of the box rather than the middle. */
.consent-block { display: grid; gap: 0.6rem; margin: 0.25rem 0 1rem; padding: 0.85rem 0.95rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
label.checkbox-row.consent-pay, .consent-block label.checkbox-row { align-items: flex-start; align-self: stretch;
  padding-bottom: 0; font-weight: 400; line-height: 1.45; }
.consent-block input[type="checkbox"], .consent-pay input[type="checkbox"] { margin-top: 0.15rem; flex: none; }
label.checkbox-row.consent-pay { margin: 0.6rem 0 0.9rem; }
.terms-box { margin: 1rem 0; padding: 0.75rem 0.95rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.terms-box summary { cursor: pointer; font-weight: 600; }
.terms-box .terms-rows { margin-top: 0.85rem; }
.terms-box .hint { margin: 0; }

/* Get paid: the business's own PayPal and Stripe connections */
.payto-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin: 0.4rem 0 1rem; }
.payto-card { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.payto-card.is-on { border-color: var(--brand); }
.payto-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.75rem; align-items: start; }
.payto-head h3 { margin: 0 0 0.2rem; font-size: 1rem; }
.payto-head p { margin: 0; }
.payto-logo { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700; }
.payto-logo-paypal { background: #003087; }
.payto-logo-stripe { background: #635bff; }
.payto-logo-other { background: var(--brand); }
/* One row per payment link: mark, name and address, whether it is on, and what can be done with it. */
.paylink { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.paylink + .paylink { margin-top: 0.6rem; }
.paylink.is-on { border-color: var(--brand); }
.paylink-main { flex: 1 1 14rem; min-width: 0; display: grid; }
.paylink-url { overflow-wrap: anywhere; }
.paylink-help { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.paylink-help li + li { margin-top: 0.25rem; }
@media (max-width: 640px) {
  .paylink { gap: 0.5rem; }
  .paylink-main { flex-basis: 100%; }
}
.payto-facts { margin: 0.9rem 0 0.6rem; display: grid; gap: 0.3rem; }
.payto-facts > div { display: flex; justify-content: space-between; gap: 1rem; }
.payto-facts dt { color: var(--muted); font-size: 0.86rem; }
.payto-facts dd { margin: 0; font-size: 0.86rem; text-align: right; }
.payto-form { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.payto-form summary { cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.payto-form form { margin-top: 0.8rem; }
.verify-pay { margin: 1.25rem 0; padding: 1rem 1.1rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); }
.verify-pay h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.verify-pay p { margin: 0 0 0.8rem; }
.pay-choices { display: grid; gap: 1rem; margin: 0.5rem 0 1.25rem; }
.pay-choice { margin: 0; }
.pay-choice .hint { margin: 0.4rem 0 0; }

/* The language picker in the top bar: a menu with flags, like the rest of the account furniture. */
.flag { display: block; flex: none; border-radius: 3px; }
.langmenu { position: relative; }
.langmenu > summary { display: flex; align-items: center; gap: 0.4rem; height: 36px; padding: 0 0.55rem; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text);
  font-size: 0.86rem; font-weight: 600; list-style: none; white-space: nowrap; }
.langmenu > summary::-webkit-details-marker { display: none; }
.langmenu > summary:hover { border-color: var(--line-strong); }
.langmenu[open] > summary { border-color: var(--brand); }
.langmenu-now { max-width: 8ch; overflow: hidden; text-overflow: ellipsis; }
.langmenu-panel { position: absolute; top: calc(100% + 0.4rem); inset-inline-end: 0; z-index: 40; min-width: 210px;
  padding: 0.4rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.18); }
.langmenu-panel h2 { margin: 0.25rem 0.55rem 0.4rem; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); }
.langmenu-panel form { margin: 0; }
.langmenu-panel button { display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.45rem 0.55rem;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 0.92rem;
  text-align: start; cursor: pointer; }
.langmenu-panel button:hover { background: var(--surface-2); }
.langmenu-panel button.is-on { color: var(--brand); font-weight: 600; }
.langmenu-panel button span { flex: 1; min-width: 0; }
.langmenu-tick { flex: none; }
@media (max-width: 900px) { .langmenu-now, .langmenu > summary svg:not(.flag) { display: none; } }

/* Appearance on the document form: what is set now, with the picker behind a button. */
.appearance-now { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.25rem 0 0.5rem;
  padding: 0.7rem 0.85rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.appearance-swatch { flex: none; width: 34px; height: 34px; border-radius: 9px; background: var(--sw, var(--brand));
  border: 1px solid rgba(0, 0, 0, 0.12); box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.25); }
.appearance-sum { display: grid; gap: 0.05rem; min-width: 0; flex: 1; }
.appearance-sum strong { font-size: 0.98rem; }
.appearance-now .btn { flex: none; }
#appearance-body { padding-top: 0.25rem; }

/* Signatories in Business details, and the one chosen on a document */
.signatories .hint { margin-top: 0; }
#sig-list { display: grid; gap: 0.75rem; margin: 0.5rem 0 0.9rem; }
.sig-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 1rem; align-items: start;
  padding: 0.85rem 0.95rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.sig-fields { display: grid; gap: 0.6rem; min-width: 0; }
.sig-image .upload-preview { margin: 0.25rem 0 0.4rem; }
.sig-actions { display: grid; gap: 0.4rem; justify-items: start; }
.sig-actions .checkbox-row { align-self: start; padding-bottom: 0; }
.sig-shown .upload-preview { margin-top: 0.3rem; }
.sig-shown img, .sig-image img { max-height: 48px; }
@media (max-width: 760px) { .sig-row { grid-template-columns: minmax(0, 1fr); } }

/* Business details: each subject is its own panel on a tinted ground, so Payment details, bank accounts,
   tax rates and signatories read as separate things rather than one long run of fields. */
.biz-section { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem 1.1rem;
  background: var(--surface-2); margin: 0.35rem 0 0.25rem; }
.biz-section > legend { float: left; width: 100%; margin: 0 0 0.15rem; padding: 0; font-weight: 700;
  font-size: 1rem; color: var(--text); }
.biz-section > legend ~ * { clear: both; }
.biz-section > .hint:first-of-type { margin-top: 0.15rem; }
.biz-section label { display: grid; gap: 0.3rem; }
/* a tick and its words belong on one line, not stacked by the grid above */
.biz-section label.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.biz-section > label + label { margin-top: 0.8rem; }
/* The rows inside a section sit on the card colour, so they stand off the tinted ground. */
.biz-section .sig-row, .biz-section .bank-row, .biz-section .rate-row { background: var(--surface); }

/* A bank account, written field by field */
#banks-list { display: grid; gap: 0.9rem; margin: 0.5rem 0 0.9rem; }
.bank-row { display: grid; gap: 0.8rem; padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.bank-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 0.8rem; align-items: end; }
.bank-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem 0.9rem;
  padding-top: 0.8rem; border-top: 1px solid var(--line); }
.bank-fields .span-2 { grid-column: 1 / -1; }
.bank-label { display: grid; gap: 0.25rem; min-width: 0; font-weight: 600; font-size: 0.88rem; }
.bank-label > span:first-child { display: block; }
.bank-label input, .bank-label select { font-weight: 400; }
.bank-label .req { color: var(--danger); font-weight: 700; }
.bank-fields .checkbox-row { font-weight: 500; padding-bottom: 0; }
@media (max-width: 760px) {
  .bank-head, .bank-fields { grid-template-columns: minmax(0, 1fr); }
  .bank-head .icon-btn { justify-self: end; }
}

/* A saved bank account, shown the way it is printed */
.bank-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 0.85rem 1rem; }
.bank-card.is-main { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.bank-card-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.bank-card-head strong { font-size: 0.98rem; }
.bank-card-head .row-actions { margin-inline-start: auto; display: flex; gap: 0.75rem; }
.bank-block { margin: 0; padding: 0.7rem 0.85rem; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--line); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.bank-editor-actions { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; padding-top: 0.6rem;
  border-top: 1px solid var(--line); }
.bank-editor-actions .field-error { margin: 0; }

/* The chosen account on a document, shown as the block the customer will read */
#f-paymentDetails[readonly] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem; line-height: 1.55; background: var(--surface-2); border-color: var(--line);
  color: var(--text); }
.bank-pick { display: grid; gap: 0.3rem; margin-bottom: 0.6rem; }
.bank-block strong, #payment-shown strong { font-weight: 700; color: var(--text); }

/* Managing the groups saved items are filed under */
.cat-list { list-style: none; margin: 0.5rem 0 1rem; padding: 0; display: grid; gap: 0.4rem; }
.cat-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 0.6rem; align-items: center;
  padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.cat-order { display: flex; gap: 0.15rem; }
.cat-order .icon-btn { width: 26px; height: 26px; font-size: 0.8rem; }
.cat-name { font-weight: 600; }
.cat-count { white-space: nowrap; }
.cat-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem; align-items: end; margin-bottom: 0.5rem; }
.cat-add label { display: grid; gap: 0.25rem; }
@media (max-width: 620px) { .cat-list li { grid-template-columns: auto minmax(0, 1fr); } .cat-count, .cat-list .danger-link { grid-column: 2; justify-self: start; } }
.empty-items { display: grid; gap: 0.9rem; justify-items: start; }
.empty-items .empty { margin: 0; }
.empty-items .hint { margin: 0; }

/* Managing saved items in bulk */
/* The dialog itself has to grow, not just its contents. */
.modal:has(.modal-body.wide) { width: min(94vw, 760px); }
.manage-items { margin: 0.6rem 0 0.2rem; }
.manage-items td { vertical-align: middle; }
.manage-items select { min-width: 10rem; }
.manage-items .actions { display: flex; gap: 0.75rem; justify-content: flex-end; white-space: nowrap; }
#manage-rows { max-height: 48vh; overflow: auto; }

/* Finding an existing saved item before writing a new one */
.item-find { display: grid; gap: 0.4rem; padding: 0.8rem 0.9rem; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2); }
.item-find label { display: grid; gap: 0.25rem; font-weight: 600; font-size: 0.9rem; }
.item-find .hint { margin: 0; }
.find-list { list-style: none; margin: 0.15rem 0 0; padding: 0; display: grid; gap: 0.25rem;
  max-height: 11rem; overflow: auto; }
.find-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.find-main { display: grid; gap: 0.1rem; min-width: 0; flex: 1; }
.found-main { display: grid; gap: 0.1rem; min-width: 0; flex: 1; }
.found-actions { display: flex; gap: 0.75rem; white-space: nowrap; }
.find-list .saved-empty { justify-content: center; color: var(--muted); }

/* Payment terms in Business details */
.pt-rows { display: grid; gap: 0.5rem; margin: 0.5rem 0 0.9rem; }
.pt-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.4fr) auto auto; gap: 0.75rem;
  align-items: start; padding: 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.pt-row textarea { resize: vertical; min-height: 4.2rem; line-height: 1.45; }
.pt-row .checkbox-row, .pt-row .icon-btn { margin-top: 1.5rem; }
.pt-label { display: grid; gap: 0.25rem; min-width: 0; font-weight: 600; font-size: 0.86rem; }
.pt-label input { font-weight: 400; }

.pay-terms .empty { margin: 0.4rem 0 0.8rem; }
#wrap-payment-terms { display: grid; gap: 0.3rem; }
#wrap-payment-terms > label { font-weight: 600; }
#wrap-payment-terms select { margin-bottom: 0.25rem; }
#wrap-payment-terms textarea { resize: vertical; }
@media (max-width: 760px) { .pt-row { grid-template-columns: minmax(0, 1fr) auto; } .pt-label:first-child { grid-column: 1 / -1; } }
.pt-side { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; min-width: 0; }
@media (max-width: 760px) { .pt-side { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.switch-row { align-items: flex-start; gap: 0.6rem; padding: 0.55rem 0; }
.switch-row > span { display: grid; gap: 0.1rem; }
.switch-row input { margin-top: 0.2rem; }
.bottom-blocks .switch-row + .switch-row { border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ touch
   Everything below applies only where the pointer is coarse — a finger, not a
   mouse. A desktop browser never matches it, so the desktop layout is exactly
   as it was. Two things change on a phone or tablet:

   * Form fields are set to 16px. Below that, iOS zooms the page in every time
     somebody taps a field, and they then have to pinch back out.
   * Anything you tap is given room for a fingertip: Apple asks for 44pt,
     Android for 48dp. */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
  .item-row input, .item-row select, .item-row textarea,
  .field-row input[type="text"], .pos-inputs input[type="number"],
  .year-select select, .rate-input input { font-size: 16px; }

  .btn, .btn-sm, button, select, summary, [role="button"] { min-height: 44px; }
  .btn, .btn-sm { padding-block: 0.6rem; }
  .icon-btn { width: 44px; height: 44px; }

  /* A checkbox or radio is small by nature, so the label beside it is made the
     target instead, which is what a finger lands on anyway. */
  .checkbox-row, .switch-row { min-height: 44px; align-items: center; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }

  /* Rows of links in a list: the whole row, not the few words in it. */
  .tabbar a, .tabbar button { min-height: 52px; }
  .table td a, .docs-table td a { display: inline-block; padding-block: 0.35rem; }
}

/* Closing an account: set apart from the rest of the page, and not a button to lean on. */
.danger-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.danger-card h2 { color: var(--danger); }
.close-account { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.8rem; }
.close-account summary { cursor: pointer; font-weight: 600; color: var(--danger); }
.close-account form { margin-top: 0.8rem; max-width: 26rem; }

/* Shown only where there is a finger and a camera: a desktop never sees it. */
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline-flex; } }

/* A delivery address: folded away until it is needed. */
.ship-to { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.ship-to summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; min-height: 44px; display: flex; align-items: center; gap: 0.4rem; }

/* Where the money stands: one row of chips with counts, above the list. */
.money-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0 0 0.1rem; }
.money-chip { font: inherit; font-size: 0.85rem; font-weight: 600; display: inline-flex; align-items: center; gap: 0.4rem;
  min-height: 36px; padding: 0 0.7rem; border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); color: var(--muted); cursor: pointer; }
.money-chip:hover { border-color: var(--line-strong); color: var(--text); }
.money-chip .chip-count { font-size: 0.78rem; font-weight: 700; padding: 0.05rem 0.4rem; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); }
.money-chip.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.money-chip.is-on .chip-count { background: rgba(255, 255, 255, 0.22); color: #fff; }
.money-chip.chip-overdue.is-on { background: var(--danger); border-color: var(--danger); }
.money-chip.chip-paid.is-on { background: var(--success); border-color: var(--success); }
.money-line { margin: 0.5rem 0 0.2rem; font-size: 0.88rem; color: var(--muted); }
@media (pointer: coarse) {
  .money-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 0.3rem; }
  .money-chips::-webkit-scrollbar { display: none; }
  .money-chip { min-height: 44px; flex: none; }
}

/* A dot to read the list at a glance. It repeats the status chip rather than replacing it, so the
   list still works for anyone who cannot tell the colours apart. */
.row-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.45rem;
  vertical-align: 0.05em; background: var(--line-strong); }
.dot-overdue, .dot-expired, .dot-declined { background: var(--danger); }
.dot-sent, .dot-issued { background: var(--brand); }
.dot-part { background: var(--warning); }
.dot-paid, .dot-accepted, .dot-refunded { background: var(--success); }
.dot-draft { background: var(--line-strong); }
.dot-revised, .dot-converted { background: var(--muted); }

/* Simple and full. In simple mode the panels that are set once in Business details are folded away;
   the document itself is unchanged, and nothing is lost by not looking at them. */
.editor-mode { margin: 0 0 0.9rem; }
.editor-mode .checkbox-row { min-height: 44px; }
body.simple-form .editor-form .advanced-only { display: none; }

/* On a phone the editor reads as a list of sections you open one at a time, the way a phone app does,
   rather than one long form. On a desktop it stays exactly as it was. */
@media (pointer: coarse) {
  .editor-form .panel { padding: 0; }
  .editor-form .panel > legend {
    float: none; width: 100%; box-sizing: border-box; margin: 0; padding: 0.95rem 1rem;
    font-size: 1rem; font-weight: 700; border-bottom: 1px solid var(--line);
  }
  .editor-form .panel > *:not(legend) { padding-inline: 1rem; }
  .editor-form .panel > *:nth-last-child(1):not(legend) { padding-bottom: 1rem; }
  .editor-form .panel > legend + * { padding-top: 0.9rem; }
}

/* An invoice that comes round again. */
.recur-block { display: grid; gap: 0.3rem; }
.recur-block > label { font-weight: 600; }

/* Archived saved items, folded under the live ones. */
.archived-items { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
.archived-items summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

/* What to do with one document, on a phone. */
.doc-sheet .sheet-actions { display: grid; gap: 0.5rem; margin-top: 0.9rem; }
.sheet-action { font: inherit; font-size: 1rem; font-weight: 600; text-align: left; min-height: 52px;
  padding: 0 1rem; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); }
.sheet-action:hover { border-color: var(--line-strong); }
.sheet-action[data-sheet="delete"] { color: var(--danger); border-color: var(--edge-danger); }

/* ------------------------------------------------------------------ the editor on a phone
   Each section is a row carrying its name and what it currently says; tapping opens it where it sits.
   None of this applies to a mouse: the desktop form is untouched. */
@media (pointer: coarse) {
  .editor-form .panel.is-row { padding: 0; overflow: hidden; }
  /* The row carries the section's name, so the fieldset's own legend is taken out of the layout:
     a legend keeps a full-width box even when it is clipped, which pushes the page sideways. */
  .editor-form .panel.is-row > legend[hidden] { display: none; }
  .panel-row { width: 100%; display: flex; align-items: center; gap: 0.7rem; min-height: 56px;
    padding: 0.6rem 0.9rem; background: none; border: 0; font: inherit; text-align: left; color: var(--text); }
  .panel-row-name { font-weight: 700; font-size: 1rem; flex: none; }
  .panel-row-value { flex: 1; min-width: 0; text-align: right; color: var(--muted); font-size: 0.9rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .panel-row-mark { flex: none; color: var(--muted); transition: transform 0.15s ease; }
  .panel.is-open .panel-row-mark { transform: rotate(90deg); }
  .panel.is-open .panel-row { border-bottom: 1px solid var(--line); }
  .panel.is-open .panel-row-value { display: none; }

  .panel-body { display: none; padding: 0.9rem; }
  .panel.is-open > .panel-body { display: block; }

  /* The sections sit as one list rather than as separate cards. */
  .editor-form .panel.is-row + .panel.is-row { margin-top: 0.5rem; }
}

/* ------------------------------------------------------------------ the editor's toolbar on a phone
   Four full-size buttons on their own lines pushed the document itself a third of the way down the
   screen. They become one short row under the title instead, and the switch between editor layouts
   goes altogether: below 1100px both layouts are the same single column, so it changes nothing. */
@media (pointer: coarse) {
  .editor-toolbar { padding: 0.6rem 0 0.7rem; gap: 0.5rem; }
  .editor-title { width: 100%; align-items: baseline; gap: 0.5rem; row-gap: 0.1rem; }
  .editor-title h1 { font-size: 1.1rem; order: 2; flex: 1 1 100%; }
  .editor-title .back-link { order: 1; font-size: 0.86rem; }
  .save-state { order: 3; flex: 1 1 100%; font-size: 0.78rem; }

  .editor-actions { width: 100%; flex-wrap: nowrap; gap: 0.4rem; }
  .editor-actions .btn { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 0.45rem;
    font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .btn-long { display: none; }
  .btn-short { display: inline; }

  .editor-layout-switch { display: none; }

  /* This row was being clipped by the sticky toolbar above it. */
  .editor-mode { margin: 0.2rem 0 0.7rem; }
  .editor-mode .checkbox-row { align-items: flex-start; min-height: 0; padding: 0.35rem 0; }
}

/* ------------------------------------------------------------------ a page's heading on a phone
   The title, the small buttons beside it and the company picker underneath, rather than three full
   rows stacked down the screen. "New document" is already a round + button on a phone, so the only
   buttons left up here are the occasional ones. */
@media (pointer: coarse) {
  .page-head { align-items: flex-start; gap: 0.45rem 0.5rem; margin-bottom: 0.9rem; }
  .page-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  .page-head h1 { font-size: 1.3rem; }
  .page-head > div:first-child > p { font-size: 0.86rem; }

  /* The buttons become items of the heading row itself, so they can sit beside the title while the
     company picker drops to a line of its own underneath. */
  .page-head-actions { display: contents; }
  .page-head-actions > .btn { order: 1; min-height: 36px; padding: 0 0.7rem; font-size: 0.8rem; font-weight: 600; }
  .page-head-actions > .company-filter,
  .page-head-actions > form,
  .page-head-actions > label { order: 2; flex: 1 1 100%; }
  .page-head-actions > .company-filter select { width: 100%; }
}

/* Sidebar colour tiles in the dark theme: the same colours, lifted so the deeper ones (indigo, slate)
   still read against a dark sidebar, on a slightly stronger tint. The page you are on keeps its solid
   tile. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .appnav a:not(.is-active) .appnav-icon { filter: brightness(1.45) saturate(1.1); }
}
:root[data-theme="dark"] .appnav a:not(.is-active) .appnav-icon { filter: brightness(1.45) saturate(1.1); }

/* Save is always green and delete is always red, everywhere. app.js gives every button whose label starts
   with "Save" the btn-save class; delete buttons already carry btn-danger. */
:root { --save-bg: #17794f; --save-bg-hover: #0f5f3d; --del-bg: #b3261e; --del-bg-hover: #8c1d17; }
:root[data-theme="dark"] { --save-bg: #1f8a58; --save-bg-hover: #25a068; --del-bg: #c2362d; --del-bg-hover: #d6473d; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --save-bg: #1f8a58; --save-bg-hover: #25a068; --del-bg: #c2362d; --del-bg-hover: #d6473d; }
}
.btn.btn-save, .btn.btn-save:hover { color: #fff; border-color: transparent; }
.btn.btn-save { background: var(--save-bg); }
.btn.btn-save:hover:not(:disabled) { background: var(--save-bg-hover); }
.btn.btn-danger, .btn.btn-danger:hover { color: #fff; border-color: transparent; }
.btn.btn-danger { background: var(--del-bg); }
.btn.btn-danger:hover:not(:disabled) { background: var(--del-bg-hover); }
:root[data-theme="dark"] :is(.btn.btn-save, .btn.btn-save:hover, .btn.btn-danger, .btn.btn-danger:hover) { color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.btn.btn-save, .btn.btn-save:hover, .btn.btn-danger, .btn.btn-danger:hover) { color: #fff; }
}

/* After Save in the document editor: the finished document, with what to do next (editor.js). It covers
   the whole screen; the email window and messages still sit above it. */
.doc-review { position: fixed; inset: 0; z-index: 48; display: flex; flex-direction: column; background: var(--bg); animation: review-in .3s ease-out; }
.doc-review[hidden] { display: none; }
body.is-reviewing { overflow: hidden; }
.review-bar { display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem max(1rem, calc((100vw - 1280px) / 2 + 1rem)); background: var(--success-tint); border-bottom: 1px solid var(--edge-success, var(--line)); }
.review-bar h2 { font-size: 1.08rem; margin: 0; }
.review-bar p { margin: 0.1rem 0 0; font-size: 0.88rem; color: var(--muted); }
.review-ok { flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; background: var(--save-bg); color: #fff; font-weight: 800; animation: review-pop .5s cubic-bezier(.3, 1.6, .5, 1); }
.review-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 1.25rem; width: 100%; max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem; }
.review-doc { overflow: auto; min-height: 0; padding: 0.25rem 1rem 2rem; }
.review-scaler { margin: 0 auto; overflow: hidden; border-radius: 4px; box-shadow: 0 18px 44px rgba(20, 23, 28, 0.2); background: #fff; animation: review-rise .5s cubic-bezier(.2, .9, .3, 1); }
.review-acts { align-self: start; display: flex; flex-direction: column; gap: 0.6rem; padding: 1.1rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(20, 23, 28, 0.08); }
.review-q { margin: 0 0 0.2rem; font-weight: 700; }
.review-acts .btn { width: 100%; justify-content: center; padding-block: 0.7rem; font-size: 0.95rem; }
.btn.review-edit { background: transparent; border-style: dashed; }
.review-link { text-align: center; font-size: 0.88rem; font-weight: 600; margin-top: 0.15rem; }
/* phones: the document fills the screen and the choices sit in a panel at the bottom */
@media (max-width: 760px) {
  .review-bar { padding: 0.7rem 1rem; }
  .review-body { display: flex; flex-direction: column; padding: 0; gap: 0; }
  .review-doc { flex: 1; padding: 0.9rem 0.5rem 1rem; }
  .review-acts { align-self: stretch; }
  .review-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom)); box-shadow: 0 -10px 30px rgba(20, 23, 28, 0.14); }
  .review-q { grid-column: 1 / -1; font-size: 0.9rem; }
  .review-acts .btn { font-size: 0.9rem; }
  .review-acts .review-send, .review-acts .review-edit, .review-link { grid-column: 1 / -1; }
}
/* My documents: the one you have just sent, downloaded or saved */
.docs-table tbody tr.is-just > td { animation: just-glow 5s ease-out 1; }
.just-tag { display: inline-block; margin-inline-start: 0.4rem; padding: 0.08rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; vertical-align: middle;
  background: linear-gradient(100deg, #9a7630, #d9b862 55%, #f0da92); color: #1d1606; }
@keyframes just-glow { 0%, 55% { background-color: rgba(217, 184, 98, 0.22); box-shadow: inset 0 1px 0 rgba(195, 156, 76, .6), inset 0 -1px 0 rgba(195, 156, 76, .6); } 100% { background-color: transparent; box-shadow: none; } }
@keyframes review-in { from { opacity: 0; } }
@keyframes review-pop { from { transform: scale(.3); } }
@keyframes review-rise { from { opacity: 0; transform: translateY(18px); } }
@media (prefers-reduced-motion: reduce) { .doc-review, .review-ok, .review-scaler, .docs-table tbody tr.is-just > td { animation: none; } }

/* A label's words with a small badge beside them (the editor's "Project PRO"): kept together on one line,
   so the badge stays a tag rather than stretching across the field. */
.label-with-badge { display: inline-flex; align-items: center; gap: 0.35rem; justify-self: start; }
.label-with-badge .pro-badge { margin-left: 0; }

/* A setting with its name on the left and its choice on the right (Business details → Email me a summary).
   The choice is as wide as its longest option, so "Every month" is never cut off. */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.5rem 0; border-top: 1px solid var(--line); }
.setting-row > span { font-weight: 600; }
.setting-row select { width: auto; min-width: 11rem; flex: 0 0 auto; }

/* Share to WhatsApp (document editor and the screen after Save): WhatsApp's own green, with its mark. */
.btn.btn-whatsapp, .btn.btn-whatsapp:hover { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  background: #25d366; border-color: transparent; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.btn.btn-whatsapp:hover:not(:disabled) { background: #1ebe5b; }
.btn.btn-whatsapp:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.35); }
.btn-whatsapp .wa-icon { width: 18px; height: 18px; flex: none; }
:root[data-theme="dark"] :is(.btn.btn-whatsapp, .btn.btn-whatsapp:hover) { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.btn.btn-whatsapp, .btn.btn-whatsapp:hover) { color: #fff; } }
.review-acts .review-wa { grid-column: 1 / -1; }
/* on a phone the editor's top bar has no room for the word: the mark alone, named for screen readers */
@media (max-width: 760px) { .editor-actions .btn-whatsapp .btn-long { display: none; } }

/* The document actions, each in its own colour so they are told apart at a glance: Print slate, PDF
   gold, Email blue (the Send button on the Saved screen too). Save and WhatsApp keep their own. */
.btn.btn-act { border-width: 1px; border-style: solid; }
.btn.btn-act-print, .btn.btn-act-print:hover { background: #e3e8ef; border-color: #c7d0db; color: #262b33; }
.btn.btn-act-print:hover:not(:disabled) { background: #d5dce6; }
.btn.btn-act-pdf, .btn.btn-act-pdf:hover { background: #9a7630; border-color: #b8923f; color: #fff; }
.btn.btn-act-pdf:hover:not(:disabled) { background: #876628; }
.btn.btn-act-email, .btn.btn-act-email:hover { background: #2f5d8a; border-color: #3f74a8; color: #fff; }
.btn.btn-act-email:hover:not(:disabled) { background: #284f76; }
:root[data-theme="dark"] :is(.btn.btn-act-print, .btn.btn-act-print:hover) { background: #33404f; border-color: #4a5a6c; color: #e6edf5; }
:root[data-theme="dark"] .btn.btn-act-print:hover:not(:disabled) { background: #3d4c5e; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.btn.btn-act-print, .btn.btn-act-print:hover) { background: #33404f; border-color: #4a5a6c; color: #e6edf5; }
  :root:not([data-theme="light"]) .btn.btn-act-print:hover:not(:disabled) { background: #3d4c5e; }
}
:is(.btn-act-pdf, .btn-act-email):focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(63, 116, 168, 0.4); }
.btn-act-pdf:focus-visible { box-shadow: 0 0 0 3px rgba(184, 146, 63, 0.45); }

/* "Install Genuine Invoice" — a card that slides in on phones (app.js). Android opens the phone's own
   install confirmation; iPhone shows the two steps, because Safari has no install button for websites. */
.gi-appcard { position: fixed; left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top)); z-index: 1000;
  display: flex; align-items: center; gap: 14px; padding: 14px 12px 14px 16px; border-radius: 18px;
  background: #262b33; color: #eef0f3; box-shadow: 0 18px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(240, 218, 146, .18);
  transform: translateY(calc(-100% - 30px)); transition: transform .45s cubic-bezier(.2, .9, .3, 1); }
.gi-appcard.is-on { transform: none; }
.gi-appcard img { width: 52px; height: 52px; border-radius: 13px; flex: none; }
.gi-appcard .t { flex: 1; min-width: 0; }
.gi-appcard b { display: block; font-size: 1.02rem; font-weight: 650; line-height: 1.3; }
.gi-appcard small { display: block; color: #aab3bf; font-size: .82rem; margin-top: 2px; }
.gi-appcard .go { border: 0; border-radius: 999px; padding: 10px 16px; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
  background: linear-gradient(100deg, #9a7630, #d9b862 55%, #f0da92); color: #1d1606; min-height: 0; }
.gi-appcard .x { border: 0; background: none; color: #aab3bf; font-size: 1.5rem; line-height: 1; padding: 6px; cursor: pointer; min-height: 0; }
.gi-appcard .go:focus-visible, .gi-appcard .x:focus-visible { outline: 2px solid #f0da92; outline-offset: 2px; }
.gi-appsheet { position: fixed; inset: 0; z-index: 1001; background: rgba(20, 23, 28, .45); display: flex; align-items: flex-end; }
.gi-appsheet[hidden] { display: none; }
.gi-appsheet .box { width: 100%; background: #fff; color: #262b33; border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); animation: gi-appsheet-up .35s cubic-bezier(.2, .9, .3, 1); }
.gi-appsheet h2 { margin: 0 0 12px; font-size: 1.1rem; }
.gi-appsheet ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 10px; }
.gi-appsheet .share { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: #eef1f5; vertical-align: middle; margin: 0 2px; }
.gi-appsheet .share svg { width: 16px; height: 16px; }
.gi-appsheet .ok { margin-top: 16px; width: 100%; border: 0; border-radius: 12px; padding: 13px; font: inherit; font-weight: 700; background: #262b33; color: #fff; cursor: pointer; }
@keyframes gi-appsheet-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .gi-appcard { transition: none; } .gi-appsheet .box { animation: none; } }

/* privacy policy: a list of rights inside a terms-style section */
.terms-section .ticks { margin: 0.7rem 0 1.1rem; }

/* Promotional codes: the home page column, a headline box and its button side by side. */
.promo-home-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.promo-home-form input[type="text"] { min-width: 12rem; flex: 1; }
.promo-home .muted.small { max-width: 14rem; }

/* Admin → Mail settings: the test message's progress, and the delivery list */
.mail-live { margin: 0.75rem 0; }
.mail-live.is-good { background: var(--success-tint); color: var(--success); }
.mail-live.is-bad { background: var(--danger-tint); color: var(--danger); }
.mail-log { table-layout: fixed; width: 100%; }
.mail-log th:nth-child(1) { width: 8.5rem; } .mail-log th:nth-child(3) { width: 8rem; } .mail-log th:nth-child(4) { width: 7.5rem; }
.mail-log .mail-to, .mail-log .mail-why { overflow-wrap: anywhere; }
#webhook input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
#webhook .steps-list { margin: 0.75rem 0 1rem 1.2rem; display: grid; gap: 0.3rem; }

/* ---------------------------------------------------------------- feedback competition (includes/feedback.php)
   A teal ribbon under the menu on signed-in pages, and the short form it opens. Until 31 January 2027. */
.fb-app-ribbon { display: flex; align-items: center; gap: 12px; margin: 0 0 1rem; padding: 12px 14px 12px 16px; border-radius: var(--radius);
  background: #0f766e; color: #fff; }
.fb-app-ribbon[hidden] { display: none; }
.fb-app-ribbon p { flex: 1; margin: 0; line-height: 1.45; color: #fff; }
.fb-app-ribbon strong { color: #fff; }
.fb-app-ribbon a { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.fb-app-gift { font-size: 1.5rem; line-height: 1; flex: none; }
.fb-app-open { flex: none; padding: 8px 16px; border: 0; border-radius: 999px; background: #fff; color: #0b4f49; font: inherit; font-weight: 800; cursor: pointer; }
.fb-app-open:hover, .fb-app-open:focus-visible { background: #ccfbf1; }
.fb-app-x { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .18); color: #fff; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.fb-app-x:hover, .fb-app-x:focus-visible { background: rgba(0, 0, 0, .35); }
@media (max-width: 700px) {
  .fb-app-ribbon { flex-wrap: wrap; position: relative; padding-right: 48px; }
  .fb-app-x { position: absolute; top: 8px; right: 8px; }
  .fb-app-ribbon p { flex: 1 1 calc(100% - 40px); font-size: .92rem; }
  .fb-app-open { margin-left: 36px; }
}

.fb-dialog { width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.fb-dialog::backdrop { background: rgba(10, 12, 16, .6); }
.fb-dialog-form { position: relative; display: grid; gap: 14px; padding: 26px 26px 22px; border-top: 6px solid #0f766e; }
.fb-dialog-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer; }
.fb-dialog-tag { margin: 0; color: #0f766e; font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.fb-dialog h2 { margin: -6px 40px 0 0; font-size: 1.45rem; line-height: 1.2; }
.fb-dialog-lede { margin: -6px 0 0; color: var(--muted); }
.fb-dialog-who { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.fb-dialog-who dt { font-size: .76rem; color: var(--muted); }
.fb-dialog-who dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.fb-dialog-form > .hint { margin: -8px 0 0; }
.fb-dialog-form label textarea { margin-top: 6px; }
.fb-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
@media (max-width: 600px) { .fb-dialog-who { grid-template-columns: 1fr; } .fb-dialog-form { padding: 22px 18px 18px; } }
:root[data-theme="dark"] .fb-dialog-tag { color: #5eead4; }
/* The offer wording in red: on white tags in the ribbon, so it stays readable on the teal. */
.fb-app-ribbon .fb-offer { display: inline-block; padding: 1px 8px; border-radius: 6px; background: #fff; color: #c8102e; font-weight: 800; }
.fb-dialog .fb-offer-text { color: #c8102e; }
:root[data-theme="dark"] .fb-dialog .fb-offer-text { color: #ff6b6b; }
/* ---------------------------------------------------------------- rating card (includes/rating.php)
   Bottom right on a wide screen, above the help button; a sheet along the bottom on a phone. */
.rt-card { position: fixed; z-index: 70; right: 24px; bottom: 96px; width: min(340px, calc(100vw - 32px)); box-sizing: border-box;
  border-radius: 16px; background: var(--surface); color: var(--text); border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22); transform: translateY(16px); opacity: 0; transition: transform .35s ease, opacity .35s ease; }
.rt-card[hidden] { display: none; }
.rt-card.is-in { transform: none; opacity: 1; }
.rt-form { position: relative; display: grid; gap: 10px; padding: 18px 18px 16px; }
.rt-x { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--text); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.rt-title { margin: 0 34px 0 0; font-size: 1.05rem; line-height: 1.3; }
.rt-stars { display: flex; gap: 4px; margin: 0; padding: 0; border: 0; }
.rt-star { cursor: pointer; }
.rt-star input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rt-star span[aria-hidden] { display: block; font-size: 2rem; line-height: 1; color: var(--line-strong); transition: color .15s, transform .15s; }
.rt-stars:hover .rt-star span[aria-hidden] { color: #f5b301; }
.rt-star:hover ~ .rt-star span[aria-hidden] { color: var(--line-strong); }
.rt-star input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.rt-card[data-stars] .rt-star span[aria-hidden] { color: var(--line-strong); }
.rt-card[data-stars="1"] .rt-star:nth-of-type(-n+1) span[aria-hidden],
.rt-card[data-stars="2"] .rt-star:nth-of-type(-n+2) span[aria-hidden],
.rt-card[data-stars="3"] .rt-star:nth-of-type(-n+3) span[aria-hidden],
.rt-card[data-stars="4"] .rt-star:nth-of-type(-n+4) span[aria-hidden],
.rt-card[data-stars="5"] .rt-star:nth-of-type(-n+5) span[aria-hidden] { color: #f5b301; }
.rt-ask, .rt-public { margin: 0; font-size: .92rem; }
.rt-public a { font-weight: 700; }
.rt-more { display: grid; gap: 10px; }
.rt-more[hidden], .rt-more [hidden] { display: none; }
.rt-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 600px) { .rt-card { right: 0; left: 0; bottom: 0; width: 100%; border-radius: 16px 16px 0 0; } }
@media (prefers-reduced-motion: reduce) { .rt-card { transition: none; transform: none; } }