/* ============================================================
   MapleFix — design system
   ============================================================ */

/* Inter, self-hosted. One variable file covers every weight, so the whole
   interface has real typography with no network request and no CDN. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter.woff2') format('woff2-variations');
}

/* Light / dark: <html data-theme="light|dark"> is always set — before the first
   paint by theme-boot.js, then kept in step by lib/theme.js ("Automatic" follows
   Windows). The dark tokens live in one block below. .theme-light/.theme-dark
   scope either set to a box inside the page (the Settings → Appearance preview).
   The --accent-* tokens here are Maple red, the default shop colour; any other
   shop colour is laid over them by lib/theme.js (<style id="shop-theme">). */
:root, .theme-light {
  /* --- neutrals: very slightly warm, so the app never reads as cold grey --- */
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --surface-3: #f2f2f0;
  --border: #e7e6e2;
  --border-strong: #d6d5d0;
  /* Text, strongest to faintest: shared/theme/palettes.js ink … ink4, so the
     web, the phone and the printed pages read alike. --text-3 is the faintest
     writing (4.5:1 or more on every surface); --text-4 is for placeholders,
     borders and decorative icons only (3:1). */
  --text: #16181c;
  --text-2: #4a5058;
  --text-3: #696f78;
  --text-4: #868c95;

  /* --- brand: a deep, restrained crimson rather than a flat red --- */
  --accent: #9e2a2b;
  --accent-hover: #832122;
  --accent-active: #6d1c1d;
  --accent-tint: #fbeeee;
  --accent-border: #efd4d4;
  --accent-contrast: #ffffff;
  /* The shop colour as writing (a selected chip, a link, the "required" star):
     4.5:1 on its own tint and every surface. Maple red already is; another
     shop colour gets its own from lib/theme.js accentInk(). */
  --accent-ink: #9e2a2b;
  --accent-top: #ab3132;          /* lighter top of a filled button's gradient */
  --accent-hover-top: #9b2b2c;
  --accent-bright: #c23a3b;       /* the light end of accent ramps (meters) */
  --accent-shadow: rgba(109, 28, 29, .3);
  /* The sidebar is dark in both themes and puts white on these, so they keep
     the white-text-safe light shade in dark mode too. */
  --accent-solid: #9e2a2b;
  --accent-solid-bright: #c23a3b;
  --accent-solid-deep: #6d1c1d;
  --accent-solid-glow: rgba(158, 42, 43, .4);

  /* --- semantic: shared/theme/palettes.js, each hue on its own tint 4.5:1 or more ---
     green good · amber waiting · red urgent · blue info · violet closed ·
     teal parked on something outside the shop (a job waiting for parts) */
  --blue: #2f5d8a;
  --blue-tint: #e9eef5;
  --green: #1f6b4a;
  --green-tint: #e7f3ec;
  --amber: #8a5a10;
  --amber-tint: #faf1e2;
  --red: #a32724;
  --red-tint: #fbebea;
  --violet: #5b4b8a;
  --violet-tint: #f0edf8;
  --teal: #2f6f6f;
  --teal-tint: #e5f0f0;

  /* --- the MapleFix wordmark's "Fix" (assets/brand/README.md): the same in every shop colour --- */
  --brand-fix: #d42a31;
  --brand-fix-on-dark: #ff5a4a;

  /* --- sidebar: near-black with a hint of warmth --- */
  --nav-bg: #1a1917;
  --nav-bg-2: #211f1d;
  --nav-text: #a8a49c;
  --nav-text-active: #ffffff;
  --nav-hover: #272522;
  --nav-active: #322f2b;

  /* --- geometry --- */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* --- elevation: layered, low-opacity, never muddy --- */
  --e1: 0 1px 2px rgba(28, 27, 25, .05), 0 1px 1px rgba(28, 27, 25, .03);
  --e2: 0 2px 4px rgba(28, 27, 25, .05), 0 4px 12px rgba(28, 27, 25, .05);
  --e3: 0 4px 8px rgba(28, 27, 25, .06), 0 12px 28px rgba(28, 27, 25, .09);
  --e4: 0 8px 16px rgba(28, 27, 25, .08), 0 24px 56px rgba(28, 27, 25, .16);
  --ring: 0 0 0 3px rgba(47, 93, 138, .18);

  /* --- type --- */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text',
          'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'SF Mono', 'Cascadia Mono', 'Segoe UI Mono', ui-monospace, Menlo, Consolas, monospace;

  --ease: cubic-bezier(.32, .72, .29, 1);
  --fast: 130ms var(--ease);

  /* --- type scale: every screen picks from these eight sizes and three weights --- */
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-display: 44px;
  --fw-regular: 450;
  --fw-medium: 550;
  --fw-bold: 650;

  /* --- spacing: 4 / 8 / 12 / 16 / 24 / 32 --- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* --- charts (renderer/lib/charts.js): validated against #ffffff.
         Series in fixed categorical order; profit/loss wear the status pair. --- */
  --viz-revenue: #2a78d6;
  --viz-expenses: #eb6834;
  --viz-collected: #1baf7a;   /* 2.8:1 on white — always direct-labelled + table view */
  --viz-profit: #0ca30c;
  --viz-loss: #d03b3b;
  --viz-deemph: #898781;      /* palettes.js chart.muted */
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --viz-hover: rgba(28, 27, 25, .045);
  /* The same bucket a year earlier: a pale column behind the current one. */
  --viz-parts: #8db6ea;        /* parts beside labour: a lighter step of the revenue blue */
  --viz-echo: #dddbd3;
  --viz-ink: #55534e;          /* a thin running-total / reference line */
  /* Receivables by age: green while not late, then one warm hue getting
     darker and redder the later it is (a clear step between each). */
  --aging-current: #4f9e74;
  --aging-1: #f0c25a;
  --aging-2: #e8873f;
  --aging-3: #cd4b2c;
  --aging-4: #8f1d1d;

  color-scheme: light;
}

:root[data-theme="dark"], .theme-dark {
  --bg: #131312;
  --surface: #1b1b1a;
  --surface-2: #131312;
  --surface-3: #272625;
  --border: #2e2d2b;
  --border-strong: #403e3b;
  --text: #ecebe8;
  --text-2: #a8a6a0;
  --text-3: #8f8d87;
  --text-4: #7a7872;

  --accent: #e06b6b;
  --accent-hover: #ea7f7f;
  --accent-active: #f19393;
  --accent-tint: #2e1d1d;
  --accent-border: #452a2a;
  --accent-contrast: #1a1010;
  --accent-ink: #e06b6b;
  --accent-top: #e47b7b;
  --accent-hover-top: #ee8f8f;
  --accent-bright: #e88686;
  --accent-shadow: rgba(0, 0, 0, .3);

  --blue: #7aa9d8;
  --blue-tint: #18242f;
  --green: #5cb98d;
  --green-tint: #142620;
  --amber: #d4a355;
  --amber-tint: #2a2113;
  --red: #e8807b;
  --red-tint: #2e1b1a;
  --violet: #a394d8;
  --violet-tint: #221e30;
  --teal: #63a8a8;
  --teal-tint: #152626;

  --brand-fix: #ff5a4a;

  --nav-bg: #0e0e0d;
  --nav-bg-2: #141413;
  --nav-text: #8b8983;
  --nav-text-active: #ffffff;
  --nav-hover: #1c1c1a;
  --nav-active: #282725;

  --e1: 0 1px 2px rgba(0, 0, 0, .4);
  --e2: 0 2px 6px rgba(0, 0, 0, .45);
  --e3: 0 8px 24px rgba(0, 0, 0, .55);
  --e4: 0 16px 48px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px rgba(122, 169, 216, .22);

  /* charts: dark steps of the same hues, validated against #1b1b1a */
  --viz-revenue: #3987e5;
  --viz-expenses: #d95926;
  --viz-collected: #199e70;
  --viz-profit: #0ca30c;
  --viz-loss: #d03b3b;
  --viz-deemph: #898781;
  --viz-grid: #2c2c2a;
  --viz-axis: #383835;
  --viz-hover: rgba(255, 255, 255, .045);
  --viz-parts: #8fbbf0;
  --viz-echo: #3a3936;
  --viz-ink: #c9c7c1;
  /* On a dark surface the later buckets get brighter, not darker. */
  --aging-current: #3f8f66;
  --aging-1: #8c6a24;
  --aging-2: #c06a2c;
  --aging-3: #e0533d;
  --aging-4: #ff8a7a;

  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv05' 1, 'cv08' 1, 'ss03' 1; /* nicer l, i, and ampersand */
  overflow: hidden;
}

::selection { background: var(--accent); color: var(--accent-contrast); }

/* Scrollbars that don't shout */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: content-box; }

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

.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--nav-bg-2) 0%, var(--nav-bg) 100%);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  overflow-y: auto;
  user-select: none;
  border-right: 1px solid rgba(255, 255, 255, .05);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }

/* The MapleFix icon: its own dark tile (brand/maplefix-icon.svg), the same whatever colour the
   shop picked. 22.5% is the tile's own corner, so the shadow follows it. */
.brand-mark {
  display: block;
  width: 38px; height: 38px;
  border-radius: 22.5%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.brand-mark img { display: block; width: 100%; height: 100%; }

/* The wordmark: "Maple" in the writing colour, "Fix" in brand red (assets/brand/README.md). */
.wordmark, .lock-brand-text .wordmark { font-weight: 700; letter-spacing: -.02em; }
.wordmark-fix { color: var(--brand-fix); }
.sidebar .wordmark-fix { color: var(--brand-fix-on-dark, #ff5a4a); }

.brand-text { min-width: 0; }
.brand-text strong { display: block; color: #fff; font-size: 15px; }
.brand-text small {
  display: block; color: var(--nav-text); font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}

.nav-group { margin-bottom: 18px; }

.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: #8f8c85; padding: 8px 10px 6px; font-weight: 650;
}

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--nav-text);
  text-decoration: none;
  font-size: var(--fs-base); font-weight: var(--fw-regular);
  margin-bottom: 2px;
  transition: background var(--fast), color var(--fast);
}

.nav-item:hover { background: var(--nav-hover); color: #e8e6e2; }
.nav-item.active { background: var(--nav-active); color: var(--nav-text-active); font-weight: var(--fw-medium); }

/* Left rail marker on the active item */
.nav-item.active::before {
  content: '';
  position: absolute; left: -12px; top: 50%;
  width: 3px; height: 18px;
  transform: translateY(-50%);
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-item svg { flex-shrink: 0; opacity: .72; transition: opacity var(--fast); }
.nav-item:hover svg, .nav-item.active svg { opacity: 1; }
.nav-item span { flex: 1; }

.nav-count {
  font-style: normal; font-size: 11px; font-weight: 650;
  background: var(--accent-solid); color: #fff;
  border-radius: var(--r-pill); padding: 1px 7px;
}

.nav-spacer { flex: 1; }

/* Most windows (19 items now) and short ones (a laptop at 1366x768, or a window dragged small): the nav
   tightens so Settings and the theme button never fall off the bottom. */
@media (max-height: 960px) {
  .sidebar { padding-top: 12px; padding-bottom: 8px; }
  .brand { padding-bottom: 12px; }
  .brand-mark { width: 32px; height: 32px; }
  .nav-group { margin-bottom: 8px; }
  .nav-label { padding-top: 4px; padding-bottom: 4px; }
  .nav-item { padding-top: 6px; padding-bottom: 6px; margin-bottom: 1px; }
  .theme-toggle { margin-top: 2px; padding-top: 5px; padding-bottom: 5px; }
  .user-chip { margin-top: 4px; padding-top: 8px; }
}
@media (max-height: 800px) {
  .brand { padding-bottom: 6px; }
  .brand-text small { display: none; }
  .nav-group { margin-bottom: 4px; }
  .nav-label { display: none; }
  .nav-item { padding-top: 4.5px; padding-bottom: 4.5px; font-size: var(--fs-sm); }
  .nav-item svg { width: 15px; height: 15px; }
}

.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-5);
  padding: 18px var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.topbar h1 {
  margin: 0; font-size: var(--fs-xl); font-weight: var(--fw-bold);
  letter-spacing: -.022em; line-height: 1.25;
}
/* The title keeps to one line; when the buttons don't fit beside it they
   move to a row of their own, right-aligned, rather than squeeze it. */
.topbar { flex-wrap: wrap; row-gap: var(--sp-3); }
.topbar-left { min-width: 0; flex: 1 1 260px; }
.topbar-left h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

.page-subtitle { margin: 2px 0 0; color: var(--text-3); font-size: var(--fs-sm); }

.topbar-right { display: flex; gap: var(--sp-2); align-items: center; flex-shrink: 0; }

.content { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-6) 72px; outline: none; }
@media (max-width: 1180px) {
  .topbar { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .content { padding-left: var(--sp-5); padding-right: var(--sp-5); }
}

/* ---------------------------------------------------------- typography */

h2 { font-size: var(--fs-md); font-weight: var(--fw-bold); margin: 0 0 var(--sp-3); letter-spacing: -.012em; }
h3 { font-size: var(--fs-base); font-weight: var(--fw-bold); margin: 0 0 var(--sp-2); }
p { margin: 0 0 10px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .93em; }
/* Money and counts line up digit for digit. */
.num, .col-num, .stat-value, .totals-row .num, .money, .kv dd, .badge, .et-sum-total {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'cv05' 1;
}
.strong { font-weight: var(--fw-medium); }
.mt { margin-top: var(--sp-4); }
.mt-lg { margin-top: var(--sp-6); }
.mb { margin-bottom: var(--sp-4); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: var(--fs-base); font-weight: var(--fw-medium);
  letter-spacing: -.006em;
  cursor: pointer; white-space: nowrap;
  box-shadow: var(--e1);
  transition: background var(--fast), border-color var(--fast),
              box-shadow var(--fast), transform var(--fast);
}

.btn:hover { background: var(--surface-2); border-color: var(--text-4); box-shadow: var(--e2); }
.btn:active { transform: translateY(1px); box-shadow: var(--e1); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }

/* The one filled button on a screen: the next step. A solid shop colour with
   white writing in both themes (--accent-solid is always white-text-safe). */
.btn-primary {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  color: #fff;
  box-shadow: 0 1px 2px var(--accent-shadow);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent-solid) 86%, #000);
  border-color: color-mix(in srgb, var(--accent-solid) 86%, #000);
  box-shadow: 0 2px 6px var(--accent-shadow);
}
.btn-primary:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-solid) 30%, transparent); }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; box-shadow: none; }

.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-tint); border-color: var(--red); }

.btn-sm { min-height: 28px; padding: 3px 10px; font-size: var(--fs-sm); border-radius: 5px; }
.btn-icon { padding: 6px 8px; }
.btn-sm.btn-icon { padding: 3px 6px; }
.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.btn .caret { margin-left: 1px; margin-right: -3px; opacity: .6; flex-shrink: 0; }
.btn[aria-expanded="true"] { background: var(--surface-3); }

/* ---------------------------------------------------------- menus (ui.js openMenu)
   "Share ▾", "Export ▾" and a table row's "⋯": a short list under the button. */
.menu-pop {
  position: fixed; z-index: 150;
  min-width: 210px; max-width: 320px;
  padding: var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--e3);
  animation: menu-in 120ms var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; padding: 7px 10px;
  border: 0; border-radius: 6px; background: none;
  color: var(--text); font: inherit; font-size: var(--fs-base); font-weight: var(--fw-medium);
  text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item:disabled { opacity: .45; cursor: not-allowed; background: none; }
.menu-item.is-danger { color: var(--red); }
.menu-item.is-danger:hover, .menu-item.is-danger:focus-visible { background: var(--red-tint); }
.menu-item-detail { font-size: var(--fs-xs); font-weight: var(--fw-regular); color: var(--text-3); line-height: 1.4; }
.menu-sep { height: 1px; margin: var(--sp-1) 2px; background: var(--border); }
.menu-label {
  padding: 6px 10px 2px; font-size: var(--fs-xs); font-weight: var(--fw-medium);
  color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
}
/* A row's "⋯": quiet until the row is pointed at. */
.row-more { color: var(--text-3); }
.row-more:hover { color: var(--text); }

/* ---------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-5);
  box-shadow: var(--e1);
}

.card + .card { margin-top: var(--sp-4); }

.card-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-4);
}
.card-head h2 { margin: 0; }

.grid { display: grid; gap: var(--sp-4); }
/* Cards side by side in a row are one height, however much each holds. */
.grid > .card { margin-top: 0; }
.grid-equal > * { height: 100%; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* A column that steps aside on a narrow window so the rest stay readable. */
@media (max-width: 1240px) {
  .hide-narrow { display: none; }
  /* Tighter list tables, so the money column stays on screen. */
  .table-wrap table.data th, .table-wrap table.data td { padding-left: 10px; padding-right: 10px; }
  .table-wrap table.data .with-avatar .avatar { display: none; }
  .table-wrap table.data td.cell-vehicle { white-space: normal; min-width: 120px; }
}
@media (max-width: 840px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- stat tiles */

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--e1);
  overflow: hidden;
  transition: box-shadow var(--fast), border-color var(--fast);
}
a.stat:hover, .stat.tire-tile:hover { box-shadow: var(--e2); border-color: var(--border-strong); }

.stat-label {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: var(--fw-medium); margin-bottom: var(--sp-2);
}

.stat-value {
  font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.028em; line-height: 1.1;
}
/* A list's count tiles: smaller figures than the dashboard's. */
.stat-value.is-compact { font-size: var(--fs-xl); }

.stat-meta { font-size: var(--fs-sm); color: var(--text-3); margin-top: var(--sp-1); }
.stat-value.is-alert { color: var(--red); }
.stat-value.is-good { color: var(--green); }
.stat-meta.is-alert { color: var(--red); }
/* A stat that opens its screen (the dashboard's HST to set aside). */
a.stat-link { display: block; color: inherit; text-decoration: none; }

/* Accent hairline along the top of a highlighted tile */
.stat.is-flagged::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--e1);
}

table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }

table.data th {
  text-align: left;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: var(--fw-medium);
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}

table.data td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.data tbody tr { transition: background var(--fast); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }

/* Hairline rows, no stripes; the row under the pointer lights up. */
.table-wrap table.data tbody tr:hover { background: var(--surface-2); }
.table-wrap table.data tbody tr.clickable:hover { background: var(--surface-3); }
:root[data-theme="dark"] .table-wrap table.data tbody tr:hover { background: var(--surface-3); }

/* A table that sits straight inside a card: no box of its own, no inner border. */
.card .table-wrap { border: 0; border-radius: 0; box-shadow: none; background: none; }
.card .table-wrap table.data th { background: none; }
.table-plain { overflow-x: auto; margin: 0 calc(-1 * var(--sp-5)); }
.table-plain table.data th { background: none; position: static; }
.table-plain table.data th:first-child, .table-plain table.data td:first-child { padding-left: var(--sp-5); }
.table-plain table.data th:last-child, .table-plain table.data td:last-child { padding-right: var(--sp-5); }
.table-plain table.data tbody tr:hover { background: var(--surface-2); }
.table-plain table.data tbody tr:last-child td { border-bottom: none; }
.card > .table-plain:last-child { margin-bottom: calc(-1 * var(--sp-3)); }
/* Number cells never break: "WO-2026-0001", "$1,299.36", "Oct 7, 2026". */
td.cell-id { white-space: nowrap; }

table.data tfoot td {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-strong);
  font-weight: var(--fw-bold);
  background: var(--surface-2);
}

.col-num, table.data th.col-num { text-align: right; white-space: nowrap; }
.row-actions {
  display: flex; gap: var(--sp-1); justify-content: flex-end; align-items: center; flex-wrap: nowrap;
}

/* ---------------------------------------------------------- avatars */

.avatar {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 11.5px; font-weight: 620; letter-spacing: .01em;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), var(--e1);
}
.avatar-sm { width: 24px; height: 24px; font-size: 9.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-xl { width: 60px; height: 60px; font-size: 20px; }

.with-avatar { display: flex; align-items: center; gap: 10px; min-width: 0; }
.with-avatar .who { min-width: 0; }
.with-avatar .who > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------- badges */

/* One status palette for every badge and chip, the phone's and the printed
   pages' too (shared/theme/palettes.js statusColorsFor):
   grey = not started · blue = being worked on · amber = waiting on the
   customer · teal = waiting on a supplier · green = paid / approved / done ·
   violet = closed, no money (void, declined, expired, cancelled) · red = late. */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: -.002em;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}

.badge-draft    { background: var(--surface-3); color: var(--text-3); border-color: var(--border); }
.badge-sent     { background: var(--blue-tint); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 20%, transparent); }
.badge-partial  { background: var(--amber-tint); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 22%, transparent); }
.badge-paid     { background: var(--green-tint); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.badge-overdue  { background: var(--red-tint); color: var(--red); border-color: color-mix(in srgb, var(--red) 24%, transparent); }
.badge-void     { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }
/* Written off as a bad debt: off the books like a void, so it looks like one. */
.badge-written-off { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }
.badge-accepted { background: var(--green-tint); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.badge-declined { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }
.badge-expired  { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }
.badge-neutral  { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
/* A job that has become an invoice: done with, so it steps back. */
.badge-invoiced { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.badge-invoiced::before { background: var(--text-3); }

.badge-open               { background: var(--surface-3); color: var(--text-3); border-color: var(--border); }
.badge-in-progress        { background: var(--blue-tint); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 20%, transparent); }
.badge-awaiting-approval  { background: var(--amber-tint); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 22%, transparent); }
.badge-approved           { background: var(--green-tint); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.badge-waiting-parts      { background: var(--teal-tint); color: var(--teal); border-color: color-mix(in srgb, var(--teal) 30%, transparent); }
.badge-completed          { background: var(--green-tint); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
/* Solid, not tinted: "done, go get it" stands out from everything else. */
.badge-ready              { background: var(--green); color: var(--surface); border-color: var(--green); }
.badge-ready::before      { background: var(--surface); }
.badge-cancelled          { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }

.color-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-left: 7px; vertical-align: middle;
  border: 1px solid color-mix(in srgb, black 15%, transparent);
}

/* ---------------------------------------------------------- DVI checklist */

.dvi-points { display: flex; flex-direction: column; }
.dvi-point { padding: 9px 0; border-bottom: 1px solid var(--border); }
.dvi-point:last-child { border-bottom: none; }
.dvi-point-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dvi-point-label { font-size: var(--fs-base); }
.dvi-sev-buttons { display: flex; gap: var(--sp-1); flex-shrink: 0; }
.dvi-sev-btn {
  min-width: 52px; height: 34px; padding: 0 10px;
  border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
}
.dvi-sev-btn:disabled { cursor: default; }
.dvi-sev-btn:hover { background: var(--surface-3); }
.dvi-sev-good.active { background: var(--green-tint); color: var(--green); border-color: var(--green); }
.dvi-sev-attention.active { background: var(--amber-tint); color: var(--amber); border-color: var(--amber); }
.dvi-sev-urgent.active { background: var(--red-tint); color: var(--red); border-color: var(--red); }
.dvi-point-detail { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.dvi-point-detail .textarea { flex: 1; min-height: 32px; }

/* A flagged point: what the fix is, its price, and photos of what was found */
.dvi-fix { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; margin-top: 8px; }
.dvi-fix label { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dvi-fix-label { font-size: 11.5px; font-weight: 540; color: var(--text-3); }
.dvi-fix-hint { margin-top: 4px; }
.dvi-photos { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.dvi-photo { position: relative; width: 76px; height: 57px; flex-shrink: 0; }
.dvi-photo-open {
  display: block; width: 100%; height: 100%; padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); overflow: hidden; cursor: pointer;
}
.dvi-photo-open:hover { border-color: var(--accent); }
.dvi-photo-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dvi-photo-remove {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-3);
  box-shadow: var(--e1); cursor: pointer;
}
.dvi-photo-remove:hover { color: var(--red); background: var(--red-tint); border-color: var(--red); }
.dvi-photo-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dvi-photos-label { flex-basis: 100%; font-size: 11.5px; font-weight: 540; color: var(--text-3); margin-bottom: -2px; }
/* A video among the photos: its first frame, with a play badge */
.dvi-photo.is-video .dvi-photo-open { position: relative; background: #111; }
.dvi-photo.is-video video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.dvi-video-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; padding-left: 2px;
  background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; line-height: 1;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85);
}
.dvi-photo-open:hover .dvi-video-badge { background: var(--accent-solid); }
.dvi-photo.is-uploading {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1px dashed var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2);
  font-size: 10.5px; color: var(--text-3);
}
.dvi-photo.is-uploading .spinner { width: 16px; height: 16px; }
.modal-foot .dvi-video-remove { margin-right: auto; color: var(--red); }

/* ---------------------------------------------------------- send inspection to customer */

.send-replaces { margin-bottom: 14px; }
.send-via { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.send-via-option {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color var(--fast), background var(--fast);
}
.send-via-option:hover { border-color: var(--text-4); }
.send-via-option:focus-visible { outline: none; box-shadow: var(--ring); }
.send-via-option.active { border-color: var(--accent); background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }
.send-via-option:disabled { cursor: default; opacity: .7; }
.send-via-icon { display: inline-flex; flex-shrink: 0; color: var(--text-3); }
.send-via-option.active .send-via-icon { color: var(--accent-ink); }
.send-via-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.send-via-label { font-size: 13px; font-weight: 600; }
.send-via-detail { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-message { min-height: 92px; }
.send-summary {
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2);
}
.send-summary-head { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.send-summary-list { list-style: none; margin: 0; padding: 0; }
.send-summary-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.send-summary-name { flex: 1; min-width: 0; }
.send-summary-total { display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; font-size: 13px; color: var(--text-2); }
.send-unpriced { margin: 8px 0 0; color: var(--amber); }
.send-error { margin: 14px 0 0; }
.sev-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--text-4); }
.sev-dot-urgent { background: var(--red); }
.sev-dot-attention { background: var(--amber); }

/* The customer's answer: Sent · Opened · Answered, then each item */
.approval-steps { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.approval-step { position: relative; display: flex; align-items: flex-start; gap: 10px; }
.approval-step:not(:last-child)::after {
  content: ''; position: absolute; left: 9px; top: 22px; bottom: -9px;
  width: 2px; background: var(--border);
}
.approval-step-dot {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--border-strong); background: var(--surface); color: var(--surface);
}
.approval-step.is-done .approval-step-dot { background: var(--green); border-color: var(--green); }
.approval-step.is-stopped .approval-step-dot { border-style: dashed; border-color: var(--text-4); }
.approval-step-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; padding-top: 1px; }
.approval-step-title { font-size: 13px; font-weight: 560; color: var(--text); overflow-wrap: anywhere; }
.approval-step:not(.is-done) .approval-step-title { font-weight: 500; color: var(--text-2); }
.approval-step-detail { font-size: 11.5px; color: var(--text-3); }
.approval-items { border-top: 1px solid var(--border); }
.approval-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.approval-choice {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-4);
}
.approval-item.is-approved .approval-choice { background: var(--green-tint); color: var(--green); }
.approval-item.is-declined .approval-choice { background: var(--red-tint); color: var(--red); }
.approval-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.approval-item-state { font-size: 11.5px; color: var(--text-3); }
.approval-item.is-approved .approval-item-state { color: var(--green); }
.approval-item.is-declined .approval-item-state { color: var(--red); }
.approval-item.is-declined .approval-item-price { color: var(--text-3); text-decoration: line-through; }
.approval-total { display: flex; justify-content: space-between; gap: 12px; padding-top: 10px; font-size: 13.5px; }
.approval-expiry { margin-top: 10px; }
.approval-declined-note { margin-top: 8px; color: var(--amber); line-height: 1.45; }
.approval-actions { margin-top: 14px; }
.approval-cancel { color: var(--red); }
.approval-cancel:hover { background: var(--red-tint); }
.approvals-online { margin: 0; padding-left: 18px; }
.approvals-online li + li { margin-top: 3px; }

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

.field { margin-bottom: var(--sp-4); }

.field > label, .label {
  display: block;
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2);
  margin-bottom: 5px; letter-spacing: -.003em;
}

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: var(--fs-base);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
/* A date box shows its format until a date is picked, so it never looks broken. */
.input[type="date"]:invalid, .input[type="date"]:placeholder-shown { color: var(--text-3); }

.input::placeholder, .textarea::placeholder { color: var(--text-4); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--text-4); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}

.input:disabled, .select:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.input.is-invalid { border-color: var(--red); }
.textarea { min-height: 80px; resize: vertical; line-height: 1.55; }
.input-sm { padding: 5.5px 9px; font-size: 13px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2383817a' d='M1 1l4 4 4-4' stroke='%2383817a' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  cursor: pointer;
}

.field-row { display: flex; gap: 14px; }
.field-row > * { flex: 1; min-width: 0; }
.field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; line-height: 1.45; }
.field-error { font-size: 12px; color: var(--red); margin-top: 4px; }
/* A heads-up that never blocks a save (HST on insurance, a missing supplier GST/HST number). */
.field-hint.is-warn { color: var(--amber); }
.hst-note { margin: -8px 0 14px; }

.checkbox, .radio {
  display: flex; align-items: flex-start; gap: 9px;
  cursor: pointer; font-size: 13.5px; margin-bottom: 9px;
}
/* Only the tick box / round button itself: a text box inside a choice (the
   check-in's "up to $___") keeps its normal size. */
.checkbox input[type=checkbox], .checkbox input[type=radio],
.radio input[type=radio], .radio input[type=checkbox] {
  margin: 2px 0 0; flex-shrink: 0;
  accent-color: var(--accent);
  width: 15px; height: 15px; cursor: pointer;
}
.checkbox span small, .radio span small { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; line-height: 1.45; }

.input-prefix { position: relative; }
.input-prefix .prefix {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 13px; pointer-events: none; font-weight: 500;
}
.input-prefix .input { padding-left: 24px; }

fieldset { border: none; padding: 0; margin: 0 0 26px; }
fieldset:last-child { margin-bottom: 0; }
legend {
  font-size: 13px; font-weight: 620; padding: 0 0 12px; color: var(--text);
  letter-spacing: -.008em;
}

/* ---------------------------------------------------------- toolbar */

.toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-4); }
.toolbar .input, .toolbar .select { width: auto; min-width: 155px; }
/* Wide enough that the hint is never cut off; the full list of what it
   searches is in the box's tooltip. */
.toolbar .input.search, .search { width: 300px; min-width: 220px !important; max-width: 100%; }
.toolbar-spacer { flex: 1; }

/* Segmented filter: a sunken track, the chosen one raised on it. Neutral —
   the shop colour is kept for the one next-step button. */
.seg {
  display: inline-flex; gap: 2px;
  padding: 2px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: calc(var(--r-sm) + 2px);
}
.seg button {
  border: none; background: transparent;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  cursor: pointer; color: var(--text-2);
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.seg button:hover { color: var(--text); }
.seg button:focus-visible { outline: none; box-shadow: var(--ring); }
.seg button.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(28, 27, 25, .1), 0 0 0 1px var(--border);
}
:root[data-theme="dark"] .seg button.active { background: var(--border-strong); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }

/* ---------------------------------------------------------- job status strip
   Work order page: one pill per status (the current one pressed, in its badge
   colours) and the next step on the right. Wraps on narrow windows. */

.job-status {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
}
.job-status-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.job-status-label {
  font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
}
.job-status-actions { flex-shrink: 0; }

.status-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.status-chip {
  --chip: var(--text-3);
  --chip-tint: var(--surface-3);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium);
  white-space: nowrap; cursor: pointer;
  transition: background var(--fast), border-color var(--fast), color var(--fast), box-shadow var(--fast);
}
.status-chip::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--chip); flex-shrink: 0;
}
.status-chip:hover { background: var(--surface-2); border-color: var(--text-4); color: var(--text); }
.status-chip:focus-visible { outline: none; box-shadow: var(--ring); }
.status-chip[aria-pressed="true"] {
  background: var(--chip-tint); color: var(--chip); font-weight: var(--fw-bold);
  border-color: color-mix(in srgb, var(--chip) 55%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chip) 35%, transparent);
  cursor: default;
}
.status-chip:disabled { opacity: .5; cursor: progress; }
.status-chip[aria-pressed="true"]:disabled { opacity: .8; }

.status-chip[data-status="in-progress"]       { --chip: var(--blue);   --chip-tint: var(--blue-tint); }
.status-chip[data-status="awaiting-approval"] { --chip: var(--amber);  --chip-tint: var(--amber-tint); }
.status-chip[data-status="approved"]          { --chip: var(--violet); --chip-tint: var(--violet-tint); }
.status-chip[data-status="waiting-parts"]     { --chip: var(--amber);  --chip-tint: var(--amber-tint); }
.status-chip[data-status="completed"]         { --chip: var(--teal);   --chip-tint: var(--teal-tint); }
.status-chip[data-status="ready"]             { --chip: var(--green);  --chip-tint: var(--green-tint); }
.status-chip[data-status="ready"][aria-pressed="true"] { background: var(--green); color: var(--surface); border-color: var(--green); box-shadow: none; }
.status-chip[data-status="ready"][aria-pressed="true"]::before { background: var(--surface); }
.status-chip[data-status="open"][aria-pressed="true"] { --chip: var(--text-2); }

/* ---------------------------------------------------------- tabs */

.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); }
.tab {
  padding: 9px 14px;
  border: none; background: none;
  font: inherit; font-size: var(--fs-base); font-weight: var(--fw-medium);
  color: var(--text-3); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--fast), border-color var(--fast);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------- empty state */

.empty { text-align: center; padding: 64px 20px; color: var(--text-3); }
.empty-art {
  width: 62px; height: 62px; margin: 0 auto 16px;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-4);
}
.empty h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.empty p { max-width: 400px; margin: 0 auto 18px; font-size: 13px; line-height: 1.6; }

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

.lines { width: 100%; border-collapse: collapse; }
.lines th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650; text-align: left;
  padding: 0 8px 8px;
}
.lines td { padding: 3px 4px; vertical-align: top; }
.lines td:first-child { padding-left: 0; }
.lines tbody tr { transition: background var(--fast); }
.lines tbody tr:hover { background: var(--surface-2); }
.lines .line-amount {
  padding-top: 14px; text-align: right;
  font-variant-numeric: tabular-nums; font-weight: 560; white-space: nowrap;
}
.lines .drag-handle {
  cursor: grab; color: var(--text-4); padding: 12px 2px 0;
  user-select: none; line-height: 1;
}
.lines .drag-handle:active { cursor: grabbing; }
.lines tr.dragging { opacity: .35; }
.lines tr.drag-over td { box-shadow: inset 0 2px 0 var(--accent); }

.totals-box { margin-left: auto; }
.totals-row {
  display: flex; justify-content: space-between; gap: 18px;
  padding: 6px 0; font-size: 13.5px;
}
.totals-row.sub { color: var(--text-2); }
.totals-row.grand {
  border-top: 1px solid var(--border-strong);
  margin-top: var(--sp-2); padding-top: var(--sp-3);
  font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: -.02em;
}

/* ---------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 19, 17, .42);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 100; padding: 28px;
  animation: fade 140ms var(--ease);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--e4);
  width: 100%; max-width: 540px; max-height: 88vh;
  display: flex; flex-direction: column;
  animation: pop 180ms var(--ease);
}

.modal.modal-lg { max-width: 800px; }
.modal-head {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-head h2 { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); letter-spacing: -.016em; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex; justify-content: flex-end; gap: 9px;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }

/* ---------------------------------------------------------- toast */

.toast-root {
  position: fixed; bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 9px;
  z-index: 200; pointer-events: none;
}

.toast {
  background: var(--nav-bg);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--r-sm);
  box-shadow: var(--e4);
  font-size: 13px; font-weight: 480;
  max-width: 400px;
  animation: slide 200ms var(--ease);
  /* Words only, nothing to press: a click goes through to the button it covers
     (three stacked toasts sit over the bottom-right of a screen for seconds). */
  pointer-events: none;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid rgba(255, 255, 255, .09);
}
.toast::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--blue); flex-shrink: 0;
}
.toast.error::before { background: #e8807b; }
.toast.success::before { background: #5cb98d; }

@keyframes slide { from { opacity: 0; transform: translateX(20px); } }

/* ---------------------------------------------------------- banners */

.banner {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r);
  font-size: var(--fs-base); line-height: 1.55;
  margin-bottom: var(--sp-4);
  border: 1px solid transparent;
}
.banner-info { background: var(--blue-tint); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 20%, transparent); }
.banner-warn { background: var(--amber-tint); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 24%, transparent); }
.banner-danger { background: var(--red-tint); color: var(--red); border-color: color-mix(in srgb, var(--red) 22%, transparent); }
.banner strong { display: block; margin-bottom: 2px; font-weight: var(--fw-bold); }
/* A banner that reads as one line: the message, then a link or button at the end. */
.banner-line { align-items: center; }
.banner-line > :first-child { flex: 1; min-width: 0; }
.banner-line strong { display: inline; margin: 0; }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---------------------------------------------------------- misc */

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 72px; }

/* Reports → Receivables aging and Sales */
.aging-card { padding: var(--sp-5); }
.aging-total { text-align: right; }
.aging-total-value { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.aging-th { display: inline-flex; align-items: center; gap: 6px; }
.aging-invoices { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 6px; }
.aging-invoice {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 2px 7px; border-radius: 5px;
  background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 500;
}
.aging-invoice:hover { color: var(--text); }
.aging-invoice-days { color: var(--text-3); }
.aging-invoice.is-late .aging-invoice-days { color: var(--red); font-weight: 600; }
.sales-note { margin: 0 0 10px; }
.sales-meter { margin-top: 6px; max-width: 220px; height: 5px; }
.meter.sales-meter > i { background: var(--viz-revenue); }
.sales-table td .chip { margin-left: 4px; vertical-align: 1px; }

/* Receivables by age (lib/aging.js): the bar, then a key with amounts and shares. */
.aging-summary .viz-segbar { margin-bottom: 14px; }
.aging-key { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 44px; align-items: center; gap: 9px 10px; font-size: 13px; }
.aging-key-row { display: contents; }
.aging-key-label { color: var(--text-2); }
.aging-key-value { text-align: right; color: var(--text); font-weight: 560; }
.aging-key-share { text-align: right; color: var(--text-3); font-size: 12px; }
.aging-key.is-inline { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.aging-key.is-inline .aging-key-row { display: inline-flex; align-items: center; gap: 7px; }
.aging-key.is-inline .aging-key-share { display: none; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-base); margin: 0; }
.kv dt.strong, .kv dd.strong { font-weight: var(--fw-bold); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; text-align: right; }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-5); align-items: start; }
/* minmax(0, …): a plain 1fr would let the letter-size preview push the page sideways. */
@media (max-width: 1160px) { .split { grid-template-columns: minmax(0, 1fr); } }
.sticky-side { position: sticky; top: 0; }
@media (max-width: 1160px) {
  .sticky-side { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); align-items: start; }
  .sticky-side > .card + .card { margin-top: 0; }
}
@media (max-width: 860px) { .sticky-side { grid-template-columns: minmax(0, 1fr); } }

/* Printed-document preview */
.doc-preview {
  background: #fff;
  box-shadow: var(--e3);
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
}
.doc-preview-scale { transform-origin: top left; background: #fff; }
/* White paper stays white, but a touch dimmer at night so it doesn't glare. */
:root[data-theme="dark"] .doc-preview { filter: brightness(.9); border-color: var(--border-strong); }

/* Progress meter used on client/report screens */
.meter { height: 7px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.meter > i {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
}

/* ---------------------------------------------------------- vehicles */

.vehicle-list { display: flex; flex-direction: column; gap: 12px; }

.vehicle-row {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px 4px;
  background: var(--surface-2);
}

.vehicle-row-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}

.lbl-mini {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 650; color: var(--text-3);
}

.catalogue-group + .catalogue-group { margin-top: 18px; }
.catalogue-group-label { margin-bottom: 6px; }

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 12px;
}
@media (max-width: 760px) { .vehicle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Vehicle identity shown on a document or in a picker */
.vehicle-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 7px;
  border-radius: var(--r-pill);
  background: var(--violet-tint);
  color: var(--violet);
  border: 1px solid color-mix(in srgb, var(--violet) 20%, transparent);
  font-size: 12px; font-weight: 560; white-space: nowrap;
}
.vehicle-chip svg { opacity: .8; }

.vehicle-card {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 13px 15px;
  background: var(--surface-2);
}
.vehicle-card + .vehicle-card { margin-top: 10px; }
.vehicle-card .title { font-weight: 620; font-size: 13.5px; letter-spacing: -.01em; }
.vehicle-card .meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ---------------------------------------------------------- tabbed panels */

.tabbed { display: flex; flex-direction: column; min-height: 0; }

/* Tabs inside a dialog sit flush with its edges */
.tabs-inset {
  margin: -20px -22px 18px;
  padding: 0 22px;
  gap: 2px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.tabs-inset .tab { padding: 12px 14px; display: flex; align-items: center; gap: 7px; }

.tab-badge {
  font-size: 10.5px; font-weight: 650;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-3);
  display: inline-grid; place-items: center;
  line-height: 1;
}
.tab.active .tab-badge { background: var(--text); color: var(--surface); }

/* A consistent floor keeps the dialog from jumping as tabs change */
.tab-stack { min-height: 330px; }
.tab-panel[hidden] { display: none !important; }

.modal-body-tabbed { padding-top: 20px; }

/* ---------------------------------------------------------- form furniture */

/* Labelled divider inside a form section */
.section-rule {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0 14px;
  color: var(--text-3);
  font-size: 10.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .09em;
}
.section-rule::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.req { color: var(--accent-ink); font-weight: 700; }

/* Required fields flag themselves once touched and left empty */
.input.is-invalid, .select.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 14%, transparent);
}

/* Value shown in caps (VIN, plate) without shouting the placeholder too */
.upper { text-transform: uppercase; }
.upper::placeholder { text-transform: none; }

/* The single Ontario rate, stated once instead of a one-row table */
.rate-card {
  display: flex; align-items: center; gap: 20px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  background: var(--surface-2);
}
.rate-figure { flex-shrink: 0; text-align: center; min-width: 92px; }
.rate-value {
  font-size: 30px; font-weight: 660; letter-spacing: -.03em;
  color: var(--accent-ink); line-height: 1;
}
.rate-name {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 650; color: var(--text-3); margin-top: 5px;
}

/* ---------------------------------------------------------- parts inventory */

.stock-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-pill);
}
.stock-badge.ok { background: var(--green-tint); color: var(--green); }
.stock-badge.low { background: var(--amber-tint); color: var(--amber); }
.stock-badge.out { background: var(--red-tint); color: var(--red); }

tr.is-low-stock td:first-child { box-shadow: inset 3px 0 0 var(--amber); }

/* Part chip on an invoice line: distinguishes a catalogue part from a
   custom, one-off one typed straight into the description. */
.line-part-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; color: var(--violet);
  background: var(--violet-tint); border-radius: 4px;
  padding: 1px 6px; margin-top: 3px;
}

.catalogue-tabs { display: flex; gap: 2px; margin-bottom: 14px; }

/* ---------------------------------------------------------- attachments */

.attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 12px;
}

.attach-tile { display: flex; flex-direction: column; gap: 5px; }
.attach-empty { grid-column: 1 / -1; margin: 0; }

.attach-tile-open {
  display: block; width: 100%; aspect-ratio: 4 / 3;
  padding: 0; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); overflow: hidden; cursor: pointer;
  box-shadow: none;
}
.attach-tile-open:hover { border-color: var(--accent); }
.attach-tile-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-tile.is-video .attach-tile-open { position: relative; background: #111; }
.attach-tile.is-video video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

.attach-pdf {
  width: 100%; height: 100%; display: grid; place-items: center;
  color: var(--text-3);
}

.attach-tile-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
}
.attach-tile-meta .btn { padding: 2px 4px; color: var(--text-4); }
.attach-tile-meta .btn:hover { color: var(--red); background: var(--red-tint); }

.attach-count {
  background: var(--violet-tint); color: var(--violet);
  border: none; font-weight: 600;
}

.attach-lightbox { position: relative; display: flex; justify-content: center; }
.attach-lightbox-img { max-width: 100%; max-height: 62vh; border-radius: var(--r-sm); }
.attach-lightbox-pdf { width: 100%; height: 62vh; border: 1px solid var(--border); border-radius: var(--r-sm); }
.attach-lightbox-caption { text-align: center; margin-top: 10px; }
.attach-lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: var(--surface); box-shadow: var(--e2);
}
.attach-lightbox-nav.prev { left: -6px; }
.attach-lightbox-nav.next { right: -6px; }

/* ---------------------------------------------------------- camera capture */

.camera-stage {
  position: relative;
  background: #000;
  border-radius: var(--r);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center;
}
.camera-stage video, .camera-stage .camera-preview {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
/* Recording a video: how long so far, and how long is left */
.camera-timer {
  position: absolute; top: 10px; left: 10px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: pre;
  pointer-events: none;
}
.camera-timer.is-recording { background: rgba(176, 30, 30, .88); }
.attach-lightbox-video { max-width: 100%; max-height: 62vh; border-radius: var(--r-sm); background: #000; }

/* The plate the reader found, ready to check before searching. */
.plate-read-result { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.plate-read-input {
  font-size: 28px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  text-align: center; font-family: var(--mono, ui-monospace, monospace); max-width: 320px;
}
.plate-read-alts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------------- service history */

.service-history-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.service-history-row:last-child { border-bottom: none; }
.service-history-row:hover { background: var(--surface-2); margin: 0 -8px; padding: 8px; border-radius: var(--r-sm); }
.service-history-row .num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- customer lookup */

/* On a job: one quiet line about money the customer owes — "Camille owes
   $88.36 (34 days late) — collect at pickup · View". */
.balance-note {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--amber-tint); color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 22%, transparent);
  font-size: var(--fs-base);
}
.balance-note-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.balance-note-text { flex: 1; min-width: 0; color: var(--text); }
.balance-note-text strong { font-weight: var(--fw-bold); }
.balance-note-text .muted { color: var(--text-2); }
.balance-note a { color: var(--amber); font-weight: var(--fw-medium); text-decoration: underline; }

.finder-card { margin-bottom: 12px; }
.finder-card .card-head { margin-bottom: 8px; }
.finder-results { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.finder-empty { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 2px; }
.finder-hit {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 10px;
}
.finder-hit:hover, .finder-hit:focus-visible { background: var(--surface-2); border-color: var(--accent); outline: none; }
.finder-hit-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.finder-chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; flex-shrink: 0; }
.finder-chip {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--blue-tint); color: var(--blue);
}
.finder-chip-owes { background: var(--red-tint); color: var(--red); }

.balance-slot:empty { display: none; }
.balance-slot { margin-bottom: 12px; }
.balance-banner {
  border-radius: var(--r); padding: var(--sp-3) var(--sp-4); border: 1px solid;
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.balance-owing { background: var(--amber-tint); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.balance-overdue { background: var(--red-tint); color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.balance-list { margin: 4px 0 0; padding-left: 18px; font-size: 13px; }
.balance-list a { margin-right: 8px; font-weight: 600; }
.balance-subhead { margin-top: 6px; }
.balance-list li.balance-row-overdue {
  font-weight: 600; background: rgba(163, 39, 36, 0.10); border-radius: 4px;
  padding: 2px 6px; margin: 2px 0 2px -6px; list-style-position: inside;
}
.finder-input-row { display: flex; gap: 8px; }
.finder-input-row .input { flex: 1; min-width: 0; }

/* ===== Document editor tabs + summary bar (editor-tabs.js) ===== */
.et-summary {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--e2); padding: 10px 16px; margin-bottom: 16px;
}
.et-sum-info { display: flex; align-items: center; gap: 22px; min-width: 0; flex: 1 1 320px; }
.et-sum-cell { min-width: 0; }
.et-sum-grow { flex: 1 1 0; }
.et-sum-label { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.et-sum-val { font-size: 13.5px; font-weight: 560; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.et-sum-val.et-empty { color: var(--text-3); font-weight: 450; }
.et-sum-total { font-size: 19px; font-weight: 680; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.et-sum-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.et-strip {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 4px; margin-bottom: 16px;
}
.et-tab {
  flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border: 0; border-radius: var(--r); background: transparent;
  color: var(--text-2); font: inherit; font-size: 13.5px; font-weight: 520; white-space: nowrap;
  cursor: pointer; transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.et-tab:hover { color: var(--text); background: var(--surface-2); }
.et-tab:focus-visible { outline: none; box-shadow: var(--ring); }
.et-tab.active { background: var(--surface); color: var(--text); font-weight: var(--fw-bold); box-shadow: var(--e1); }
.et-tab.has-error { color: var(--red); }
.et-num {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-3);
  font-size: 11px; font-weight: 640;
}
.et-tab.active .et-num { background: var(--text); border-color: var(--text); color: var(--surface); }
.et-count {
  min-width: 18px; padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-3);
  border: 1px solid var(--border-strong); color: var(--text-2); font-size: 11px; font-weight: 640; line-height: 17px; text-align: center;
}
.et-count[hidden], .et-dot[hidden] { display: none; }
.et-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.et-dot-warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-tint); }
.et-dot-error { background: var(--red); box-shadow: 0 0 0 3px var(--red-tint); }
/* Said in words on the tab, not a dot to decode: "Owes $88". */
.et-pill {
  padding: 0 8px; border-radius: var(--r-pill); line-height: 18px;
  font-size: var(--fs-xs); font-weight: var(--fw-medium); white-space: nowrap;
  background: var(--amber-tint); color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 28%, transparent);
}
.et-pill[hidden] { display: none; }

.et-panel[hidden] { display: none !important; }
.et-card-title { font-size: 13px; font-weight: 640; color: var(--text-2); margin: 0 0 10px; }
.et-card-title:not(:first-child) { margin-top: 18px; }
/* Back / save / Next: one bar that stays at the bottom of the window while the
   step scrolls, so the save buttons are always in reach (and never repeated
   in the header). */
.et-foot {
  display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 14px 0 16px;
  border-top: 1px solid var(--border);
  position: sticky; bottom: -72px; z-index: 5;
  background: var(--bg);
  margin-bottom: -56px; padding-bottom: 72px;
}
.et-foot-gap { flex: 1; }
.et-review { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.et-review .card + .card { margin-top: 16px; }
@media (max-width: 1000px) {
  .et-review { grid-template-columns: 1fr; }
  .et-sum-info { gap: 14px; }
}
@media (max-width: 640px) {
  .et-summary { padding: 8px 12px; }
  .et-sum-info { flex-basis: 100%; }
  .et-sum-actions { width: 100%; }
  .et-sum-actions .btn { flex: 1; }
  .et-tab { padding: 9px 12px; }
}

/* Review recap + narrow-window line items */
.et-recap { margin-top: 16px; }
.et-recap-kv { margin-bottom: 4px; }
.et-recap-lines {
  list-style: none; margin: 12px 0 0; padding: 12px 0 0;
  border-top: 1px solid var(--border); display: grid; gap: 6px; font-size: 13px;
}
.et-recap-lines li { display: flex; justify-content: space-between; gap: 12px; }
.et-recap-desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.et-recap-lines .num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Keep the description readable: when the window is narrow the line items scroll sideways
   instead of squeezing every column. */
.card:has(> table.lines), .card:has(> .table-wrap > table.lines) { overflow-x: auto; }
table.lines { min-width: 920px; }
.et-strip { scrollbar-width: thin; }

/* ---------------------------------------------------------- past work (customer history) */
.history-slot:empty { display: none; }
.history-slot { margin-bottom: 16px; }
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 12px;
}
.history-row:hover, .history-row:focus-visible { background: var(--surface-2); border-color: var(--accent); outline: none; }
.history-when, .history-what { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.history-lines { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
@media (max-width: 900px) { .history-row { grid-template-columns: 110px minmax(0, 1fr) auto; gap: 10px; } }

/* ---------------------------------------------------------- accounting */
/* Journal and statements group rows under headings, so zebra striping would
   cut across entries; only rows you can click get a hover. */
.table-wrap table.data.ledger-plain tbody tr:nth-child(even),
.table-wrap table.data.ledger-plain tbody tr:hover { background: none; }
.table-wrap table.data.ledger-plain tbody tr.clickable:hover { background: var(--surface-2); }

table.data.ledger-journal tbody + tbody tr:first-child td { border-top: 1px solid var(--border); }
table.data.ledger-journal tr.je-head td { border-bottom: none; padding-bottom: 5px; }
table.data.ledger-journal tr.je-line td {
  border-bottom: none; padding-top: 2px; padding-bottom: 2px; font-size: 12.5px; color: var(--text-2);
}
table.data.ledger-journal tr.je-line:last-child td { padding-bottom: 13px; }
table.data.ledger-journal td.je-acct { padding-left: 30px; }
/* Credits sit indented under debits, the way a paper journal is written. */
table.data.ledger-journal tr.je-line.is-credit td.je-acct { padding-left: 58px; }

table.data tr.fs-head td {
  background: var(--surface-2);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650;
  padding-top: 9px; padding-bottom: 9px;
}
table.data tr.fs-total td { font-weight: 620; border-top: 1px solid var(--border-strong); }
table.data tr.fs-note td { color: var(--text-2); font-style: italic; }
table.data tr.is-inactive td { opacity: .55; }

.ledger-check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600;
  border: 1px solid transparent;
}
.ledger-check.ok { background: var(--green-tint); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.ledger-check.bad { background: var(--red-tint); color: var(--red); border-color: color-mix(in srgb, var(--red) 24%, transparent); }

/* Journal entry form lines */
.je-form { width: 100%; border-collapse: collapse; }
.je-form th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 650; text-align: left;
  padding: 0 4px 6px;
}
.je-form td { padding: 3px 4px; vertical-align: middle; }
.je-form td:first-child { width: 36%; }
.je-form .input-prefix .input { text-align: right; }
.je-totals {
  display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline; gap: 8px 22px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 13px;
}
.je-total { display: flex; gap: 8px; align-items: baseline; }
.je-status { flex-basis: 100%; text-align: right; font-weight: 560; }

/* ---------------------------------------------------------- sign-in & roles */

/* Until /auth/status answers, nobody sees a sidebar they may not be allowed. */
.app.is-booting { visibility: hidden; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Signed-in user, at the foot of the sidebar */
.user-chip {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px; padding: 12px 4px 2px 8px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.user-chip-who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-chip-text { min-width: 0; line-height: 1.3; }
.user-chip-text strong {
  display: block; color: #fff; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-chip-text small { display: block; color: var(--nav-text); font-size: 11.5px; }
.user-chip-actions { display: flex; gap: 2px; flex-shrink: 0; }
.user-chip-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: none; border-radius: 7px;
  background: transparent; color: var(--nav-text);
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.user-chip-btn:hover { background: var(--nav-hover); color: #fff; }
.user-chip-btn:focus-visible { outline: 2px solid var(--nav-text); outline-offset: 1px; }

/* The PIN lock screen: covers the whole window, app and modals included */
.lock-screen {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  padding: 24px; overflow-y: auto;
  background:
    radial-gradient(circle at 50% 0%, var(--accent-tint) 0%, transparent 55%),
    var(--bg);
  animation: fade 160ms var(--ease);
}
.lock-panel {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--e3);
  padding: 28px 28px 24px;
  text-align: center;
  outline: none;
}
.lock-brand {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 22px; text-align: left;
}
.lock-mark { width: 48px; height: 48px; }
.lock-brand-text { min-width: 0; }
.lock-brand-text strong {
  display: block; font-size: 15px; font-weight: 620; letter-spacing: -.012em; color: var(--text);
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lock-brand-text small { display: block; font-size: 12px; color: var(--text-3); }
.lock-title { margin: 0; font-size: 20px; font-weight: 640; letter-spacing: -.02em; }
.lock-note { margin: 6px 0 0; font-size: 13px; color: var(--text-2); line-height: 1.5; }
.lock-previous { margin: 4px 0 0; font-size: 12.5px; color: var(--text-3); }

.pin-dots {
  display: flex; justify-content: center; gap: 12px;
  height: 16px; margin: 22px 0 6px;
}
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong);
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
}
.pin-dot.filled { background: var(--text); border-color: var(--text); transform: scale(1.05); }
.lock-panel.has-error .pin-dot { border-color: var(--red); }

.lock-error { min-height: 20px; margin: 6px 0 10px; font-size: 13px; font-weight: 550; color: var(--red); }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 14px;
}
.pin-key {
  height: 60px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: 22px; font-weight: 560; font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: var(--e1);
  transition: background var(--fast), border-color var(--fast), transform var(--fast);
  user-select: none;
}
.pin-key:hover { background: var(--surface-3); border-color: var(--border-strong); }
.pin-key:active { transform: translateY(1px); background: var(--border); }
.pin-key:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--blue); }
.pin-key:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.pin-key-action { background: transparent; box-shadow: none; border-color: transparent; color: var(--text-2); }
.pin-key-text { font-size: 13.5px; font-weight: 580; }
.lock-submit { width: 100%; justify-content: center; padding: 11px 16px; font-size: 14.5px; }

.lock-panel.shake { animation: lock-shake 360ms var(--ease); }
@keyframes lock-shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
@media (prefers-reduced-motion: reduce) {
  .lock-screen, .lock-panel.shake { animation: none; }
  .pin-dot, .pin-key { transition: none; }
}
@media (max-height: 640px) {
  .lock-panel { padding: 20px 22px 18px; }
  .lock-brand { margin-bottom: 14px; }
  .pin-key { height: 50px; }
}

/* The foot of the lock and sign-in panels: who this device is signed in as, and signing it out */
.lock-foot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border);
}
.lock-signed-in-as { margin: 0; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }

/* Sign in, forgot password, a new password, choose your PIN, suspended (views/auth/) */
.auth-panel { max-width: 380px; }
.auth-panel-wide { max-width: 460px; }
.auth-form { margin-top: 14px; text-align: left; }
.auth-field { margin-bottom: 12px; }
.auth-field .input { width: 100%; }
.auth-pin { letter-spacing: .3em; font-size: 18px; }
.auth-error:empty { min-height: 0; margin: 6px 0 0; }
.auth-sent { margin: 14px 0 0; font-size: 13px; line-height: 1.5; color: var(--text-2); }
.auth-sent:empty { display: none; }
.auth-panel .lock-submit { margin-top: 6px; }
body.is-signed-out .toast-root { z-index: 400; }

/* "Your payment is past due" above every screen (app.js paintBanner) */
.shell-banner { margin: 12px 24px 0; }
.shell-banner span { display: block; }

/* The in-page "Are you sure?" (ui.js confirm) */
.confirm-message { margin: 0 0 6px; font-weight: 550; }
.confirm-detail { margin: 0; line-height: 1.5; }

/* Settings → Help & about */
.help-links { margin: 0; padding-left: 18px; line-height: 1.9; }

/* ============================================================
   Charts (lib/charts.js) and the Financial report
   Thin marks, hairline recessive grid, text in text tokens only.
   ============================================================ */

.viz-chart { position: relative; width: 100%; }
.viz-svg { display: block; }
.viz-svg text { font-family: var(--font); }

.viz-gridline { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-baseline { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.viz-crossline { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz-tick {
  fill: var(--text-3); font-size: 11px;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1;
}
.viz-label {
  fill: var(--text-2); font-size: 11.5px; font-weight: 620;
  /* A surface-coloured halo keeps the label legible where it crosses a line. */
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
.viz-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area-fill { fill-opacity: .1; }
.viz-dot { stroke: var(--surface); stroke-width: 2; }
.viz-grid, .viz-marks, .viz-direct, .viz-xlabels, .viz-cross { pointer-events: none; }

.viz-echo { fill: var(--viz-echo); }
.viz-partial-edge { fill: none; stroke-width: 1; opacity: .9; }
.viz-tick.is-partial { fill: var(--text-2); }
.viz-sofar { font-size: 10.5px; font-style: italic; }
.viz-sublabel { font-size: 10.5px; fill: var(--text-2); font-weight: 560; }
.viz-value-label { font-size: 10.5px; font-weight: 600; }
.viz-overlay-line { stroke-width: 1.75; }
.viz-overlay-line.is-dashed { stroke-dasharray: 4 3; }
.viz-dot-sm { stroke-width: 1.5; }

.viz-hit { fill: transparent; outline: none; }
.viz-hit.is-active { fill: var(--viz-hover); }
.viz-hit:focus-visible { fill: var(--viz-hover); stroke: var(--blue); stroke-width: 1; }
/* The area chart answers hover with a crosshair instead of a band wash. */
.viz-chart.viz-kind-area .viz-hit.is-active { fill: transparent; }

.viz-spark { width: 100%; margin-top: 10px; }
.viz-spark-line { fill: none; stroke: var(--viz-deemph); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.viz-key-rect { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.viz-key-line { display: inline-block; width: 12px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.viz-key-dash { display: inline-block; width: 14px; height: 0; border-top: 2px dashed; flex-shrink: 0; }
.viz-key-hatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
  background: repeating-linear-gradient(135deg, var(--key) 0 2px, color-mix(in srgb, var(--key) 32%, transparent) 2px 4px) !important;
}

.viz-tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 168px; max-width: 290px;
  padding: 9px 12px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--e3);
  font-size: 12.5px; line-height: 1.4;
}
.viz-tooltip-title { font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; }
.viz-tooltip-row {
  display: grid; grid-template-columns: 12px auto 1fr; align-items: center;
  gap: 8px; padding: 2px 0;
}
.viz-tooltip-value {
  color: var(--text); font-weight: 620;
  font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1;
}
.viz-tooltip-label { color: var(--text-2); }
.viz-tooltip-foot {
  margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--border);
  color: var(--text-3); font-size: 11.5px;
}

.viz-barlist { position: relative; display: flex; flex-direction: column; gap: 10px; }
.viz-barlist-row {
  padding: 3px 6px 4px; margin: 0 -6px; border-radius: 6px; outline: none;
  transition: background var(--fast);
}
.viz-barlist-row:hover, .viz-barlist-row:focus-visible { background: var(--viz-hover); }
.viz-barlist-row:focus-visible { box-shadow: var(--ring); }
.viz-barlist-head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.viz-barlist-label {
  font-size: 13px; color: var(--text); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.viz-barlist-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.viz-barlist-track { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.viz-barlist-bar {
  display: block; height: 12px; flex-shrink: 0;
  border-radius: 0 4px 4px 0; /* square at the baseline, rounded at the data end */
  transition: opacity var(--fast);
}
.viz-barlist-row:hover .viz-barlist-bar,
.viz-barlist-row:focus-visible .viz-barlist-bar { opacity: .82; }
.viz-barlist-value { font-size: 12.5px; color: var(--text-2); font-weight: 560; white-space: nowrap; font-variant-numeric: tabular-nums; }
.viz-barlist-delta { font-size: 11.5px; white-space: nowrap; color: var(--text-3); font-variant-numeric: tabular-nums; }
.viz-barlist-delta.is-good { color: var(--green); }
.viz-barlist-delta.is-bad { color: var(--red); }

.viz-segbar { position: relative; }
.viz-segbar-track {
  display: flex; gap: 2px; height: 12px; border-radius: var(--r-pill);
  overflow: hidden; background: var(--surface-3);
}
.viz-segbar-part { display: block; min-width: 3px; height: 100%; transition: opacity var(--fast); }
.viz-segbar-part:hover { opacity: .82; }

/* ---- Financial report ---- */

.fin-filters { margin-bottom: 14px; }
.seg.seg-quiet button.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.fin-dates { display: inline-flex; align-items: center; gap: 6px; }
.fin-date-label { font-size: 12.5px; color: var(--text-3); }
.toolbar .input.fin-date { min-width: 0; width: 140px; }
.fin-error { margin-bottom: 14px; }
.fin-filters-break { flex-basis: 100%; height: 0; }
.fin-compare { display: inline-flex; align-items: center; gap: 8px; }

.fin-results { transition: opacity 160ms var(--ease); }
.fin-results.is-stale { opacity: .5; pointer-events: none; }

.fin-hero { padding: var(--sp-5); }
.fin-hero-label {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.fin-hero-range { font-weight: 450; color: var(--text-3); font-size: 12.5px; }
.fin-hero-value {
  margin: 6px 0 8px;
  font-size: var(--fs-display); font-weight: var(--fw-bold); letter-spacing: -.035em; line-height: 1.05;
  color: var(--text);
  font-variant-numeric: proportional-nums; /* big standalone figure: never tabular */
}
.fin-hero-sub { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 13.5px; color: var(--text-2); }
.fin-dot { color: var(--text-4); }

.fin-delta { margin-top: 8px; font-size: 12.5px; font-weight: 580; }
.fin-delta.is-good { color: var(--green); }
.fin-delta.is-bad { color: var(--red); }
.fin-delta.is-flat { color: var(--text-3); font-weight: 450; }
.fin-delta-arrow { font-size: 10px; margin-right: 4px; position: relative; top: -1px; }
.fin-delta-vs { color: var(--text-3); font-weight: 450; }

.fin-tile { display: flex; flex-direction: column; padding: var(--sp-4) var(--sp-5) var(--sp-3); }
.fin-tile .stat-label { margin-bottom: 6px; }
.fin-tile-value {
  font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.028em; line-height: 1.1;
  color: var(--text); font-variant-numeric: proportional-nums;
}
.fin-tile-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.fin-asof {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 30px;
  padding: 12px 18px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2);
}
.fin-asof-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .075em;
  color: var(--text-3); font-weight: 620;
}
.fin-asof-item { display: inline-flex; align-items: baseline; gap: 8px; }
.fin-asof-label { font-size: 12.5px; color: var(--text-3); }
.fin-asof-value { font-size: 14px; font-weight: 600; color: var(--text-2); }
a.fin-asof-value:hover { color: var(--text); }

.fin-card { padding: var(--sp-5) var(--sp-5) var(--sp-4); min-width: 0; }
.fin .grid > .card + .card { margin-top: 0; } /* grid cells align; the grid gap spaces them */
.fin-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 8px 16px; margin-bottom: 14px;
}
.fin-card-head h2 { margin: 0; }
.fin-card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; font-weight: 400; }
.fin-card-head .viz-legend { padding-top: 2px; }
.fin-quiet { color: var(--text-3); font-size: 13px; margin: 6px 0 4px; }
.fin-tile-aging { margin-top: 12px; }
.fin-tile.stat-link { color: inherit; }
.fin-callout {
  margin-top: 16px; padding: 10px 12px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.fin-callout-title { font-size: 13px; font-weight: 620; color: var(--text); font-variant-numeric: tabular-nums; }
.fin-callout-text { font-size: 12.5px; color: var(--text-2); margin-top: 2px; line-height: 1.45; }
.fin-mix-summary {
  display: flex; flex-wrap: wrap; gap: 4px 18px; margin: -4px 0 10px;
  font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.fin-mix-summary strong { color: var(--text); font-weight: 620; }
.dash-chart-head { align-items: flex-start; flex-wrap: wrap; gap: 8px 16px; }
.dash-chart-head h2 { margin: 0; }
.dash-chart-foot { margin-top: 10px; }

table.data.fin-mini-table th { background: none; position: static; padding: 0 6px 8px; }
table.data.fin-mini-table td { padding: 10px 6px; }
table.data.fin-mini-table th:first-child, table.data.fin-mini-table td:first-child { padding-left: 0; }
table.data.fin-mini-table th:last-child, table.data.fin-mini-table td:last-child { padding-right: 0; }

.fin-details { padding: 0; overflow: clip; }
.fin-details > summary {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px;
  padding: 16px 22px; cursor: pointer; list-style: none; user-select: none;
}
.fin-details > summary::-webkit-details-marker { display: none; }
.fin-details > summary::before {
  content: ""; align-self: center;
  width: 7px; height: 7px; margin-right: 2px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg); transition: transform var(--fast);
}
.fin-details[open] > summary::before { transform: rotate(45deg); }
.fin-details > summary:focus-visible { outline: none; box-shadow: inset var(--ring); }
.fin-details[open] > summary { border-bottom: 1px solid var(--border); }
.fin-details-title { font-size: 15px; font-weight: 600; letter-spacing: -.012em; }
.fin-table-scroll { overflow-x: auto; }
table.data.fin-table th { position: static; }
table.data.fin-table td.fin-period { white-space: nowrap; color: var(--text); }
table.data.fin-table tbody tr:nth-child(even) { background: var(--surface-2); }
.fin-profit { color: var(--green); }
.fin-loss { color: var(--red); }

@media (prefers-reduced-motion: reduce) {
  .fin-results, .viz-barlist-bar, .viz-barlist-row, .fin-details > summary::before { transition: none; }
}

/* ---------------------------------------------------------- monthly bills */

.bills-toolbar { gap: 6px; }
.bills-month-label {
  margin: 0 6px; min-width: 150px; text-align: center;
  font-size: 15px; font-weight: 620; letter-spacing: -.012em;
}
.bills-stat-quiet { background: var(--surface-2); box-shadow: none; }
.bills-stat-quiet .stat-value { font-size: 20px; color: var(--text-2); }
.bills-stat-alert { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.bills-alert {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--red); font-weight: 600;
}
.bill-icon { flex-shrink: 0; }
.bill-pill::before { display: none; }
.bill-pill { padding-left: 8px; }
.bills-note { margin-top: 4px; }

.bills-card + .bills-card { margin-top: 18px; }
table.data.bills-table td { vertical-align: middle; }
table.data.bills-table .col-num { font-variant-numeric: tabular-nums; }
table.data.bills-table .row-actions { flex-wrap: nowrap; }
table.data.bills-table tr.is-skipped td:nth-child(2) .strong { color: var(--text-3); font-weight: 560; }
table.data.bills-table tr.bill-paused td:not(:last-child) { opacity: .6; }

/* Pay dialog: what is being paid, before the fields */
.bill-pay-summary {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
}
.bill-pay-summary .label { margin-bottom: 2px; }

/* Bill form: quick picks */
.bill-picks { margin-bottom: 16px; }
.bill-picks-row { display: flex; flex-wrap: wrap; gap: 6px; }
.bill-pick {
  font: inherit; font-size: 12.5px; font-weight: 540;
  padding: 5px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.bill-pick:hover { background: var(--surface-3); color: var(--text); }
.bill-pick:focus-visible { outline: none; box-shadow: var(--ring); }
.bill-pick[aria-pressed="true"] { background: var(--blue-tint); color: var(--blue); border-color: var(--blue); }
.bill-amount-field { max-width: calc(50% - 7px); }

/* Dashboard card */
.bills-dash-overdue {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 10px;
  background: var(--red-tint); color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 24%, transparent); border-radius: var(--r-sm);
  font-size: 13px;
}
.bills-dash table.data td { padding-top: 9px; padding-bottom: 9px; }

/* Journal: the entry a paid bill's "View in journal" pointed at */
table.data tbody.je-focus > tr > td { background: var(--blue-tint); }

/* Settings → Mobile app: the pairing QR code. White behind it in both themes,
   so any phone camera can read it. */
.pair-qr { display: flex; align-items: center; gap: 16px; margin: 8px 0 14px; }
.pair-qr img { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--border); flex-shrink: 0; }
.pair-qr .small { max-width: 260px; }

/* ---------------------------------------------------------- email */

/* "Email to client" dialog */
.email-from { margin: 0 0 14px; }
.email-from strong { color: var(--text); font-weight: 580; }
.email-note {
  margin: 0 0 14px; padding: 8px 12px;
  background: var(--amber-tint); color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 24%, transparent); border-radius: var(--r-sm);
  font-size: 12.5px; font-weight: 540;
}
.email-message { min-height: 170px; }
.email-attachment {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--text-3);
}
.email-attachment-icon { display: inline-flex; color: var(--text-2); }
.email-attachment-name { color: var(--text); font-weight: 580; word-break: break-all; }
.email-error { margin: 14px 0 0; }

/* Side pane: "Last emailed to … · date" */
.emailed-note {
  display: flex; align-items: flex-start; gap: 7px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
  font-size: 12px; line-height: 1.5; color: var(--text-3);
}
.emailed-note-icon { display: inline-flex; margin-top: 2px; flex-shrink: 0; }
.emailed-note-to { color: var(--text-2); font-weight: 560; word-break: break-all; }

/* Settings → Email */
.mail-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-2);
}
.mail-status.is-on {
  background: var(--green-tint); color: var(--green);
  border-color: color-mix(in srgb, var(--green) 22%, transparent);
}
.mail-status strong { font-weight: 620; word-break: break-all; }
.mail-status-icon { display: inline-flex; flex-shrink: 0; }
.mail-help { margin: -4px 0 16px; }
.mail-help ol { margin: 4px 0 0; padding-left: 20px; }
.mail-help li + li { margin-top: 2px; }
.mail-custom {
  padding: 14px 16px 2px; margin-bottom: 15px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
}
.mail-problem { margin: 4px 0 0; }

/* ---------------------------------------------------------- tires
   Season colours match the printed storage tags and shared/tires: winter
   blue, summer amber, all-season teal (never the green of "done"). */

.season-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 620; white-space: nowrap;
  border: 1px solid transparent;
}
.season-winter     { background: var(--blue-tint); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 22%, transparent); }
.season-all-season { background: var(--teal-tint); color: var(--teal); border-color: color-mix(in srgb, var(--teal) 30%, transparent); }
.season-summer     { background: var(--amber-tint); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 26%, transparent); }
.season-none       { background: var(--surface-3); color: var(--text-3); border-color: var(--border); }

.tire-size { font-family: var(--mono); font-weight: 620; font-size: 13px; letter-spacing: -.01em; }

.tire-tile { cursor: pointer; }
.tire-tile:focus-visible { outline: none; box-shadow: var(--ring); }

/* Order status (shared/tires ORDER_STATUS_COLOURS): waiting on the supplier
   (teal) → arrived, waiting on the customer (amber) → customer told (blue) →
   done (green); cancelled is closed (violet). */
.tire-status-ordered   { background: var(--teal-tint); color: var(--teal); border-color: color-mix(in srgb, var(--teal) 30%, transparent); }
.tire-status-arrived   { background: var(--amber-tint); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 22%, transparent); }
.tire-status-notified  { background: var(--blue-tint); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 20%, transparent); }
.tire-status-installed,
.tire-status-received  { background: var(--green-tint); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.tire-status-cancelled { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }

.tire-late { color: var(--red); font-weight: 600; }
.tire-line-summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
tr.is-returned td { color: var(--text-3); }

/* Order dialog: one box per tire line. */
.tire-lines { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.tire-line {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2);
}
.tire-line-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tire-line-fields { display: grid; grid-template-columns: 118px 1.3fr 1fr 1fr 72px 72px; gap: 6px; }
.tire-line-money { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.tire-line-cell { display: flex; flex-direction: column; gap: 2px; width: 132px; }
.tire-line-cell.tl-qty { width: 80px; }
.tire-line-remove { margin-left: auto; }
.tire-lines-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tire-lines-total { margin: 8px 0 14px; text-align: right; }
@media (max-width: 760px) { .tire-line-fields { grid-template-columns: 1fr 1fr; } }

/* Customer + vehicle in the tire dialogs: the finder without its card chrome. */
.tire-customer .finder-card { border: none; box-shadow: none; padding: 0; background: none; margin-bottom: 8px; }
.tire-customer-who {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.tire-customer-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.tread-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tread-cell { display: flex; flex-direction: column; gap: 3px; }
.tread-read { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); }

.tire-name-preview { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-3); }

/* Order and stored-set dialogs. */
.tire-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.tire-steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; }
.tire-steps li {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-align: center; font-size: 12.5px; color: var(--text-3);
}
.tire-steps li::before {
  content: ''; position: absolute; top: 6px; left: -50%; right: 50%;
  height: 2px; background: var(--border-strong);
}
.tire-steps li:first-child::before { display: none; }
.tire-steps li.done::before, .tire-steps li.current::before { background: var(--green); }
.tire-step-dot {
  position: relative; z-index: 1;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.tire-steps li.done .tire-step-dot { background: var(--green); border-color: var(--green); }
.tire-steps li.current .tire-step-dot { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }
.tire-steps li.done .tire-step-label { color: var(--text-2); }
.tire-steps li.current .tire-step-label { color: var(--text); font-weight: 620; }
.tire-next { margin-bottom: 16px; }
.tire-on-job { font-size: 13px; }
.tire-kv { max-width: 480px; }
.tire-kv dd { text-align: left; }
.tire-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.tire-history li { display: flex; gap: 8px; flex-wrap: wrap; }

/* A list of choices, one button each ("Email them now" / "I called them"). */
.tire-choice {
  width: 100%; justify-content: flex-start; text-align: left;
  margin-bottom: 6px; padding: 10px 12px; white-space: normal;
}

/* Tires on the work order and the customer screen. */
.tire-link-list { display: flex; flex-direction: column; }
.tire-link-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  color: inherit;
}
.tire-link-row:last-child { border-bottom: none; }
.tire-link-row:hover { text-decoration: none; background: var(--surface-2); margin: 0 -8px; padding: 8px; border-radius: var(--r-sm); }
.tire-link-row > span:first-child { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.tire-check { padding-top: 8px; }
.tire-check .checkbox { margin: 0; }
.tire-link-row > span:last-child { white-space: nowrap; flex-shrink: 0; }

/* ---------------------------------------------------------- returns & cores
   shared/returns STATUS_COLOURS: waiting (amber) → on the shelf (teal) →
   sent (blue) → credited or replaced (green); refused and denied read red,
   and so does an overdue core; cancelled, or a status this app doesn't know,
   is closed (violet). */

.rt-status          { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }
.rt-status-overdue  { background: var(--red-tint); color: var(--red); border-color: color-mix(in srgb, var(--red) 24%, transparent); }
.rt-status-set-aside,
.rt-status-waiting  { background: var(--amber-tint); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 22%, transparent); }
.rt-status-on-shelf { background: var(--teal-tint); color: var(--teal); border-color: color-mix(in srgb, var(--teal) 30%, transparent); }
.rt-status-sent     { background: var(--blue-tint); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 20%, transparent); }
.rt-status-credited,
.rt-status-replaced,
.rt-status-issued   { background: var(--green-tint); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.rt-status-refused,
.rt-status-denied   { background: var(--red-tint); color: var(--red); border-color: color-mix(in srgb, var(--red) 24%, transparent); }
.rt-status-cancelled { background: var(--violet-tint); color: var(--violet); border-color: color-mix(in srgb, var(--violet) 24%, transparent); }

.rt-overdue { color: var(--red); font-weight: 600; }
.rt-stock-hint { margin: -6px 0 14px; }
.rt-stock-hint:empty { display: none; }
.rt-quick { margin-top: 4px; padding-left: 0; }
.rt-steps li.is-refused .tire-step-dot { background: var(--red); border-color: var(--red); }
.rt-steps li.is-refused::before { background: var(--red); }
.rt-steps li.is-refused .tire-step-label { color: var(--red); }
.rt-links { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--text-2); }

/* Which part: search the parts list, or type one in. */
.rt-part { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; align-items: flex-start; }
.rt-part > .input, .rt-part > .field-row { width: 100%; }
.rt-part-results {
  width: 100%; display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
  max-height: 232px; overflow-y: auto;
}
.rt-part-results:empty { display: none; }
.rt-part-hit {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 10px; border: none; border-bottom: 1px solid var(--border);
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.rt-part-hit:last-child { border-bottom: none; }
.rt-part-hit:hover, .rt-part-hit:focus-visible { background: var(--surface-2); outline: none; }
.rt-part-hit-name { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.rt-part-none { padding: 8px 10px; }
.rt-part-picked {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2);
}
.rt-part-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rt-line-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: -6px 0 12px; }
.rt-line-chips:empty { display: none; }
.rt-line-chip { cursor: pointer; border: 1px solid var(--border); font: inherit; font-size: 12px; }
.rt-line-chip:hover { border-color: var(--border-strong); background: var(--surface-3); }

/* Returns listed on the job, the invoice and the customer. */
.rt-link-row { flex-wrap: wrap; row-gap: 6px; }
.rt-link-row > a { color: inherit; display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; min-width: 0; flex: 1 1 190px; }
.rt-link-row > a .strong { white-space: nowrap; }
.rt-link-row > a:hover { text-decoration: none; }
.rt-link-row > a:hover .strong { text-decoration: underline; }
.rt-link-row:hover { background: none; margin: 0; padding: 8px 0; }
.rt-link-end { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }

/* Return items (credit note). */
.rt-cn-lines { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.rt-cn-line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 168px 96px; gap: 12px; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.rt-cn-line:last-child { border-bottom: none; }
.rt-cn-line.is-done { background: var(--surface-2); color: var(--text-3); }
.rt-cn-line-desc { display: flex; flex-direction: column; min-width: 0; }
.rt-cn-line-credit { text-align: right; font-weight: 600; }
.rt-cn-restock { margin: 0; font-size: 13px; }
.rt-qty { display: flex; align-items: center; gap: 4px; }
.rt-qty .btn { width: 30px; justify-content: center; padding-left: 0; padding-right: 0; }
.rt-qty-input { width: 58px; text-align: center; }
.rt-cn-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 24px; margin-top: 4px; }
.rt-cn-settle { margin-top: 10px; }
@media (max-width: 760px) {
  .rt-cn-line { grid-template-columns: 1fr auto; }
  .rt-cn-bottom { grid-template-columns: 1fr; }
}
.gst-supplier-credits {
  margin-top: 6px; padding: 6px 9px; border-radius: var(--r-sm);
  background: var(--amber-tint); color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 24%, transparent);
}
.gst-supplier-credits a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------- common services library */
.svc-lib-list { max-height: 52vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r); }
.svc-lib-cat + .svc-lib-cat { border-top: 1px solid var(--border); }
.svc-lib-cat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface-2); position: sticky; top: 0; z-index: 1; cursor: pointer; }
.svc-lib-cat-head .small { margin-left: auto; }
.svc-lib-row { display: grid; grid-template-columns: 20px 1fr auto 90px; align-items: center; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--border); cursor: pointer; }
.svc-lib-row:hover { background: var(--surface-2); }
.svc-lib-row.is-have { opacity: .55; cursor: default; }
.svc-lib-main { display: flex; flex-direction: column; min-width: 0; }
.svc-lib-price { text-align: right; }

/* Settings: a menu down the left, in groups, and the chosen page beside it. */
.settings-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--sp-6); align-items: start; }
.settings-nav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.settings-nav-group {
  padding: var(--sp-3) 10px var(--sp-1);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3);
}
.settings-nav-group:first-child { padding-top: 0; }
.settings-nav-item {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-2);
  font: inherit; font-size: var(--fs-base); font-weight: var(--fw-medium);
  cursor: pointer; white-space: nowrap;
  transition: background var(--fast), color var(--fast);
}
.settings-nav-item:hover { background: var(--surface-3); color: var(--text); }
.settings-nav-item:focus-visible { outline: none; box-shadow: var(--ring); }
.settings-nav-item.active { background: var(--surface); color: var(--text); box-shadow: var(--e1), 0 0 0 1px var(--border); }
.settings-body { min-width: 0; }
@media (max-width: 1000px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .settings-nav-group { display: none; }
  .settings-nav-item { width: auto; }
}

/* "Unsaved changes" beside Save: a quiet amber pill. */
.unsaved-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--amber-tint); color: var(--amber);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.unsaved-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.unsaved-pill[hidden] { display: none; }

/* Accounting: the everyday tabs, then the accountant's under a quiet label. */
.tabs .tabs-group-label {
  align-self: center; margin-left: var(--sp-4); padding: 0 var(--sp-2) 0 var(--sp-4);
  border-left: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); white-space: nowrap;
}
.tabs-wrap { flex-wrap: wrap; }
/* Accounting: the everyday tabs, then "Year end ▾" and "For your accountant ▾"
   menus at the right — one row at any window width. */
.tabs-grouped { align-items: flex-end; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs-grouped .tab { white-space: nowrap; flex-shrink: 0; }
.tabs-spacer { flex: 1 1 var(--sp-4); min-width: var(--sp-4); }
.tab-menu { display: inline-flex; align-items: center; gap: 5px; }
.tab-menu .caret { opacity: .7; transition: transform var(--fast); }
.tab-menu[aria-expanded="true"] .caret { transform: rotate(180deg); }

/* ---------------------------------------------------------- year end (views/year-end.js) */
.ye-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-4); }
.ye-toolbar a { color: inherit; }
.ye-hero { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.ye-hero-main { flex: 1 1 320px; min-width: 0; }
.ye-hero-title { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -.02em; }
.ye-hero.is-ready .ye-hero-title { color: var(--green); }
.ye-hero-sub { color: var(--text-2); margin: 4px 0 var(--sp-3); }
.ye-meter { max-width: 420px; }
.ye-hero.is-ready .ye-meter > i { background: var(--green); }
.ye-steps { list-style: none; margin: 0 0 var(--sp-5); padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.ye-steps > .card + .card { margin-top: 0; }
.ye-step { display: flex; gap: var(--sp-4); align-items: flex-start; border-left: 3px solid var(--border-strong); }
.ye-step.is-green { border-left-color: var(--green); }
.ye-step.is-amber { border-left-color: var(--amber); }
.ye-step.is-red { border-left-color: var(--red); }
.ye-step.is-na { border-left-color: var(--border); opacity: .78; }
.ye-step-mark {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-3);
}
.ye-step.is-green .ye-step-mark { background: var(--green-tint); color: var(--green); }
.ye-step.is-amber .ye-step-mark { background: var(--amber-tint); color: var(--amber); }
.ye-step.is-red .ye-step-mark { background: var(--red-tint); color: var(--red); }
.ye-step-main { flex: 1; min-width: 0; }
.ye-step-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.ye-step-title { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-bold); }
.ye-pill {
  display: inline-flex; align-items: center; padding: 1px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); background: var(--surface-3); color: var(--text-3);
}
.ye-pill.is-green { background: var(--green-tint); color: var(--green); }
.ye-pill.is-amber { background: var(--amber-tint); color: var(--amber); }
.ye-pill.is-red { background: var(--red-tint); color: var(--red); }
.ye-step-reason { margin: 6px 0 0; color: var(--text); line-height: 1.5; }
.ye-step-why { margin: 8px 0 0; line-height: 1.5; }
.ye-checks { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; line-height: 1.5; }
.ye-check.is-problem { color: var(--red); }
.ye-check.is-warn { color: var(--amber); }
.ye-check.is-info, .ye-check.is-ok { color: var(--text-2); }
.ye-items { margin: 4px 0 0; padding-left: 18px; font-size: var(--fs-sm); color: var(--text-2); }
.ye-items a { color: var(--text); }
.ye-step-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin-top: var(--sp-3); }
.ye-step-actions:empty { display: none; }
.ye-skip { margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.ye-contents-list { display: grid; grid-template-columns: minmax(140px, max-content) minmax(0, 1fr); gap: 6px var(--sp-4); margin: 0; font-size: var(--fs-sm); }
.ye-contents-list dt { font-weight: var(--fw-medium); color: var(--text); }
.ye-contents-list dd { margin: 0; color: var(--text-2); }
@media (max-width: 720px) { .ye-contents-list { grid-template-columns: 1fr; } .ye-contents-list dd { margin-bottom: 6px; } }

/* Recalls on the inspection: one line that opens to the list. */
.recall-line { margin-bottom: var(--sp-4); }
.recall-line .banner { margin-bottom: 0; }
.recall-line.is-open .banner { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.recall-list {
  border: 1px solid color-mix(in srgb, var(--amber) 24%, transparent); border-top: 0;
  border-radius: 0 0 var(--r) var(--r);
  background: var(--surface); padding: var(--sp-2) var(--sp-4) var(--sp-3);
}
.recall-item { padding: var(--sp-3) 0; border-bottom: 1px solid var(--border); }
.recall-item:last-of-type { border-bottom: none; }

/* ---------------------------------------------------------- appearance (Settings)
   Theme on this computer, the shop colour swatches and the light/dark preview.
   The preview boxes carry .theme-light / .theme-dark (tokens at the top of this
   file) plus the trial colour's --accent-* inline, from lib/theme.js. */
.theme-seg button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; font-size: 13px; }
.theme-seg button svg { flex-shrink: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  width: 96px; padding: 11px 6px 9px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 11.5px; font-weight: 520; line-height: 1.3;
  cursor: pointer;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.swatch:hover { border-color: var(--border-strong); background: var(--surface-2); }
.swatch:focus-visible, .swatch:focus-within { outline: none; box-shadow: var(--ring); }
.swatch:disabled { cursor: default; background: var(--surface); }
.swatch.is-selected { border-color: var(--text-2); box-shadow: inset 0 0 0 1px var(--text-2); color: var(--text); font-weight: 620; }
.swatch.is-selected .swatch-dot { outline: 2px solid var(--text); outline-offset: 2px; }
.swatch-dot {
  position: relative; display: inline-block; flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
.swatch-dot-custom {
  background: conic-gradient(#e5484d, #f5a524, #e8d34a, #30a46c, #0ea5e9, #6e56cf, #d6409f, #e5484d);
}
.swatch-dot-inline { width: 12px; height: 12px; vertical-align: -2px; }
.swatch-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; cursor: pointer;
}
.swatch-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-colour-note:empty { display: none; }

.shop-colour-ref { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.shop-colour-ref .swatch-dot { width: 22px; height: 22px; }
.shop-colour-ref .btn { margin-left: auto; }

.logo-colours { display: flex; gap: 18px; align-items: flex-start; }
.logo-colours-thumb {
  width: 132px; height: 72px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden; padding: 6px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff;
}
.logo-colours-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-colours-side { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.logo-colours-side p, .logo-colours-empty p { margin: 0 0 8px; }

.theme-previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .theme-previews { grid-template-columns: 1fr; } }
.theme-preview {
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px 16px 16px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-lg);
}
.theme-preview-label {
  font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3);
}
.theme-preview-tabs { margin: 0; }
.theme-preview-tabs .tab { cursor: default; }
.theme-preview-badge { background: var(--accent-tint); color: var(--accent-ink); border-color: var(--accent-border); }
.theme-preview-chip { background: var(--accent-tint); color: var(--accent-ink); border-color: var(--accent-border); }
/* The printed document is white paper in either theme (in readableAccent()). */
.theme-preview-doc {
  background: #fff; color: #1f1f1f;
  border-top: 3px solid var(--doc-accent); border-radius: 6px;
  box-shadow: var(--e2);
  padding: 13px 16px 12px; font-size: 12px;
}
.tpd-head { display: flex; justify-content: space-between; gap: 12px; }
.tpd-name { font-size: 13.5px; font-weight: 700; }
.tpd-sub { margin-top: 2px; font-size: 11px; color: #6b6b6b; }
.tpd-right { text-align: right; }
.tpd-kind { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--doc-accent); }
.tpd-no { margin-top: 2px; font-size: 13px; font-weight: 650; }
.tpd-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 12px; padding-top: 8px; border-top: 1px solid #e6e6e2;
}
.tpd-total strong { font-size: 14px; color: var(--doc-accent); }

/* ---------------------------------------------------------- sidebar theme button */
.theme-toggle {
  display: flex; align-items: center; gap: 10px; width: calc(100% - 16px); margin: 8px 8px 4px;
  padding: 8px 12px; border: 1px solid transparent; border-radius: var(--r); background: transparent;
  color: var(--nav-text); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.theme-toggle:hover { color: #e8e6e2; background: rgba(255, 255, 255, .06); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Staff page: pay ---- */

.pay-card .card-head { align-items: flex-start; }
.pay-card .card-head h2 { margin-bottom: 3px; }
.pay-filters { margin-bottom: 14px; }
.pay-results { transition: opacity 160ms var(--ease); }
.pay-results.is-stale { opacity: .5; pointer-events: none; }
.pay-table td .chip { margin-left: 4px; }

/* ---- GST/HST return (views/gst.js) ---- */

.gst-period { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin-bottom: 18px; }
.gst-period .label { margin-bottom: 6px; }
.gst-due { text-align: right; }
.gst-due-date { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -.015em; line-height: 1.2; }
.gst-due-date.is-late { color: var(--red); }
.gst-due-dates { display: flex; gap: 22px; justify-content: flex-end; }
.gst-period-select { width: auto; min-width: 220px; }
.gst-result-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.gst-result-main.is-late { color: var(--red); }
.gst-ins-facts { margin: 0 0 10px; }
.gst-checks:empty { display: none; }
.gst-status-line {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap;
  margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); padding: 0 var(--sp-1);
  font-size: var(--fs-sm);
}
.gst-status-text { flex: 1 1 320px; min-width: 0; }
.gst-check-list { margin: 4px 0 0; padding-left: 18px; }
.gst-check-list li + li { margin-top: 4px; }
.gst-result { margin-bottom: 18px; border-left: 4px solid var(--border-strong); }
.gst-flow { margin-bottom: 18px; }
.gst-result.is-owe { border-left-color: var(--red); }
.gst-result.is-refund { border-left-color: var(--green); }
.gst-result-main { font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: -.02em; line-height: 1.2; margin-bottom: var(--sp-1); font-variant-numeric: tabular-nums; }
.gst-result.is-owe .gst-result-main { color: var(--red); }
.gst-result.is-refund .gst-result-main { color: var(--green); }
.gst-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.gst-layout .card + .card { margin-top: 18px; }
@media (max-width: 1000px) { .gst-layout { grid-template-columns: 1fr; } }
.gst-result, .gst-lines { transition: opacity 160ms var(--ease); }
.gst.is-stale .gst-result, .gst.is-stale .gst-lines { opacity: .55; }
table.data.gst-table td { vertical-align: middle; padding-top: 9px; padding-bottom: 9px; }
table.data.gst-table td.gst-no { width: 58px; padding-left: 0; }
table.data.gst-table td.gst-amount { white-space: nowrap; font-size: 14px; }
table.data.gst-table td.gst-copy { width: 1%; padding-right: 0; }
.gst-label { font-weight: 560; }
table.data.gst-table tr.is-total .gst-label, table.data.gst-table tr.is-total .gst-amount { font-weight: 680; }
table.data.gst-table tr.is-total td { background: var(--surface-2); }
table.data.gst-table tr.is-answer td { background: var(--blue-tint); }
table.data.gst-table tr.is-answer .gst-amount, table.data.gst-table tr.is-answer .gst-label { font-weight: 700; }
.gst-form .field + .field { margin-top: 12px; }
.gst-details-body { padding: 4px 22px 18px; }
.gst-detail h3 { font-size: 13.5px; margin: 16px 0 2px; }
.gst-detail p { margin: 0 0 8px; }
.gst-table-scroll { overflow-x: auto; }
table.data.gst-detail-table th { position: static; }
table.data.gst-detail-table tr.gst-aside td { font-weight: 400; color: var(--text-3); }
.gst-foot { margin-top: 18px; }
.gst-foot p { margin: 0 0 4px; }

/* ---------------------------------------------------------- receipts → expenses */

.receipt-drop {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; margin-bottom: 16px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r);
  background: var(--surface-2); color: var(--text-2);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.receipt-drop:hover, .receipt-drop:focus-visible { border-color: var(--accent); outline: none; }
.receipt-drop.is-over { border-color: var(--accent); background: var(--accent-tint); }
.receipt-drop.is-large { flex-direction: column; text-align: center; padding: 44px 24px; margin: 0; }
.receipt-drop-icon { display: inline-flex; color: var(--accent); flex-shrink: 0; }
.receipt-drop-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.receipt-drop-text strong { color: var(--text); font-weight: 600; }
.receipt-drop-link { color: var(--accent-ink); text-decoration: underline; }

.modal.modal-receipt { max-width: 1000px; }
.receipt-review { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 22px; align-items: start; }
.receipt-preview {
  position: sticky; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r);
}
.receipt-preview img { max-width: 100%; max-height: 62vh; object-fit: contain; border-radius: var(--r-sm); }
.receipt-preview iframe { width: 100%; height: 62vh; border: 0; border-radius: var(--r-sm); background: #fff; }
.receipt-preview-pdf { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 12px; color: var(--text-3); }
.receipt-preview-name { word-break: break-all; text-align: center; }
.receipt-reading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 260px; text-align: center;
}
.receipt-source {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
}
.receipt-source > div { display: flex; flex-direction: column; gap: 1px; }
.receipt-source strong { font-size: 13px; font-weight: 600; }
.receipt-source-ai strong { color: var(--green); }
.receipt-source-offline strong, .receipt-source-manual strong { color: var(--amber); }
.receipt-kept { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.receipt-steps { margin: 0; padding-left: 20px; }
.receipt-steps li + li { margin-top: 4px; }
.receipt-ways { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.receipt-way { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.receipt-way h3 { margin: 0 0 6px; font-size: 13.5px; font-weight: 620; }
.receipt-way ul { margin: 0; padding-left: 18px; }
@media (max-width: 860px) {
  .receipt-review, .receipt-ways { grid-template-columns: 1fr; }
  .receipt-preview { position: static; }
}

/* ---- shop floor: check-in, tell the customer, reminders ---- */

/* Tell the customer (lib/tell-customer.js): the send-via choices, two by two. */
.send-via.tell-ways { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tell-who { display: flex; flex-direction: column; gap: 1px; margin-bottom: 10px; }
.tell-pref {
  margin-left: 6px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--green-tint); color: var(--green);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
}
.tell-note { margin: 0; }
.told-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.told-earlier summary { cursor: pointer; }
.told-earlier > div { margin-top: 3px; }

/* Drop-off check-in (lib/checkin.js). */
.ci-note { margin-top: 10px; }
.ci-note .small { white-space: pre-wrap; }
.ci-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.ci-form .ci-photos { margin-top: 0; }
.ci-photo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ci-photo-open, .ci-photo-add {
  display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); overflow: hidden; cursor: pointer;
}
.ci-photo-open:hover { border-color: var(--accent); }
.ci-photo-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ci-photo-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border-style: dashed; border-color: var(--border-strong); color: var(--text-3); font: inherit;
}
.ci-photo-add:hover { border-color: var(--accent); color: var(--accent-ink); }
.ci-photo-add:focus-visible, .ci-photo-open:focus-visible { outline: none; box-shadow: var(--ring); }
.ci-photo-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 22px; }
.ci-photo-meta .btn { padding: 2px 4px; color: var(--text-4); }
.ci-photo-meta .btn:hover { color: var(--red); background: var(--red-tint); }
.ci-auth-option { align-items: flex-start; line-height: 1.9; }
.ci-limit { display: inline-block; width: 120px; vertical-align: middle; }
.ci-limit .input { padding-top: 4px; padding-bottom: 4px; }
/* The signature box is paper-white in either theme, like the printed form. */
.ci-sign-pad { border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; padding: 6px 10px 4px; }
.ci-sign-canvas { display: block; width: 100%; max-width: 600px; aspect-ratio: 3 / 1; margin: 0 auto; touch-action: none; cursor: crosshair; }
.ci-sign-line { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #c9c6bf; padding-top: 2px; min-height: 28px; }
.ci-sign-line .muted { color: #696f78; }
.ci-sign-line .btn { color: #4a4843; }
.ci-sign-kept { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.ci-sign-note { margin-bottom: 12px; }
.ci-sign-svg { display: block; max-width: 100%; height: auto; color: var(--text); }
.ci-signed { margin-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.ci-unsigned { margin-top: 12px; color: var(--amber); }

/* Next service (lib/service-reminders.js). */
.ns-block { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.ns-text { display: flex; flex-direction: column; min-width: 0; }
.ns-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-foot .ns-remove { margin-right: auto; color: var(--red); }
.ns-vehicle { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.ns-line { padding: 2px 0; }
.ns-flag {
  margin-left: 6px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--amber-tint); color: var(--amber); font-size: var(--fs-xs); font-weight: var(--fw-medium);
}
.ns-flag.is-overdue { background: var(--red-tint); color: var(--red); }

/* Reminders screen (views/reminders.js). */
.rem-group + .rem-group { margin-top: var(--sp-4); }
.rem-list { display: flex; flex-direction: column; }
.rem-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: 6px 18px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--border);
}
.rem-row:first-child { border-top: none; padding-top: 4px; }
.rem-row.is-overdue .rem-why { color: var(--red); }
.rem-contacted { color: var(--green); margin-top: 2px; }
.rem-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
@media (max-width: 860px) {
  .rem-row { grid-template-columns: 1fr; }
  .rem-actions { justify-content: flex-start; }
}

/* Settings → Messages to customers. */
.msg-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.msg-label label { margin: 0; }

/* ---- Accounting: Bank, Equipment, Parts on hand (views/bank.js, views/equipment.js) ---- */
.bank-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-3); }
.bank-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--e1); cursor: pointer; font: inherit; color: var(--text);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.bank-card:hover { border-color: var(--border-strong); }
.bank-card:focus-visible { outline: none; box-shadow: var(--ring); }
.bank-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--e2); }
.bank-card-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.bank-card-balance { font-size: var(--fs-xl); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.bank-card-meta { font-size: var(--fs-xs); color: var(--text-3); }
.bank-card-status { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); }
.bank-card-status .ledger-check { padding: 2px 9px; font-size: var(--fs-xs); }
.chip.chip-warn { background: var(--amber-tint); color: var(--amber); }
/* The shop colour as a chip: its tint, with its writing shade (--accent-ink). */
.chip.chip-accent { background: var(--accent-tint); color: var(--accent-ink); border-color: var(--accent-border); }
.bank-title { margin: 0; font-size: var(--fs-lg); }
.bank-subhead { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-1); }
.bank-matched { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.bank-matched > .small, .bank-matched > .tiny { flex: 1 1 160px; min-width: 0; }
.bank-lines td.bank-action { min-width: 260px; }
.bank-waiting { display: flex; flex-direction: column; gap: 6px; margin-top: var(--sp-2); width: 100%; }
.money-in { color: var(--green); font-weight: var(--fw-medium); }
.bank-line-summary {
  display: flex; gap: var(--sp-3); align-items: baseline; flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-4);
  background: var(--surface-3); border-radius: var(--r); font-size: var(--fs-sm); color: var(--text-2);
}
.bank-line-summary strong { flex: 1; color: var(--text); font-weight: var(--fw-medium); min-width: 0; }
.bank-line-summary .num { font-weight: var(--fw-bold); color: var(--text); font-variant-numeric: tabular-nums; }
.chip-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-2); }
.chip-picks .btn.is-on { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-tint); }
.bank-columns-wrap { overflow-x: auto; }
.bank-columns .select { min-width: 150px; }
.rec-summary .stat { padding: var(--sp-3) var(--sp-4); }
tr.rec-outstanding td { color: var(--text-2); }
.cca-table .input-sm, .count-table .input-sm { max-width: 130px; margin-left: auto; text-align: right; }
.count-table td > div { display: flex; align-items: center; gap: 6px; }
.asset-more { margin-top: var(--sp-3); }
.asset-more > summary { cursor: pointer; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.cleared-mark { color: var(--green); font-weight: var(--fw-bold); margin-left: 4px; }
@media (max-width: 860px) {
  .rec-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bank-lines td.bank-action { min-width: 0; }
}

/* ---- profit per job (owner only): the Profit card, the cost on a one-off line, Reports → Profit by job */
.profit-hero { margin-bottom: var(--sp-3); }
.profit-hero-value { font-size: var(--fs-xl); font-weight: var(--fw-bold); color: var(--green); font-variant-numeric: tabular-nums; }
.profit-hero.is-loss .profit-hero-value { color: var(--red); }
.profit-hero-sub { font-size: var(--fs-sm); color: var(--text-3); }
.profit-kv dt { display: flex; flex-direction: column; }
.profit-sub { font-size: 11.5px; color: var(--text-3); }
.profit-rate { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); padding-top: var(--sp-2); border-top: 1px solid var(--border); }
.profit-who { margin-top: var(--sp-2); }
.profit-notes { margin: var(--sp-3) 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.profit-note { font-size: 12.5px; color: var(--text-2); padding: 6px 8px; border-radius: var(--r); background: var(--surface-3); }
.profit-note.is-missing, .profit-note.is-no-rate { background: var(--amber-tint); color: var(--amber); }
.line-cost { margin-top: 2px; }
.line-cost-field { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; }
.line-cost-input { width: 96px; }
.profit-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3); }
.profit-tiles > .card, .profit-pair > .card { margin: 0; }
.profit-flag-list { margin: 4px 0 0; padding-left: 18px; }
.profit-table .th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-transform: inherit; letter-spacing: inherit; }
.profit-table .th-sort:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }
.profit-table td .chip { margin-top: 2px; }
.profit-pair { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--sp-3); align-items: start; }
.profit-pair .card { overflow-x: auto; }
.profit-least { display: flex; flex-direction: column; }
.profit-least-row { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); padding: 8px 0; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.profit-least-row:first-child { border-top: 0; }
.profit-least-row:hover .strong { color: var(--accent-ink); }
.profit-least-row .num { white-space: nowrap; font-weight: var(--fw-medium); }
@media (max-width: 860px) {
  .profit-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profit-pair { grid-template-columns: minmax(0, 1fr); }
}

/* ---- payroll (owner only): run payroll, pay runs, remittances, T4s, settings (views/payroll.js) */
.pr-estimate { margin-bottom: var(--sp-4); }
.pr-review td { vertical-align: top; }
.pr-review th, .pr-review td { padding-left: 8px; padding-right: 8px; }
.pr-review .pr-name { min-width: 150px; }
.pr-review .pr-amount { width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.pr-review .pr-amount.is-typed { border-color: var(--amber); background: var(--amber-tint); color: var(--text); }
.pr-review tr.pr-off td { opacity: .5; }
.pr-review tr.pr-off td:first-child { opacity: 1; }
.pr-totals .stat { min-width: 0; }
.pr-post { align-items: flex-end; flex-wrap: wrap; }
.pr-post-buttons { flex: 0 0 auto; justify-content: flex-end; margin-bottom: 18px; }
.pr-late { color: var(--red); }
.pr-h3 { font-size: var(--fs-base); font-weight: var(--fw-medium); margin: var(--sp-4) 0 var(--sp-2); }
.pr-rates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-4); }
.pr-rates textarea { font-variant-numeric: tabular-nums; resize: vertical; }
.pr-rate label .badge { margin-left: 6px; vertical-align: 1px; }
.pr-t4 th { white-space: normal; }
.select.pr-year { width: auto; min-width: 110px; flex: 0 0 auto; }
@media (max-width: 860px) {
  .pr-rates { grid-template-columns: minmax(0, 1fr); }
  .pr-post-buttons { margin-bottom: 0; }
}

/* ---------------------------------------------------------- narrow windows
   The app is built for a desktop window, but a phone browser or a narrow
   window must still work without the page sliding sideways: under 760px the
   sidebar becomes one scrolling row of links across the top, the page gets
   the full width, and wide pieces (tabs, tables, toolbars) scroll or wrap
   inside themselves. */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; }

  .sidebar {
    flex-direction: row; align-items: center; gap: 2px;
    padding: 6px 8px; overflow-x: auto; overflow-y: hidden;
    border-right: none; border-bottom: 1px solid rgba(255, 255, 255, .05);
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { padding: 0 6px 0 0; flex-shrink: 0; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-text { display: none; }
  .nav-group { display: flex; gap: 2px; margin: 0; flex-shrink: 0; }
  .nav-label, .nav-spacer { display: none; }
  .nav-item { padding: 7px 10px; margin: 0; gap: 7px; font-size: var(--fs-sm); white-space: nowrap; flex-shrink: 0; }
  .nav-item svg { width: 15px; height: 15px; }
  .nav-item.active::before { display: none; }
  .theme-toggle { width: auto; margin: 0; padding: 7px 9px; flex-shrink: 0; }
  .theme-toggle span { display: none; }
  .user-chip { margin: 0 0 0 4px; padding: 0 0 0 6px; border-top: none; border-left: 1px solid rgba(255, 255, 255, .07); flex-shrink: 0; }
  .user-chip-text { display: none; }

  .topbar { padding: 12px var(--sp-4) 10px; gap: var(--sp-2); }
  .topbar-left { flex-basis: 100%; }
  .topbar h1 { font-size: var(--fs-lg); }
  .topbar-right { margin-left: 0; justify-content: flex-start; flex-shrink: 1; min-width: 0; }
  .content { padding: var(--sp-4) var(--sp-4) 56px; }

  /* Wide pieces keep inside the page. */
  .tabs { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .tabs .tab { white-space: nowrap; flex-shrink: 0; }
  .tabs-wrap { flex-wrap: nowrap; }
  .toolbar > * { min-width: 0; max-width: 100%; }
  .toolbar .input, .toolbar .select { min-width: 0; }
  .toolbar .input.search, .search { width: 100%; min-width: 0 !important; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .field-row { flex-wrap: wrap; }
  .field-row > .field { min-width: 0; flex-basis: 100% !important; }
  .card { min-width: 0; }
  .card-head { flex-wrap: wrap; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .settings-nav-item { white-space: nowrap; flex-shrink: 0; }
  pre, code { white-space: pre-wrap; word-break: break-word; }

  .modal-backdrop { padding: 8px; }
  .modal { max-height: calc(100dvh - 16px); }
  .modal-head, .modal-body, .modal-foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .modal-foot { flex-wrap: wrap; }
}
