/* The desk's Calm look (SPEC §23.10, D-133; mockup B): light only, IBM Plex Sans served by the desk itself, a white
   sidebar, white cards with a 1 px rule on a grey ground, copper for the primary button, the chosen chip and the open
   area. Classes the areas use (dom.js writes most of them): .subnav, .toolbar, .tiles and .tile, .filters, .chips and
   .chip, .card, .table-box, .amount, .date, .wrap, .nowrap, .badge, .details, .field, .lines-editor, .actions, .split
   with .panel (a form that only reads, its answer beside it), .sheet (where a form that writes waits), .inbox (the
   document cards and the review card), (UI8) .editor (the invoice editor's page), .muted and .error. Every text colour is at least 4.5:1 on the surface it sits
   on; control and chip borders are at least 3:1. */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/desk/plex-regular.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/desk/plex-medium.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/desk/plex-semibold.woff2) format("woff2");
}

:root {
  color-scheme: light;
  --ink: #1D2B3A;          /* text: 14.39:1 on white */
  --ink-2: #3A4A5C;
  --muted: #5B6878;        /* 5.68:1 on white, 5.24:1 on the ground */
  --rule: #D3DCE5;         /* card and table rules (never text) */
  --line: #E4E9EE;         /* rules inside a card */
  --edge: #7D8A99;         /* control and chip borders: 3.52:1 on white, 3.25:1 on the ground */
  --paper: #FFFFFF;
  --ground: #F4F6F8;
  --tint: #EEF1F4;
  --copper: #B4501F;       /* the accent: 5.11:1 on white, and white on it */
  --copper-strong: #963F15;
  --copper-wash: #FBF1EC;
  --ok: #1E6B3A;
  --ok-wash: #E7F4EC;
  --ok-edge: #B7DCC4;
  --info: #1F4F7A;
  --info-wash: #E6EEF6;
  --warn: #8A4600;
  --warn-wash: #FDF1DC;
  --end: #9B1C1C;
  --end-wash: #FBE9E9;
  --end-edge: #EFC4C0;
  --radius: 10px;
  --control: 36px;         /* every button, chip, link row and field: 36 px tall here, 44 px on phones */
  --side: 240px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 16px 40px rgba(29, 43, 58, 0.16), 0 2px 8px rgba(29, 43, 58, 0.08);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--ground);
  font: 400 15px/1.5 var(--font);
}

h1, h2, h3, h4 { color: var(--ink); }
h3 { margin: 28px 0 10px; font-size: 16px; font-weight: 600; }
h4 { margin: 16px 0 6px; font-size: 14px; font-weight: 600; }
p { margin: 0 0 12px; }

/* Controls: a visible copper focus ring, a hover state, and a pointer on everything that is pressed or chosen. Text
   fields keep the text cursor. Transitions run on hover and focus only (not when a route marks the open area). */
a { color: var(--copper); cursor: pointer; text-underline-offset: 2px; }
a:hover { color: var(--copper-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
a:hover, button:hover, input:hover, select:hover, textarea:hover,
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

button {
  min-height: var(--control);
  padding: 5px 16px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  touch-action: manipulation;
}
button:hover:not(:disabled) { border-color: var(--ink); background: var(--ground); }
button.primary { border-color: var(--copper); background: var(--copper); color: var(--paper); font-weight: 600; }
button.primary:hover:not(:disabled) { border-color: var(--copper-strong); background: var(--copper-strong); }
button:disabled { border-color: var(--rule); background: var(--tint); color: var(--muted); cursor: not-allowed; }
button .reason { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }

/* A link that acts like a button (a PDF, Back to the draft, the Xero files) looks like one beside the buttons. */
.toolbar > a, .actions > a, .card-head > a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control);
  padding: 5px 16px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.toolbar > a:hover, .actions > a:hover, .card-head > a:hover { border-color: var(--ink); background: var(--ground); color: var(--ink); }
.toolbar > a.primary { border-color: var(--copper); background: var(--copper); color: var(--paper); font-weight: 600; }
.toolbar > a.primary:hover { border-color: var(--copper-strong); background: var(--copper-strong); color: var(--paper); }

input, select, textarea {
  max-width: 100%;
  min-height: var(--control);
  padding: 5px 12px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--paper);
}
textarea { min-height: 72px; padding: 8px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
/* A select draws its own chevron, so it matches the fields beside it in every browser. */
select {
  padding-right: 34px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select, input[type="checkbox"], input[type="radio"], input[type="file"], input[type="date"] { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--copper); }
input[type="file"] { padding: 6px 8px; border-style: dashed; }
input.amount { text-align: right; font-variant-numeric: tabular-nums; }

/* The shell: a white sidebar (the mark, the areas, Bill review, who is at the desk) beside the page. */
.side {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: var(--side);
  padding: 20px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--rule);
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; margin: 0; padding: 4px 8px; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.brand img { display: block; }
#menu { display: grid; gap: 2px; }
#menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: none;
}
#menu a:hover { background: var(--ground); color: var(--ink); }
#menu a[aria-current="page"] { background: var(--copper-wash); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--copper); }
#menu a[aria-current="page"] .icon { color: var(--copper); }
#menu .review-link { margin-top: 10px; color: var(--copper); }
.icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.owner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  margin-top: auto;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--ground);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.avatar:empty { display: none; }
.owner select { grid-column: 1 / -1; width: 100%; color: var(--ink); font-size: 14px; font-weight: 600; }
/* (AC1) Signed in: the account's name beside the avatar, Sign out beneath them; (AC2) a demo book's line under the name. */
.owner .sign-out { grid-column: 1 / -1; width: 100%; font-size: 14px; }
.owner .owner-book { grid-column: 2; margin-top: -8px; color: var(--muted); font-size: 12px; font-weight: 500; }

/* The page: the status line above the content, then the area's view. */
.page { min-width: 0; margin-left: var(--side); padding: 0 32px 48px; }
#status {
  margin: 20px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  overflow-wrap: anywhere;
}
#status:empty { display: none; }
#status:focus { outline: none; }   /* it takes the focus after a sheet's send succeeds; it is not a control */
#status[data-tone="error"] { border-color: var(--end-edge); background: var(--end-wash); color: var(--end); }
#status[data-tone="done"] { border-color: var(--ok-edge); background: var(--ok-wash); color: var(--ok); }
main { max-width: 1440px; min-width: 0; padding-top: 24px; }

/* A view: its area's pages, its heading and actions, tiles, filters, then cards. */
.subnav { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 20px; border-bottom: 1px solid var(--rule); }
.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: max(40px, var(--control));
  margin-bottom: -1px;
  padding: 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: none;
}
.subnav a:hover { border-bottom-color: var(--edge); color: var(--ink); }
.subnav a[aria-current="page"] { border-bottom-color: var(--copper); color: var(--ink); font-weight: 600; }
/* (UI14) The heading has its own row; the actions follow on the next, left-aligned, never pushed to the right edge. */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 20px; }
.toolbar-head { display: flex; flex: 1 0 100%; flex-wrap: wrap; gap: 10px 12px; align-items: center; }
.toolbar h2 { min-width: 0; margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.card-head h3:has(+ .badge) { flex: 0 1 auto; }
.card-head h3 + .badge { margin-right: auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin: 0 0 24px; }
.tile { padding: 18px 20px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); }
.tile-label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.tile-figure { margin: 6px 0 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-figure small { margin-right: 6px; color: var(--muted); font-size: 14px; font-weight: 500; }
.tile-note { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin: 0 0 16px; }
.filters .field { display: flex; align-items: center; gap: 8px; margin: 0 0 0 auto; }
.filters .field > label { color: var(--ink-2); font-size: 14px; }
.filters select { min-width: 200px; border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
button.chip { padding: 5px 16px; border-color: var(--edge); border-radius: 999px; background: var(--paper); color: var(--ink-2); }
button.chip:hover:not(:disabled) { border-color: var(--ink); background: var(--paper); color: var(--ink); }
button.chip[aria-pressed="true"] { border-color: var(--copper); background: var(--copper); color: var(--paper); font-weight: 600; }
button.chip[aria-pressed="true"]:hover:not(:disabled) { border-color: var(--copper-strong); background: var(--copper-strong); color: var(--paper); }

/* Cards: white on the ground, a 1 px rule and a 10 px radius. Tables, a record's fields and the read-only forms sit
   in them. */
.card, .table-box, .details, .panel { border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); }
.card { min-width: 0; padding: 20px; }
.card-head { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; margin: 0 0 16px; }
.card-head h3 { flex: 1; min-width: 8em; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.card > h3:first-child, .card > h4:first-child { margin-top: 0; }
.panel { min-width: 0; margin: 0 0 20px; padding: 20px; }
.panel > h3:first-child { margin-top: 0; }
.panel > h3 { margin-top: 24px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 20px; align-items: start; margin: 0 0 20px; }
.split > .panel { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0; }
/* (CH1) A row's own buttons in a table cell (Books, Accounts: Edit, Hide or Show) sit on the row's line. */
td > .actions { margin: 0; flex-wrap: nowrap; }
.muted { color: var(--muted); }
.error { color: var(--end); }
.error:empty { display: none; }

/* Tables: a header row, amounts right-aligned in tabular figures, dates on one line. Text wraps at spaces, so no column
   is cut off at 1440 px; a table still too wide scrolls inside its card, never the page. */
.table-box { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
td.wrap { min-width: 12em; overflow-wrap: anywhere; }
td.nowrap, td.date { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--ground); }
.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.empty { color: var(--muted); }
td.empty:hover { background: var(--paper); }
td > a { white-space: nowrap; }

/* States as small text badges, every state the routes answer in one of four groups: in progress (blue), needs
   attention (amber), settled (green) and ended (red). */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}
.badge::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* In progress: a document or run on its way (drafts, open bills and invoices, payout steps); (BK2) a bank feed whose file
   type carries no balance to compare. */
.badge[data-state="no bank balance"], .badge[data-state="draft"], .badge[data-state="open"], .badge[data-state="part_paid"], .badge[data-state="approved"],
.badge[data-state="exported"], .badge[data-state="submitted"], .badge[data-state="submitting"], .badge[data-state="quoted"],
.badge[data-state="created"], .badge[data-state="funded"], .badge[data-state="sent"], .badge[data-state="ready"],
.badge[data-state="todo"] {
  background: var(--info-wash); color: var(--info);
}
/* Needs attention: the owner has something to look at or fix. */
.badge[data-state="out of sync"], .badge[data-state="blocked"], .badge[data-state="blocking"],
.badge[data-state="quarantined"], .badge[data-state="bounced"], .badge[data-state="failed"], .badge[data-state="needs_review"],
.badge[data-state="needs_manual_entry"], .badge[data-state="not_a_bill"], .badge[data-state="duplicate_file"],
.badge[data-state="attention"], .badge[data-state="expired"] {
  background: var(--warn-wash); color: var(--warn);
}
/* Settled: done and in force. */
.badge[data-state="settled"], .badge[data-state="in sync"], .badge[data-state="allocated"], .badge[data-state="classified"],
.badge[data-state="active"], .badge[data-state="posted"], .badge[data-state="live"], .badge[data-state="cleared"],
.badge[data-state="enabled"], .badge[data-state="linked"], .badge[data-state="resolved"], .badge[data-state="accepted"],
.badge[data-state="saved_as_draft"], .badge[data-state="done"] {
  background: var(--ok-wash); color: var(--ok);
}
/* Ended: undone, replaced or stopped for good. */
.badge[data-state="void"], .badge[data-state="cancelled"], .badge[data-state="returned"], .badge[data-state="ignored"],
.badge[data-state="reversed"], .badge[data-state="unmatched"], .badge[data-state="replaced"], .badge[data-state="disabled"],
.badge[data-state="rejected"], .badge[data-state="declined"] {
  background: var(--end-wash); color: var(--end);
}

/* Setup (ON1, SPEC §31.2): the steps as a column of cards, each with its state, whether it is required, the guidance
   for Australia and an attention's sentence; a key's name or the profile's path as code (never a value). */
.progress { margin: -8px 0 20px; }
.steps { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
/* The title wraps before its state does: the badge and Required stay together on the title's first line, at any width. */
.step .card-head { flex-wrap: nowrap; align-items: flex-start; margin-bottom: 12px; }
.step .card-head h3 { flex: 1 1 auto; min-width: 0; }
.step-state { display: inline-flex; flex: none; gap: 8px; align-items: center; min-height: 27px; }
.step .required { color: var(--muted); font-size: 13px; font-weight: 600; }
.step p:last-child, .step .actions:last-child { margin-bottom: 0; }
.step .guidance { padding: 8px 12px; border-radius: 8px; background: var(--info-wash); color: var(--info); font-size: 14px; }
.step .attention, .gst-section .attention { padding: 8px 12px; border-radius: 8px; background: var(--warn-wash); color: var(--warn); font-weight: 500; }
.step code { padding: 1px 6px; border-radius: 6px; background: var(--tint); font-size: 14px; overflow-wrap: anywhere; }
/* (AC2, SPEC §35.4) Your account: the last section, apart from the steps above it. */
.card.account { margin-top: 24px; }
.card.account .card-head { margin-bottom: 4px; }
.card.account .actions:last-child { margin-bottom: 0; }
/* (BS1, SPEC §40) Connections: apart from the steps above it; each connection its title and state, a line, then its
   paste field with Save (and Remove once connected), divided by a rule. */
.card.connections { margin-top: 24px; }
.card.bills-email { margin-top: 24px; }
.card.bills-email .card-head { margin-bottom: 4px; }
.inbox-address { padding: 16px 0 0; border-top: 1px solid var(--line); margin-top: 16px; }
.inbox-address h4 { margin: 0 0 4px; font-size: 16px; }
.inbox-line { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.inbox-line code { overflow-wrap: anywhere; font-size: 15px; }
.card.bills-email .senders { margin: 16px 0 8px; overflow-wrap: anywhere; }
.card.connections .card-head { margin-bottom: 4px; }
.connection { padding: 16px 0 0; border-top: 1px solid var(--line); margin-top: 16px; }
.connection-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 6px; }
.connection-head h4 { margin: 0; font-size: 16px; }
.connection .desk-form { max-width: 32em; }
.connection .desk-form .field { margin-bottom: 12px; }
.connection .actions { margin-bottom: 0; }
/* (TPL1, SPEC §43) Invoice template, after the steps. */
.card.template { margin-top: 24px; }
.card.template .card-head { margin-bottom: 4px; }
.step .chips { margin: 0 0 12px; }
/* (WI1) Add feed's kind of feed, above the Wise or Bank CSV form or the line that says to connect Wise first. */
.sheet-body > .chips { margin: 0 0 12px; }
.step-items { display: grid; gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.step-items li { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.step-items li:last-child { border-bottom: 0; }
.step-items li > button { margin-left: auto; }

/* A record's fields: a card of label and value pairs. */
.details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 24px; margin: 0 0 16px; padding: 18px 20px; }
.details dt { color: var(--muted); font-size: 14px; }
.details dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.card .details, .sheet .details { padding: 0; border: 0; }

/* Forms: each label above its control, the error beneath it. */
.field { display: grid; gap: 6px; min-width: 0; margin: 0 0 16px; }
.field > label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.field > input:not([type="checkbox"]):not([type="radio"]), .field > select, .field > textarea { width: 100%; }
.field.check { grid-template-columns: max-content minmax(0, 1fr); align-items: center; gap: 4px 10px; min-height: var(--control); }
.field.check .error { grid-column: 1 / -1; }
.field .error { font-size: 13px; }
/* (UI9) A group of radio buttons: its legend as a field's label, each choice a label with its button. */
fieldset.radios { display: block; margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.radios > legend { margin: 0 0 6px; padding: 0; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.radios > .radio { display: inline-flex; align-items: center; gap: 8px; min-height: var(--control); margin-right: 24px; cursor: pointer; }
.radios > .error { display: block; }
.radios > .error:empty { display: none; }
.form-error { margin: 8px 0 0; }
.lines-editor { margin: 8px 0 16px; }
.lines-editor .table-box { margin-bottom: 8px; }
.lines td { padding: 6px; }
.lines input, .lines select { width: 100%; min-width: 72px; }
.lines th.amount, .lines td.amount { width: 9em; }
.lines td.text input { min-width: 16em; }
.lines select { min-width: 104px; }
.lines .error { display: block; font-size: 13px; }
.lines td:last-child { width: 1%; }
/* (PR1) Your details: the colour as a swatch, the logo as stored. (UI9) A name's hint beneath its control; Bank account
   details as one line, each fixed label beside its input (stacked on a phone), in a sheet wide enough for both. */
.desk-form .field > input[type="color"] { width: 64px; padding: 2px; }
.profile-logo { display: block; max-width: 160px; max-height: 64px; }
.field > .hint { margin: 0; font-size: 13px; }
.bank-account h3 { margin-bottom: 4px; }
.account-line { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
.account-line .field { grid-template-columns: max-content minmax(0, 1fr); align-items: center; column-gap: 10px; }
.account-line .field .error { grid-column: 2; }
/* (NUM1) Setup's Invoice numbers: a row per kind, its title, then Prefix, Digits and Next number side by side with the
   next number as it will print beside them; on a phone the example goes beneath the three fields. */
.numbering-row { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)) minmax(0, 1.6fr); gap: 0 16px;
  align-items: start; padding-top: 12px; border-top: 1px solid var(--line); }
.numbering-row:first-of-type { padding-top: 0; border-top: 0; }
.numbering-row h4 { grid-column: 1 / -1; margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.numbering-example { align-self: start; margin: 25px 0 16px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* The sheet: a form waits here, over the dimmed page, until it is sent or closed. The sheet element is the dimmed page;
   its panel is a centred dialog (a bottom sheet on phones), wider for a form with a lines editor. */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(29, 43, 58, 0.36); }
.sheet[hidden] { display: none; }
body:has(.sheet:not([hidden])) { overflow: hidden; }
.sheet-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: sheet-in 220ms var(--ease);
}
.sheet-panel:has(.lines-editor) { width: min(1000px, calc(100vw - 24px)); }
.sheet-panel:has(.bank-account) { width: min(760px, calc(100vw - 24px)); }
.sheet-panel:focus { outline: none; }
@keyframes sheet-in { from { transform: translate(-50%, calc(-50% + 16px)); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.sheet-head .close { border-color: transparent; }
.sheet-head .close:hover:not(:disabled) { border-color: var(--edge); }
.sheet-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 20px 24px 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet-body > :last-child { margin-bottom: 24px; }
/* A form's buttons sit at the foot of the sheet: a short form grows to fill it, and a long one keeps them in view as it
   scrolls. */
.sheet-body > .desk-form:last-child { display: flex; flex-direction: column; flex: 1 0 auto; }
.sheet-body > .desk-form > .actions {
  position: sticky;
  bottom: 0;
  margin: auto -24px 0;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.sheet-body > .desk-form:last-child { margin-bottom: 0; }

/* The inbox: the documents as a column of cards, the open one's review as a card beside them (below on a narrow
   screen). */
.inbox { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 24px; align-items: start; }
.doc-list { display: grid; gap: 10px; }
.doc-card {
  display: grid;
  gap: 4px;
  min-height: 44px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}
.doc-card:hover { border-color: var(--edge); color: var(--ink); }
.doc-card[aria-current="page"] { border-color: var(--copper); box-shadow: inset 0 0 0 1px var(--copper); }
.doc-name { font-weight: 600; overflow-wrap: anywhere; }
.doc-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.doc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { display: inline-flex; align-items: center; padding: 1px 10px; border-radius: 999px; background: var(--tint); color: var(--ink-2); font-size: 13px; font-weight: 500; line-height: 20px; }
/* (EM2, SPEC §28.6) An invoice whose newest email bounced or was marked as spam: Bounced beside its number in the list, in
   the error colour. */
.tag.bounced { background: var(--end-wash); color: var(--end); }
.number-tagged { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.doc-list .empty { padding: 20px; border: 1px dashed var(--edge); border-radius: var(--radius); color: var(--muted); }

/* The home dashboard (SPEC §23.11): the owner's widgets as cards in a grid, two side by side at 1440 px and one on a
   phone. A card's head is the handle it is dragged by; the card it would land on is outlined in copper. */
.widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 20px; align-items: start; }
.widget { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.widget .card-head { margin: 0; cursor: grab; }
.widget .card-head:active { cursor: grabbing; }
.widget .card-head a { cursor: pointer; }
.widget .tiles { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 10px; margin: 0; }
.widget .tile { padding: 12px 14px; }
.widget .table-box { border: 0; border-radius: 0; }
.widget th:first-child, .widget td:first-child { padding-left: 0; }
.widget th:last-child, .widget td:last-child { padding-right: 0; }
.widget td.wrap { min-width: 8em; }
.widget.dragging { opacity: 0.55; }
.widget.drop-target { border-color: var(--copper); box-shadow: inset 0 0 0 1px var(--copper); }
.widget-error {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--end-edge);
  border-radius: 8px;
  background: var(--end-wash);
  overflow-wrap: anywhere;
}
.widget-body > .muted { margin: 0; }
/* The Widgets sheet: each widget with its Show box and its Move buttons, in the layout's order. */
.widget-list { display: grid; gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; }
.widget-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 6px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.widget-list .field { flex: 1 1 12em; margin: 0; }
.widget-list .field > label { color: var(--ink); font-size: 15px; font-weight: 500; cursor: pointer; }
/* The Show box's label fills its field's height, so a press anywhere beside the box toggles it. */
.widget-list .field.check > label { display: flex; align-items: center; align-self: stretch; }

/* The invoice editor (UI8, SPEC §23.13): a page in Xero's order, never a sheet. The head's five fields (the bill
   editor's too) on one row at 1440 px (three on a narrower screen, one on a phone); the grid of lines, each cell a
   labelled field whose label the header row stands for (shown again on a phone's card), the answered Amount in tabular
   figures (no line GST); the totals on the right, the total last and strongest; the buttons beneath, and (UI12) under them the muted line on what
   Issue does. */
.editor { margin: 0 0 20px; padding: 20px 24px 4px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); }
.editor-head {
  display: grid; grid-template-columns: minmax(12em, 1.4fr) repeat(2, minmax(13.5em, 1.2fr)) repeat(2, minmax(0, 1fr)); gap: 0 16px;
  align-items: start;
}
.editor-contact { display: grid; gap: 6px; min-width: 0; margin: 0 0 16px; }
.editor-contact > .field { margin: 0; }
.editor-contact > button { justify-self: start; }
/* (UI13) A new customer's line and Email under Contact, and Edit customer, each shown only when it applies. */
.editor-contact > [hidden] { display: none; }
.new-customer { margin: 0; font-size: 13px; }
.due-note { margin: 0; font-size: 13px; }
/* (UI11, SPEC §23.15) A quick date field: the text input with its calendar button beside it (not a tab stop), the hidden
   date input the button opens the browser's picker on (kept in the layout, unseen, so the picker can open), and beneath
   them the error, the muted weekday line and (the due date) the terms' note. */
.field.date-field { position: relative; grid-template-columns: minmax(0, 1fr) auto; column-gap: 6px; }
.field.date-field > label, .field.date-field > .error, .field.date-field > .weekday, .field.date-field > .due-note { grid-column: 1 / -1; }
.field.date-field > .calendar { padding: 0 10px; font-size: 13px; }
.field.date-field > input.date-picker {
  position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none;
}
.weekday { margin: 0; font-size: 13px; }
.weekday:empty { display: none; }
/* (NUM1) A new invoice's number: text above the head row until the first save, never a control; (UI12) a saved draft's
   is in its title. */
.editor-number { margin: 0 0 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.due-note:empty, .preview-note:empty { display: none; }
.editor-lines { margin: 4px 0 16px; }
.editor-lines .table-box { margin-bottom: 10px; }
.editor-grid td { padding: 6px; }
.editor-grid .field { gap: 2px; margin: 0; }
.editor-grid .field > label, .editor-grid .cell-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.editor-grid td.text input { min-width: 16em; }
/* Qty, Price, (DISC1) Disc %, Account, Tax rate, Amount. */
.editor-grid th:nth-child(2), .editor-grid td:nth-child(2) { width: 5.5em; }
.editor-grid th:nth-child(3), .editor-grid td:nth-child(3) { width: 8em; }
.editor-grid th:nth-child(4), .editor-grid td:nth-child(4) { width: 5.5em; }
.editor-grid td:nth-child(5) select { min-width: 11em; }
.editor-grid th:nth-child(6), .editor-grid td:nth-child(6) { width: 8.5em; }
.editor-grid th:nth-child(7), .editor-grid td:nth-child(7) { width: 7.5em; }
.editor-grid td.figure { padding: 14px 10px 6px; }
.editor-foot { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; margin: 0 0 8px; }
.preview-note { margin: 0; }
.editor-totals {
  display: grid;
  grid-template-columns: max-content minmax(8em, max-content);
  gap: 8px 0;
  margin: 0 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.editor-totals dt { padding-right: 32px; color: var(--muted); }
.editor-totals dd { margin: 0; text-align: right; }
.editor-totals dt:last-of-type, .editor-totals dd:last-of-type {
  padding-top: 8px; border-top: 1px solid var(--rule); color: var(--ink); font-size: 18px; font-weight: 600;
}
.editor > .actions { margin: 8px -24px 0; padding: 16px 24px 8px; border-top: 1px solid var(--line); }
.editor > .issue-note { margin: 0 0 16px; font-size: 13px; }
/* (UI10, SPEC §23.14) The bill editor, on the same rules: five head fields; the grid's own widths (Description, Account,
   Tax rate, then the Amount typed with its answered figure beneath it); the GST on the supplier's invoice beneath the
   totals, on the right; once saved, the supplier's invoice attached above the buttons, its files as links. */
.bill-grid th:nth-child(n), .bill-grid td:nth-child(n) { width: auto; }
.bill-grid th:first-child, .bill-grid td:first-child { width: 42%; }
.bill-grid td:nth-child(2) select { min-width: 14em; }
.bill-grid td:nth-child(3) select { min-width: 10em; }
.bill-grid th:nth-child(4), .bill-grid td:nth-child(4) { width: 9em; }
.bill-grid .figure-value { display: block; min-height: 18px; padding: 2px 2px 0; color: var(--muted); font-size: 13px; text-align: right;
  font-variant-numeric: tabular-nums; }
.editor-foot .document-gst { flex: 0 0 100%; justify-items: end; margin: 0; }
.editor-foot .document-gst > input.amount { width: 12em; text-align: right; }
.editor-foot .document-gst .hint { text-align: right; }
.editor-attach { display: grid; gap: 8px; justify-items: start; margin: 0 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.editor-attach[hidden] { display: none; }
.editor-attach > .field { margin: 0; }
.editor-attach .attached { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.editor-attach .attached p { margin: 0; }

/* The auth page (AC1, SPEC §32.4): the mark above one card, centred on the grey ground; the form's button as wide as
   the card, the links to the other views beneath a rule. */
main.auth { display: grid; justify-items: center; align-content: start; gap: 20px; max-width: none; min-height: 100vh; padding: 64px 16px 48px; }
.auth-card { width: min(100%, 420px); padding: 28px; }
.auth-card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.auth-card h2 + .desk-form, .auth-card h2 + .banner { margin-top: 16px; }
.auth-card .intro { margin: 0 0 20px; color: var(--muted); }
.auth-card .banner { margin-bottom: 20px; padding: 10px 14px; border: 1px solid var(--ok-edge); border-radius: 8px; background: var(--ok-wash); color: var(--ok); }
.auth-card .terms { margin: 0; font-size: 13px; }
.auth-card .actions { margin-bottom: 0; }
.auth-card .actions button { flex: 1 1 auto; }
.auth-card .resend { width: 100%; margin-top: 10px; }
.auth-links { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }
.auth-links p { margin: 0 0 6px; }
.auth-links p:last-child { margin-bottom: 0; }
/* (FU2, SPEC §32.6) The terms and privacy links beneath the sign-in view's own links, small. */
.auth-links .legal { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; font-size: 13px; }

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .editor-head { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  :root { --side: 216px; }
  .owner select { font-size: 13px; }
  .page { padding: 0 20px 40px; }
  .inbox { grid-template-columns: minmax(0, 1fr); }
}

/* Phones: the sidebar becomes a top bar, every control 44 px tall, forms in a bottom sheet. */
@media (max-width: 767px) {
  :root { --control: 44px; }
  .side {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    width: auto;
    padding: 10px 16px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .brand { margin-right: auto; padding: 4px 0; }
  .owner { order: 2; grid-template-columns: auto minmax(0, 190px); flex: 0 1 auto; min-width: 0; margin: 0; padding: 0; background: transparent; }
  .avatar { width: 32px; height: 32px; font-size: 12px; }
  .owner-label, .owner .owner-book { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .owner select { grid-column: auto; }
  /* (AC1) Signed in, the chooser is hidden: the avatar and Sign out, beside the mark. */
  .owner:has(select[hidden]) { grid-template-columns: auto auto; }
  .owner .sign-out { grid-column: auto; width: auto; }
  #menu { order: 3; flex: 1 0 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  #menu a { justify-content: center; gap: 5px; min-height: 44px; padding: 0 4px; background: var(--ground); font-size: 13px; text-align: center; }
  #menu .icon { width: 18px; height: 18px; }
  #menu .review-link { margin-top: 0; }
  .page { margin-left: 0; padding: 0 16px 40px; }
  #status { margin-top: 16px; }
  main { padding-top: 16px; }
  .toolbar h2 { font-size: 21px; }
  .toolbar > button, .toolbar > a { flex: 1 1 auto; justify-content: center; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile { padding: 14px 16px; }
  .tile-figure { font-size: 22px; }
  .filters .field { width: 100%; margin: 0; }
  .filters select { flex: 1; min-width: 0; }
  input, select, textarea { font-size: 16px; }
  .details { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .details dd + dt { margin-top: 8px; }
  .details dd a { display: inline-flex; align-items: center; min-height: 44px; }
  .card { padding: 16px; }
  main.auth { padding-top: 32px; }
  .auth-card { padding: 20px; }
  .account-line, .account-line .field { grid-template-columns: minmax(0, 1fr); }
  .account-line .field .error { grid-column: auto; }
  .numbering-row { grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); gap: 0 10px; }
  .numbering-example { grid-column: 1 / -1; margin: 0 0 16px; }
  .sheet-panel, .sheet-panel:has(.lines-editor), .sheet-panel:has(.bank-account) {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    animation-name: sheet-up;
  }
  .sheet-head { padding: 16px; }
  .sheet-body { padding: 16px 16px 0; }
  .sheet-body > .desk-form > .actions { margin: auto -16px 0; padding: 12px 16px; }
  .sheet-body > .desk-form > .actions button { flex: 1 1 auto; }
  /* A widget's table fits the card: tighter cells, and an amount, a date or a file name may wrap. */
  .widget th, .widget td { padding: 8px 6px; }
  .widget td.amount, .widget td.nowrap, .widget td.wrap { min-width: 0; white-space: normal; }
  /* The invoice editor: one field per row, each line a card of labelled fields, the totals full width. */
  .editor { padding: 16px 16px 4px; }
  .editor-head { grid-template-columns: minmax(0, 1fr); }
  .editor-lines .table-box { border: 0; overflow: visible; }
  .editor-grid thead { display: none; }
  .editor-grid, .editor-grid tbody, .editor-grid tr, .editor-grid td { display: block; width: auto; }
  .editor-grid th:nth-child(n), .editor-grid td:nth-child(n) { width: auto; }
  .editor-grid tr { margin: 0 0 12px; padding: 12px; border: 1px solid var(--rule); border-radius: var(--radius); }
  .editor-grid tbody tr:hover { background: var(--paper); }
  .editor-grid td, .editor-grid tbody tr:last-child td { padding: 0 0 10px; border: 0; }
  .editor-grid .field > label, .editor-grid .cell-label {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal;
  }
  .editor-grid .field > label { color: var(--ink-2); font-size: 13px; font-weight: 500; text-align: left; }
  .editor-grid td.text input, .editor-grid td:nth-child(4) select { min-width: 0; }
  .editor-grid td.figure { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0 8px; }
  .editor-grid .cell-label { color: var(--muted); font-size: 13px; }
  .editor-grid td.remove { padding: 4px 0 0; }
  .editor-grid td.remove button, .editor-lines > button { width: 100%; }
  .editor-totals { width: 100%; margin: 0; grid-template-columns: minmax(0, 1fr) max-content; }
  .editor > .actions { margin: 8px -16px 0; padding: 12px 16px 8px; }
  .editor > .actions button { flex: 1 1 auto; }
  /* (UI10) The bill editor's GST on the supplier's invoice and its attach row full width. */
  .editor-foot .document-gst { justify-items: stretch; }
  .editor-foot .document-gst > input.amount { width: 100%; }
  .editor-foot .document-gst .hint { text-align: left; }
  .editor-attach, .editor-attach > .field, .editor-attach > button { justify-items: stretch; width: 100%; }
  /* In the Widgets sheet, each widget's Show box above its two Move buttons. */
  .widget-list li { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget-list .field { grid-column: 1 / -1; }
}
@keyframes sheet-up { from { transform: translateY(32px); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
