/* ARFA design system (redesign stage 1).
   The --color-* names are the ones a client's own theme overrides
   (app/utils/theme.py), so a client's button colour, background and font
   still apply on top of everything below. Fonts and icons are stored in
   the app (static/fonts, static/img/icons.svg), never fetched from the
   internet, so offline counters look the same. */
@font-face { font-family: "Figtree"; src: url("../fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("../fonts/bricolage-grotesque.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: swap; }

:root {
  --color-bg: #f4f6f2;
  --color-surface: #ffffff;
  --color-surface-2: #f6f8f5;
  --color-border: #e1e6df;
  --color-border-strong: #cbd4c9;
  --color-text: #17241c;
  --color-text-muted: #5b6a61;
  --color-primary: #1f7a4d;
  --color-primary-dark: #175c3a;
  --color-accent: #d9891a;
  --color-accent-soft: #fcf0dd;
  --color-danger: #b3261e;
  --color-danger-bg: #fdecea;
  --color-success-bg: #e8f5ec;
  --color-info-bg: #eef3fb;
  /* A tint of the client's own button colour (falls back to the green). */
  --color-primary-soft: var(--color-success-bg);
  --radius: 10px;
  --radius-lg: 14px;
  --touch: 48px;
  --shadow-1: 0 1px 2px rgba(23, 36, 28, 0.05), 0 1px 3px rgba(23, 36, 28, 0.04);
  --shadow-2: 0 2px 6px rgba(23, 36, 28, 0.06), 0 10px 24px rgba(23, 36, 28, 0.08);
  --shadow-3: 0 10px 24px rgba(23, 36, 28, 0.12), 0 28px 64px rgba(23, 36, 28, 0.18);
  --font-body: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Bricolage Grotesque", var(--font-body);
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sidenav-w: 252px;
  --rail-w: 72px;
  --topbar-h: 60px;
  /* Colours for states and overlays, so dark mode can swap them too. */
  --color-primary-hover: var(--color-primary-dark);
  --color-warn-bg: #fff4d6;
  --color-warn-text: #8a5300;
  --color-info-text: #2b4a7a;
  --color-neutral-bg: #eef0ee;
  --color-danger-border: #f3c9c6;
  --color-ink: #17241c;          /* toasts, the save bar, chart tooltips */
  --color-on-ink: #eef4f0;
  --color-inverse: #17241c;      /* a picked chip */
  --color-on-inverse: #ffffff;
  --color-scrim: rgba(15, 24, 19, 0.42);
  --color-scrim-strong: rgba(20, 26, 22, 0.55);
  --color-glass: rgba(255, 255, 255, 0.84);
  --color-focus: var(--color-primary);
  color-scheme: light;
  font-size: 16px;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --color-primary-soft: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
    /* Chart bars other than today's. */
    --color-chart-quiet: color-mix(in srgb, var(--color-primary) 30%, var(--color-surface));
  }
}

/* Dark mode (redesign stage 6): follows the device unless the person
   picked Light or Dark in their account menu (html[data-theme], set
   before first paint in base.html / auth_base.html). Only on screens -
   printing from the browser always comes out light. The selectors are
   more specific than a client theme's ":root", so their page background
   and text colour step aside in the dark; their button colour stays. */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0e1511;
    --color-surface: #16201a;
    --color-surface-2: #1c2821;
    --color-border: #2a392f;
    --color-border-strong: #3a4c40;
    --color-text: #e6eee8;
    --color-page-text: #e6eee8;
    --color-text-muted: #9fb0a5;
    --color-primary-dark: #7fd1a6;
    --color-primary-hover: #1a6b43;
    --color-accent: #eba947;
    --color-accent-soft: #33270f;
    --color-danger: #f08a75;
    --color-danger-bg: #3a1d17;
    --color-danger-border: #5c2c22;
    --color-success-bg: #173326;
    --color-info-bg: #172234;
    --color-info-text: #a9c4f5;
    --color-warn-bg: #33270f;
    --color-warn-text: #eeb45c;
    --color-neutral-bg: #26332b;
    --color-ink: #26352c;
    --color-on-ink: #eef4f0;
    --color-inverse: #e6eee8;
    --color-on-inverse: #102017;
    --color-scrim: rgba(0, 0, 0, 0.55);
    --color-scrim-strong: rgba(0, 0, 0, 0.66);
    --color-glass: rgba(22, 32, 26, 0.86);
    --color-focus: #7fd1a6;
    --color-primary-soft: #173326;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.3), 0 10px 24px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 10px 24px rgba(0, 0, 0, 0.4), 0 28px 64px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --color-bg: #0e1511;
    --color-surface: #16201a;
    --color-surface-2: #1c2821;
    --color-border: #2a392f;
    --color-border-strong: #3a4c40;
    --color-text: #e6eee8;
    --color-page-text: #e6eee8;
    --color-text-muted: #9fb0a5;
    --color-primary-dark: #7fd1a6;
    --color-primary-hover: #1a6b43;
    --color-accent: #eba947;
    --color-accent-soft: #33270f;
    --color-danger: #f08a75;
    --color-danger-bg: #3a1d17;
    --color-danger-border: #5c2c22;
    --color-success-bg: #173326;
    --color-info-bg: #172234;
    --color-info-text: #a9c4f5;
    --color-warn-bg: #33270f;
    --color-warn-text: #eeb45c;
    --color-neutral-bg: #26332b;
    --color-ink: #26352c;
    --color-on-ink: #eef4f0;
    --color-inverse: #e6eee8;
    --color-on-inverse: #102017;
    --color-scrim: rgba(0, 0, 0, 0.55);
    --color-scrim-strong: rgba(0, 0, 0, 0.66);
    --color-glass: rgba(22, 32, 26, 0.86);
    --color-focus: #7fd1a6;
    --color-primary-soft: #173326;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.3), 0 10px 24px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 10px 24px rgba(0, 0, 0, 0.4), 0 28px 64px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
/* A client's own button colour, mixed for the dark: tinted surfaces and
   a light shade of it for links and picked menu entries. */
@supports (color: color-mix(in srgb, red 50%, blue)) {
  @media screen and (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --color-primary-soft: color-mix(in srgb, var(--color-primary) 24%, #16201a);
      --color-success-bg: color-mix(in srgb, var(--color-primary) 22%, #16201a);
      --color-primary-dark: color-mix(in srgb, var(--color-primary) 45%, #ffffff);
      --color-primary-hover: color-mix(in srgb, var(--color-primary) 82%, #000000);
      --color-chart-quiet: color-mix(in srgb, var(--color-primary) 62%, #16201a);
    }
  }
  @media screen {
    :root[data-theme="dark"] {
      --color-primary-soft: color-mix(in srgb, var(--color-primary) 24%, #16201a);
      --color-success-bg: color-mix(in srgb, var(--color-primary) 22%, #16201a);
      --color-primary-dark: color-mix(in srgb, var(--color-primary) 45%, #ffffff);
      --color-primary-hover: color-mix(in srgb, var(--color-primary) 82%, #000000);
      --color-chart-quiet: color-mix(in srgb, var(--color-primary) 62%, #16201a);
    }
  }
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  /* --color-page-text is only ever set by a tenant theme override (see
     app/utils/theme.py), computed for contrast against their chosen
     --color-bg. Falls back to the normal text color otherwise. White
     "surface" containers (cards, inputs, the topbar...) pin their own
     color below instead of inheriting this, since --color-bg is a page
     background only - their background stays white regardless. */
  color: var(--color-page-text, var(--color-text));
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.015em; line-height: 1.2; }
h4, h5 { line-height: 1.3; }
code, kbd, .mono { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--color-focus, var(--color-primary)); outline-offset: 2px; }
::selection { background: var(--color-primary-soft); }

.card, .topbar, .sidenav, .auth-card, .cart-panel, .checkout-sheet, .totals-box, .product-tile, table {
  color: var(--color-text);
}

a { color: var(--color-primary-dark); }

.icon { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; padding: 10px 14px; border-radius: var(--radius); background: var(--color-primary); color: #fff; font-weight: 700; }
.skip-link:focus { top: 12px; }

/* --- App shell: side menu + top bar ------------------------------------ */
.shell { display: flex; min-height: 100vh; }
.shell-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.sidenav {
  position: sticky; top: 0; height: 100vh; z-index: 40;
  width: var(--sidenav-w); flex: 0 0 var(--sidenav-w);
  display: flex; flex-direction: column;
  background: var(--color-surface); border-right: 1px solid var(--color-border);
  transition: width 0.22s var(--ease-out), flex-basis 0.22s var(--ease-out);
}
.sidenav-head { height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--color-border); }
.sidenav .brand { flex: 1 1 auto; }
.sidenav-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 6px 10px 24px; scrollbar-width: thin; }
.nav-group-label {
  margin: 16px 12px 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--color-text-muted); white-space: nowrap;
}
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 42px; padding: 8px 12px; margin: 1px 0; border-radius: var(--radius);
  color: var(--color-text-muted); font-weight: 600; font-size: 0.95rem; text-decoration: none; white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}
.nav-link .icon { transition: transform 0.2s var(--ease-out); }
.nav-link:hover { background: var(--color-surface-2); color: var(--color-text); }
.nav-link:hover .icon { transform: translateX(1px) scale(1.06); }
.nav-link.active { background: var(--color-primary-soft); color: var(--color-primary-dark); }
.nav-link.active::before {
  content: ""; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--color-primary); animation: grow-y 0.3s var(--ease-out) backwards;
}
.nav-label { overflow: hidden; text-overflow: ellipsis; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--color-text); }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-display); }
.brand-logo { height: 34px; width: auto; max-width: 120px; object-fit: contain; border-radius: 6px; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px;
  background: var(--color-primary); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem;
}

.icon-btn {
  width: 40px; height: 40px; flex-shrink: 0; display: inline-grid; place-items: center;
  border: none; border-radius: var(--radius); background: transparent; color: var(--color-text-muted); cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-text); }
.when-rail, .menu-btn, .drawer-close, .brand-compact { display: none; }
.scrim { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
@supports (backdrop-filter: blur(8px)) {
  .topbar { background: var(--color-glass); backdrop-filter: saturate(1.4) blur(10px); }
}
.search-trigger {
  flex: 0 1 440px; min-width: 0; display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 8px 0 12px; border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-surface-2); color: var(--color-text-muted); font-size: 0.92rem; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.search-trigger:hover { border-color: var(--color-border-strong); background: var(--color-surface); box-shadow: var(--shadow-1); }
.search-text { flex: 1 1 auto; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
kbd {
  font-size: 0.72rem; font-weight: 600; padding: 2px 6px; white-space: nowrap;
  border: 1px solid var(--color-border); border-bottom-width: 2px; border-radius: 6px;
  background: var(--color-surface); color: var(--color-text-muted);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-name { color: var(--color-text-muted); font-size: 0.9rem; }
.btn-new { min-height: 40px; padding: 8px 16px 8px 12px; gap: 6px; }
.bell-btn { position: relative; }
.bell-dot {
  position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--color-accent); box-shadow: 0 0 0 2px var(--color-surface); animation: pulse 2.4s ease-out infinite;
}
.bell-dot[hidden] { display: none; }
.avatar-btn { border: none; background: none; padding: 2px; border-radius: 50%; cursor: pointer; }
.avatar {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  background: var(--color-primary); color: #fff; font-weight: 700; transition: box-shadow 0.15s;
}
.avatar-btn:hover .avatar { box-shadow: 0 0 0 4px var(--color-primary-soft); }

/* Folded to icons ("rail"): remembered per browser; the counter starts folded. */
@media (min-width: 1024px) {
  html.is-rail .sidenav { width: var(--rail-w); flex-basis: var(--rail-w); }
  html.is-rail .sidenav-head { padding: 0; justify-content: center; }
  html.is-rail .sidenav .brand, html.is-rail .nav-label { display: none; }
  html.is-rail .nav-group-label { font-size: 0; height: 1px; margin: 10px 12px; background: var(--color-border); }
  html.is-rail .nav-group:first-child .nav-group-label { display: none; }
  html.is-rail .nav-link { justify-content: center; padding: 8px; }
  html.is-rail .when-rail { display: block; }
  html.is-rail .when-wide { display: none; }
}

/* Tablets and phones: the menu slides in from the left. */
@media (max-width: 1023px) {
  .sidenav {
    position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(300px, 86vw);
    transform: translateX(-102%); visibility: hidden;
    transition: transform 0.26s var(--ease-out), visibility 0s linear 0.26s;
  }
  .sidenav.is-open { transform: none; visibility: visible; box-shadow: var(--shadow-3); transition: transform 0.26s var(--ease-out); }
  .rail-toggle { display: none; }
  .drawer-close, .menu-btn { display: inline-grid; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: var(--color-scrim); }
  .topbar { padding: 0 12px 0 8px; gap: 6px; }
}
@media (max-width: 719px) {
  .brand-compact { display: flex; flex: 1 1 auto; font-size: 1rem; }
  .brand-compact .brand-logo { height: 28px; }
  .search-trigger { flex: 0 0 40px; width: 40px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
  .search-trigger .search-text, .search-trigger kbd { display: none; }
  .no-menu .topbar { padding: 0 14px; }
  .no-menu .user-name { display: none; }
}

/* --- Pop-up menus (New, bell, account) ---------------------------------- */
.pop-wrap { position: relative; }
.pop {
  position: absolute; top: calc(100% + 8px); z-index: 60; min-width: 250px; max-height: min(72vh, 540px); overflow: auto;
  padding: 6px; background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  transform-origin: top right;
}
.pop-right { right: 0; }
.pop-wide { width: 360px; max-width: calc(100vw - 24px); }
.pop-title { margin: 6px 10px 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); }
.pop-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
  color: var(--color-text); text-decoration: none; font-weight: 600; font-size: 0.94rem; white-space: nowrap;
}
.pop-item .icon { color: var(--color-text-muted); transition: color 0.15s, transform 0.2s var(--ease-out); }
.pop-item:hover, .pop-item:focus-visible { background: var(--color-surface-2); outline: none; }
.pop-item:hover .icon { color: var(--color-primary); transform: scale(1.08); }
.pop-who { display: flex; flex-direction: column; padding: 10px 10px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--color-border); }
.pop-who span { color: var(--color-text-muted); font-size: 0.85rem; }
.pop-empty { display: flex; align-items: center; gap: 8px; margin: 6px 10px 12px; color: var(--color-text-muted); }
.pop-empty .icon { color: var(--color-primary); }
.pop-enter { transition: opacity 0.16s var(--ease-out), transform 0.18s var(--ease-out); }
.pop-leave { transition: opacity 0.1s ease-in, transform 0.1s ease-in; }
.pop-from { opacity: 0; transform: translateY(-6px) scale(0.97); }

/* Appearance: Auto / Light / Dark (account menu) */
.theme-pick { padding: 4px 10px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--color-border); }
.pop > .theme-pick:only-child { border-bottom: none; margin-bottom: 0; }
.theme-pick-label { margin: 4px 0 8px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 10px; background: var(--color-surface-2); border: 1px solid var(--color-border); }
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 8px;
  border: none; border-radius: 8px; background: transparent; color: var(--color-text-muted); font-weight: 600; font-size: 0.85rem; cursor: pointer;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg-btn .icon { width: 16px; height: 16px; }
.seg-btn:hover { color: var(--color-text); }
.seg-btn.is-on { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1); }
.seg-btn.is-on .icon { color: var(--color-primary); }

.needs-list { list-style: none; margin: 0; padding: 0; }
.needs-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border-radius: 10px; color: var(--color-text); text-decoration: none; }
.needs-item:hover { background: var(--color-surface-2); }
.needs-item strong { display: block; font-size: 0.92rem; line-height: 1.3; }
.needs-item small { color: var(--color-text-muted); }
.needs-icon { width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--color-accent-soft); color: var(--color-warn-text); }
.tone-bad .needs-icon { background: var(--color-danger-bg); color: var(--color-danger); }

/* --- Search palette (Ctrl K) ------------------------------------------- */
.palette-scrim { position: fixed; inset: 0; z-index: 90; background: var(--color-scrim); }
.palette {
  position: fixed; top: 12vh; left: 50%; z-index: 91; transform: translateX(-50%);
  width: min(640px, calc(100vw - 24px)); overflow: hidden;
  background: var(--color-surface); color: var(--color-text); border-radius: 16px; box-shadow: var(--shadow-3);
}
.palette-from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.98); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px 0 18px; border-bottom: 1px solid var(--color-border); color: var(--color-text-muted); }
.palette-input input[type="text"], .palette-input input[type="text"]:focus { flex: 1; min-height: 58px; border: none; padding: 0; font-size: 1.05rem; background: transparent; outline: none; box-shadow: none; color: var(--color-text); }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: min(52vh, 460px); overflow-y: auto; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--color-text); text-decoration: none; font-weight: 600; }
.palette-item .icon { color: var(--color-text-muted); }
.palette-item.is-picked { background: var(--color-primary-soft); color: var(--color-primary-dark); }
.palette-item.is-picked .icon { color: var(--color-primary); }
.palette-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-group { flex-shrink: 0; font-size: 0.78rem; font-weight: 500; color: var(--color-text-muted); }
.palette-none { padding: 22px; text-align: center; color: var(--color-text-muted); }

/* --- Toasts (flashed messages) ----------------------------------------- */
.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: 120; width: min(420px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 10px 12px 14px;
  border-radius: 12px; border-left: 4px solid #4cc286; background: var(--color-ink); color: var(--color-on-ink);
  font-weight: 600; box-shadow: var(--shadow-3); animation: toast-in 0.34s var(--ease-out) backwards;
}
.toast .icon { margin-top: 1px; color: #6fd39c; }
.toast-error { border-left-color: #ec7a63; } .toast-error .icon { color: #ff9b86; }
.toast-warning { border-left-color: #eba947; } .toast-warning .icon { color: #f3c06e; }
.toast-info { border-left-color: #8fb4ff; } .toast-info .icon { color: #a9c4ff; }
.toast-text { flex: 1 1 auto; min-width: 0; }
.toast-close { border: none; background: transparent; color: inherit; opacity: 0.6; padding: 2px; border-radius: 6px; cursor: pointer; }
.toast-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.toast-leave { transition: opacity 0.22s ease-in, transform 0.22s ease-in; }
.toast-from { opacity: 0; transform: translateX(16px); }

/* --- Phone: bottom bar and the New sheet -------------------------------- */
.bottom-tabs, .sheet, .sheet-scrim { display: none; }
@media (max-width: 719px) {
  .has-tabs .bottom-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-surface); border-top: 1px solid var(--color-border); box-shadow: 0 -8px 24px rgba(23, 36, 28, 0.06);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: none; background: none; color: var(--color-text-muted); text-decoration: none;
    font-size: 0.7rem; font-weight: 700; cursor: pointer;
  }
  .tab.active { color: var(--color-primary-dark); }
  .tab-new {
    width: 54px; height: 54px; align-self: center; justify-self: center; margin-top: -22px; border-radius: 50%;
    background: var(--color-primary); color: #fff; box-shadow: 0 8px 20px rgba(23, 36, 28, 0.25);
    transition: transform 0.15s var(--ease-out);
  }
  .tab-new:active { transform: scale(0.94); }
  .tab-new .icon { width: 26px; height: 26px; }
  .has-tabs .new-wrap { display: none; }
  .has-tabs .app-main { padding-bottom: 104px; }
  .has-tabs .toast-stack { bottom: calc(78px + env(safe-area-inset-bottom)); right: 12px; }
  .sheet-scrim { display: block; position: fixed; inset: 0; z-index: 94; background: var(--color-scrim); }
  .sheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; max-height: 80vh; overflow-y: auto;
    padding: 10px 14px calc(20px + env(safe-area-inset-bottom)); background: var(--color-surface); color: var(--color-text);
    border-radius: 20px 20px 0 0; box-shadow: var(--shadow-3);
  }
  .sheet::before { content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 8px; border-radius: 4px; background: var(--color-border-strong); }
  .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .sheet-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 12px;
    background: var(--color-surface-2); color: var(--color-text); text-decoration: none; text-align: center; font-size: 0.8rem; font-weight: 600;
  }
  .sheet-item .icon { color: var(--color-primary); width: 22px; height: 22px; }
  .sheet-enter { transition: transform 0.28s var(--ease-out); }
  .sheet-leave { transition: transform 0.2s ease-in; }
  .sheet-from { transform: translateY(100%); }
}

/* --- Page area ---------------------------------------------------------- */
.app-main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 28px 72px; outline: none; }
.is-counter .app-main { max-width: none; }
/* Content rises into place as a page opens, cards a beat after each other.
   (Not on the counter, which shows full-screen overlays from the start.) */
.app-main > * { animation: rise 0.32s var(--ease-out) backwards; }
.app-main > *:nth-child(2) { animation-delay: 0.04s; }
.app-main > *:nth-child(3) { animation-delay: 0.08s; }
.app-main > *:nth-child(4) { animation-delay: 0.12s; }
.app-main > *:nth-child(n+5) { animation-delay: 0.16s; }
.is-counter .app-main > * { animation: none; }
@media (max-width: 1023px) { .app-main { padding: 20px 16px 56px; } }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes grow-y { from { transform: scaleY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 2px rgba(217, 137, 26, 0.55); }
  70% { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 9px rgba(217, 137, 26, 0); }
  100% { box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 9px rgba(217, 137, 26, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Sign-in screens (redesign stage 6): brand on one side, form on the
   other. The brand side wears the client's button colour on their own
   sign-in link; on a phone it becomes a strip above the form. --- */
.auth-body { background: var(--color-bg); }
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 5fr) 7fr; }
.auth-side {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center;
  padding: 48px clamp(28px, 5vw, 72px); color: #fff; background-color: var(--color-primary);
  background-image:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.16), transparent 42%),
    radial-gradient(circle at 92% 88%, rgba(0, 0, 0, 0.22), transparent 48%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.18));
}
/* Quiet ledger lines behind the brand. */
.auth-side::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 34px);
  -webkit-mask-image: linear-gradient(120deg, transparent 20%, #000 75%); mask-image: linear-gradient(120deg, transparent 20%, #000 75%);
}
.auth-side-inner { position: relative; max-width: 440px; animation: rise 0.45s var(--ease-out) backwards; }
.auth-logo-tile { display: inline-grid; place-items: center; padding: 10px; border-radius: 18px; background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
.auth-logo { display: block; max-height: 64px; max-width: 180px; object-fit: contain; border-radius: 8px; }
.auth-mark {
  width: 72px; height: 72px; display: grid; place-items: center; border-radius: 20px;
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.3);
  font-family: var(--font-display); font-weight: 800; font-size: 2.2rem;
}
.auth-brand { margin: 22px 0 6px; font-family: var(--font-display); font-weight: 800; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.1; letter-spacing: -0.02em; }
.auth-pitch { margin: 0; font-size: 1.08rem; opacity: 0.9; max-width: 34ch; }
.auth-points { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; align-items: center; gap: 12px; font-weight: 600; opacity: 0.95; animation: rise 0.4s var(--ease-out) backwards; }
.auth-points li:nth-child(2) { animation-delay: 0.06s; }
.auth-points li:nth-child(3) { animation-delay: 0.12s; }
.auth-points .icon { width: 34px; height: 34px; padding: 7px; border-radius: 10px; background: rgba(255, 255, 255, 0.14); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--color-surface); color: var(--color-text); }
.auth-card {
  width: 100%; max-width: 420px; padding: 8px 4px;
  animation: rise 0.36s 0.05s var(--ease-out) backwards;
}
.auth-title { margin: 0 0 6px; font-size: 1.75rem; font-weight: 800; }
.auth-sub { margin: 0 0 22px; color: var(--color-text-muted); }
.auth-card > .flash-stack { margin-top: 4px; }
.password-wrap { position: relative; }
.password-wrap .field-input { padding-right: 52px; }
.password-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px;
  display: grid; place-items: center; border: none; border-radius: 8px; background: transparent; color: var(--color-text-muted); cursor: pointer;
}
.password-eye:hover { color: var(--color-text); background: var(--color-surface-2); }
.password-eye .when-shown, .password-eye.is-shown .when-hidden { display: none; }
.password-eye.is-shown .when-shown { display: block; }
/* An error page reached while signed out keeps the same frame. */
.auth-card .empty-state { padding: 24px 0; }
@media (max-width: 860px) {
  .auth-split { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-side { padding: 22px 20px; justify-content: flex-start; }
  .auth-side-inner { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; max-width: none; }
  .auth-logo-tile { padding: 6px; border-radius: 12px; grid-row: span 2; }
  .auth-logo { max-height: 40px; max-width: 110px; }
  .auth-mark { width: 48px; height: 48px; font-size: 1.4rem; border-radius: 14px; grid-row: span 2; }
  .auth-brand { margin: 0; font-size: 1.3rem; }
  .auth-pitch { font-size: 0.92rem; }
  .auth-points { display: none; }
  .auth-main { align-items: flex-start; padding: 28px 18px 40px; }
}

.theme-preview {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px; border-radius: var(--radius); border: 1px solid var(--color-border);
}
.theme-preview button { border: none; }

/* --- Flash messages (sign-in pages; the app itself uses toasts) --- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 12px 16px; border-radius: var(--radius); font-weight: 600; }
.flash-success { background: var(--color-success-bg); color: var(--color-primary-dark); }
.flash-error { background: var(--color-danger-bg); color: var(--color-danger); }
.flash-info { background: var(--color-info-bg); color: var(--color-info-text); }
.flash-warning { background: var(--color-warn-bg); color: var(--color-warn-text); }

/* --- Account-status banners (outside .app-main, so they span full width
   and sit below the topbar on every page, not scoped to page content) --- */
.notice-bar { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 10px 20px; font-weight: 600; text-align: center; }
.notice-impersonating { background: #2b4a7a; color: #fff; }
.notice-impersonating .btn-quiet { background: rgba(255,255,255,0.15); color: #fff; }
.notice-billing { background: var(--color-warn-bg); color: var(--color-warn-text); }
.btn-sm { padding: 6px 12px; min-height: auto; font-size: 0.85rem; }

/* --- Cards / page headers --- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 1.65rem; font-weight: 700; }
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-1); }

/* --- Forms --- */
.field { margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.92rem; }
.field-input, input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus, input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="date"]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft);
}
textarea { min-height: 88px; }
.field-error input, .field-error select, .field-error textarea { border-color: var(--color-danger); }
.field-error-msg { color: var(--color-danger); font-size: 0.85rem; margin: 4px 0 0; }
.field-help { color: var(--color-text-muted); font-size: 0.85rem; margin: 4px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 20px; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s var(--ease-out), box-shadow 0.15s, background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn[disabled], .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 1px 2px rgba(23, 36, 28, 0.12); }
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: 0 4px 12px rgba(23, 36, 28, 0.16); }
.btn-secondary:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-1); }
.btn-quiet:hover { background: var(--color-surface-2); color: var(--color-text); }
/* A button that is working: <button class="btn is-busy"> */
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
.btn-secondary.is-busy::after, .btn-quiet.is-busy::after { border-color: var(--color-border); border-top-color: var(--color-primary); }
.btn-secondary { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-quiet { background: transparent; border-color: var(--color-border); color: var(--color-text-muted); }
.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger-border); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.1rem; padding: 12px 24px; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; }
tbody tr { transition: background-color 0.12s; }
tbody tr:hover { background: var(--color-surface-2); }
td.num, th.num, .totals-row, .cart-total-row { font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--color-border); }
th { background: var(--color-surface-2); font-size: 0.82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted); }
tr:last-child td { border-bottom: none; }
.status-badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.status-issued { background: var(--color-success-bg); color: var(--color-primary-dark); }
.status-void { background: var(--color-danger-bg); color: var(--color-danger); }
.status-draft { background: var(--color-neutral-bg); color: var(--color-text-muted); }

/* --- Invoice line items --- */
.line-items { border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; }
.line-items table { border-radius: 0; }
.line-item-row input, .line-item-row select { min-height: 40px; }
.totals-panel { margin-top: 20px; display: flex; justify-content: flex-end; }
.totals-box { min-width: 280px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px 20px; }
.totals-row { display: flex; justify-content: space-between; padding: 4px 0; }
.totals-row.grand { font-size: 1.3rem; font-weight: 800; border-top: 1px solid var(--color-border); margin-top: 8px; padding-top: 10px; }

/* --- POS terminal --- */
.pos-search { min-height: 56px; font-size: 1.1rem; margin-bottom: 16px; }

/* Held bills live in a drawer (see "The counter" below), their count
   always on the counter's bar. */
.held-bill-card { border: 1px solid var(--color-border); border-radius: 8px; padding: 10px; }
.held-bill-card .held-bill-label { font-weight: 700; }
.held-bill-card .held-bill-meta { color: var(--color-text-muted); font-size: 0.85rem; margin-top: 2px; }
.held-bill-card .row { margin-top: 8px; gap: 8px; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.product-tile {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 1rem;
  overflow: hidden;
}
.product-tile:active, .product-tile:hover { background: var(--color-success-bg); border-color: var(--color-primary); }
.product-tile .tile-image {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-bg);
}
.product-tile .tile-image img { width: 100%; height: 100%; object-fit: cover; }
.product-tile .tile-image-placeholder { font-size: 1.6rem; font-weight: 800; color: var(--color-text-muted); }
.product-tile .tile-name { font-weight: 700; line-height: 1.2; }
.product-tile .tile-price { color: var(--color-text-muted); margin-top: 4px; }

/* Category/sub-category tree - app.pos.catalog.build_category_tree. */
.category-group { border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.category-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: var(--color-surface); border: none;
  font-size: 1.05rem; font-weight: 700; cursor: pointer; color: var(--color-text);
}
.category-body { padding: 0 16px 16px; }
.subcategory-group { border-top: 1px solid var(--color-border); padding-top: 10px; margin-top: 10px; }
.subcategory-group:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.subcategory-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; background: none; border: none; font-weight: 600; cursor: pointer; color: var(--color-text);
}

.cart-panel { position: sticky; top: 20px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 100px); }
.cart-items { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.cart-empty { text-align: center; color: var(--color-text-muted); padding: 30px 10px; }
/* Grid, not flex: a flex `name { flex: 1 }` has an implicit min-width of
   `auto` (its content's natural width), so a longer name wraps to a
   second line instead of shrinking - which then makes that one row
   taller, and `align-items: center` centers its stepper/amount against
   that extra height, throwing the whole row out of line with its
   single-line neighbors. `minmax(0, 1fr)` has no such floor, so the
   name always has a definite width to truncate against instead. */
/* A bare `<input>` contributes its UA-default preferred size (not its
   CSS `width`) to a grid/flex ancestor's intrinsic-size calculation, so
   neither `auto` nor `max-content` sizes this column to the 124px the
   stepper actually renders at - the column inflates to the input's
   unstyled ~200px notional width instead, starving the fr column next
   to it. Pinning the column to the stepper's real pixel width (kept in
   sync with --qty-stepper-w below) sidesteps that entirely. */
.cart-line {
  --qty-stepper-w: 124px;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--qty-stepper-w) max-content;
  align-items: center; gap: 8px;
}
.cart-line .cart-line-name {
  font-weight: 600; font-size: 0.92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cart-line .cart-line-amount { font-weight: 700; min-width: 70px; text-align: right; white-space: nowrap; }
.qty-stepper { display: flex; align-items: center; gap: 6px; width: 100%; }
.qty-stepper button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--color-border);
  background: var(--color-bg); font-size: 1.1rem; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.qty-stepper .qty-value { min-width: 22px; text-align: center; font-weight: 700; }
/* `.qty-stepper .qty-input` (two classes), not the bare `.qty-input`
   used before - a plain class selector loses to the global form reset
   two rules up (`input[type="number"] { width: 100%; min-height: 48px }`
   combines an attribute selector with the element type, which outranks
   a single class), so the UA rule's width/min-height were winning and
   silently stretching this input to fill the row every time regardless
   of what was written here. */
.qty-stepper .qty-input {
  width: 48px; height: 32px; min-height: 0; padding: 0 2px; border-radius: 8px; border: 1px solid var(--color-border);
  text-align: center; font-weight: 700; font-size: 0.95rem; -moz-appearance: textfield; flex-shrink: 0;
}

@media (max-width: 480px) {
  /* A real phone viewport (this is also what the Android branch-POS
     app's WebView renders at) has less room than the 360px desktop
     cart column ever needed to budget for. */
  .cart-line { --qty-stepper-w: 104px; }
  .qty-stepper button { width: 28px; height: 28px; font-size: 1rem; }
  .qty-stepper .qty-input { width: 38px; height: 28px; font-size: 0.85rem; }
  .cart-line .cart-line-amount { min-width: 60px; font-size: 0.9rem; }
}
.cart-total-row { display: flex; justify-content: space-between; font-size: 1.4rem; font-weight: 800; padding-top: 10px; border-top: 1px solid var(--color-border); }

.checkout-overlay {
  position: fixed; inset: 0; background: var(--color-scrim-strong);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.checkout-sheet { background: var(--color-surface); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 420px; text-align: center; }
.payment-mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.payment-mode-btn { min-height: 88px; border-radius: var(--radius); border: 2px solid var(--color-border); background: var(--color-bg); font-size: 1.1rem; font-weight: 700; cursor: pointer; }
.payment-mode-btn.selected { border-color: var(--color-primary); background: var(--color-success-bg); color: var(--color-primary-dark); }

@media (max-width: 900px) {
  .cart-panel { position: static; max-height: none; }
}

/* --- Empty / coming soon --- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-muted); }
.coming-soon { text-align: center; padding: 80px 20px; }

/* --- Utility --- */
.text-muted { color: var(--color-text-muted); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; }

@media (max-width: 640px) {
  .app-main { padding: 16px 14px 48px; }
}

/* --- Live dashboard: F1-style branch leaderboard --- */
.leaderboard { position: relative; margin-top: 4px; }
.leaderboard-row {
  position: absolute;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 46px;
  padding: 0 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  /* The move itself - a branch overtaking another slides to its new
     row position instead of jumping, since each row keeps the same
     DOM node (Alpine's :key) across a refresh. */
  transition: top 0.6s ease;
}
.leaderboard-row-top { border-color: var(--color-primary); background: var(--color-success-bg); }
.leaderboard-row-idle { opacity: 0.6; }
.leaderboard-rank { font-weight: 800; width: 24px; text-align: center; color: var(--color-text-muted); }
.leaderboard-name { font-weight: 600; width: 160px; flex-shrink: 0; }
.leaderboard-bar-track { flex: 1; height: 10px; background: var(--color-border); border-radius: 6px; overflow: hidden; }
.leaderboard-bar { height: 100%; background: var(--color-primary); transition: width 0.6s ease; }
.leaderboard-revenue { font-weight: 700; width: 120px; text-align: right; flex-shrink: 0; }
.leaderboard-orders { color: var(--color-text-muted); font-size: 0.85rem; width: 90px; flex-shrink: 0; }
.leaderboard-idle-tag {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--color-text-muted); border: 1px solid var(--color-border); border-radius: 999px;
  padding: 2px 8px;
}

.pie-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pie-legend li { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; display: inline-block; }

@media (max-width: 700px) {
  .leaderboard-name { width: 110px; }
  .leaderboard-orders { display: none; }
}

/* --- Item form: optional "More details" section --- */
.more-details { border-top: 1px solid var(--color-border); padding-top: 12px; }
.more-details > summary { cursor: pointer; font-weight: 600; color: var(--color-primary-dark); min-height: var(--touch); display: flex; align-items: center; }

/* --- POS for every business (Phase 2) ---
   Two-class selectors throughout where they touch inputs - the global
   `input[type="number"]` reset outranks a single class (see .qty-stepper). */
.shortcut-sheet { margin-bottom: 16px; }
.shortcut-sheet ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.8; }
.shortcut-sheet kbd { border: 1px solid var(--color-border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 0.85em; background: var(--color-bg); }
.shortcut-hint-btn { min-width: 44px; font-weight: 800; }
.day-open-card { margin-bottom: 16px; border-color: var(--color-primary); }
.exchange-banner { margin-bottom: 16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--color-success-bg); }
.scan-note { margin: 8px 0 0; color: var(--color-danger); font-weight: 600; }

.favourites-row { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; }
.favourite-chip {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 56px; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--color-border);
  background: var(--color-surface); cursor: pointer; font-weight: 700; text-align: left;
}
.favourite-chip:hover, .favourite-chip:active { border-color: var(--color-primary); background: var(--color-success-bg); }
.favourite-chip .text-muted { font-weight: 400; font-size: 0.85rem; }

.cart-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.customer-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--color-success-bg); font-weight: 600; font-size: 0.9rem; max-width: 100%; }
.customer-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-chip button { border: none; background: none; font-size: 1.1rem; cursor: pointer; line-height: 1; }
.cart-tools .price-list-select { width: auto; min-height: 36px; padding: 4px 8px; margin: 0; flex: 1; min-width: 120px; }
.cart-line .cart-line-name { cursor: pointer; }
.cart-line .cart-line-note { grid-column: 1 / -1; margin-top: -6px; font-size: 0.8rem; color: var(--color-text-muted); }
.cart-sub-row { display: flex; justify-content: space-between; color: var(--color-text-muted); font-weight: 600; }

.checkout-sheet .field { text-align: left; }
.split-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.split-row .field-input { margin: 0; }
.split-row .split-amount { width: 100%; min-height: 44px; }
.split-remaining { font-weight: 700; color: var(--color-danger); }
.split-remaining.ok { color: var(--color-primary-dark); }
.tender-box { margin: 10px 0 16px; text-align: left; }
.tender-box .tender-input { font-size: 1.3rem; }
.tender-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.change-due { font-size: 1.8rem; font-weight: 800; color: var(--color-primary-dark); margin: 12px 0 4px; text-align: center; }
.change-due.short { color: var(--color-danger); font-size: 1.2rem; }
.upi-box { margin: 10px 0 16px; }
.upi-box img { display: block; margin: 0 auto 8px; background: #fff; padding: 6px; border-radius: 8px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 14px; }
.keypad button { min-height: 56px; font-size: 1.4rem; font-weight: 700; border-radius: var(--radius); border: 1px solid var(--color-border); background: var(--color-bg); cursor: pointer; }
.checkout-sheet .keypad-display { font-size: 1.6rem; text-align: center; font-weight: 800; }

.customer-results { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 240px; overflow-y: auto; }
.customer-result { display: flex; flex-direction: column; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-bg); cursor: pointer; text-align: left; }
.customer-add { text-align: left; }
.customer-add summary { cursor: pointer; font-weight: 700; margin-bottom: 8px; }
.customer-add .field-input { margin-bottom: 8px; }

@media (max-width: 480px) {
  .split-row { grid-template-columns: minmax(0, 1fr) 96px 32px; }
  .checkout-sheet { padding: 20px 16px; }
}
.return-table .return-qty { width: 110px; display: inline-block; margin: 0 6px 0 0; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 16px; margin-top: 6px; }
.checkbox-grid ul { display: contents; }
.price-list-table .list-price-input { max-width: 160px; margin: 0; }
/* Grid items default to min-width:auto, so a long favourites row (which
   scrolls sideways on its own) would otherwise widen the items column
   and push the bill off the right edge of the screen. */
.pos-main > * { min-width: 0; }
.daybook-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.daybook-actions form { margin: 0; }
.discount-row { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 8px; }
.discount-row .field-input { margin: 0; }

.pos-js-error { background: var(--color-danger-bg); color: var(--color-danger); border-bottom: 2px solid var(--color-danger); padding: 10px 16px; font-weight: 600; }
.pos-version { margin: 24px 0 0; text-align: center; font-size: 0.8rem; color: var(--color-text-muted); }

/* --- Stock & Purchases: section tabs, low-stock and movement tags --- */
.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin: -6px 0 18px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }
.subnav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--color-text-muted); font-size: 0.9rem; }
.subnav a.active, .subnav a:hover { background: var(--color-success-bg); color: var(--color-primary-dark); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; background: var(--color-neutral-bg); color: var(--color-text-muted); }
.tag-low, .tag-dead, .tag-expired { background: var(--color-danger-bg); color: var(--color-danger); }
.tag-fast { background: var(--color-success-bg); color: var(--color-primary-dark); }
.tag-slow, .tag-soon, .tag-warn { background: var(--color-warn-bg); color: var(--color-warn-text); }
.tag-ok { background: var(--color-success-bg); color: var(--color-primary-dark); }
td.num, th.num { text-align: right; white-space: nowrap; }
.qty-neg { color: var(--color-danger); }
.stock-lines td { vertical-align: top; }
.stock-lines input, .stock-lines select { min-height: 38px; width: 100%; }
.void-box { margin-top: 20px; }
.cart-line .cart-serials { grid-column: 1 / -1; min-height: 36px; font-size: 0.85rem; }

/* Home dashboard (Phase 7): compact lists that stay inside their cards. */
.dash-list { width: 100%; table-layout: auto; font-size: 0.92rem; margin-bottom: 10px; }
.dash-list td { padding: 6px 4px; background: transparent; word-break: break-word; }
.dash-list td.num { white-space: nowrap; }

/* Restaurant tables (Phase 9) */
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.table-tile { border: 2px solid var(--color-border); border-radius: 10px; background: var(--color-surface); display: flex; flex-direction: column; }
.table-tile.busy { border-color: var(--color-accent); background: var(--color-accent-soft); }
.table-tile-main { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; text-decoration: none; color: inherit; min-height: 92px; }
.table-name { font-size: 1.35rem; font-weight: 700; }
.table-section, .table-meta { color: var(--color-text-muted); font-size: 0.85rem; }
.table-amount { font-weight: 700; color: var(--color-warn-text); }
.table-actions { padding: 0 12px 10px; font-size: 0.9rem; }
.table-actions .field-input { min-width: 0; }
.pos-context { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.product-tile.sold-out { opacity: 0.45; }
.tile-badge { font-size: 0.72rem; font-weight: 700; color: var(--color-danger); text-transform: uppercase; }
.cart-line-note.kitchen { color: var(--color-warn-text); }
.charge-row { display: flex; justify-content: space-between; color: var(--color-text-muted); font-size: 0.92rem; padding: 2px 0; }
.weight-quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }

/* --- Phase 10: two-step sign-in, cashier PIN pad, offline counter ---------------------- */
.code-input { font-size: 1.6rem; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
.setup-steps { padding-left: 20px; }
.setup-steps li { margin-bottom: 12px; }
.qr-box { display: flex; justify-content: center; padding: 12px 0; }
.qr-box img { background: #fff; border-radius: 8px; }
.secret-key { word-break: break-all; font-size: 0.95rem; }
.recovery-codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 16px 0; }
.recovery-codes code { display: block; text-align: center; padding: 8px; background: var(--color-surface-2); border-radius: 6px; font-size: 1rem; }
.cashier-chip { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.cashier-overlay { position: fixed; inset: 0; background: rgba(10, 16, 12, 0.82); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.cashier-pad { width: 100%; max-width: 340px; text-align: center; }
.pin-dots { font-size: 1.8rem; letter-spacing: 0.4em; min-height: 2.4rem; margin: 8px 0; }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-key { min-height: 60px; font-size: 1.4rem; }
.offline-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-weight: 600; background: var(--color-success-bg); }
.offline-status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); }
.offline-status.is-offline { background: var(--color-warn-bg); color: var(--color-warn-text); }
.offline-status.is-offline .dot { background: #d18b00; }
.offline-status.is-waiting .dot { background: #d18b00; }
.offline-problem { flex-basis: 100%; color: var(--color-danger); font-weight: 500; }
.offline-banner { background: var(--color-warn-bg); color: var(--color-warn-text); border-radius: 8px; padding: 10px 12px; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.stat-grid .stat { display: flex; flex-direction: column; gap: 2px; }
.stat-grid .stat strong { font-size: 1.4rem; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.summary-grid table { width: 100%; }
.summary-text { white-space: pre-wrap; font-family: inherit; background: var(--color-surface-2); padding: 12px; border-radius: 8px; margin: 0; }
.first-run-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.first-run-steps li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--color-border); }
.first-run-steps li > div { flex: 1; min-width: 0; }
.first-run-steps .tick { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; background: var(--color-neutral-bg); flex-shrink: 0; }
.first-run-steps li.is-done .tick { background: var(--color-primary); color: #fff; }
.first-run-steps li.is-done strong { text-decoration: line-through; color: var(--color-text-muted); }

/* --- Settings in sections (redesign stage 2) ------------------------------ */
.settings-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav-title { margin: 0 12px 8px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: var(--color-text-muted); }
.settings-nav-link {
  position: relative; display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 8px 12px;
  border-radius: var(--radius); color: var(--color-text-muted); font-weight: 600; text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.settings-nav-link:hover { background: var(--color-surface); color: var(--color-text); }
.settings-nav-link.active { background: var(--color-surface); color: var(--color-primary-dark); box-shadow: var(--shadow-1); }
.settings-nav-link.active .icon { color: var(--color-primary); }
.settings-body { min-width: 0; }
.settings-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.settings-head > div { flex: 1 1 auto; min-width: 0; }
.settings-head h1 { margin: 2px 0 2px; font-size: 1.55rem; }
.settings-head p { margin: 0; }
.settings-head-icon {
  width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px;
  background: var(--color-primary-soft); color: var(--color-primary);
}
.settings-card h2 { margin: 0 0 12px; font-size: 1.08rem; }
.settings-card input[type="color"] { width: 100%; max-width: 180px; height: 48px; padding: 4px; cursor: pointer; }
.settings-card > .field-help { margin-top: 0; }
.settings-form { position: relative; padding-bottom: 8px; }

/* The save bar: in view without JavaScript; with it, it slides up only
   once something has changed. */
.save-bar {
  position: sticky; bottom: 16px; z-index: 20; margin-top: 16px;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px;
  background: var(--color-ink); color: var(--color-on-ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  transition: transform 0.28s var(--ease-out), opacity 0.2s;
}
.save-bar-text { flex: 1 1 auto; display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.save-bar-text .icon { color: var(--color-accent); }
.save-bar .btn-quiet { color: var(--color-on-ink); border-color: rgba(255, 255, 255, 0.22); }
.save-bar .btn-quiet:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.settings-form.is-tracking:not(.is-dirty) .save-bar { transform: translateY(calc(100% + 32px)); opacity: 0; pointer-events: none; }
.has-tabs .save-bar { bottom: calc(76px + env(safe-area-inset-bottom)); }

/* On/off switch around a real checkbox (so forms post exactly as before). */
.switch { position: relative; display: inline-flex; flex-shrink: 0; width: 44px; height: 26px; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: absolute; inset: 0; border-radius: 999px; background: var(--color-border-strong);
  transition: background-color 0.2s var(--ease-out);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.22s var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--color-primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.switch-row { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
.switch-row > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.switch-row small { color: var(--color-text-muted); font-size: 0.88rem; }

/* Modules: switches grouped by purpose. */
.module-search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; flex: 0 1 240px;
  border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); color: var(--color-text-muted);
}
.module-search input[type="search"] { border: none; min-height: 0; height: 100%; padding: 0; background: transparent; outline: none; box-shadow: none; width: 100%; font-size: 0.95rem; }
.module-group { margin-bottom: 26px; }
.module-group-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 1.05rem; }
.module-count { font-family: var(--font-body); font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted); letter-spacing: 0; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.module-card {
  display: flex; flex-direction: column; background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.module-card:hover { box-shadow: var(--shadow-2); }
.module-card:has(input:checked) { border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border)); }
.module-main { display: flex; align-items: flex-start; gap: 12px; padding: 14px 14px 12px; cursor: pointer; flex: 1 1 auto; }
.module-icon {
  width: 38px; height: 38px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px;
  background: var(--color-surface-2); color: var(--color-text-muted); transition: background-color 0.2s, color 0.2s;
}
.module-card:has(input:checked) .module-icon { background: var(--color-primary-soft); color: var(--color-primary); }
.module-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.module-text small {
  color: var(--color-text-muted); font-size: 0.84rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.module-card:hover .module-text small { -webkit-line-clamp: unset; }
.module-setup {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 14px 12px 64px; font-weight: 700; font-size: 0.88rem;
  color: var(--color-primary-dark); text-decoration: none;
}
.module-setup .icon { transition: transform 0.2s var(--ease-out); }
.module-setup:hover .icon { transform: translateX(3px); }
.module-setup.is-later { color: var(--color-text-muted); font-weight: 500; }

/* Payment modes as chips. */
.chip-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-check { position: relative; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip-check > span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 8px 16px 8px 12px; border-radius: 999px;
  border: 1px solid var(--color-border); background: var(--color-surface); font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.chip-check > span .icon { opacity: 0; transform: scale(0.6); transition: opacity 0.15s, transform 0.2s var(--ease-out); width: 16px; }
.chip-check input:checked + span { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary-dark); }
.chip-check input:checked + span .icon { opacity: 1; transform: none; }
.chip-check input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Links to a module's own setup screens. */
.link-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.link-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--color-border); background: var(--color-surface-2); color: var(--color-text); text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s var(--ease-out);
}
.link-tile:hover { border-color: var(--color-border-strong); background: var(--color-surface); transform: translateY(-1px); }
.link-tile > span:nth-child(2) { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.link-tile small { color: var(--color-text-muted); font-size: 0.84rem; }
.link-tile-icon { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--color-surface); color: var(--color-primary); }
.link-tile-go { color: var(--color-text-muted); transition: transform 0.2s var(--ease-out); }
.link-tile:hover .link-tile-go { transform: translateX(3px); }
.icon-flip { transform: scaleX(-1); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.pill-ok { background: var(--color-success-bg); color: var(--color-primary-dark); }
.pill-warn { background: var(--color-warn-bg); color: var(--color-warn-text); }
.pill-muted { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text-muted); }
.copy-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.copy-row code { padding: 8px 12px; border-radius: 8px; background: var(--color-surface-2); border: 1px solid var(--color-border); word-break: break-all; }

/* Appearance: logo and a live preview of the colours. */
.logo-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.logo-frame {
  width: 104px; height: 104px; flex-shrink: 0; display: grid; place-items: center; border-radius: 16px;
  border: 1px dashed var(--color-border-strong); background: #fff; overflow: hidden;
}
.logo-frame img { width: 100%; height: 100%; object-fit: contain; }
.logo-empty { color: var(--color-text-muted); }
.logo-empty .icon { width: 32px; height: 32px; }
.logo-pick { flex: 1 1 260px; }
.appearance-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.theme-mock { display: flex; height: 190px; border-radius: 14px; overflow: hidden; border: 1px solid var(--color-border); box-shadow: var(--shadow-1); }
.theme-mock-side { width: 56px; background: #fff; border-right: 1px solid var(--color-border); display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 14px; }
.theme-mock-side span { width: 24px; height: 24px; border-radius: 7px; }
.theme-mock-side i { width: 22px; height: 6px; border-radius: 3px; background: var(--color-border); }
.theme-mock-page { flex: 1 1 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; transition: background-color 0.2s; }
.theme-mock-card { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; background: #fff; color: #17241c; font-size: 0.8rem; box-shadow: var(--shadow-1); }
.theme-mock-page .btn { margin-top: auto; }

@media (max-width: 1100px) { .appearance-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .settings-shell { grid-template-columns: 1fr; gap: 14px; }
  .settings-nav { position: static; flex-direction: row; gap: 6px; overflow-x: auto; padding: 0 0 4px; scrollbar-width: none; }
  .settings-nav-title { display: none; }
  .settings-nav-link { flex-shrink: 0; min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--color-border); background: var(--color-surface); white-space: nowrap; }
  .settings-nav-link.active { border-color: var(--color-primary); }
  .settings-head { flex-wrap: wrap; }
  .settings-head-icon { display: none; }
  .module-search { flex: 1 1 100%; }
  .module-grid { grid-template-columns: 1fr; }
}

/* --- Page patterns (redesign stage 3) -------------------------------------
   Lists, single records and forms share one shape: a header with the page's
   one main action, a toolbar, then cards. */
.page-header h1 { letter-spacing: -0.02em; }
.page-header > div:first-child > .text-muted, .page-header > div:first-child > p { margin: 4px 0 0; }
.page-header .row { gap: 8px; }
.page-header .btn-lg { min-height: 46px; font-size: 1rem; padding: 10px 20px; }

/* "More": the header's other actions, folded away by shell.js. */
.more-wrap { position: relative; }
.more-btn .icon { width: 16px; height: 16px; transition: transform 0.2s var(--ease-out); }
.more-wrap.is-open .more-btn .icon { transform: rotate(180deg); }
.more-pop { display: flex; flex-direction: column; gap: 2px; }
.more-pop[hidden] { display: none; }
.more-wrap.is-open .more-pop { animation: pop-in 0.16s var(--ease-out); }
.more-pop > form { margin: 0; display: block; }
.more-pop .btn {
  width: 100%; justify-content: flex-start; min-height: 40px; padding: 8px 12px; border: none; border-radius: 8px;
  background: transparent; color: var(--color-text); font-weight: 600; font-size: 0.94rem; box-shadow: none; transform: none;
}
.more-pop .btn:hover { background: var(--color-surface-2); transform: none; box-shadow: none; }
.more-pop .btn-danger { color: var(--color-danger); }
.more-pop .btn-primary { color: var(--color-primary-dark); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(0.97); } }

/* Search / filter toolbar above a list. */
.search-bar {
  align-items: center; padding: 10px; margin-bottom: 18px; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); flex-wrap: wrap;
}
.search-bar > .field-input, .search-bar > input, .search-bar > select { margin: 0; min-height: 44px; }
.search-bar > input[type="text"]:first-of-type, .search-bar > input[type="search"]:first-of-type {
  flex: 1 1 220px; padding-left: 40px;
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235b6a61' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 13px center;
}

/* Section tabs (Stock, Purchases, Accounts, Invoices & notes...). */
.subnav {
  gap: 2px; margin: -4px 0 20px; padding: 0; border-bottom: 1px solid var(--color-border);
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.subnav a {
  position: relative; flex-shrink: 0; padding: 10px 14px; border-radius: 0; font-weight: 600; white-space: nowrap;
  transition: color 0.15s;
}
.subnav a::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--color-primary); transform: scaleX(0); transition: transform 0.22s var(--ease-out);
}
.subnav a:hover { background: transparent; color: var(--color-text); }
.subnav a.active { background: transparent; color: var(--color-primary-dark); }
.subnav a.active::after { transform: scaleX(1); }

/* Cards and their headings. */
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card h2 { font-size: 1.15rem; }
.card h3 { font-size: 1rem; }
.card-danger { border-color: var(--color-danger) !important; }
.callout-danger { border-left: 4px solid var(--color-danger) !important; }

/* A record's details: "Label / value" pairs inside a card's grid. */
.card .form-grid > div > strong:first-child {
  display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted);
}
.card .form-grid > div > strong:first-child + p { margin: 4px 0 12px; font-weight: 600; }

/* Tables. */
.table-wrap.card { padding: 6px; }
.table-wrap.card > table { border-radius: 10px; }
th { font-weight: 700; letter-spacing: 0.06em; font-size: 0.74rem; }
td a { font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
.status-badge, .tag { letter-spacing: 0.01em; }
.status-badge::before, .tag-ok::before, .tag-low::before, .tag-warn::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%;
  background: currentColor; vertical-align: 1px; opacity: 0.8;
}

/* Nothing here yet. */
.empty-state { color: var(--color-text-muted); }
.empty-state::before {
  content: ""; display: block; width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px;
  background: var(--color-primary-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%231f7a4d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E") no-repeat center;
}
td.empty-state { padding: 40px 20px; text-align: center; }

/* Form controls in the app's colours. */
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--color-primary); vertical-align: -3px; cursor: pointer; }
input[type="file"] { padding: 6px; }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; border: 1px solid var(--color-border); border-radius: 8px;
  background: var(--color-surface-2); color: var(--color-text); font: inherit; font-weight: 600; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
input[type="file"]::file-selector-button:hover { background: var(--color-surface); border-color: var(--color-border-strong); }
.more-details > summary::-webkit-details-marker { color: var(--color-primary); }

/* Phones: list tables become stacked cards (labels added by shell.js). */
@media (max-width: 640px) {
  table.is-stack thead { display: none; }
  table.is-stack, table.is-stack tbody, table.is-stack tr, table.is-stack td { display: block; width: 100%; }
  table.is-stack tr { padding: 10px 4px; border-bottom: 1px solid var(--color-border); }
  table.is-stack tr:last-child { border-bottom: none; }
  table.is-stack td { padding: 3px 10px; border: none; text-align: right; overflow: hidden; }
  table.is-stack td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--color-text-muted); font-size: 0.78rem; font-weight: 600; line-height: 1.9; text-align: left; }
  table.is-stack td:first-child { font-size: 1.02rem; font-weight: 700; }
  table.is-stack td:not([data-label])::before { content: none; }
  table.is-stack td.empty-state { display: block; text-align: center; }
  /* Tables that can't stack (they hold inputs) scroll inside their own box
     instead of widening the page. */
  .app-main table:not(.is-stack) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .page-header { align-items: flex-start; }
  .page-header h1 { font-size: 1.4rem; }
}

/* --- Home dashboard (redesign stage 4) -------------------------------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stat-grid-lg { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-tile {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 18px 18px 16px; overflow: hidden;
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1); transition: box-shadow 0.2s, transform 0.2s var(--ease-out);
}
.stat-tile:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.stat-lead { grid-column: span 2; }
.stat-label { display: flex; align-items: center; gap: 6px; color: var(--color-text-muted); font-size: 0.88rem; font-weight: 600; }
.stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; color: var(--color-text); text-decoration: none; font-variant-numeric: tabular-nums; }
.stat-lead .stat-value { font-size: 2.3rem; }
a.stat-value:hover { color: var(--color-primary-dark); }
.stat-rs { font-size: 0.6em; font-weight: 600; color: var(--color-text-muted); }
.stat-sub { color: var(--color-text-muted); font-size: 0.84rem; margin-top: auto; padding-top: 6px; }
.stat-warn { display: inline-flex; align-items: center; gap: 4px; color: var(--color-warn-text); font-weight: 600; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.82rem; font-weight: 700; }
.delta.is-up { color: var(--color-primary-dark); }
.delta.is-down { color: var(--color-danger); }
.delta.is-same { color: var(--color-text-muted); }
.delta-vs { color: var(--color-text-muted); font-weight: 500; }
.stat-sub .delta { margin-left: 6px; }
/* A 14-day sparkline under the lead figure: past days quiet, today in the accent. */
.spark { position: absolute; right: 18px; top: 18px; display: flex; align-items: flex-end; gap: 2px; height: 46px; width: 120px; }
.spark i { flex: 1; height: max(2px, var(--h)); border-radius: 2px 2px 0 0; background: var(--color-chart-quiet, var(--color-border-strong)); }
.spark i.is-today { background: var(--color-primary); }

.dash-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; margin-bottom: 16px; }
.chart-card h2, .needs-card h2, .dash-grid h2 { margin: 0 0 4px; font-size: 1.08rem; }
.chart-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
/* Daily sales: one series, so no legend - the title names it. Bars are
   capped in width, rounded only at the data end, 2px apart. */
.bars { display: flex; align-items: stretch; gap: 2px; height: 200px; padding-top: 22px; border-bottom: 1px solid var(--color-border); }
.bar-slot { position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; outline: none; cursor: default; }
.bar { width: min(24px, 70%); height: max(2px, var(--h)); border-radius: 4px 4px 0 0; background: var(--color-chart-quiet, var(--color-border-strong)); transition: background-color 0.15s, height 0.6s var(--ease-out); animation: bar-grow 0.6s var(--ease-out) backwards; transform-origin: bottom; }
.bar-slot.is-today .bar { background: var(--color-primary); }
:root[data-theme="dark"] .bar-slot.is-today .bar, :root[data-theme="dark"] .spark i.is-today { background: var(--color-primary-dark); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bar-slot.is-today .bar, :root:not([data-theme="light"]) .spark i.is-today { background: var(--color-primary-dark); } }
.bar-slot:hover .bar, .bar-slot:focus-visible .bar { background: var(--color-primary-hover); }
.bar-cap { font-size: 0.72rem; font-weight: 700; color: var(--color-text); margin-bottom: 4px; white-space: nowrap; }
.bar-day { position: absolute; bottom: -22px; font-size: 0.7rem; color: var(--color-text-muted); white-space: nowrap; }
.bar-slot.is-today .bar-day { color: var(--color-text); font-weight: 700; }
.bar-slot::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% - 14px); left: 50%; z-index: 5; transform: translate(-50%, 4px);
  padding: 6px 10px; border-radius: 8px; background: var(--color-ink); color: var(--color-on-ink); font-size: 0.78rem; font-weight: 600;
  white-space: nowrap; pointer-events: none; display: none;
}
/* Only there while shown, so a hidden tooltip never widens the page. */
.bar-slot:hover::after, .bar-slot:focus-visible::after { display: block; transform: translate(-50%, 0); animation: tip-in 0.12s ease-out; }
@keyframes tip-in { from { opacity: 0; } }
.bar-slot:first-child::after { left: 0; transform: translate(0, 4px); }
.bar-slot:first-child:hover::after, .bar-slot:first-child:focus-visible::after { transform: none; }
.bar-slot:last-child::after { left: auto; right: 0; transform: translate(0, 4px); }
.bar-slot:last-child:hover::after, .bar-slot:last-child:focus-visible::after { transform: none; }
.chart-card { padding-bottom: 34px; }
@keyframes bar-grow { from { transform: scaleY(0); } }

.needs-card .needs-list { margin: 8px -10px 0; }
.all-clear { display: flex; align-items: center; gap: 14px; padding: 18px 0 6px; }
.all-clear p { margin: 0; }
.all-clear-tick {
  width: 46px; height: 46px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary); animation: tick-pop 0.5s var(--ease-out) 0.2s backwards;
}
@keyframes tick-pop { from { transform: scale(0.4); opacity: 0; } }

.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.dash-grid .card { display: flex; flex-direction: column; }
.card-link { margin-top: auto; padding-top: 12px; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.9rem; text-decoration: none; color: var(--color-primary-dark); }
.card-link .icon { transition: transform 0.2s var(--ease-out); }
.card-link:hover .icon { transform: translateX(3px); }
.rank-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank-row { display: flex; justify-content: space-between; gap: 10px; font-size: 0.94rem; }
.rank-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.rank-meta small { color: var(--color-text-muted); white-space: nowrap; }
.rank-bar { flex: 0 0 auto; width: calc(var(--w) * 0.75); min-width: 4px; height: 6px; border-radius: 4px; background: color-mix(in srgb, var(--color-primary) 55%, var(--color-surface)); animation: bar-grow-x 0.6s var(--ease-out) backwards; transform-origin: left; }
@keyframes bar-grow-x { from { transform: scaleX(0); } }
.kv-list { list-style: none; margin: 8px 0 0; padding: 0; }
.kv-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 0; border-top: 1px solid var(--color-border); font-size: 0.94rem; }
.kv-list li:first-child { border-top: none; }
.kv-list li > span:last-child { white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv-list a { font-weight: 600; text-decoration: none; }
.dash-grid .empty-state { padding: 20px 0; }

@media (max-width: 1100px) { .dash-row { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .stat-lead { grid-column: auto; }
  .stat-lead .stat-value { font-size: 1.9rem; }
  .spark { position: static; width: 100%; height: 36px; margin-top: 8px; }
  .bars { height: 160px; }
  .bar-day { font-size: 0.6rem; }
  .bar-slot:not(.is-today):nth-child(even) .bar-day { visibility: hidden; }
}

/* --- Reports hub (redesign stage 4) ------------------------------------ */
.report-search { flex: 0 1 280px; }
.report-jump { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: -6px 0 22px; padding-bottom: 2px; }
.report-jump a {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted);
  font-weight: 600; font-size: 0.9rem; text-decoration: none; transition: border-color 0.15s, color 0.15s;
}
.report-jump a:hover { border-color: var(--color-primary); color: var(--color-primary-dark); }
.report-group { margin-bottom: 26px; scroll-margin-top: calc(var(--topbar-h) + 16px); }
[id^="sec-"] { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.report-group-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 1.15rem; }
.report-group-title .icon { color: var(--color-primary); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.report-tile {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px; border-radius: var(--radius-lg);
  background: var(--color-surface); color: var(--color-text); text-decoration: none;
  border: 1px solid var(--color-border); box-shadow: var(--shadow-1);
  transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s var(--ease-out);
}
a.report-tile:hover { border-color: color-mix(in srgb, var(--color-primary) 40%, var(--color-border)); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.report-icon { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 11px; background: var(--color-primary-soft); color: var(--color-primary); }
.report-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.report-text small { color: var(--color-text-muted); font-size: 0.86rem; line-height: 1.45; }
.report-go { margin-top: 10px; color: var(--color-text-muted); transition: transform 0.2s var(--ease-out), color 0.15s; }
a.report-tile:hover .report-go { transform: translateX(3px); color: var(--color-primary); }
.report-form { grid-column: 1 / -1; }
.report-inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 10px; }
.report-inline-form .field { min-width: 180px; }
.report-inline-form .field-input { min-height: 44px; }
@media (max-width: 640px) { .report-grid { grid-template-columns: 1fr; } .report-search { flex: 1 1 100%; } }

/* --- The counter (redesign stage 5) ------------------------------------ */
/* Full screen: the site menu steps aside into a drawer (the menu button
   opens it), so the items and the bill get the whole width. */
.is-counter .sidenav {
  position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: 40;
  transform: translateX(-102%); visibility: hidden; transition: transform 0.26s var(--ease-out), visibility 0s linear 0.26s;
}
.is-counter .sidenav.is-open { transform: none; visibility: visible; box-shadow: var(--shadow-3); transition: transform 0.26s var(--ease-out); }
.is-counter .sidenav .brand, .is-counter .sidenav .nav-label { display: revert; }
.is-counter .sidenav .nav-link { justify-content: flex-start; padding: 8px 12px; }
.is-counter .sidenav .nav-group-label { font-size: 0.68rem; height: auto; margin: 16px 12px 6px; background: none; }
.is-counter .sidenav .nav-group:first-child .nav-group-label { display: block; }
.is-counter .rail-toggle { display: none; }
.is-counter .drawer-close, .is-counter .menu-btn { display: inline-grid; }
.is-counter .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: var(--color-scrim); }
.is-counter .app-main { padding-top: 18px; }

.pos-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.pos-title { flex: 1 1 auto; margin: 0; font-size: 1.35rem; }
.pos-held-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 10px 8px 14px; border-radius: 999px;
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font-weight: 700; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pos-held-btn:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-1); }
.pos-count {
  min-width: 26px; height: 26px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 999px;
  background: var(--color-surface-2); color: var(--color-text-muted); font-size: 0.85rem;
}
.pos-held-btn.has-held { border-color: var(--color-accent); }
.pos-held-btn.has-held .pos-count { background: var(--color-accent); color: #241600; animation: pulse 2.4s ease-out infinite; }
.pos-menu { min-width: 260px; }
.pos-menu .pop-item { width: 100%; border: none; background: none; text-align: left; cursor: pointer; font: inherit; font-weight: 600; }
.pos-menu kbd { margin-left: 6px; }

.pos-main { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 20px; align-items: start; }
.pos-catalog { min-width: 0; }
.pos-search-wrap {
  display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; border-radius: var(--radius-lg);
  background: var(--color-surface); border: 1px solid var(--color-border); box-shadow: var(--shadow-1); color: var(--color-text-muted);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pos-search-wrap:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.pos-search-wrap .pos-search, .pos-search-wrap .pos-search:focus { flex: 1; margin: 0; min-height: 56px; border: none; padding: 0; background: transparent; box-shadow: none; font-size: 1.1rem; }

.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 14px 0 2px; }
.chip-row-sub { padding-top: 8px; }
.cat-chip {
  flex-shrink: 0; min-height: 42px; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text); font: inherit; font-weight: 700; cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.12s var(--ease-out);
}
.cat-chip:hover { border-color: var(--color-border-strong); }
.cat-chip:active { transform: scale(0.96); }
.cat-chip.is-active { background: var(--color-inverse); border-color: var(--color-inverse); color: var(--color-on-inverse); }
.cat-chip-sub { min-height: 36px; padding: 6px 14px; font-weight: 600; font-size: 0.9rem; }
.cat-chip-sub.is-active { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary-dark); }

.pos-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.pos-grid .product-tile, .is-counter .product-tile {
  aspect-ratio: auto; min-height: 168px; padding: 10px; border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
  transition: transform 0.12s var(--ease-out), box-shadow 0.15s, border-color 0.15s;
}
.is-counter .product-tile:hover { background: var(--color-surface); border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border)); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.is-counter .product-tile:active { transform: scale(0.97); background: var(--color-primary-soft); }
.is-counter .product-tile .tile-image { min-height: 92px; border-radius: 10px; }
.is-counter .tile-image-placeholder { font-family: var(--font-display); font-size: 2rem; color: color-mix(in srgb, var(--color-primary) 55%, var(--color-text-muted)); }
.is-counter .product-tile .tile-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.95rem; }
.is-counter .product-tile .tile-price { color: var(--color-text); font-weight: 700; font-variant-numeric: tabular-nums; }

.is-counter .cart-panel {
  top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 32px); padding: 18px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
}
.cart-count { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; margin-left: 4px; border-radius: 999px; background: var(--color-primary); color: #fff; font-size: 0.8rem; vertical-align: 3px; }
.is-counter .cart-total-row { align-items: baseline; font-size: 1.05rem; }
.cart-total-value { display: inline-block; font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; transform-origin: right center; }
.cart-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cart-actions form { margin: 0; }
.cart-actions .btn { width: 100%; min-height: 44px; }
.cart-actions > .btn:only-child, .cart-actions form:only-child { grid-column: 1 / -1; }

.drawer-scrim { position: fixed; inset: 0; z-index: 60; background: var(--color-scrim); }
.held-drawer {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 61; width: min(380px, 92vw); display: flex; flex-direction: column;
  background: var(--color-bg); box-shadow: var(--shadow-3); color: var(--color-text);
  transform: translateX(-102%); visibility: hidden; transition: transform 0.28s var(--ease-out), visibility 0s linear 0.28s;
}
.held-drawer.is-open { transform: none; visibility: visible; transition: transform 0.28s var(--ease-out); }
.held-drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--color-border); background: var(--color-surface); }
.held-drawer-list { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.held-drawer .held-bill-card { background: var(--color-surface); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-1); }

.fly-dot { position: fixed; z-index: 300; width: 18px; height: 18px; border-radius: 50%; background: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-soft); pointer-events: none; }

/* Paid: the circle draws itself, then the tick. */
.paid-tick { width: 76px; height: 76px; margin: 0 auto 8px; }
.paid-tick svg { width: 100%; height: 100%; fill: none; stroke: var(--color-primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.paid-tick circle { stroke-dasharray: 145; stroke-dashoffset: 145; animation: draw 0.5s var(--ease-out) forwards; fill: var(--color-primary-soft); }
.paid-tick path { stroke-width: 4; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 0.3s var(--ease-out) 0.42s forwards; }
.paid-tick.is-queued svg { stroke: var(--color-accent); }
.paid-tick.is-queued circle { fill: var(--color-accent-soft); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.change-done { font-size: 1.8rem; animation: rise 0.4s var(--ease-out) 0.5s backwards; }
.checkout-sheet { border-radius: 20px; box-shadow: var(--shadow-3); animation: sheet-up 0.24s var(--ease-out); }
@keyframes sheet-up { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.payment-mode-btn { border-radius: var(--radius-lg); transition: border-color 0.15s, background-color 0.15s, transform 0.12s var(--ease-out); }
.payment-mode-btn:hover { border-color: var(--color-primary); }
.payment-mode-btn:active { transform: scale(0.97); }

/* PIN pad. */
.cashier-overlay { backdrop-filter: blur(6px); }
.cashier-pad { border-radius: 22px; padding: 26px 24px; box-shadow: var(--shadow-3); animation: sheet-up 0.26s var(--ease-out); }
.pin-dots { font-size: 1.6rem; letter-spacing: 0.5em; color: var(--color-primary-dark); }
.pin-keys { gap: 12px; }
.pin-key { min-height: 64px; border-radius: 18px; font-size: 1.5rem; font-weight: 700; }
.cashier-chip { justify-content: flex-start; margin-bottom: 10px; color: var(--color-text-muted); }

/* Restaurant tables. */
.table-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.table-tile {
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-1);
  transition: transform 0.15s var(--ease-out), box-shadow 0.2s, border-color 0.15s; overflow: hidden;
}
.table-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.table-tile.free { border-top: 4px solid color-mix(in srgb, var(--color-primary) 55%, var(--color-surface)); }
.table-tile.busy { border-color: color-mix(in srgb, var(--color-accent) 60%, var(--color-border)); border-top: 4px solid var(--color-accent); background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface)); }
.table-tile-main { min-height: 110px; padding: 16px 14px; }
.table-changed { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 8px 10px; border-radius: 10px;
  background: var(--color-primary-soft); color: var(--color-text); font-size: 0.9rem; font-weight: 600; }
.table-changed span { flex: 1; }
/* Live tables: a table another counter or phone just changed glows once. */
.table-tile.is-updated { animation: table-updated 1.2s ease-in-out 2; }
@keyframes table-updated { 50% { box-shadow: 0 0 0 5px var(--color-primary-soft); } }
@media (prefers-reduced-motion: reduce) { .table-tile.is-updated { animation: none; outline: 3px solid var(--color-primary-soft); } }
.table-name { font-family: var(--font-display); font-size: 1.5rem; }
.table-amount { color: var(--color-warn-text); font-size: 1.05rem; }
.table-actions summary { cursor: pointer; color: var(--color-text-muted); font-weight: 600; padding: 4px 0; }

.pos-mini-bill { display: none; }
@media (max-width: 900px) {
  .pos-mini-bill {
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 34;
    display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px;
    background: var(--color-ink); color: var(--color-on-ink); box-shadow: var(--shadow-3); animation: toast-in 0.25s var(--ease-out);
  }
  .has-tabs .pos-mini-bill { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .pos-mini-view { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; border: none; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
  .pos-mini-view span { font-size: 0.78rem; opacity: 0.75; }
  .pos-mini-view strong { font-size: 1.15rem; }
  .pos-mini-bill .btn { min-height: 46px; }
  .is-counter .app-main { padding-bottom: 120px; }
  .has-tabs.is-counter .app-main { padding-bottom: 180px; }
}
@media (max-width: 1100px) { .pos-main { grid-template-columns: minmax(0, 1fr) 340px; } }
@media (max-width: 900px) {
  .pos-main { grid-template-columns: 1fr; }
  .is-counter .cart-panel { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .pos-title { display: none; }
  .pos-bar { justify-content: space-between; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .is-counter .product-tile { min-height: 150px; }
  }

/* --- Utilities (redesign stage 3) ---------------------------------------
   What used to be one-off inline style="..." attributes, now named and
   shared. !important so each wins exactly where its inline style did. */
.m-0 { margin: 0 !important; }
.mt-4 { margin-top: 4px !important; }
.mt-6 { margin-top: 6px !important; }
.mt-8 { margin-top: 8px !important; }
.mt-10 { margin-top: 10px !important; }
.mt-12 { margin-top: 12px !important; }
.mt-16 { margin-top: 16px !important; }
.mt-20 { margin-top: 20px !important; }
.mt-24 { margin-top: 24px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 4px !important; }
.mb-6 { margin-bottom: 6px !important; }
.mb-8 { margin-bottom: 8px !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mt-0 { margin-top: 0 !important; }
.gap-4 { gap: 4px !important; }
.gap-6 { gap: 6px !important; }
.gap-8 { gap: 8px !important; }
.gap-10 { gap: 10px !important; }
.gap-12 { gap: 12px !important; }
.gap-16 { gap: 16px !important; }
.gap-20 { gap: 20px !important; }
.gap-24 { gap: 24px !important; }
.grow { flex: 1 !important; }
.flex-wrap { flex-wrap: wrap !important; }
.nowrap { white-space: nowrap !important; }
.text-warn { color: var(--color-warn-text) !important; }
.items-end { align-items: flex-end !important; }
.items-center { align-items: center !important; }
.items-start { align-items: flex-start !important; }
.justify-between { justify-content: space-between !important; }
.justify-end { justify-content: flex-end !important; }
.justify-center { justify-content: center !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-danger { color: var(--color-danger) !important; }
.text-primary { color: var(--color-primary) !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.fs-sm { font-size: 0.85rem !important; }
.fs-sm2 { font-size: 0.9rem !important; }
.fs-xs { font-size: 0.8rem !important; }
.fs-md { font-size: 1.05rem !important; }
.fs-lg { font-size: 1.1rem !important; }
.d-none { display: none !important; }
.d-inline { display: inline !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.break-all { word-break: break-all !important; }
.w-full { width: 100% !important; }
.flex-col { flex-direction: column !important; }
.shrink-0 { flex-shrink: 0 !important; }
.maxw-120 { max-width: 120px !important; }
.maxw-140 { max-width: 140px !important; }
.maxw-150 { max-width: 150px !important; }
.maxw-160 { max-width: 160px !important; }
.maxw-170 { max-width: 170px !important; }
.maxw-180 { max-width: 180px !important; }
.maxw-200 { max-width: 200px !important; }
.maxw-220 { max-width: 220px !important; }
.maxw-260 { max-width: 260px !important; }
.maxw-420 { max-width: 420px !important; }
.maxw-480 { max-width: 480px !important; }
.maxw-640 { max-width: 640px !important; }
.minw-180 { min-width: 180px !important; }
.minw-200 { min-width: 200px !important; }
.minw-220 { min-width: 220px !important; }
.minw-230 { min-width: 230px !important; }
.minw-240 { min-width: 240px !important; }
.w-100 { width: 100px !important; }
.w-110 { width: 110px !important; }
.w-120 { width: 120px !important; }
.w-130 { width: 130px !important; }
.w-140 { width: 140px !important; }
.w-150 { width: 150px !important; }
.w-36 { width: 36px !important; }
.w-70 { width: 70px !important; }
.w-90 { width: 90px !important; }
/* Big figures (totals, counts) in the display face. */
.figure-xl { font-size: 1.8rem !important; font-weight: 800 !important; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.figure { font-size: 1.6rem !important; font-weight: 800 !important; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.figure-md { font-size: 1.5rem !important; font-weight: 800 !important; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.figure-sm { font-size: 1.4rem !important; font-weight: 800 !important; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Printing a page from the browser prints the page, not the frame. */
@media print {
  .sidenav, .scrim, .topbar, .bottom-tabs, .sheet, .sheet-scrim, .toast-stack, .palette, .palette-scrim, .skip-link { display: none !important; }
  .app-main { max-width: none; padding: 0; }
  .app-main > * { animation: none; }
  body { background: #fff; }
}

/* Anyone whose phone or computer asks for less motion gets none. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
}

/* --- Firm console (redesign stage 6) ------------------------------------- */
.console-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.console-stat {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; cursor: pointer;
  background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1); font: inherit; transition: border-color 0.15s, box-shadow 0.2s, transform 0.15s var(--ease-out);
}
.console-stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.console-stat.is-on { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.console-stat strong { display: block; font-family: var(--font-display); font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.console-stat small { color: var(--color-text-muted); font-weight: 600; font-size: 0.85rem; }
.console-stat-icon { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: var(--color-primary-soft); color: var(--color-primary-dark); }
.console-stat-icon.tone-ok { background: var(--color-success-bg); color: var(--color-primary-dark); }
.console-stat-icon.tone-warn { background: var(--color-warn-bg); color: var(--color-warn-text); }
.console-stat-icon.tone-bad { background: var(--color-danger-bg); color: var(--color-danger); }
.console-toolbar { margin-bottom: 14px; }
.console-search { max-width: 420px; height: 44px; }
.console-card { padding: 0; overflow: hidden; }
.console-card > .empty-state { padding: 36px 20px; }
.client-cell { display: flex; align-items: center; gap: 12px; color: var(--color-text); }
.client-cell:hover { text-decoration: none !important; }
.client-cell:hover strong { color: var(--color-primary-dark); }
.client-mark {
  width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px;
  background: var(--color-primary-soft); color: var(--color-primary-dark); font-family: var(--font-display); font-weight: 800;
}
.client-name { display: flex; flex-direction: column; min-width: 0; }
.client-name small { color: var(--color-text-muted); font-weight: 500; }
.mono-cell { font-family: var(--font-mono); font-size: 0.86rem; white-space: nowrap; }
.status-warn { background: var(--color-warn-bg); color: var(--color-warn-text); }
.row-go { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--color-text-muted); }
.row-go:hover { background: var(--color-surface-2); color: var(--color-text); }
@media (max-width: 900px) { .console-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.print-note a { color: var(--color-on-ink); font-weight: 700; }

/* --- Packages (packages and powers, stage 2) ----------------------------- */
.pill-choice { background: var(--color-warn-bg); color: var(--color-warn-text); }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px; font-weight: 600; font-size: 0.9rem; text-decoration: none; color: var(--color-text-muted); }
.back-link:hover { color: var(--color-text); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.package-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.package-card {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-1);
  transition: box-shadow 0.2s, transform 0.15s var(--ease-out);
}
.package-card:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.package-card.is-retired { opacity: 0.7; }
.package-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.package-card-head h2 { font-size: 1.2rem; }
.package-card-head a { color: var(--color-text); text-decoration: none; }
.package-card-head a:hover { color: var(--color-primary-dark); }
.package-meter { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--color-neutral-bg); }
.package-meter span { width: var(--w); }
.package-meter .seg-inc { background: var(--color-primary); }
.package-meter .seg-choice { background: var(--color-accent); }
.package-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0; }
.package-facts div { display: flex; flex-direction: column; }
.package-facts dt { font-size: 0.74rem; color: var(--color-text-muted); font-weight: 600; }
.package-facts dd { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.package-line { font-size: 0.88rem; color: var(--color-text-muted); }
.package-line strong { color: var(--color-text); }

.state-list { display: flex; flex-direction: column; margin-bottom: 18px; }
.state-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--color-border); }
.state-row:first-child { border-top: none; }
.state-name { display: flex; flex-direction: column; min-width: 0; }
.state-name small { color: var(--color-text-muted); font-size: 0.82rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.state-seg { display: inline-grid; grid-template-columns: repeat(3, auto); gap: 2px; padding: 3px; border-radius: 10px; background: var(--color-surface-2); border: 1px solid var(--color-border); }
.state-seg.two { grid-template-columns: repeat(2, auto); }
.state-seg input { position: absolute; opacity: 0; pointer-events: none; }
.state-seg label {
  padding: 7px 11px; border-radius: 8px; font-size: 0.82rem; font-weight: 600; color: var(--color-text-muted); cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.state-seg label:hover { color: var(--color-text); }
.state-seg input:checked + label { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1); }
.state-seg input:checked + label.state-inc { color: var(--color-primary-dark); }
.state-seg input:checked + label.state-choice { color: var(--color-warn-text); }
.state-seg input:focus-visible + label { outline: 2px solid var(--color-focus, var(--color-primary)); outline-offset: 1px; }
@media (max-width: 640px) {
  .state-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .state-seg label { padding: 7px 8px; }
}

.package-assign { display: grid; gap: 12px; max-width: 720px; }
.package-assign-opts { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.package-preview { padding: 14px; border-radius: var(--radius); background: var(--color-surface-2); border: 1px solid var(--color-border); }
.package-preview:empty { display: none; }
.preview-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 0.88rem; }
.preview-changes { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; }
.preview-changes li { display: flex; align-items: center; gap: 8px; }
.preview-changes .turns-on .icon { color: var(--color-primary); }
.preview-changes .turns-off .icon { color: var(--color-danger); }
.exceptions > summary { cursor: pointer; padding: 6px 0; list-style-position: outside; }
.exceptions-table select { min-height: 38px; padding: 6px 10px; }
.exceptions-table .group-row th { background: transparent; padding-top: 16px; color: var(--color-text); letter-spacing: 0.04em; }
.exceptions-table tr.has-exception td:first-child { box-shadow: inset 3px 0 0 var(--color-accent); font-weight: 700; }
.limit-field { border: none; padding: 0; margin: 0 0 16px; min-width: 0; }
.notice-read-only { background: var(--color-neutral-bg); color: var(--color-text); }
.lock-pill { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; padding: 4px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; background: var(--color-primary-soft); color: var(--color-primary-dark); }
.module-card.is-included { border-color: color-mix(in srgb, var(--color-primary) 30%, var(--color-border)); }
.module-card.is-included .module-icon { background: var(--color-primary-soft); color: var(--color-primary); }
.outside-package { margin-top: 0; padding-top: 18px; border-top: 1px dashed var(--color-border-strong); }
.module-card.is-outside { border-style: dashed; box-shadow: none; }
.module-card.is-outside .module-icon { color: var(--color-text-muted); }
.module-outside-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 0 14px 14px; }
.read-only-note, .asked-note { display: inline-flex; align-items: center; gap: 5px; font-size: 0.82rem; font-weight: 600; color: var(--color-text-muted); }
.read-only-note a { margin-left: 4px; }
.module-card.is-included .module-main, .module-card.is-outside .module-main { cursor: default; }
.lock-fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.lock-fieldset[disabled] .field-input, .lock-fieldset[disabled] .chip-check, .lock-fieldset[disabled] .switch-row { opacity: 0.75; cursor: not-allowed; }
.lock-note { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--color-primary-soft); color: var(--color-primary-dark); font-weight: 600; font-size: 0.9rem; }
.lock-note .icon { margin-top: 2px; }
/* "3 of 5 used" meters (packages and powers, stage 5) */
.limit-meter { display: grid; gap: 6px; max-width: 360px; margin: 0 0 16px; font-size: 0.9rem; }
.limit-meter-bar { height: 6px; border-radius: 999px; background: var(--color-border); overflow: hidden; }
.limit-meter-bar span { display: block; height: 100%; border-radius: 999px; background: var(--color-primary); }
.limit-meter.is-full .limit-meter-text { color: var(--color-warn-text); }
.limit-meter.is-full .limit-meter-bar span { background: var(--color-warn-text); }
.set-by-arfa { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--color-primary-dark); }
.role-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.role-option { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); cursor: pointer; background: var(--color-surface); }
.role-option:has(input:checked) { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); }
.role-option small { display: block; color: var(--color-text-muted); font-weight: 400; }
.perm-row.is-capped { opacity: 0.6; }
.plain-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
/* The "Changes" list (packages and powers, stage 6) */
.change-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.change-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.change-row:last-child { border-bottom: 0; }
.change-icon { flex-shrink: 0; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; background: var(--color-primary-soft); color: var(--color-primary-dark); }
.change-text { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
a.cat-chip { text-decoration: none; display: inline-flex; align-items: center; }
.login-switches { border-top: 1px solid var(--color-border); padding-top: 12px; margin-top: 8px; }
.request-list { display: grid; gap: 8px; padding: 14px; margin-bottom: 18px; border-radius: var(--radius); background: var(--color-warn-bg); }
.request-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.request-row > span:first-of-type { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* A read-only module (taken away by the package while it held records):
   its pages open, but the actions that would save are hidden - the
   server refuses them anyway. Printing and exports are plain links. */
.is-read-only .app-main form[method="post"], .is-read-only .app-main form[method="POST"],
.is-read-only .app-main a[href$="/new"], .is-read-only .app-main a[href*="/new?"],
.is-read-only .app-main a[href$="/edit"] { display: none !important; }
.power-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 12px 24px; }
.power-row.is-fixed { opacity: 0.6; cursor: not-allowed; }

/* Second-hand goods (margin scheme) */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.plain-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.plain-list li { overflow-wrap: anywhere; }
.step-list { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; }
.step-list li::marker { font-weight: 700; color: var(--color-primary-dark); }
.seller-kind { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-bottom: 12px; }
.buy-line { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.buy-line .new-item { grid-column: 1 / -1; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 8px; }
.buy-line .serials { grid-column: 1 / -1; }
@media (max-width: 720px) { .buy-line, .buy-line .new-item { grid-template-columns: 1fr 1fr; } }
.preview-box { position: sticky; top: 76px; }
.preview-box .preview-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.preview-box .preview-row.total { border-top: 1px solid var(--color-border); margin-top: 6px; padding-top: 8px; font-weight: 700; }
.preview-box .is-loss { color: var(--color-danger); }
.sell-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .sell-layout { grid-template-columns: 1fr; } .preview-box { position: static; } }
.sell-table input[type=number] { max-width: 130px; }
.law-note { font-size: 0.9rem; }
a.stat-tile { display: block; color: inherit; text-decoration: none; }
a.stat-tile .stat-label, a.stat-tile .stat-sub { text-decoration: none; }

/* The one catalogue (console cleanup, stage 1): kind headings, area
   titles under them, add-ons indented under the module they need. */
.kind-heading { display: flex; flex-direction: column; gap: 2px; margin: 26px 0 10px; padding-top: 16px; border-top: 1px solid var(--color-border); font-size: 1.15rem; }
.kind-heading small { font-family: var(--font-body); font-size: 0.84rem; font-weight: 500; color: var(--color-text-muted); }
.card .kind-heading:first-of-type, .settings-form .kind-heading:first-of-type { border-top: none; padding-top: 0; margin-top: 8px; }
h4.module-group-title { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin: 14px 0 2px; }
.kind-count { margin: -4px 0 10px; }
.state-row.is-addon { padding-left: 22px; position: relative; }
.state-row.is-addon::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 50%; width: 10px; border-left: 2px solid var(--color-border-strong); border-bottom: 2px solid var(--color-border-strong); border-bottom-left-radius: 6px; }
.needs-note { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 0.78rem; font-weight: 600; color: var(--color-text-muted); }
.needs-note.is-off { color: var(--color-warn-text); }
.module-card.is-addon { border-left: 3px solid var(--color-border-strong); }
.module-needs { display: flex; align-items: center; gap: 6px; margin: 0 14px 10px 64px; font-size: 0.82rem; font-weight: 600; color: var(--color-warn-text); }
.business-type-note { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; padding: 10px 14px; border-radius: var(--radius); background: var(--color-surface-2); border: 1px solid var(--color-border); font-size: 0.9rem; }
.business-type-note a { margin-left: 6px; font-weight: 700; }
.type-brings { display: flex; align-items: center; gap: 8px; margin: -4px 0 4px; font-size: 0.88rem; color: var(--color-text-muted); }
.exceptions-table .kind-row th { background: var(--color-surface-2); padding-top: 12px; color: var(--color-text); font-size: 0.95rem; text-transform: none; letter-spacing: 0; }
.exceptions-table tr.is-addon td:first-child { padding-left: 26px; }
.exceptions-table .needs-note { display: flex; }
.chip-kind { margin: 12px 0 6px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
@media (max-width: 640px) {
  .module-needs { margin-left: 14px; }
}

/* Console Today page (console cleanup, stage 2). */
a.console-stat { text-decoration: none; }
.console-stat.is-static { cursor: default; }
.console-stat.is-static:hover { transform: none; box-shadow: var(--shadow-1); }
.console-stat-icon.tone-info { background: var(--color-info-bg); color: var(--color-info-text); }
.today-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.today-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.today-item { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 14px; background: var(--color-surface); }
.today-item.tone-bad { border-left: 3px solid var(--color-danger); }
.today-item.tone-warn { border-left: 3px solid var(--color-warn-text); }
.today-item-head { display: flex; align-items: center; gap: 12px; }
.today-item-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.today-item-text small { color: var(--color-text-muted); font-size: 0.84rem; }
.today-rows { list-style: none; margin: 10px 0 0 52px; padding: 0; border-top: 1px solid var(--color-border); }
.today-rows a { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--color-border); color: var(--color-text); text-decoration: none; font-size: 0.92rem; }
.today-rows a span { font-weight: 600; }
.today-rows a small { color: var(--color-text-muted); margin-left: auto; }
.today-rows a:hover { color: var(--color-primary-dark); }
.today-rows li:last-child a { border-bottom: none; }
.today-more a { color: var(--color-primary-dark); font-weight: 700; }
.today-feed { list-style: none; margin: 0; padding: 0; }
.today-feed li { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 8px; padding: 9px 0; border-top: 1px solid var(--color-border); font-size: 0.9rem; }
.today-feed li:first-child { border-top: none; }
.today-feed time { color: var(--color-text-muted); font-variant-numeric: tabular-nums; font-weight: 600; }
.today-feed small { display: block; color: var(--color-text-muted); }
.today-feed a { color: var(--color-text); }
/* Clients and Auditors lists: one row of filter chips with counts. */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); font: inherit; font-weight: 600; font-size: 0.9rem;
}
.filter-chip:hover { border-color: var(--color-border-strong); }
.filter-chip.is-on { background: var(--color-inverse); border-color: var(--color-inverse); color: var(--color-on-inverse); }
.filter-chip b { font-variant-numeric: tabular-nums; font-weight: 700; opacity: 0.75; }
.filter-chip:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (max-width: 900px) {
  .today-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .today-rows { margin-left: 0; }
  .today-item-head { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px; row-gap: 10px; align-items: start; }
  .today-item-head .btn { grid-column: 2; justify-self: start; }
}

/* A client's page in tabs (console cleanup, stage 3). */
.client-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.client-mark-lg { width: 48px !important; height: 48px !important; font-size: 1.3rem !important; border-radius: 14px !important; flex-shrink: 0; }
.client-head .text-muted { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.client-tabs { position: sticky; top: var(--topbar-h, 60px); z-index: 20; background: var(--color-bg); margin-top: 4px; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.client-tabs a { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--color-surface-2); color: var(--color-text-muted); font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tab-count.is-alert { background: var(--color-warn-bg); color: var(--color-warn-text); }
.tab-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-warn-text); }
.client-panel { animation: panel-in 0.18s var(--ease-out); }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }
.notice-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 14px; border-radius: var(--radius); background: var(--color-warn-bg); color: var(--color-warn-text); text-decoration: none; }
.notice-row span { flex: 1 1 auto; color: var(--color-text); }
.client-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 20px; margin: 0; }
.client-facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.client-facts dt { font-size: 0.78rem; font-weight: 600; color: var(--color-text-muted); }
.client-facts dd { margin: 0; font-weight: 700; display: flex; flex-direction: column; }
.client-facts dd small { font-weight: 500; color: var(--color-text-muted); font-size: 0.82rem; }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.client-logo { width: 72px; height: 72px; object-fit: contain; border-radius: var(--radius); border: 1px solid var(--color-border); background: #fff; }
.login-table td { vertical-align: middle; }
.row-end { justify-content: flex-end; }
.block { display: block; }
.maxw-360 { max-width: 360px; }
.menu-wrap .more-pop { min-width: 220px; }
.menu-wrap .more-pop .btn small { font-weight: 500; margin-left: 4px; }
.seg-pills { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--color-surface-2); border: 1px solid var(--color-border); flex-wrap: wrap; }
.seg-pills button { border: none; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--color-text-muted); cursor: pointer; }
.seg-pills button.is-on { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1); }
.seg-pills b { font-variant-numeric: tabular-nums; opacity: 0.7; margin-left: 2px; }
@media (max-width: 900px) {
  .client-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
}
/* "Only what differs": a client's exceptions table shows just their own changes. */
.exceptions-table.only-changed tbody tr:not(.has-exception) { display: none; }

/* The package editor in tabs (console cleanup, stage 4). Tabs are buttons
   here - switching mustn't leave the unsaved form. */
.subnav .tab-btn {
  position: relative; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border: none;
  background: transparent; font: inherit; font-weight: 600; color: var(--color-text-muted); white-space: nowrap; cursor: pointer;
}
.subnav .tab-btn::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0;
  background: var(--color-primary); transform: scaleX(0); transition: transform 0.22s var(--ease-out);
}
.subnav .tab-btn:hover { color: var(--color-text); }
.subnav .tab-btn.active { color: var(--color-primary-dark); }
.subnav .tab-btn.active::after { transform: scaleX(1); }
.subnav .tab-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; border-radius: 8px; }
.editor-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.set-all { gap: 6px; flex-wrap: wrap; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.type-card { position: relative; display: flex; cursor: pointer; }
.type-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.type-card > span {
  flex: 1; display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: var(--radius-lg);
  border: 1px solid var(--color-border); background: var(--color-surface); transition: border-color 0.15s, box-shadow 0.15s;
}
.type-card small { color: var(--color-text-muted); font-size: 0.82rem; }
.type-card:hover > span { border-color: var(--color-border-strong); }
.type-card input:checked + span { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.type-card input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.editor-save {
  position: sticky; bottom: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -4px; padding: 12px 16px; border-radius: var(--radius-lg); border: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow-2);
}
/* Compare packages. */
.compare-table th, .compare-table td { text-align: center; white-space: nowrap; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; white-space: normal; min-width: 220px; position: sticky; left: 0; background: var(--color-surface); z-index: 1; }
.compare-table td.is-addon-cell { padding-left: 28px; }
.compare-table tr.differs td:first-child { box-shadow: inset 3px 0 0 var(--color-accent); font-weight: 700; }
.compare-table .group-row th { text-align: left; background: var(--color-surface-2); }
.cmp { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 8px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
.cmp-inc { background: var(--color-success-bg); color: var(--color-primary-dark); }
.cmp-choice { background: var(--color-warn-bg); color: var(--color-warn-text); }
.cmp-off { color: var(--color-text-muted); }
.compare-table.only-diff tbody tr.same { display: none; }
@media (max-width: 640px) {
  .editor-save { flex-direction: column; align-items: stretch; }
}
.package-for { display: flex; align-items: center; gap: 6px; font-size: 0.86rem; font-weight: 600; color: var(--color-primary-dark); }

/* Onboarding in three steps (console cleanup, stage 5). */
.onboard { max-width: 920px; }
.stepper { list-style: none; display: flex; gap: 8px; margin: 0 0 16px; padding: 0; counter-reset: step; flex-wrap: wrap; }
.stepper li { flex: 1 1 0; min-width: 140px; }
.stepper button {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-lg); cursor: pointer;
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text-muted); font: inherit; font-weight: 600; text-align: left;
}
.step-num { width: 26px; height: 26px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; background: var(--color-surface-2); font-size: 0.82rem; font-weight: 700; }
.stepper li.is-on button { border-color: var(--color-primary); color: var(--color-text); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.stepper li.is-on .step-num, .stepper li.is-done .step-num { background: var(--color-primary); color: var(--color-on-ink, #fff); }
.stepper li.is-done button { color: var(--color-text); }
.step-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 6px; }
.package-peek, .final-check .client-facts { padding: 14px; border-radius: var(--radius); background: var(--color-surface-2); border: 1px solid var(--color-border); }
.final-check { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--color-border); }
@media (max-width: 640px) { .stepper li { min-width: 0; } .stepper button { padding: 8px; font-size: 0.86rem; } }

/* The audit log's filters (console cleanup, stage 5). */
.audit-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.audit-filter-actions { display: flex; gap: 8px; }
.audit-table td { vertical-align: top; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; }

/* Pairing a phone for the ARFA Counter app (counter app, stage 1). */
.pair-show { max-width: 560px; }
.pair-steps { margin: 0 0 8px; padding-left: 20px; line-height: 1.6; }
.pair-steps code { display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.pair-big { display: flex; gap: 14px; margin: 10px 0 12px; font: 800 3rem/1 var(--font-mono); letter-spacing: 0.12em; color: var(--color-primary-dark); }
.pair-big span { padding: 12px 16px; border-radius: 16px; background: var(--color-primary-soft); }
@media (max-width: 640px) { .pair-big { font-size: 2.2rem; } }
.devices-note { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--color-info-bg); color: var(--color-info-text); }

/* The app's own confirm / question box (static/js/dialog.js) - used in
   place of the browser's confirm() and prompt(), which the Android app
   can't show. */
.arfa-dialog-scrim { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: var(--color-scrim-strong); animation: arfa-dialog-fade 0.14s ease-out; }
.arfa-dialog { width: min(420px, 100%); padding: 22px 20px 18px; border-radius: var(--radius-lg); background: var(--color-surface);
  color: var(--color-text); border: 1px solid var(--color-border); box-shadow: var(--shadow-3); animation: arfa-dialog-rise 0.18s ease-out; }
.arfa-dialog-text { margin: 0 0 16px; font-size: 1.02rem; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.arfa-dialog-input { width: 100%; margin: 0 0 6px; resize: vertical; min-height: 64px; font: inherit; }
.arfa-dialog-error { margin: 0 0 8px; color: var(--color-danger); font-size: 0.88rem; font-weight: 600; }
.arfa-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.arfa-dialog-actions .btn { min-width: 96px; min-height: 44px; }
/* One deep red in both themes: white text stays readable on it in dark mode too. */
.arfa-dialog-actions .btn-danger { background: #b3261e; color: #fff; border-color: #b3261e; }
.arfa-dialog-actions .btn-danger:hover { background: #8f1d17; border-color: #8f1d17; }
html.arfa-dialog-open { overflow: hidden; }
@keyframes arfa-dialog-fade { from { opacity: 0; } }
@keyframes arfa-dialog-rise { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .arfa-dialog-scrim, .arfa-dialog { animation: none; } }
@media print { .arfa-dialog-scrim { display: none; } }

/* Edit a client's details (console): one block per business location. */
.location-edit { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0 0 12px; }
.location-edit legend { padding: 0 6px; font-weight: 700; }
.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.plain-facts { display: grid; gap: 8px; margin: 0 0 10px; }
.plain-facts > div { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 10px; }
.plain-facts dt { color: var(--color-text-muted); font-size: 0.9rem; }
.plain-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 520px) { .plain-facts > div { grid-template-columns: 1fr; gap: 2px; } }

/* Console: each module Off / On (locked) / Client decides for one client. */
.module-locks { width: 100%; }
.module-locks td { vertical-align: middle; }
.module-locks .kind-row th { background: var(--color-surface-2); text-transform: none; letter-spacing: 0; font-size: 0.95rem; }
.module-locks .group-row th { background: transparent; padding-top: 14px; }
.module-locks tr.has-exception td:first-child { box-shadow: inset 3px 0 0 var(--color-accent); }
.module-locks tr.is-addon td:first-child { padding-left: 26px; }
.lock-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--color-surface-2); border: 1px solid var(--color-border); }
.lock-seg label { position: relative; }
.lock-seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.lock-seg span { display: block; padding: 6px 12px; border-radius: 8px; font-size: 0.86rem; font-weight: 600; color: var(--color-text-muted); white-space: nowrap; }
.lock-seg input:checked + span { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1); }
.lock-seg .lock-seg-off input:checked + span { color: var(--color-danger); }
.lock-seg .lock-seg-on input:checked + span { color: var(--color-primary); }
.lock-seg input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.lock-note { display: inline-flex; align-items: center; gap: 4px; color: var(--color-text-muted); font-size: 0.86rem; }
.d-block { display: block; }
.maxw-260 { max-width: 260px; }
.maxw-560 { max-width: 560px; }

/* --- Scan bills (app/scan) ------------------------------------------------------------------- */
.row-between { justify-content: space-between; }
.scan-drop { border: 2px dashed var(--color-border-strong); text-align: center; }
.scan-drop.is-over { border-color: var(--color-primary); background: var(--color-success-bg); }
.scan-drop-inner { display: grid; justify-items: center; gap: 10px; padding: 8px 0; }
.scan-drop-icon { width: 36px; height: 36px; color: var(--color-primary); }
.scan-pick { justify-content: center; flex-wrap: wrap; }
.scan-tip { font-size: 0.85rem; }
@media (hover: hover) and (pointer: fine) { .scan-camera { display: none; } }
.scan-queue { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.scan-queue:empty { display: none; }
.scan-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px;
  background: var(--color-surface); font-size: 0.9rem; }
.scan-row-name { overflow-wrap: anywhere; }
.scan-row-state { color: var(--color-text-muted); text-align: right; }
.scan-row-state.is-ok { color: var(--color-primary-dark); font-weight: 600; }
.scan-row-state.is-warn, .scan-warn { color: var(--color-warn-text); }
.scan-row-state.is-bad { color: var(--color-danger, #b42318); }
.scan-queue-done { margin-top: 12px; }
.scan-list { display: grid; gap: 8px; }
.scan-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  color: inherit; text-decoration: none; padding: 10px 12px; }
.scan-item:hover { border-color: var(--color-border-strong); }
.scan-thumb { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; background: var(--color-surface);
  display: grid; place-items: center; }
.scan-thumb img { width: 100%; height: 100%; object-fit: cover; }
.scan-item-body { min-width: 0; overflow-wrap: anywhere; }
.scan-item-end { display: grid; justify-items: end; gap: 4px; }
/* The review uses the whole screen: the page isn't held to the usual width,
   and once there is room for the invoice beside it the bill sits in a tall
   viewer on the left that zooms to whatever is pointed at (scan_zoom.js). */
.is-wide .app-main { max-width: none; }
.scan-review-wrap { container-type: inline-size; }
.scan-review { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.scan-picture { display: grid; gap: 8px; padding: 10px; }
.scan-viewer { position: relative; height: min(62vh, 760px); overflow: hidden; border-radius: 8px;
  background: var(--color-bg, #f4f4f0); touch-action: pan-y; }
.scan-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0;
  transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.2, 1); will-change: transform; }
.scan-stage-img { display: block; width: 100%; height: 100%; user-select: none; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12); }
.scan-stage-mark { position: absolute; border: 2px solid var(--color-primary); border-radius: 3px;
  background: rgba(31, 122, 77, 0.10); box-shadow: 0 0 0 4000px rgba(20, 24, 22, 0.18); pointer-events: none; }
.scan-viewer.is-zoomed .scan-viewer-hint { opacity: 0; }
.scan-all-mark { position: absolute; padding: 0; margin: 0; cursor: pointer; border-radius: 2px;
  border: var(--mark-w, 1.5px) solid rgba(31, 122, 77, 0.85); background: rgba(31, 122, 77, 0.12); }
.scan-all-mark:hover, .scan-all-mark:focus-visible { background: rgba(31, 122, 77, 0.32); outline: none; }
.scan-viewer.is-showing-all .scan-lens { display: none; }
[data-show-all][aria-pressed="true"] { background: var(--color-primary-soft); color: var(--color-primary); }
.scan-invoice .is-pointed, .scan-invoice .is-pointed .inv-input { background: var(--color-primary-soft); transition: background 0.3s ease; }
.scan-viewer-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 4px 10px;
  border-radius: 999px; background: rgba(20, 24, 22, 0.72); color: #fff; font-size: 0.78rem; white-space: nowrap;
  pointer-events: none; transition: opacity 0.2s ease; }
.scan-viewer-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; font-size: 0.88rem; }
@container (min-width: 1240px) {
  .scan-review { grid-template-columns: minmax(400px, 0.85fr) minmax(800px, 1.4fr); }
  .scan-picture { position: sticky; top: 76px; }
  .scan-viewer { height: calc(100vh - 160px); min-height: 420px; }
}
@media (prefers-reduced-motion: reduce) { .scan-stage { transition: none; } }
.scan-verdict { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 8px; font-weight: 600; }
.scan-verdict.is-ok { color: var(--color-primary-dark); }
.scan-verdict.is-warn { color: var(--color-warn-text); }
.scan-verdict.is-bad { color: var(--color-danger, #b42318); }
.scan-check-list { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: 0.9rem; }
.scan-check-list .is-bad strong { color: var(--color-danger, #b42318); }
.scan-flag .field-input { border-color: var(--color-warn-text); background: var(--color-warn-bg); }
.scan-lines .field-input { min-width: 0; padding: 6px 8px; }
.scan-lines td { padding: 4px; vertical-align: middle; }
.scan-w-hsn { width: 90px; } .scan-w-num { width: 90px; } .scan-w-unit { width: 70px; } .scan-w-small { width: 76px; }
.scan-total { padding: 10px 12px; border-radius: 8px; background: var(--color-surface); }
.scan-total.is-off { background: var(--color-warn-bg); }
.scan-w-item { min-width: 160px; }
.scan-totals { width: 100%; max-width: 420px; border-collapse: collapse; }
.scan-totals td { padding: 4px 0; border-bottom: 1px solid var(--color-border); }
.scan-totals-grand td { font-weight: 700; border-bottom: 0; padding-top: 8px; }
.scan-line-list { display: grid; gap: 10px; }
.scan-line { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; }
.scan-line-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; }
.scan-line-nums { display: grid; grid-template-columns: 1.5fr 0.9fr 0.9fr 1.4fr 0.9fr 1fr 1.3fr 34px; gap: 6px; align-items: end; }
.scan-line .field { margin: 0; min-width: 0; }
.scan-line .field-label { font-size: 0.75rem; }
.scan-line .field-input { padding: 7px 6px; min-width: 0; }
.scan-line-amount { display: block; padding: 8px 0; }
.scan-line-remove { align-self: end; padding: 6px; min-width: 0; }
@media (max-width: 640px) {
  .scan-line-top { grid-template-columns: minmax(0, 1fr); }
  .scan-line-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Scan bills - the review screen as a tax invoice */
.scan-invoice { display: grid; gap: 14px; padding: 18px 20px; }
.inv-head { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px;
  padding-bottom: 14px; border-bottom: 2px solid var(--color-text, #1f2a24); }
.inv-party, .inv-meta { display: grid; gap: 6px; align-content: start; }
.inv-meta { border-left: 1px solid var(--color-border); padding-left: 16px; }
.inv-meta label, .inv-pair label { display: grid; gap: 2px; }
.inv-pair { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.inv-ledger { display: grid; gap: 2px; padding-bottom: 6px; margin-bottom: 2px; border-bottom: 1px dashed var(--color-border); }
.inv-title { margin: 0 0 4px; font-weight: 800; letter-spacing: 0.08em; font-size: 0.95rem; }
.inv-title small { font-weight: 500; letter-spacing: 0; color: var(--color-text-muted); }
.inv-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.scan-invoice .inv-input, .scan-invoice .inv-select { width: 100%; min-width: 0; min-height: 0; font: inherit;
  font-size: inherit; color: inherit; background: transparent; border: 0;
  border-bottom: 1px dashed var(--color-border-strong); border-radius: 0; padding: 4px 2px; box-shadow: none; }
.scan-invoice .inv-input:hover, .scan-invoice .inv-select:hover { background: var(--color-surface); }
.scan-invoice .inv-input:focus, .scan-invoice .inv-select:focus { outline: none; box-shadow: none;
  border-bottom: 2px solid var(--color-primary); background: var(--color-surface); }
.scan-invoice .inv-input.is-flagged, .scan-invoice .is-flagged .inv-input, .scan-invoice .inv-select.is-flagged {
  background: var(--color-warn-bg); border-bottom-color: var(--color-warn-text); }
.scan-invoice .inv-name { font-size: 1.15rem; font-weight: 700; }
.inv-mono { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.inv-static { padding: 4px 2px; }
.inv-note { margin: 0; font-size: 0.82rem; color: var(--color-text-muted); }
.inv-check { display: flex !important; align-items: center; gap: 6px; font-size: 0.9rem; }
.inv-table-wrap { margin: 0; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.inv-table th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted);
  text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--color-border-strong); white-space: nowrap; }
.inv-table td { padding: 4px 3px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.inv-table td.num { padding-top: 8px; white-space: nowrap; }
.inv-table th.num, .inv-summary th.num { text-align: right; }
.inv-sno { color: var(--color-text-muted); width: 24px; }
.inv-desc { min-width: 150px; width: 30%; }
.inv-item { font-size: 0.78rem; color: var(--color-text-muted); }
.scan-invoice .inv-w-hsn { width: 78px; } .scan-invoice .inv-w-qty { width: 46px; } .scan-invoice .inv-w-unit { width: 50px; }
.scan-invoice .inv-w-rate { width: 84px; }
.scan-invoice .inv-w-disc { width: 58px; }
.inv-disc { white-space: nowrap; }
.scan-invoice .inv-table .inv-disc-type { width: auto; font-size: 0.74rem; color: var(--color-text-muted); padding: 2px 0; } .scan-invoice .inv-w-gst { width: 66px; padding-right: 0; }
.scan-invoice .inv-table .inv-input, .scan-invoice .inv-table .inv-select { font-size: 0.86rem; padding: 4px 1px; }
.inv-remove { border: 0; background: none; color: var(--color-text-muted); cursor: pointer; padding: 6px 2px; }
.inv-remove:hover { color: var(--color-danger); }
.inv-remove:disabled { opacity: 0.3; cursor: default; }
.inv-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); gap: 18px; align-items: start;
  border-top: 2px solid var(--color-text, #1f2a24); padding-top: 12px; }
.inv-summary { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.inv-summary th { font-size: 0.7rem; text-transform: uppercase; color: var(--color-text-muted); padding: 4px; border-bottom: 1px solid var(--color-border); }
.inv-summary td { padding: 4px; border-bottom: 1px solid var(--color-border); }
.inv-totals { margin: 0; display: grid; gap: 2px; }
.inv-totals > div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.inv-totals dt { color: var(--color-text-muted); }
.inv-totals dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }
.inv-grand { border-top: 1px solid var(--color-border-strong); margin-top: 4px; padding-top: 6px !important; font-weight: 800; font-size: 1.05rem; }
.inv-grand dt { color: inherit; }
.inv-printed dd { width: 120px; }
.scan-invoice .inv-printed .inv-input { text-align: right; font-weight: 700; }
.inv-diff { color: var(--color-warn-text); font-weight: 700; }
.inv-diff dt { color: inherit; }
.inv-qr { display: inline-block; padding: 0 5px; border-radius: 4px; background: var(--color-primary-soft);
  color: var(--color-primary); font-weight: 700; font-size: 0.62rem; letter-spacing: 0.04em; vertical-align: 1px; }
.inv-more-btn { display: block; border: 0; background: none; padding: 2px 1px; cursor: pointer; text-align: left;
  font: inherit; font-size: 0.76rem; color: var(--color-primary); }
.inv-more-btn:hover { text-decoration: underline; }
.inv-table tr.inv-more td { background: var(--color-surface-alt, rgba(0, 0, 0, 0.025)); padding: 6px 4px 10px; }
.inv-line tr:first-child td { border-bottom-style: dashed; }
.inv-more-grid { display: grid; gap: 8px 12px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.inv-more-grid label, .inv-details-grid label { display: grid; gap: 2px; }
.inv-more-serials { grid-column: span 2; }
.scan-invoice .inv-more-grid textarea { resize: vertical; min-height: 44px; }
.inv-tds dt { display: flex; align-items: center; gap: 6px; }
.scan-invoice .inv-tds .inv-select { width: auto; font-size: 0.8rem; padding: 2px; }
.inv-tds dd { width: 120px; }
.scan-invoice .inv-tds .inv-input { text-align: right; }
.inv-details { border-top: 1px solid var(--color-border); padding-top: 10px; }
.inv-details summary { cursor: pointer; }
.inv-details-grid { display: grid; gap: 8px 14px; margin: 10px 0 6px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.detail-list { display: grid; gap: 6px 18px; margin: 8px 0 0; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.detail-list dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
/* Pointing at a value shows where on the bill it was read (scan_zoom.js). */
.scan-zoom { position: fixed; z-index: 60; padding: 6px; border-radius: 10px; background: var(--color-surface);
  border: 1px solid var(--color-border-strong); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  opacity: 0; transform: translateY(4px) scale(0.98); transition: opacity 0.14s ease, transform 0.14s ease;
  pointer-events: none; }
.scan-zoom.is-on { opacity: 1; transform: none; }
.scan-zoom-view { position: relative; border-radius: 6px; background-color: #fff; background-repeat: no-repeat; }
.scan-zoom-mark, .scan-pic-mark { position: absolute; border: 2px solid var(--color-primary); border-radius: 4px;
  background: rgba(31, 122, 77, 0.10); box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.0); pointer-events: none; }
.scan-pic-mark { box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.25); transition: all 0.12s ease; }
.scan-zoom-caption { display: block; padding: 4px 2px 0; font-size: 0.72rem; color: var(--color-text-muted); }
.scan-lens { position: absolute; z-index: 2; width: 220px; height: 220px; border-radius: 50%; pointer-events: none;
  border: 2px solid var(--color-surface); box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35); background-color: #fff;
  background-repeat: no-repeat; }
.scan-zoom-tip { font-size: 0.8rem; }
[data-zoom] { cursor: help; }
.scan-invoice input[data-zoom], .scan-invoice textarea[data-zoom] { cursor: text; }
@media (prefers-reduced-motion: reduce) { .scan-zoom { transition: none; } }
@media (max-width: 760px) {
  .inv-head, .inv-foot, .inv-pair { grid-template-columns: minmax(0, 1fr); }
  .inv-meta { border-left: 0; padding-left: 0; border-top: 1px solid var(--color-border); padding-top: 10px; }
}
.scan-app-card { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: flex-start; justify-content: space-between; }
.scan-app-card-text { flex: 1 1 340px; display: grid; gap: 6px; }
.scan-app-card h2 { font-size: 1.05rem; display: flex; gap: 8px; align-items: center; }
.scan-approvers { display: grid; gap: 8px; flex: 0 1 420px; }
.scan-approvers fieldset { border: 0; padding: 0; display: grid; gap: 6px; }
/* The list's search and filters (scan_list.js). */
.scan-finder { display: grid; gap: 10px; padding: 12px 14px; margin-bottom: 12px; }
.scan-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--color-border-strong);
  border-radius: 10px; background: var(--color-surface); }
.scan-search:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.scan-search input[type="search"] { flex: 1; min-width: 0; border: 0; outline: none; box-shadow: none; background: none;
  font: inherit; font-size: 1.02rem; padding: 11px 0; margin: 0; }
.scan-search kbd { font-size: 0.75rem; padding: 1px 6px; border: 1px solid var(--color-border); border-radius: 4px;
  color: var(--color-text-muted); }
.scan-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.scan-filters .field-input { width: auto; min-width: 150px; max-width: 280px; margin: 0; padding-top: 6px; padding-bottom: 6px; }
.scan-range { display: inline-flex; gap: 6px; align-items: center; }
.scan-range[hidden] { display: none; }
.scan-count { font-size: 0.85rem; }
.scan-queue-table mark { background: #fde68a; color: inherit; border-radius: 2px; padding: 0 1px; }
.scan-queue-table th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
.scan-queue-table th[data-sort]:hover { color: var(--color-text); }
.scan-queue-table th[aria-sort="ascending"]::after { content: " ▲"; font-size: 0.7em; }
.scan-queue-table th[aria-sort="descending"]::after { content: " ▼"; font-size: 0.7em; }
.scan-queue-table tr[hidden] { display: none; }
.scan-when { font-size: 0.86rem; }
.scan-why { max-width: 260px; white-space: normal; }
.scan-queue-table td { white-space: nowrap; vertical-align: middle; }
.scan-queue-table td:nth-child(2) { white-space: normal; min-width: 180px; }
.scan-queue-table .pill { white-space: nowrap; }
