/* CostPilot styles. The design system lives in design-system/costpilot/MASTER.md;
   the tokens below are copied from design-system/costpilot/tokens.css. */
:root {
  /* Core palette */
  /* Actions are ink; lime marks where you are (revision 3: Ink and lime) */
  --ink-action: #1D2329;
  --ink-hover: #3A424B;
  --lime: #C6F36B;
  --lime-soft: #EBF9C8;
  --lime-ink: #3F5212;
  --lime-edge: #8FBF2F;
  --range: #1D2329;
  --cast-iron: var(--range);
  --stainless: #F0F3F5;
  --flour: var(--stainless);
  /* Status: the rest of the highlighter pack (revision 4). Each colour has a fill (badges,
     ink text), a wash (large notices), a text shade (coloured text on white) and a bar shade. */
  --mint: #B8F0D2;       --mint-wash: #E3F8EC;     --mint-text: #13703F;     --mint-bar: #2BB673;
  --butter: #FFE57A;     --butter-wash: #FFF5C7;   --butter-text: #8A5300;   --butter-bar: #E9B92C;
  --coral: #FFC4BD;      --coral-wash: #FFE6E2;    --coral-text: #B42318;    --coral-bar: #F05A4F;
  --lavender: #DCD4FF;   --lavender-wash: #EEEAFF; --lavender-text: #5133C9; --lavender-bar: #8B6CFF; --lavender-hover: #CBBFFF;
  --sky: #BFE3FF;        --sky-wash: #E6F4FF;      --sky-text: #0B5B8C;      --sky-bar: #2E96DB;
  /* Older names, mapped onto the highlighter pack */
  --basil: var(--mint-text);         --basil-dark: var(--ink-900);     --basil-soft: var(--mint);
  --saffron: var(--butter-text);     --saffron-dark: var(--ink-900);   --saffron-soft: var(--butter);   --saffron-fill: var(--butter-bar);
  --tomato: var(--coral-text);       --tomato-dark: var(--ink-900);    --tomato-soft: var(--coral);
  --blueberry: var(--lavender-text); --blueberry-dark: var(--ink-900); --blueberry-soft: var(--lavender);
  /* Neutrals */
  --ink-900: #1D2329;
  --pepper: #56606B;
  --plate: #FFFFFF;
  --crumb: #DCE1E6;
  --crust: #C3CBD3;
  --stone: #E4E9ED;
  --stone-ink: #3F4852;
  /* Chart */
  --chart-1: #1D2329;
  --chart-2: #5B3FD0;
  --chart-over: #F05A4F;
  --chart-under: #2BB673;
  --chart-track: #E4E9ED;
  --chart-zero: #8A939C;
  /* Type */
  --font-heading: 'Nunito', 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible Next', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-xs: 13px;
  --text-sm: 14px;
  --text-base: 15px;
  --text-md: 17px;
  --text-lg: 22px;
  --text-xl: 28px;
  /* Spacing (density 8) */
  --space-xs: 2px;
  --space-sm: 4px;
  --space-md: 8px;
  --space-lg: 12px;
  --space-xl: 16px;
  --space-2xl: 24px;
  --space-3xl: 32px;
  /* Shape and motion */
  --radius-card: 10px;
  --radius-ticket: 3px;
  --radius-control: 8px;
  --radius-overlay: 14px;
  --shadow-overlay: 0 16px 40px rgb(29 35 41 / .2);
  --shadow-paper: drop-shadow(0 1px 1px rgb(29 35 41 / .12)) drop-shadow(0 4px 6px rgb(29 35 41 / .06));
  --ease: 150ms ease;
  /* z-index scale */
  --z-raised: 1;
  --z-sticky: 10;
  --z-dropdown: 20;
  --z-overlay: 40;   /* phone: panel backdrop */
  --z-sheet: 41;     /* phone: bottom panel and menu drawer */
  --z-viewer: 50;    /* phone: full-screen original invoice */
  --z-toast: 60;

  /* Semantic aliases (the page scripts use these names inline) */
  --bg: var(--flour);
  --panel: var(--plate);
  --ink: var(--ink-900);
  --muted: var(--pepper);
  --line: var(--crumb);
  --line-strong: var(--crust);
  --accent: var(--ink-action);
  --accent-ink: #FFFFFF;
  --accent-soft: var(--lime-soft);
  --side: var(--cast-iron);
  --side-ink: #D3DAE0;
  --warn: var(--saffron);
  --warn-soft: var(--saffron-soft);
  --info: var(--stone-ink);
  --info-soft: var(--stone);
  --ok: var(--basil);
  --ok-soft: var(--basil-soft);
  --bad: var(--tomato);
  --bad-soft: var(--tomato-soft);
  --up: var(--tomato);
  --down: var(--basil);
  --ai: var(--blueberry);
  --ai-soft: var(--blueberry-soft);
  --radius: var(--radius-card);
  --shadow: none;
}

/* ---- Base ------------------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
body {
  font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--lime-edge); text-decoration-thickness: 2px; text-underline-offset: 3px; transition: text-decoration-color var(--ease); }
a:hover { color: var(--ink); text-decoration-color: var(--ink); }
a.btn, a.stat, a.crumb, .sidebar nav a, .sidebar nav a:hover { text-decoration: none; }
h1, h2, h3 { font-family: var(--font-heading); color: var(--ink); line-height: 1.2; text-wrap: balance; }
p, li, .sub, .hint { text-wrap: pretty; }
.panel-meta { font-size: var(--text-xs); color: var(--muted); }
h1 { font-size: var(--text-xl); font-weight: 800; margin: 0; }
h2 { font-size: var(--text-md); font-weight: 800; margin: 0; }
h3 { font-size: var(--text-md); font-weight: 800; margin: 0; }
b, strong { font-weight: 700; }
.muted { color: var(--muted); }
.tiny { font-size: var(--text-xs); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: var(--z-toast); background: var(--lime); color: var(--range); padding: 10px 14px; border-radius: var(--radius-control); font-weight: 700; text-decoration: none; }
.skip-link:focus, .skip-link:focus-visible { top: 12px; }
html { scroll-padding-top: 80px; }
:focus-visible { outline: 2px solid var(--ink-action); outline-offset: 2px; box-shadow: 0 0 0 5px rgb(198 243 107 / .7); }
::selection { background: var(--lime); }
html { scrollbar-color: var(--crust) transparent; -webkit-tap-highlight-color: rgb(198 243 107 / .35); }
a, button, input, select, textarea, label, summary, tr.link { touch-action: manipulation; }
dialog.modal .modal-body { overscroll-behavior: contain; }
@media (pointer: fine) { html { overscroll-behavior: none; } }
input, textarea { caret-color: var(--ink); }

/* ---- Layout ---------------------------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: 228px; flex: none; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: var(--space-md); font-family: var(--font-heading); font-weight: 800; font-size: 20px; color: #fff; padding: 20px 20px 16px; }
.brand .logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--lime); color: var(--range); font-size: 15px; }
.brand.big { color: var(--ink); font-size: 26px; padding: 0 0 var(--space-sm); }
.brand.big .logo { width: 38px; height: 38px; border-radius: 11px; font-size: 18px; }
.sidebar nav { display: flex; flex-direction: column; gap: var(--space-xs); padding: var(--space-md) var(--space-lg); }
.sidebar nav a { display: flex; align-items: center; gap: var(--space-lg); min-height: 38px; padding: var(--space-md) var(--space-lg); border-radius: var(--radius-control); color: var(--side-ink); font-weight: 600; font-size: var(--text-sm); transition: background var(--ease), color var(--ease); }
.sidebar nav a svg { flex: none; opacity: .85; }
.sidebar nav a:hover { background: rgb(255 255 255 / .07); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--lime); color: var(--range); }
.sidebar nav a.active svg { opacity: 1; }
.sidebar nav a.child { min-height: 32px; padding: 6px 12px 6px 42px; font-size: var(--text-xs); font-weight: 600; color: #B9C2CA; }
.sidebar nav a.child.active { background: rgb(198 243 107 / .14); color: #fff; box-shadow: inset 3px 0 0 var(--lime); }
.sidebar nav a .count { margin-left: auto; background: var(--saffron-fill); color: var(--cast-iron); border-radius: 999px; font-size: var(--text-xs); font-weight: 700; padding: 0 8px; line-height: 20px; }
.sidebar nav a .count.setup-pill { background: var(--mint); color: var(--ink); }
.sidebar-foot { margin-top: auto; padding: var(--space-xl) 20px; font-size: var(--text-xs); color: #9AA4AE; line-height: 1.45; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-xl); padding: var(--space-md) var(--space-2xl); background: var(--plate); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: var(--z-sticky); }
.client-switch select { font-family: var(--font-heading); font-weight: 800; font-size: var(--text-md); border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 6px 32px 6px 12px; background-color: var(--plate); color: var(--ink); cursor: pointer; }
.user { display: flex; align-items: center; gap: var(--space-lg); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--lime-soft); color: var(--ink-hover); display: grid; place-items: center; font-weight: 700; font-size: var(--text-xs); flex: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; font-size: var(--text-sm); }
.user-meta small { color: var(--muted); font-size: var(--text-xs); }
.profile-btn { display: flex; align-items: center; gap: var(--space-lg); background: none; border: 0; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-control); cursor: pointer; font: inherit; color: inherit; text-align: left; transition: background var(--ease); }
.profile-btn:hover { background: var(--bg); }
main { padding: var(--space-2xl); outline: none; max-width: 1500px; width: 100%; }
main:focus, main:focus-visible { outline: none; box-shadow: none; } /* focused by the app after each page change, not by the user */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-xl); margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: var(--space-sm); font-size: var(--text-sm); }
.actions { display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: center; min-width: 0; max-width: 100%; }
.crumb { font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-md); display: inline-block; font-weight: 600; }
.crumb:hover { color: var(--ink-action); }

/* ---- Cards ----------------------------------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); }
.panel > table:last-child tr:last-child td, .panel .table-wrap:last-child { border-bottom-left-radius: var(--radius-card); border-bottom-right-radius: var(--radius-card); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); padding: 14px var(--space-xl); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: var(--space-xl); }
.table-wrap { overflow-x: auto; position: relative; } /* relative: screen-reader-only labels inside stay inside the scroll box instead of widening the page */

/* Order tickets: each page's summary figures hang from the pass rail as kitchen tickets.
   The one bold element in the system; the group shares a single paper shadow. */
.stats { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-lg); margin: 0 0 20px; padding: 3px 6px 0; filter: var(--shadow-paper); }
.stats::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--range); border-radius: 3px; z-index: var(--z-raised); }
.stats > .stat {
  position: relative; border: 0; border-radius: var(--radius-ticket) var(--radius-ticket) 0 0;
  padding: 16px var(--space-xl) 24px; cursor: default; background: var(--plate);
  /* torn ticket edge */
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
}
.stat .label { color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.stat .value { font-family: var(--font-body); font-size: var(--text-lg); font-weight: 700; margin-top: var(--space-xs); font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.25; }
.stat .hint { font-size: var(--text-xs); color: var(--muted); margin-top: var(--space-md); padding-top: var(--space-md); border-top: 1px dashed var(--crust); }
.stat.clickable, a.stat { cursor: pointer; transition: background var(--ease); }
.stats > .stat.clickable:hover, .stats > a.stat:hover { background: #F7F9FA; }
.stats > .stat.clickable:hover .label, .stats > a.stat:hover .label { color: var(--ink); }
a.stat { color: inherit; text-decoration: none; display: block; font-weight: 400; }
button.stat { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
a.stat:hover { text-decoration: none; color: inherit; }
a.stat:focus-visible { outline: none; background: var(--lime-soft); }

/* ---- Buttons and forms ----------------------------------------------------------------- */
.btn {
  font-family: var(--font-body); font-weight: 600; font-size: var(--text-sm); line-height: 1.2;
  min-height: 36px; border: 1px solid var(--line-strong); background: var(--plate); color: var(--ink);
  border-radius: var(--radius-control); padding: 7px 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
a.btn { text-decoration: none; }
.btn:hover { border-color: var(--ink-action); background: var(--bg); color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--ink-action); border-color: var(--ink-action); color: #fff; }
.btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); color: #fff; }
.btn.ai { background: var(--lavender); border-color: var(--lavender-bar); color: var(--ink); }
.btn.ai:hover { background: var(--lavender-hover); border-color: var(--lavender-text); color: var(--ink); }
.btn.recipe { background: var(--basil-soft); border-color: var(--basil); color: var(--basil-dark); }
.btn.recipe:hover { background: var(--basil); border-color: var(--basil); color: #fff; }
.btn.danger { color: var(--tomato); }
.btn.danger:hover { background: var(--tomato-soft); border-color: var(--tomato); color: var(--tomato-dark); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--stone); border-color: transparent; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: var(--text-xs); }
.btn.block { width: 100%; }
.btn:disabled, .btn:disabled:hover { opacity: .45; cursor: not-allowed; background: var(--plate); border-color: var(--line-strong); color: var(--ink); }
.btn.primary:disabled, .btn.primary:disabled:hover { background: var(--ink-action); border-color: var(--ink-action); color: #fff; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 15px; color: var(--muted); min-width: 30px; min-height: 30px; padding: 4px 8px; border-radius: var(--radius-control); transition: background var(--ease), color var(--ease); }
.icon-btn:hover { background: var(--stone); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn:disabled:hover { background: transparent; }
input, select, textarea { font-family: var(--font-body); font-size: var(--text-sm); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 7px 10px; background: var(--plate); min-width: 0; transition: border-color var(--ease), box-shadow var(--ease); font-variant-numeric: tabular-nums; }
input::placeholder, textarea::placeholder { color: #6B747E; }
input:hover, select:hover, textarea:hover { border-color: #A9B3BC; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-action); box-shadow: 0 0 0 3px rgb(198 243 107 / .6); }
input[type=checkbox], input[type=radio] { accent-color: var(--ink-action); width: 16px; height: 16px; cursor: pointer; }
select { cursor: pointer; }
label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); font-weight: 600; color: var(--stone-ink); }
label input, label select { font-weight: 400; font-size: var(--text-sm); }
textarea { resize: vertical; width: 100%; }
.field-error { font-size: var(--text-xs); font-weight: 600; color: var(--coral-text); }
#upload-error { display: block; margin-top: var(--space-md); }
.rule-badge { margin-left: 6px; vertical-align: 1px; cursor: help; }
tr.rule-offer td { background: var(--lime-soft); border-top: 0; padding: 8px 12px; font-size: var(--text-sm); }
/* stays in view while the table scrolls sideways on a phone, and wraps there */
tr.rule-offer .offer-box { position: sticky; left: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; max-width: min(100%, calc(100vw - 72px)); }
tr.rule-offer .offer-acts { display: inline-flex; align-items: center; gap: 12px; }
.rules-notes { width: 100%; min-height: 150px; resize: vertical; line-height: 1.5; }
#upload-error[hidden] { display: none; }
.upload-file { margin: var(--space-md) 0 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
[aria-invalid="true"] { border-color: var(--coral-bar); }
.empty-action { margin-top: var(--space-lg); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-lg); }
.form-grid > * { min-width: 0; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }
.form-grid .span2 { grid-column: span 2; }
.search { position: relative; }
.search input { padding-left: 32px; width: 260px; }
.search::before { content: ''; position: absolute; left: 11px; top: 50%; width: 11px; height: 11px; border: 2px solid var(--muted); border-radius: 50%; transform: translateY(-62%); pointer-events: none; }
.search::after { content: ''; position: absolute; left: 22px; top: 50%; width: 6px; height: 2px; background: var(--muted); transform: translateY(5px) rotate(45deg); pointer-events: none; }

/* ---- Tabs and chips -------------------------------------------------------------------- */
.tabs { display: flex; gap: var(--space-sm); border-bottom: 1px solid var(--line); margin-bottom: var(--space-xl); flex-wrap: wrap; }
.tabs button { font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; padding: 10px 12px; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; border-radius: var(--radius-control) var(--radius-control) 0 0; transition: color var(--ease), background var(--ease); }
.tabs button:hover { color: var(--ink); background: var(--stone); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink-action); }
.tabs .pill { background: var(--stone); border-radius: 999px; padding: 0 8px; font-size: var(--text-xs); color: var(--stone-ink); font-weight: 700; }
.tabs button.active .pill { background: var(--lime-soft); color: var(--ink-hover); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 600; border: 1px solid var(--line-strong); background: var(--plate); border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--stone-ink); transition: background var(--ease), border-color var(--ease); }
.chip:hover { border-color: var(--ink-action); }
.chip.active { background: var(--lime); border-color: var(--lime-edge); color: var(--range); }

/* ---- Tables ---------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th { text-align: left; font-size: var(--text-xs); color: var(--stone-ink); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--stone); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1.35; }
tr:last-child td { border-bottom: 0; }
.panel > table:first-child thead th:first-child, .panel > .table-wrap:first-child thead th:first-child { border-top-left-radius: calc(var(--radius-card) - 1px); }
.panel > table:first-child thead th:last-child, .panel > .table-wrap:first-child thead th:last-child { border-top-right-radius: calc(var(--radius-card) - 1px); }
/* Names in tables link to their record; ink keeps orange for actions */
td a:not(.btn) { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-color: var(--crust); text-underline-offset: 3px; }
td a:not(.btn):hover { color: var(--ink-hover); text-decoration-color: var(--ink-action); }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--bg); }
tbody tr.link:focus-visible { outline: 2px solid var(--ink-action); outline-offset: -2px; box-shadow: none; }
tbody tr.link:focus-visible td { background: var(--lime-soft); }
tfoot td { font-weight: 700; background: var(--plate); border-top: 2px solid var(--ink); border-bottom: 0; }
td.check, th.check { width: 40px; padding-right: 0; }
.check-hit { display: flex; flex-direction: row; align-items: center; justify-content: center; min-width: 32px; min-height: 36px; cursor: pointer; }
.row-toggle { min-width: 28px; min-height: 28px; padding: 2px 6px; }
.btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn[aria-disabled="true"]:hover { background: var(--plate); border-color: var(--line-strong); }
.empty { padding: var(--space-3xl); text-align: center; color: var(--muted); }
th.sortable { cursor: pointer; user-select: none; transition: color var(--ease); }
th.sortable:hover { color: var(--ink); }
th.sortable::after { content: '↕'; opacity: .35; margin-left: 4px; font-size: 11px; }
th.sortable[aria-sort="ascending"]::after { content: '▲'; opacity: 1; color: var(--ink-action); }
th.sortable[aria-sort="descending"]::after { content: '▼'; opacity: 1; color: var(--ink-action); }
th.sortable:focus-visible { outline: 2px solid var(--ink-action); outline-offset: -2px; }

/* ---- Badges and status ----------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 700; border-radius: 999px; padding: 1px 10px; line-height: 20px; white-space: nowrap; }
.badge.warn { background: var(--saffron-soft); color: var(--saffron-dark); }
.badge.info { background: var(--stone); color: var(--stone-ink); }
.badge.ok { background: var(--basil-soft); color: var(--basil-dark); }
.badge.bad { background: var(--tomato-soft); color: var(--tomato-dark); }
.badge.ai { background: var(--blueberry-soft); color: var(--blueberry-dark); }
.badge.plain { background: var(--stone); color: var(--stone-ink); }
.badge.credit { background: #FAD6EC; color: var(--ink); }
.badge.ask { background: var(--sky); color: var(--ink-900); }
.chg { font-size: var(--text-xs); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chg.up { color: var(--tomato); }
.chg.down { color: var(--basil); }
.chg.flat { color: var(--muted); }
.chg.alert { background: var(--tomato-soft); color: var(--tomato-dark); padding: 1px 7px; border-radius: 999px; }
.chg.down.alert { background: var(--basil-soft); color: var(--basil-dark); }
.chg.quiet { color: var(--muted); font-weight: 600; } /* under 5%: worth seeing, not worth colour */
.lines .chg[title] { cursor: help; }
.conf { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.conf.high { background: var(--mint-bar); }
.conf.medium { background: var(--saffron-fill); }
.conf.low { background: var(--coral-bar); }
.unmapped { color: var(--tomato); font-weight: 700; font-size: var(--text-xs); text-decoration-color: currentColor; }

/* ---- Notices and flags ----------------------------------------------------------------- */
.notice { background: var(--stone); color: var(--stone-ink); padding: 10px 14px; border-radius: var(--radius-control); font-size: var(--text-sm); border-left: 4px solid var(--crust); }
.alerts { display: flex; gap: var(--space-lg); align-items: center; background: var(--butter-wash); color: var(--ink); border-left: 4px solid var(--butter-bar); border-radius: var(--radius-control); padding: 10px 14px; margin-bottom: var(--space-xl); font-size: var(--text-sm); }
.flag-box { background: var(--butter-wash); border-left: 4px solid var(--butter-bar); color: var(--ink); border-radius: var(--radius-control); padding: 12px 16px; margin-bottom: var(--space-xl); font-size: var(--text-sm); }
.flag-box.bad { background: var(--coral-wash); border-left-color: var(--coral-bar); color: var(--ink); }
.flag-box h2, .flag-box h3 { margin-bottom: 6px; font-size: 16px; color: inherit; }
.flag-box ul { margin: 0 0 6px; padding-left: 18px; }
.flag-box a { color: inherit; text-decoration: underline; }
.problem-list { background: var(--coral-wash); color: var(--ink); border-left: 4px solid var(--coral-bar); border-radius: var(--radius-control); padding: 10px 14px 10px 30px; margin: 10px 0 0; font-size: var(--text-sm); }
.ai-notes { background: var(--lavender-wash); border-left: 4px solid var(--lavender-bar); border-radius: var(--radius-control); padding: 12px 16px; margin-bottom: var(--space-xl); color: var(--ink); font-size: var(--text-sm); }
.ai-notes h2, .ai-notes h3 { color: var(--lavender-text); display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 16px; }
.ai-notes ul { margin: 0; padding-left: 18px; }
.ai-notes li { margin: 3px 0; }
.locked { background: var(--stone); border-radius: var(--radius-control); padding: 10px 14px; color: var(--stone-ink); font-size: var(--text-sm); margin-bottom: var(--space-xl); }

/* ---- Bulk bar -------------------------------------------------------------------------- */
/* The bar's wrapper is what stays pinned to the bottom of the window (a sticky element can only move inside
   its parent, and the wrapper is exactly the bar's height, so pinning the bar itself never moved it) */
#bulk { position: sticky; bottom: calc(var(--space-xl) + env(safe-area-inset-bottom)); z-index: var(--z-sticky); }
.bulkbar { margin-top: var(--space-xl); display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); background: var(--cast-iron); color: #fff; padding: 12px 16px; border-radius: var(--radius-card); box-shadow: var(--shadow-overlay); flex-wrap: wrap; }
.bulkbar .btn { border-color: transparent; }
.bulkbar .btn.ghost:hover { background: rgb(255 255 255 / .1); }
.bulkbar .btn.primary { background: var(--lime); color: var(--range); border-color: var(--lime); }
.bulkbar .btn.primary:hover:not(:disabled) { background: var(--lime-edge); border-color: var(--lime-edge); }

/* ---- Invoice review -------------------------------------------------------------------- */
/* Coding on top at full width; the original invoice underneath at a readable, full size */
.review { display: flex; flex-direction: column; gap: var(--space-xl); }
.doc-pane { overflow: hidden; scroll-margin-top: 76px; }
.doc-view { background: #4A535C; padding: var(--space-2xl); display: flex; justify-content: center; }
.doc-view iframe { width: 100%; height: 90dvh; min-height: 640px; border: 0; background: #fff; border-radius: 4px; }
.doc-view img { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.paper { width: 100%; max-width: 820px; background: #fff; padding: 32px 36px 40px; font: 14px/1.5 'Courier New', monospace; color: #222; box-shadow: 0 2px 10px rgba(0,0,0,.35); border-radius: 2px; }
.link-btn { font: inherit; font-size: var(--text-xs); font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0 0 0 4px; cursor: pointer; text-decoration: underline; text-decoration-color: var(--lime-edge); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.link-btn:hover { text-decoration-color: var(--ink); }
.paper h3 { font: 700 18px var(--font-body); margin: 0 0 4px; color: #222; }
.paper table td, .paper table th { padding: 3px 4px; border: 0; font: inherit; background: none; color: #222; }
.paper table thead th { border-bottom: 1px dashed #999; font-weight: 700; }
.paper .ptot td { border-top: 1px dashed #999; font-weight: 700; }
.paper .hl td { background: #FEF3C7; }
.lines td { padding: 8px 6px; }
.lines th { padding: 10px 6px; }
.lines input.qty { width: 68px; padding-left: 6px; padding-right: 6px; text-align: right; } /* room for 12.5 and 0.25 (52px cut decimals off) */
.lines input.price { width: 82px; text-align: right; }
.lines select { width: 100%; min-width: 150px; font-size: var(--text-xs); padding: 6px 8px; }
/* Coded to: wide enough for an item name, no wider. Spare width goes to the invoice line instead */
.lines th.coded, .lines td.coded { width: 220px; min-width: 160px; max-width: 220px; }
.lines td:first-child { max-width: 420px; }
/* Number columns, Price vs. cost and Remove shrink to their content */
.lines thead th:nth-child(2), .lines thead th:nth-child(3), .lines thead th:nth-child(4), .lines thead th:nth-child(6), .lines thead th:nth-child(7) { width: 1%; }
.lines thead th:nth-child(6) { white-space: nowrap; }
.lines select.acct { margin-top: 4px; color: var(--stone-ink); }
.lines .desc { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 600; }
.lines .note { font-size: var(--text-xs); color: var(--muted); margin-top: 3px; }
.lines tr.low td { background: #FFF3F1; }
.lines tr.low td:first-child { box-shadow: inset 4px 0 0 var(--coral-bar); }
.lines tr.medium td:first-child { box-shadow: inset 4px 0 0 var(--saffron-fill); }
.totals { display: grid; grid-template-columns: 1fr 340px; gap: var(--space-xl); margin-top: var(--space-xl); align-items: start; }
.sum-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-variant-numeric: tabular-nums; font-size: var(--text-sm); }
.sum-row.total { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 16px; }
.sum-row input { width: 116px; text-align: right; }
.balance { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-control); font-weight: 700; display: flex; gap: 8px; align-items: center; font-size: var(--text-sm); }
.balance.ok { background: var(--mint-wash); color: var(--ink); box-shadow: inset 4px 0 0 var(--mint-bar); }
.balance.bad { background: var(--coral-wash); color: var(--ink); box-shadow: inset 4px 0 0 var(--coral-bar); }

/* Invoice queue (the landing page). Row one: what you're looking at (tabs, view).
   Row two: narrowing it down (search, supplier, scope note). */
.queue-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-lg); padding: 6px var(--space-xl) 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.queue-head .tabs button { padding: 12px 12px 10px; }
.queue-head .chips { padding-bottom: 8px; }
.queue-tools { display: flex; align-items: center; gap: var(--space-lg); padding: 12px var(--space-xl); flex-wrap: wrap; }
.queue-tools .search { flex: 1 1 280px; max-width: 420px; }
.queue-tools .search input { width: 100%; }
.queue-tools .queue-note { margin-left: auto; }
.queue-table th, .queue-table td { padding-left: 8px; padding-right: 8px; }
.queue-table td.check, .queue-table th.check { width: 32px; padding-right: 0; }
.queue-table th:first-child, .queue-table td:first-child { padding-left: var(--space-xl); }
.queue-table td:has(> b:only-child) { min-width: 110px; }
.badge-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

/* Distribution grid */
.dist th, .dist td { padding: 8px 10px; font-size: var(--text-xs); }
.dist td { font-size: var(--text-sm); }
.dist th.num { text-align: right; }

/* ---- Inventory ------------------------------------------------------------------------- */
.inv-table th, .inv-table td { padding-left: 8px; padding-right: 8px; }
.inv-table th:first-child, .inv-table td:first-child { padding-left: var(--space-xl); }
.inv-table .inv-name { min-width: 160px; }
.inv-table .inv-pack { min-width: 96px; }
.inv-table td:last-child .badge { white-space: normal; max-width: 120px; line-height: 1.3; padding-top: 2px; padding-bottom: 2px; }
.inv-layout { display: grid; grid-template-columns: clamp(160px, 13vw, 220px) minmax(0, 1fr); gap: var(--space-xl); align-items: start; }
.cat-list { padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-xs); }
.cat-list button { font-family: var(--font-body); font-size: var(--text-sm); text-align: left; border: 0; background: none; min-height: 36px; padding: 8px 12px; border-radius: var(--radius-control); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); transition: background var(--ease); }
.cat-list button:hover { background: var(--bg); }
.cat-list button.active { background: var(--lime); color: var(--range); }
.cat-list small { color: var(--muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.cat-list button.active small { color: var(--lime-ink); }
.item-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-xl); align-items: start; }
.section-title { font-family: var(--font-heading); font-size: 16px; color: var(--ink); font-weight: 800; margin: 20px 0 10px; }
.section-title:first-child { margin-top: 0; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: var(--space-lg); }
.radio-row label { flex-direction: row; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--ink); font-weight: 400; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: var(--text-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: 160px; }
.spark { display: block; }

/* ---- Integrations ---------------------------------------------------------------------- */
.qbo-card { display: flex; align-items: center; gap: var(--space-xl); padding: var(--space-xl); flex-wrap: wrap; }
.qbo-logo { width: 46px; height: 46px; border-radius: 12px; background: #2CA01C; color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 15px; font-family: var(--font-heading); flex: none; }
.map-table select { width: 100%; max-width: 340px; }

/* ---- Sign-in and client picker --------------------------------------------------------- */
.auth { min-height: 100dvh; display: grid; justify-items: center; align-content: start; padding: 12vh var(--space-2xl) var(--space-3xl); background: transparent; position: relative; filter: var(--shadow-paper); }
/* The sign-in ticket hangs from the same rail as the order tickets */
.auth::before { content: ''; position: absolute; left: 0; right: 0; top: calc(12vh - 3px); height: 6px; background: var(--range); z-index: var(--z-raised); }
.auth-card {
  width: 100%; max-width: 420px; background: var(--panel); border-radius: var(--radius-ticket) var(--radius-ticket) 0 0;
  padding: var(--space-3xl) var(--space-3xl) 44px; display: flex; flex-direction: column; gap: 14px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
}
.auth-card.wide-card { max-width: 700px; }
.client-list { display: flex; flex-direction: column; gap: var(--space-md); }
.client-card { font-family: var(--font-body); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-lg); text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-card); padding: 12px 14px; cursor: pointer; transition: border-color var(--ease), background var(--ease); color: var(--ink); }
.client-card b { font-family: var(--font-heading); font-weight: 800; font-size: 16px; }
.client-card:hover { border-color: var(--ink-action); background: #F7F9FA; }
.client-card small { display: block; color: var(--muted); font-size: var(--text-xs); }
.client-card .chev { margin-left: auto; color: var(--ink-action); font-size: 22px; }
.client-mark { width: 42px; height: 42px; border-radius: 11px; background: var(--lime-soft); color: var(--ink-hover); font-weight: 800; font-family: var(--font-heading); display: grid; place-items: center; font-size: var(--text-xs); flex: none; }

/* ---- Dialogs and toasts ---------------------------------------------------------------- */
dialog.modal { width: calc(100% - 40px); max-width: 540px; max-height: calc(100dvh - 40px); padding: 0; border: 0; color: var(--ink); background: var(--panel); border-radius: var(--radius-overlay); box-shadow: var(--shadow-overlay); }
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: rgb(29 35 41 / .5); }
dialog.modal.wide { max-width: 780px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-lg); padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 19px; }
.modal-body { padding: 18px 20px; overflow: auto; font-size: var(--text-sm); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-md); padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius-card); padding: 34px 20px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color var(--ease), background var(--ease), color var(--ease); }
.dropzone:hover, .dropzone.over { border-color: var(--ink-action); background: var(--lime-soft); color: var(--ink-hover); }
.dropzone.busy { cursor: progress; border-style: solid; border-color: var(--lavender-bar, #8B6CFF); background: var(--lavender-wash, #EEEAFF); }
.dropzone b { color: var(--ink); }
.steps { list-style: none; padding: 0; margin: var(--space-xl) 0 0; display: flex; flex-direction: column; gap: var(--space-md); }
.steps li { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.steps li.done { color: var(--ink); }
.steps li .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; display: grid; place-items: center; font-size: 11px; }
.steps li.done .dot { background: var(--mint); border-color: var(--mint-bar); color: var(--ink); }
.steps li.active .dot { border-color: var(--lavender-bar); border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#toasts { position: fixed; right: calc(20px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--space-md); z-index: var(--z-toast); }
.toast { background: var(--cast-iron); color: #fff; padding: 12px 16px; border-radius: var(--radius-card); box-shadow: var(--shadow-overlay); max-width: 400px; font-size: var(--text-sm); transition: opacity .2s ease-out, transform .2s ease-out; border-left: 4px solid var(--crust); }
.toast.ok { border-left-color: var(--mint-bar); }
.toast.bad { border-left-color: var(--coral-bar); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---- Period picker, count, COGS -------------------------------------------------------- */
.period-pick { min-width: 0; max-width: 100%; display: inline-flex; align-items: center; gap: var(--space-lg); flex-wrap: wrap; }
.period-pick label { min-width: 0; max-width: 100%; }
.period-pick select { max-width: 100%; text-overflow: ellipsis; font-family: var(--font-body); font-weight: 700; font-size: var(--text-sm); min-height: 36px; padding: 7px 32px 7px 12px; border-color: var(--lime-edge); background-color: var(--lime); color: var(--range); border-radius: var(--radius-control); }
.period-pick.past select { background-color: var(--butter); border-color: var(--butter-bar); }
.period-pick .past-note { font-size: var(--text-sm); font-weight: 700; color: var(--butter-text); white-space: nowrap; }
.period-pick .past-note .link-btn { font-size: var(--text-sm); }
.count-table input.cq { width: 56px; text-align: right; padding: 6px 7px; }
.count-table td, .count-table th { padding: 8px 6px; }
.cogs input.sales { width: 116px; text-align: right; padding: 6px 8px; }
.cogs tr.sub-row td { background: var(--bg); font-size: var(--text-xs); }
table.mini { width: auto; min-width: 420px; }
table.mini th, table.mini td { padding: 6px 10px; background: transparent; }

/* ---- Accounts and reporting lines (Settings, Integrations) ----------------------------- */
.acct-table .group-row td { background: var(--stone); font-family: var(--font-heading); font-size: 14px; font-weight: 800; color: var(--stone-ink); }
.acct-table input.acct-name { width: 100%; max-width: 300px; font-weight: 600; border-color: transparent; background: transparent; }
.acct-table input.acct-name:hover { border-color: var(--line-strong); background: var(--plate); }
.acct-table input.acct-name:focus { background: var(--plate); }
.acct-table td.drag { cursor: grab; color: #9AA4AE; user-select: none; }
.acct-table tr.dragging { opacity: .4; }
.acct-table tr.drop-target td { box-shadow: inset 0 3px 0 var(--ink-action); }
.acct-table tr.inactive td { background: #F5F7F9; }
.acct-table tr.inactive input.acct-name { color: var(--muted); font-weight: 400; text-decoration: line-through; }
.acct-fixed { display: inline-block; padding: 6px 10px; font-weight: 600; }
.access-list { display: grid; gap: var(--space-xs); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 8px 12px; max-height: 300px; overflow: auto; }
.access-row { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; font-weight: 600; font-size: var(--text-sm); color: var(--ink); padding: 5px 0; }
.access-row.sub { padding-left: 26px; }
.access-row input:disabled + span { opacity: .5; }

/* ---- New client and setup checklist ---------------------------------------------------- */
.wide-card .section-title { margin: 6px 0 -4px; }
.start-options { display: flex; flex-direction: column; gap: var(--space-md); }
.start-opt { flex-direction: row; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius-card); padding: 12px 14px; cursor: pointer; color: var(--ink); font-size: var(--text-sm); font-weight: 400; transition: border-color var(--ease), background var(--ease); }
.start-opt:hover { border-color: var(--crust); }
.start-opt:has(input:checked) { border-color: var(--ink-action); background: #F7F9FA; box-shadow: inset 5px 0 0 var(--lime); }
.start-opt input[type=radio] { margin-top: 2px; }
.start-opt small { display: block; color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }
.start-opt select { margin-top: 8px; font-size: var(--text-xs); }
.invite-row { display: grid; grid-template-columns: 1fr 150px 34px; gap: var(--space-md); margin-bottom: var(--space-md); }
.setup-progress { display: flex; flex-direction: column; gap: 10px; margin-bottom: var(--space-xl); }
.setup-bar { height: 10px; background: var(--stone); border-radius: 999px; overflow: hidden; }
.setup-bar span { display: block; height: 100%; background: var(--mint-bar); border-radius: 999px; }
.setup-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.setup-step { display: grid; grid-template-columns: 38px 1fr auto; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px 16px; }
.setup-step.next { border-color: var(--ink-action); box-shadow: inset 5px 0 0 var(--lime); }
.setup-step.done { background: #F7F9FA; }
.setup-step.done h2, .setup-step.done h3 { color: var(--muted); }
.setup-num { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; font-weight: 800; font-family: var(--font-heading); color: var(--muted); }
.setup-step.done .setup-num { background: var(--mint); border-color: var(--mint-bar); color: var(--ink); }
.setup-step.next .setup-num { border-color: var(--ink-action); color: var(--ink-action); }
.setup-body p { margin: 3px 0 0; color: var(--muted); font-size: var(--text-sm); }
.setup-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- Import from previous system ------------------------------------------------------- */
.steps-inline { display: flex; gap: 6px; flex-wrap: wrap; }
.steps-inline span { font-size: var(--text-xs); font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--plate); border: 1px solid var(--line); color: var(--muted); }
.steps-inline span.on { background: var(--lime); border-color: var(--lime-edge); color: var(--range); }
.imp-table td, .imp-table th { padding: 7px 8px; }
.imp-table input.imp-name { width: 100%; min-width: 260px; border-color: transparent; background: transparent; font-weight: 600; }
.imp-table input.imp-name:hover { border-color: var(--line-strong); background: var(--plate); }
.imp-table select { font-size: var(--text-xs); padding: 5px 8px; }
.imp-table tr.off td { opacity: .5; }
.imp-table tr.off td.check { opacity: 1; }
.opt-row { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--ink); font-size: var(--text-sm); font-weight: 400; }
.opt-row small { color: var(--muted); font-size: var(--text-xs); }
.opt-row input { margin-top: 3px; }
.cu-table input.cu-in { width: 116px; }
.cu-table input.cu-num { width: 84px; text-align: right; }
.cu-table td { padding: 8px 10px; }

/* ---- Recipes --------------------------------------------------------------------------- */
.recipe-tree .tree-cat { font-family: var(--font-heading); font-size: 14px; font-weight: 800; color: var(--stone-ink); padding: 12px 12px 4px; }
.recipe-tree button { padding-left: 20px; }
.ing-search { position: relative; }
.ing-search .search input { width: 340px; }
.ing-results { position: absolute; right: 0; top: calc(100% + 4px); width: 420px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-card); box-shadow: var(--shadow-overlay); z-index: var(--z-dropdown); max-height: 340px; overflow: auto; padding: 4px; }
.ing-results button { display: block; width: 100%; text-align: left; font-family: var(--font-body); font-size: var(--text-sm); border: 0; background: none; padding: 8px 10px; border-radius: var(--radius-control); cursor: pointer; color: var(--ink); }
.ing-results button:hover { background: var(--lime-soft); }
.ing-results small { display: block; color: var(--muted); font-size: var(--text-xs); }
.ing-table input[data-f="qty"] { width: 84px; text-align: right; }
.ing-table input[data-f="yieldPct"] { width: 70px; text-align: right; }
.ing-table select { font-size: var(--text-xs); padding: 5px 8px; }
.ing-table td { padding: 8px 10px; }
.menu-cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 24px; padding: 8px 16px 16px; }
.menu-cat-col .tree-cat { font-family: var(--font-heading); font-size: 15px; font-weight: 800; color: var(--ink); padding: 12px 0 8px; }
.mc-row { display: grid; grid-template-columns: 1fr 26px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.mc-row input { font-size: var(--text-sm); padding: 6px 9px; }
.mc-row input[data-new] { grid-column: 1 / -1; border-style: dashed; }

/* ---- Dashboard ------------------------------------------------------------------------- */
/* Dashboard type roles (impeccable typeset): section heading 20px Nunito, panel meta 13px,
   prose 14px at ~70ch, figures in Atkinson at the ticket size with the variance as the largest. */
.dash-clear { display: flex; align-items: center; gap: var(--space-lg); padding: 12px var(--space-xl); font-size: var(--text-sm); color: var(--muted); }
.pos-sales { padding: 12px 16px 16px; border-top: 1px solid var(--line); overflow-x: auto; }
.pos-sales summary { cursor: pointer; font-weight: 700; font-size: var(--text-sm); }
.pos-sales table { max-width: 560px; margin-top: 8px; }
.pos-sales input { width: 96px; text-align: right; }

/* ---- Sales ----------------------------------------------------------------------------- */
.balance-banner { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: var(--space-xl); align-items: center; padding: 14px 18px; border-radius: var(--radius-card); margin-bottom: 14px; border: 1px solid var(--line); background: var(--panel); border-left: 6px solid var(--mint-bar); }
.balance-banner .label { display: block; font-size: var(--text-xs); color: var(--muted); font-weight: 600; }
.balance-banner b { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.balance-banner .eq { font-size: 24px; color: var(--muted); font-weight: 700; }
.balance-banner .res { font-weight: 700; padding: 6px 14px; border-radius: 999px; font-size: var(--text-sm); }
.balance-banner.ok .res { background: var(--basil-soft); color: var(--basil-dark); }
.balance-banner.bad { border-left-color: var(--coral-bar); }
.balance-banner.bad .res { background: var(--tomato-soft); color: var(--tomato-dark); }
.rec-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-lg); align-items: start; }
.rec-panel td, .rec-panel th { padding: 7px 12px; font-size: var(--text-sm); }
.rec-panel tr.off td { opacity: .45; text-decoration: line-through; }
.rec-panel input.pay-amt { width: 96px; text-align: right; padding: 5px 8px; }
.rec-panel input.pay-amt.edited { background: var(--saffron-soft); border-color: var(--saffron-fill); color: var(--saffron-dark); font-weight: 700; }
.rec-panel td:has(> input.pay-amt) { padding-left: 4px; padding-right: 6px; }
.rec-panel tr.unmatched-row td { background: var(--coral-wash); }
.edited-val { background: var(--saffron-soft); color: var(--saffron-dark); padding: 1px 7px; border-radius: 6px; font-weight: 700; }
.je td { font-variant-numeric: tabular-nums; }

/* ---- Responsive ------------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-grid, .totals { grid-template-columns: minmax(0, 1fr); }
  .rec-grid { grid-template-columns: minmax(0, 1fr); }
  .balance-banner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) { .menu-cats { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  /* The sidebar becomes a scrollable bar above the page instead of disappearing */
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; overflow: visible; }
  .brand { padding: 12px 16px 4px; font-size: 18px; }
  .sidebar nav { flex-direction: row; overflow-x: auto; padding: 8px 12px 12px; gap: 4px; scrollbar-width: none; }
  .sidebar nav a, .sidebar nav a.child { flex: none; min-height: 44px; padding: 8px 12px; white-space: nowrap; }
  .sidebar nav a.child { box-shadow: none; }
  .sidebar-foot { display: none; }
  .topbar { padding: 8px 16px; gap: 8px; }
  .client-switch { min-width: 0; flex: 1; }
  .client-switch select { width: 100%; max-width: 240px; font-size: 15px; }
  .user { gap: 6px; }
  main { padding: 16px; }
  h1 { font-size: 24px; }
  .inv-layout { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-meta { display: none; }
  .search input, .ing-search .search input { width: 100%; }
  .ing-results { width: min(420px, calc(100vw - 32px)); }
  .btn { min-height: 44px; }
  input:not([type=checkbox]):not([type=radio]), select { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  .btn.sm, .chip, .cat-list button, .tabs button, .period-pick select { min-height: 44px; }
  .chip { padding: 8px 14px; }
  .stats, .stats[style] { grid-template-columns: 1fr 1fr !important; gap: 14px 8px; padding-top: 0; }
  .panel-head .ing-search { flex: 1 1 100%; min-width: 0; }
  .panel-head .ing-search .search { width: 100%; }
  .stats::before { display: none; }
  .stats > .stat { border-top: 6px solid var(--range); }
  .auth { padding: 8vh 16px 24px; }
  .auth::before { top: calc(8vh - 3px); }
  .setup-step { grid-template-columns: 32px 1fr; }
  .setup-actions { grid-column: 2; justify-content: flex-start; }
  .invite-row { grid-template-columns: 1fr 110px 30px; }
  .auth-card { padding: 24px 24px 40px; }
  .balance-banner { grid-template-columns: 1fr; }
  .balance-banner .eq { display: none; }
  .panel > table { display: block; overflow-x: auto; }
  .pos-sales table { display: block; overflow-x: auto; max-width: 100%; }
  .page-head > div:first-child { min-width: 0; }
  .auth-card .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .period-pick select { font-size: var(--text-xs); padding-right: 28px; }
  .auth-card .form-grid .span2, .auth-card .form-grid [style*='grid-column'] { grid-column: auto !important; }
  .doc-view { padding: 10px; }
  .paper { padding: 18px 16px 24px; font-size: 13px; overflow-x: auto; }
  .doc-view iframe { height: 75dvh; min-height: 480px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Settings → Inventory categories: on phones drop the drag handle and fixed widths so the name,
   item count, arrows and buttons all fit without sideways scrolling */
@media (max-width: 760px) {
  .panel > table.sub-table { display: table; width: 100%; overflow: visible; }
  .sub-table th, .sub-table td { padding-left: 6px; padding-right: 6px; }
  .sub-table th { width: auto !important; }
  .sub-table th:first-child, .sub-table td.drag { display: none; }
  .sub-table td:nth-child(2) { width: 100%; }
  .sub-table .acct-name { width: 100%; min-width: 0; }
  .sub-table td:last-child { white-space: normal; text-align: right; }
  .sub-table td:last-child .btn { padding: 4px 8px; }
}

/* Settings → Invoice reporting: container deposit choice */
.dep-options { display: grid; gap: var(--space-sm); }
.dep-option { flex-direction: row; align-items: flex-start; gap: 10px; font-size: var(--text-sm); color: var(--ink); font-weight: 400; cursor: pointer; }
.dep-option input { margin-top: 3px; }
.dep-option .tiny { display: block; margin-top: 2px; }

/* Very narrow phones: the item count column gives way so the row fits */
@media (max-width: 400px) { .sub-table th:nth-child(3), .sub-table td:nth-child(3) { display: none; } }

/* Integrations → POS: Toast SFTP setup */
.sftp-steps { margin: 8px 0 14px 18px; padding: 0; display: grid; gap: 10px; font-size: var(--text-sm); }
.sftp-key { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0 4px; }
.sftp-key textarea { flex: 1; min-width: 0; font: 13px/1.4 ui-monospace, Menlo, monospace; resize: none; word-break: break-all; }
@media (max-width: 760px) { #sftp-panel .form-grid { grid-template-columns: minmax(0, 1fr) !important; } .sftp-key { flex-direction: column; align-items: stretch; } }

/* Settings → Backups list */
.bk-table td:first-child { min-width: 7.5em; }
@media (max-width: 760px) { .panel .bk-table { display: table; width: 100%; } .bk-table th, .bk-table td { padding-left: 6px; padding-right: 6px; } }

/* Read-only profile for client users */
.profile-view { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: var(--text-sm); }
.profile-view dt { color: var(--muted); font-weight: 600; }
.profile-view dd { margin: 0; overflow-wrap: anywhere; }

/* Invoice review: editable lines, rotate controls */
/* The whole description stays readable, size included: it wraps instead of being cut off */
.simple-lines .acct { min-width: 200px; width: 100%; }
/* Manual invoice: expenses and coding summary in the left half, the totals box in the right half, so the
   section always spans the same width as the header above it */
.manual-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xl); align-items: start; }
.manual-layout .totals { display: contents; }
.manual-layout #lines-panel { grid-column: 1; grid-row: 1; }
.manual-layout .totals > .panel:first-child { grid-column: 1; grid-row: 2; }
.manual-layout #sum { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: var(--space-xl); }
@media (max-width: 1000px) {
  .manual-layout { grid-template-columns: minmax(0, 1fr); }
  .manual-layout #lines-panel, .manual-layout .totals > .panel:first-child, .manual-layout #sum { grid-column: 1; grid-row: auto; position: static; }
}
.lines .desc-in { width: 100%; min-width: 180px; font: inherit; line-height: 1.35; resize: none; field-sizing: content; min-height: 2.6em; padding: 6px 8px; overflow-wrap: anywhere; }
.lines input.unit-in { width: 56px; margin-left: 4px; }
.lines input.amount-in { width: 90px; text-align: right; font-weight: 700; }
.lines .line-del { color: var(--muted); }
.lines .line-del:hover { color: var(--danger, #B42318); }
.lines-foot { display: flex; align-items: center; gap: var(--space-md, 12px); padding: 10px 12px; flex-wrap: wrap; }
.doc-tools { display: inline-flex; gap: 6px; margin-left: auto; }
.doc-view canvas { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.lines .pack-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.lines .pack-row label { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.lines input.pack-in { width: 76px; text-align: right; }
.lines .pack-row .link-btn.muted { color: var(--muted); font-weight: 400; padding-left: 0; text-decoration-color: var(--line); text-decoration-thickness: 1px; }
.check-row { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; }
.check-row input { margin-top: 3px; width: auto; min-height: 0; }
.lines .pack-ok { color: var(--ok-text, #15803D); font-weight: 700; }
.lines .pack-diff { color: var(--warn-text, #92400E); }
.area-pick { border: 1px solid var(--line); border-radius: var(--radius-control); padding: 10px 12px 12px; margin: 14px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.area-pick legend { font-weight: 600; padding: 0 4px; }
.phone-link { display: none; }
@media (max-width: 760px) { .phone-link { display: inline-flex; } }

/* Count areas grid */
.ca-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ca-filters select { width: auto; }
.ca-grid th.ca-col, .ca-grid td.ca-col { text-align: center; width: 96px; }
.ca-grid .ca-head { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; cursor: pointer; }
.ca-grid input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; cursor: pointer; }
.ca-grid .ca-none { color: var(--warn-text, #92400E); }
#n-areas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
/* Waiting on client: sky, so it stands apart from price checks (butter) and flags */
.ask-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--sky-wash); border: 1px solid var(--sky); border-left: 4px solid var(--sky-bar); border-radius: var(--radius-control); padding: 12px 16px; color: var(--ink-900); }
.ask-banner b { color: var(--sky-text); }
.chip.ask-chip.active { background: var(--sky); border-color: var(--sky-bar); color: var(--ink-900); }
.count-by { align-items: end; } .count-by .count-sum { padding-bottom: 10px; }
#n-name, .upper-name { text-transform: uppercase; }
.toast .link-btn { color: #fff; text-decoration-color: var(--lime); pointer-events: auto; margin-left: 6px; }
.queue-counts { color: var(--muted); padding: 10px 0 12px; }
.queue-counts b { color: var(--ink); }
/* Invoice list: the tick boxes on unposted (ready to post) rows, in the Needs review badge's yellow */
.queue-table td.check input[type=checkbox] { appearance: none; -webkit-appearance: none; box-sizing: border-box; flex: 0 0 18px; width: 18px; height: 18px; min-width: 18px; min-height: 18px; padding: 0; margin: 0; border: 2px solid var(--butter-bar); border-radius: 4px; background: var(--butter); display: grid; place-content: center; }
.queue-table td.check input[type=checkbox]:checked { border-color: var(--range); }
.queue-table td.check input[type=checkbox]:checked::after { content: ''; width: 5px; height: 10px; border: solid var(--range); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.queue-table td.check input[type=checkbox]:focus-visible { outline: 2px solid var(--butter-text); outline-offset: 2px; }

/* Settings → Company setup: preview of the period calendar */
.co-setup .section-title { margin-top: 12px; }

/* Settings tabs that hold two sections (Reporting, Categories) */
.settings-part + .settings-part { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line, #e5e5e5); }
.settings-part-title { font-family: var(--font-heading); font-size: 20px; font-weight: 800; color: var(--ink); margin: 0 0 12px; scroll-margin-top: 16px; }
.settings-part { scroll-margin-top: 16px; }
.est-fields { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.est-fields input { width: 76px; }
.est-fields input[data-e="name"] { width: 160px; }
.ing-results button[data-est] b { color: var(--butter-text); }

/* Count: correcting a closed count */
.correct-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-md) var(--space-xl); margin-bottom: var(--space-xl); }
.correct-bar > div:first-child { flex: 1; min-width: 240px; }
.correct-bar .actions { display: flex; gap: var(--space-md); }
#count-fixes { scroll-margin-top: 76px; }

/* Integrations: the books' closing date from QuickBooks */
.qbo-closed { display: inline-flex; flex-direction: column; gap: 2px; font-weight: 600; }
.qbo-closed input { width: auto; }

/* Count: the closing inventory journal entry */
.je-panel { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-md) var(--space-lg); padding: 10px var(--space-xl); margin-bottom: var(--space-xl); font-size: var(--text-sm); }
.je-panel > span:nth-child(2) { flex: 1; min-width: 240px; }
.je-h { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-md); margin: var(--space-xl) 0 var(--space-md); font-size: 16px; }
.je-h:first-child { margin-top: 0; }
.je-table td, .je-table th { padding: 7px 8px; font-size: var(--text-sm); }
.je-log { margin: 0; padding-left: 18px; font-size: var(--text-sm); }

/* Integrations → GL accounts: type filter */
.acct-table tr[hidden] { display: none; }
.gl-foot { padding: 10px var(--space-xl); margin: 0; }

/* GL accounts: the second filter, a squared segmented control so it reads apart from the type chips */
.gl-head { align-items: flex-start; }
.gl-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-md); min-width: 0; }
.seg { display: inline-flex; flex-wrap: wrap; align-self: flex-start; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; background: var(--plate); }
.seg button { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 600; color: var(--stone-ink); background: none; border: 0; border-left: 1px solid var(--line-strong); padding: 5px 12px; min-height: 30px; cursor: pointer; transition: background var(--ease); }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--bg); }
.seg button.active { background: var(--ink); color: var(--plate); }
.seg button:focus-visible { outline: 2px solid var(--ink-action); outline-offset: -2px; }

/* Sales → Upload sales report */
.su-h { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-md); margin: var(--space-xl) 0 var(--space-md); font-size: 16px; }
.su-matches select { min-width: 220px; }
.su-matches tr.su-open td { background: color-mix(in srgb, var(--warn) 14%, transparent); }

/* Sign-in cards: the screen's heading is an h1, sized like a panel heading */
h1.auth-h { font-size: var(--text-md); }

/* Inventory list, Cost updated: the date, then where the cost came from in muted text; the ✦ (Claude read
   that invoice) is the only lavender, so the column doesn't fill with badges */
.cost-src > span { display: block; line-height: 1.35; }
.ai-mark { color: var(--lavender-text); }

/* Invoice review: the remove ✕ has its own narrow column at the end, so Price vs. cost is just the change */
.lines th.line-act, .lines td.line-act { width: 36px; padding-left: 0; text-align: right; }
.lines td.price-vs { white-space: nowrap; }
.lines td.price-vs .tiny { margin-top: 2px; }

/* Inventory → + Add item: bought or made in-house */
.add-choice { display: grid; gap: var(--space-md); }
.add-choice-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--plate); color: var(--ink); font: inherit; cursor: pointer; transition: border-color var(--ease), background var(--ease); }
.add-choice-btn:hover { border-color: var(--ink-action); background: var(--bg); }
.add-choice-btn:focus-visible { outline: 2px solid var(--ink-action); outline-offset: 2px; }
.add-choice-btn span { font-size: var(--text-sm); color: var(--muted); }

/* Invoice review: Reject and Approve sit in a bar that sticks to the bottom of the screen, next to the balance */
.review-bar { position: sticky; bottom: var(--space-lg); z-index: var(--z-sticky); display: flex; justify-content: space-between; align-items: center; gap: var(--space-lg); flex-wrap: wrap; margin-top: var(--space-xl); padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: 0 -4px 16px rgba(29, 35, 41, .08); }
.review-bar-status { font-weight: 700; font-size: var(--text-sm); padding: 6px 12px; border-radius: var(--radius-control); }
.review-bar-status.ok { background: var(--mint-wash); box-shadow: inset 4px 0 0 var(--mint-bar); }
.review-bar-status.bad { background: var(--coral-wash); box-shadow: inset 4px 0 0 var(--coral-bar); }

/* Wide screens: the original invoice sits beside the lines and stays in view while you scroll them */
@media (min-width: 1360px) {
  /* This page skips the usual 1500px page limit so a wide screen can show the invoice at full size */
  main:has(.review > .doc-pane) { max-width: none; }
  /* Width goes to the lines until they have room for every column (860px), then to the invoice until it
     shows at full size (a letter page at 100%, about 820px plus its frame), then back to the lines */
  .review:has(> .doc-pane) { display: grid; align-items: start;
    grid-template-columns: minmax(0, 1fr) clamp(320px, calc(100% - 860px - var(--space-xl)), 880px); }
  /* Tighter line table so all its columns fit beside the invoice */
  .review:has(> .doc-pane) .lines td, .review:has(> .doc-pane) .lines th { padding-left: 4px; padding-right: 4px; }
  .review:has(> .doc-pane) .lines input.qty { width: 56px; }
  .review:has(> .doc-pane) .lines input.price { width: 72px; padding-left: 6px; padding-right: 6px; }
  .review:has(> .doc-pane) .lines select { min-width: 128px; }
  .review:has(> .doc-pane) .lines td.coded { min-width: 132px; }
  .review:has(> .doc-pane) .lines td:first-child { max-width: 168px; }
  .review:has(> .doc-pane) .lines td:first-child input { width: 100%; }
  .review > .doc-pane { position: sticky; top: 76px; max-height: calc(100dvh - 76px - var(--space-lg)); display: flex; flex-direction: column; }
  .review > .doc-pane .doc-view { flex: 1; overflow: auto; padding: var(--space-lg); align-items: flex-start; }
  .review > .doc-pane .doc-view iframe { height: 100%; min-height: 0; }
  .review:has(> .doc-pane) .totals { grid-template-columns: minmax(0, 1fr); }
}

/* The original invoice at full size (Expand on invoice review) */
dialog.modal.doc-full { max-width: min(960px, calc(100% - 40px)); }
dialog.modal.doc-full .modal-body { padding: 0; }
dialog.modal.doc-full .modal-foot:empty { display: none; }
.doc-full-view { max-height: calc(100dvh - 120px); overflow: auto; }
.doc-full-view iframe { height: calc(100dvh - 170px); min-height: 0; }
/* "Invoice differs?" only shows on the line you're pointing at or working in */
@media (hover: hover) {
  .lines .pack-row .link-btn.muted { opacity: 0; transition: opacity var(--ease); }
  .lines tr:hover .pack-row .link-btn.muted, .lines tr:focus-within .pack-row .link-btn.muted { opacity: 1; }
}
