/* Retail ERP: shared styles for the back-office prototype.
   MOBILE FIRST: base rules are for a phone (about 360px).
   Wider layouts are added with min-width media queries: 640px, 720px, 960px.
   Palette and type follow the leadstreet design system tokens. */

:root {
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-2: #525252;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;

  --primary: #d02329;
  --primary-600: #b91c21;
  --primary-700: #9a171b;
  --primary-50: #fef2f2;
  --primary-200: #fccaca;

  --slate-100: #e9edf2;
  --slate-700: #33475b;

  --neutral-50: #fafafa;
  --neutral-100: #f5f5f5;
  --neutral-200: #e5e5e5;
  --neutral-300: #d4d4d4;
  --neutral-400: #a3a3a3;
  --neutral-700: #404040;
  --neutral-800: #262626;

  --success-50: #f0fdf4;
  --success-200: #bbf7d0;
  --success-700: #15803d;
  --warning-50: #fffbeb;
  --warning-100: #fef9c3;
  --warning-200: #fde68a;
  --warning-300: #fde047;
  --warning-700: #854d0e;
  --warning-800: #7a5a0b;
  --error-100: #fee2e2;
  --error-200: #fecaca;
  --error-700: #b91c1c;
  --error-800: #991b1b;

--white: #ffffff;
  --white-15: #ffffff26;
  --white-25: #ffffff40;
  --white-85: #ffffffd9;
  --ink-5: #0000000d;
  --ink-12: #0000001f;
  --ink-18: #0000002e;
  --ink-25: #00000040;
  --scrim: #0f172a73;
  --cover-shade: linear-gradient(180deg, #0f172a33 0%, #0f172acc 70%, #0f172af2 100%);
  --focus-ring: #d02329; /* solid, so the ring has 3:1 contrast against white (WCAG 2.2) */
  --focus-soft: #d0232926;
  --primary-shadow: #9a171b33;

  --slate-200: #d3dbe4;
  --slate-400: #7d91a6;
  --slate-500: #5f7389;
  --slate-900: #1f2937;
  --neutral-500: #737373;
  --success-600: #16a34a;
  --warning-500: #d4a017;
  --warning-600: #ca8a04;
  --error-600: #dc2626;
  --gold-50: #fdf6e3;
  --gold-200: #ecd9a0;
  --silver-50: #eef1f5;
  --silver-200: #cfd6df;
  --silver-700: #3f4a57;

  --neutral-150: #eeeeee;
  --neutral-900: #171717;
  --primary-300: #f1a7aa;
  --primary-8: #d0232914;
  --primary-20: #d0232933;
  --success-800: #166534;
  --success-glow: #15803d99;
  --error-300: #fca5a5;
  --ink-40: #00000066;
  --ink-55: #0000008c;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px var(--ink-5);
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
}

[hidden] { display: none !important; }

a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }

:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

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

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  min-height: var(--topbar-h); padding: 6px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.spacer { flex-grow: 1; }
.icon-btn {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--neutral-800); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--neutral-100); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--primary); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 18px;
}
.app-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; min-width: 0; }
.app-title .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Top bar, left: the store (wide screens), then the app name, which opens the app switcher. */
.top-brand { display: none; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 650; border-radius: var(--radius); padding: 4px 8px 4px 4px; white-space: nowrap; }
.top-brand:hover { background: var(--neutral-100); }
/* A long store name is cut with … so it never runs under the app name. */
.top-brand .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Between 640 and 900 px there is room for the mark only; the name shows from 900 px. */
@media (max-width: 899px) { .top-brand .label { display: none; } .top-brand { padding-right: 4px; } }
.top-brand .brand-mark { width: 32px; height: 32px; font-size: 16px; border-radius: 8px; flex: none; }
.top-sep { display: none; width: 1px; height: 24px; background: var(--border-strong); margin: 0 2px; transform: skewX(-18deg); flex: none; }
.app-switch { min-width: 0; flex: none; }
button.app-title {
  height: 44px; padding: 0 8px 0 6px; border: none; border-radius: var(--radius); background: none;
  color: var(--text); font-family: inherit; cursor: pointer; max-width: 100%;
}
button.app-title:hover, button.app-title[aria-expanded="true"] { background: var(--neutral-100); }
button.app-title > svg { flex: none; width: 16px; height: 16px; color: var(--text-2); transition: transform .15s; }
button.app-title[aria-expanded="true"] > svg { transform: rotate(180deg); }
/* Top bar, right: the branch you work in, and your account. */
.account-btn {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 4px; border: none; border-radius: 9999px;
  background: none; color: var(--text); font-family: inherit; cursor: pointer;
}
.account-btn .avatar { width: 36px; height: 36px; flex: 0 0 36px; font-size: 14px; }
.account-name, .account-btn > svg { display: none; }
.account-btn:hover .avatar, .account-btn[aria-expanded="true"] .avatar { box-shadow: 0 0 0 3px var(--slate-200); }
.app-icon {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px;
  background: var(--primary-50); color: var(--primary-600);
  display: flex; align-items: center; justify-content: center;
}
.branch-chip {
  display: none; align-items: center; gap: 8px; height: 36px;
  background: var(--neutral-50); border: 1px solid var(--border); border-radius: 9999px;
  padding: 0 14px; font-size: 13px; font-weight: 500; color: var(--neutral-700); white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success-600); display: inline-block; flex: none; }
.avatar {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
  background: var(--slate-100); color: var(--slate-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}

/* ---------- Side navigation: a drawer on phones, a column on wide screens ---------- */
.app-body { display: flex; flex: 1 1 auto; min-width: 0; }
.sidenav {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
  width: 288px; max-width: 85vw; padding: 12px 12px 16px;
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border); box-shadow: 8px 0 32px var(--ink-18);
  transform: translateX(-100%); visibility: hidden;
  transition: transform .22s ease, visibility .22s;
}
body.nav-open .sidenav { transform: none; visibility: visible; }
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; visibility: hidden; transition: opacity .22s, visibility .22s; }
body.nav-open .scrim { opacity: 1; visibility: visible; }
body.nav-open { overflow: hidden; }
.nav-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 0 12px 4px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.nav-app { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 16px; font-weight: 650; }
.nav-app .app-icon { width: 32px; height: 32px; flex: none; }
/* Menu items: icon and label; the open page is tinted with a red bar on its left edge. */
.sidenav a {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: var(--radius); color: var(--neutral-700); font-size: 15px; font-weight: 500; text-decoration: none;
  transition: background-color .12s, color .12s;
}
.sidenav a svg { flex: none; color: var(--neutral-500); transition: color .12s; }
.sidenav a:hover { background: var(--neutral-100); color: var(--text); }
.sidenav a:hover svg { color: var(--neutral-700); }
.sidenav a:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sidenav a.is-active { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.sidenav a.is-active svg { color: var(--primary-600); }
.sidenav a.is-active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.sidenav .sep { margin-top: 13px; }
.sidenav .sep::after { content: ''; position: absolute; left: 12px; right: 12px; top: -7px; height: 1px; background: var(--border); }
.nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.sidenav .group-label { margin: 12px 12px 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }

.content { flex: 1 1 auto; min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.content-narrow { max-width: 1240px; width: 100%; margin: 0 auto; }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-direction: column; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.page-head .titles { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; min-width: 0; }
.page-head h1 { font-size: 24px; font-weight: 650; line-height: 1.2; letter-spacing: -0.015em; }
/* Main pages: the menu icon in a tinted tile, left of the title and subtitle. */
.page-head .titles.has-icon { display: grid; grid-template-columns: 44px minmax(0, 1fr); column-gap: 14px; row-gap: 4px; align-items: center; }
.page-head .titles.has-icon > :not(.page-icon) { grid-column: 2; }
.page-icon {
  grid-row: 1 / span 2; align-self: start; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px; background: var(--primary-50); color: var(--primary-700);
}
.page-icon svg { width: 22px; height: 22px; }
/* Breadcrumb: muted link back to the list, a small chevron, then this page. */
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; margin-bottom: 4px; font-size: 13px; font-weight: 500; line-height: 20px; }
.crumb a { flex: 0 0 auto; color: var(--text-2); text-decoration: none; border-radius: 4px; }
.crumb a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.crumb-sep { flex: 0 0 auto; width: 7px; height: 7px; border-top: 1.5px solid var(--neutral-400); border-right: 1.5px solid var(--neutral-400); transform: rotate(45deg); margin-left: -2px; }
.crumb-here { min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head p { font-size: 15px; line-height: 1.45; color: var(--text-2); max-width: 70ch; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head .actions .btn { flex: 1 1 140px; }

/* ---------- Buttons ---------- */
/* Three looks: primary (solid red, one per screen), plain (white, outlined), danger (red outline).
   Every button: 44 px tall, 600 weight, a soft shadow, darker on hover, pressed in on click. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; text-align: center;
  border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--neutral-800); box-shadow: 0 1px 2px var(--ink-5);
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background-color .12s, border-color .12s, box-shadow .12s, transform .06s;
}
.btn svg { flex: none; width: 18px; height: 18px; margin-left: -2px; }
.btn:hover { background: var(--neutral-50); border-color: var(--neutral-400); color: var(--text); }
.btn:active { background: var(--neutral-100); transform: translateY(1px); box-shadow: none; }
.btn-primary { background: var(--primary); border-color: var(--primary-600); color: var(--white); box-shadow: 0 1px 2px var(--primary-shadow), inset 0 1px 0 var(--white-15); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-700); color: var(--white); }
.btn-primary:active { background: var(--primary-700); border-color: var(--primary-700); }
.btn-primary:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.btn-danger { border-color: var(--error-200); color: var(--error-700); }
.btn-danger:hover { background: var(--primary-50); border-color: var(--error-700); color: var(--error-800); }
.btn-danger:active { background: var(--error-100); }
.btn[disabled], .btn[aria-disabled="true"]:not(.is-loading) { background: var(--neutral-100); border-color: var(--neutral-200); color: var(--neutral-500); box-shadow: none; cursor: not-allowed; transform: none; }
.btn-icon { min-width: 44px; padding: 0; border-color: transparent; background: transparent; color: var(--text-2); font-size: 20px; box-shadow: none; }
.btn-icon:hover { border-color: transparent; background: var(--neutral-100); }
.btn-block { width: 100%; }

/* ---------- Badges and pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle;
  font-size: 12px; font-weight: 600; line-height: 18px; letter-spacing: .005em; white-space: nowrap;
  border-radius: 9999px; padding: 2px 10px 2px 8px; border: none; box-shadow: inset 0 0 0 1px var(--ring, transparent);
}
/* A status badge starts with a dot in its own colour, so it reads as a status, not a button. */
.badge::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, currentColor); }
.badge-ok      { background: var(--success-50);  color: var(--success-700); --ring: var(--success-200); --dot: var(--success-600); }
.badge-month   { background: var(--warning-50);  color: var(--warning-800); --ring: var(--warning-200); --dot: var(--warning-500); }
.badge-soon    { background: var(--warning-100); color: var(--warning-700); --ring: var(--warning-300); --dot: var(--warning-600); }
.badge-urgent  { background: var(--error-100);   color: var(--error-800);   --ring: var(--error-200);   --dot: var(--error-600); }
.badge-expired { background: var(--error-800);   color: var(--white);               --ring: var(--error-800);   --dot: var(--white); }
.badge-neutral { background: var(--neutral-100); color: var(--neutral-700); --ring: var(--neutral-200); --dot: var(--neutral-400); }
.badge-primary { background: var(--primary-50);  color: var(--primary-700); --ring: var(--primary-200); --dot: var(--primary); }
.badge-later   { background: transparent; color: var(--neutral-700); --ring: var(--neutral-400); padding: 2px 10px; }
.badge-later::before { display: none; }
/* Tags: a kind of thing (supplier or customer, member tier), not a status. */
.badge-tag { border-radius: 6px; padding: 2px 8px; }
.badge-tag::before { display: none; }
.badge-gold    { background: var(--gold-50); color: var(--warning-800); --ring: var(--gold-200); }
.badge-silver  { background: var(--silver-50); color: var(--silver-700); --ring: var(--silver-200); }

.pill {
  flex: 0 0 auto; min-height: 44px; padding: 0 16px; border-radius: 9999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--neutral-800);
  cursor: pointer; font-size: 14px; white-space: nowrap;
}
.pill.is-active { background: var(--primary); border-color: var(--primary); color: var(--white); font-weight: 500; }

/* ---------- Cards, stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.card h2 { font-size: 18px; font-weight: 600; }
.card .hint { font-size: 14px; color: var(--text-2); }
.card-note { background: var(--slate-100); border: 1px solid var(--slate-200); box-shadow: none; gap: 8px; }
.card-note h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--slate-700); }
.card-note h2::before {
  content: ''; flex: none; width: 18px; height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2333475b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 8v.01'/%3E%3C/svg%3E") no-repeat center / contain;
}
.card-note p { font-size: 14px; line-height: 1.5; color: var(--neutral-800); }
.card-note .btn { margin-top: 4px; }
/* Form sections: the title sits on its own band, the fields below it. */
.form-section { box-shadow: var(--shadow-sm); gap: 16px; }
.form-section h2 { font-size: 16px; }
.form-section .hint { margin-top: 2px; }
.form-section .form-grid { gap: 16px; }
.form-section .field { gap: 6px; }
.form-section .field .help, .form-section .field .error { margin-top: -2px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }

/* Summary cards: one card split into cells. The 1 px gap shows the border colour between cells,
   and cells grow to fill each row, so an odd last cell never leaves a hole. */
.stats {
  display: flex; flex-wrap: wrap; gap: 1px; overflow: hidden;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.stat { flex: 1 1 calc(50% - 1px); min-width: 0; background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.stat.is-wide { flex-basis: 100%; }
.stat .label { display: block; font-size: 13px; font-weight: 500; line-height: 18px; color: var(--text-2); }
/* A number with a tone gets a dot after its label, so every label and number still start on the same line. */
.stat:has(.value.good) .label::after, .stat:has(.value.warn) .label::after, .stat:has(.value.bad) .label::after {
  content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; vertical-align: 1px;
}
.stat:has(.value.good) .label::after { background: var(--success-700); }
.stat:has(.value.warn) .label::after { background: var(--warning-500); }
.stat:has(.value.bad) .label::after { background: var(--error-700); }
.stat .value { overflow-wrap: anywhere; font-size: 22px; font-weight: 650; line-height: 1.15; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.stat .value.warn { color: var(--warning-700); }
.stat .value.bad { color: var(--error-700); }
.stat .value.good { color: var(--success-700); }

.split { display: flex; flex-direction: column; gap: 16px; }
.split-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.split-side { min-width: 0; display: flex; flex-direction: column; gap: 16px; }

/* Key/value details */
.kv { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0; }
.kv div { display: flex; flex-direction: column; gap: 2px; }
.kv dt { font-size: 13px; color: var(--text-2); }
.kv dd { margin: 0; font-size: 15px; font-weight: 500; }

/* Bar chart (built by js/reports.js): every bar is a button; hover or focus shows the tooltip, click pins it. */
.chart { position: relative; padding-top: 28px; }
.chart-key { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.chart-key .sq { width: 10px; height: 10px; border-radius: 2px; background: var(--slate-700); }
.chart-key .ds { width: 14px; border-top: 2px dashed var(--neutral-500); }
.chart-plot { position: relative; height: 200px; margin-left: 40px; }
.chart-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--neutral-200); }
.chart-grid span { position: absolute; left: -40px; top: -9px; width: 34px; text-align: right; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chart-cols { position: absolute; inset: 0; display: flex; gap: 6px; align-items: flex-end; }
.chart-col { flex: 1 1 0; min-width: 0; height: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; padding: 0; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.chart-col:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.chart-col .fill { display: block; width: 100%; max-width: 56px; min-height: 2px; background: var(--slate-400); border-radius: 6px 6px 0 0; }
.chart-col:hover .fill, .chart-col:focus-visible .fill { background: var(--slate-500); }
.chart-col.is-on .fill { background: var(--slate-700); }
.chart-col .prev { position: absolute; left: 50%; width: 100%; max-width: 56px; transform: translateX(-50%); border-top: 2px dashed var(--neutral-500); pointer-events: none; }
.chart-labs { display: flex; gap: 6px; margin: 8px 0 0 40px; }
.chart-labs span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 13px; color: var(--text-2); }
.chart-labs span.is-on { color: var(--text); font-weight: 600; }
.chart-tip { position: absolute; z-index: 3; transform: translateX(-50%); padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-sm); font-size: 13px; line-height: 1.5; white-space: nowrap; pointer-events: none; }
.chart-tip[hidden] { display: none; }
.chart-tip b { font-weight: 600; }
.chart-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.chart-detail > div { padding: 12px 14px; background: var(--neutral-50); border-radius: var(--radius); }
.chart-detail small { display: block; font-size: 13px; color: var(--text-2); }
.chart-detail strong { display: block; margin-top: 2px; font-size: 16px; font-weight: 600; }
.chart-detail strong.good { color: var(--success-700); }
.chart-detail strong.bad { color: var(--error-700); }
.chart-detail > div:last-child { grid-column: 1 / -1; }
@media (min-width: 640px) { .chart-detail { grid-template-columns: repeat(3, minmax(0, 1fr)); } .chart-detail > div:last-child { grid-column: auto; } }
/* Two bars per group (Accounting overview): the first dark slate, the second light slate; the pinned group is tinted. */
.chart-col.is-pair { gap: 4px; }
.chart-col.is-pair .fill { width: 36%; max-width: 30px; }
.chart-col.is-pair .fill.is-in { background: var(--slate-700); }
.chart-col.is-pair .fill.is-out { background: var(--slate-400); }
.chart-col.is-pair:hover, .chart-col.is-pair.is-on { background: var(--neutral-100); }
.chart-key .sq.is-out { background: var(--slate-400); }
/* A third line in a summary cell, and the list of things that need a person. */
@media (min-width: 640px) { .stats.is-roomy .stat, .stats.is-roomy .stat.is-wide { flex-basis: 260px; } }
.stat .sub { font-size: 13px; line-height: 1.4; color: var(--text-2); }
.stat .sub.good { color: var(--success-700); }
.stat .sub.bad { color: var(--error-700); }
.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.attention li:first-child { border-top: 0; padding-top: 4px; }
.attention .what { display: flex; gap: 10px; min-width: 0; flex: 1 1 260px; }
.attention .dot { flex: none; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--warning-500); }
.attention .dot.bad { background: var(--error-700); }
.attention strong { display: block; font-size: 15px; font-weight: 600; }
.attention small { display: block; font-size: 13px; color: var(--text-2); }
.attention-none { color: var(--text-2); }
.attention strong .badge { margin-left: 8px; vertical-align: 1px; }
.attention .lane-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.meter { height: 10px; border-radius: 9999px; background: var(--neutral-200); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--success-700); }
.meter.warn > span { background: var(--warning-600); }
.meter.bad > span { background: var(--error-700); }

/* ---------- Launcher ---------- */
.section { display: flex; flex-direction: column; gap: 16px; }
.section h1 { font-size: 28px; font-weight: 600; }
.section h2 { font-size: 20px; font-weight: 600; }
.section .sub { font-size: 16px; color: var(--text-2); }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.app-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 16px 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  text-decoration: none; color: var(--text); box-shadow: var(--shadow-sm);
}
.app-tile:hover { border-color: var(--primary); }
.app-tile .icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--primary-50); color: var(--primary-600);
  display: flex; align-items: center; justify-content: center;
}
.app-tile .icon.slate { background: var(--slate-100); color: var(--slate-700); }
.app-tile .name { font-size: 16px; font-weight: 600; }
.app-tile .desc { font-size: 13px; color: var(--text-2); }
.app-tile.is-disabled { background: var(--neutral-100); border: 1px dashed var(--border-strong); box-shadow: none; color: var(--text-2); }
.app-tile.is-disabled:hover { border-color: var(--border-strong); }
.app-tile.is-disabled .icon { background: var(--neutral-200); color: var(--text-2); }
.app-tile.is-disabled .name { color: var(--neutral-800); }
.status-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.status-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.status-card .label { font-size: 14px; color: var(--text-2); }
.status-card .value { font-size: 26px; font-weight: 600; }
.status-card .link { align-self: flex-start; font-size: 14px; font-weight: 500; color: var(--primary-600); }

/* ---------- Filters ---------- */
.filters { display: flex; flex-direction: column; gap: 12px; }
.filters .input, .filters .select { width: 100%; }
/* Search boxes carry a magnifying glass, so they read as search before anything is typed. */
input.input[type="search"] {
  padding-left: 40px;
  background: var(--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='%23737373' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center;
}
/* Filter chips: the chosen one is tinted like the active menu item, not solid red, so it never
   competes with the page's primary button. */
.pill-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scroll-snap-type: x proximity; scrollbar-width: none; }
.pill-row::-webkit-scrollbar { display: none; }
.pill-row .pill { scroll-snap-align: start; color: var(--text-2); font-weight: 500; }
.pill-row .pill:hover { background: var(--neutral-50); color: var(--text); }
.pill-row .pill.is-active { background: var(--primary-50); border-color: var(--primary-200); color: var(--primary-700); font-weight: 600; }
.pill:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 14px; font-weight: 500; color: var(--neutral-800); }
.field .help { font-size: 13px; line-height: 1.45; color: var(--text-2); }
.req { color: var(--error-700); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 0 12px;
  font-size: 16px; color: var(--text); /* 16px stops iOS zooming into fields */
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
/* Fields: a darker border on hover, a red ring when typing in them. */
.input:hover, .select:hover, .textarea:hover { border-color: var(--neutral-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-soft); }
.input::placeholder, .textarea::placeholder { color: var(--neutral-500); }
.input[disabled]:hover, .select[disabled]:hover { border-color: var(--border-strong); }
/* Dropdowns: our own chevron, the same in every browser. */
.select {
  -webkit-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23525252' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.select[disabled] { cursor: default; }
.textarea { padding: 10px 12px; min-height: 96px; resize: vertical; }
.input[disabled], .select[disabled] { background-color: var(--neutral-100); color: var(--neutral-500); }
.input.num { text-align: right; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; flex: none; }
.check.main { font-weight: 500; }
.check.nested { margin-left: 30px; }
.check-hint { margin: -8px 0 0 30px; font-size: 13px; color: var(--text-2); }
/* Fix lots dialog (inventory/lots.html): the choice for the rest, and the before and after preview. */
.fix-rest-label { font-size: 15px; font-weight: 500; }
.check.nested .select { width: 100%; }
.fix-preview { padding: 12px 14px; background: var(--neutral-50); border-radius: var(--radius); font-size: 14px; }
.fix-preview:empty { display: none; }
.fix-preview .line { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.fix-preview .line.total { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 600; }
.fieldset { margin: 0; padding: 0; border: none; display: flex; flex-direction: column; gap: 0; }
.fieldset legend { padding: 0; margin-bottom: 4px; font-size: 14px; font-weight: 500; color: var(--neutral-800); }
.group { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-grid.group { display: grid; gap: 16px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline .input { width: 88px; text-align: right; }

.list-box { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 8px 8px 16px; min-height: 56px; }
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row .grow { flex-grow: 1; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.add-row { display: flex; flex-direction: column; gap: 8px; }

/* Bottom action bar for forms: sticks to the bottom of the screen, so Save is always in reach. */
.actionbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; gap: 8px; padding: 12px 16px; margin: 0 -16px -16px;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 12px var(--ink-5);
}
.actionbar .btn { flex: 1 1 0; }
.actionbar + .hint:empty { display: none; }

/* ---------- Tables: cards on phones, a real table from 720px ---------- */
/* A table shows as a grouped list of rows when it is narrow, and as a real table when
   its container is wide enough to hold it. shell.js adds .is-table by measuring the
   container (not the screen), so a table inside a narrow card never scrolls sideways. */
.rt-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.card .rt-wrap { border-radius: var(--radius); }
.rt { width: 100%; border-collapse: collapse; font-size: 14px; }
.rt, .rt tbody, .rt tr, .rt td { display: block; }
.rt thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); visibility: hidden; }
.rt tbody tr { position: relative; padding: 14px 16px; }
.rt tbody tr + tr { border-top: 1px solid var(--border); box-shadow: inset 0 6px 0 var(--bg), inset 0 7px 0 var(--border); padding-top: 20px; }
.rt td.name a::after { content: ''; position: absolute; inset: 0; }
.sort-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; background: var(--neutral-100); border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.sort-bar .select { width: auto; min-width: 160px; }
.rt-wrap.is-table .sort-bar { display: none; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0;
  font: inherit; font-weight: 600; color: inherit; background: none; border: none; cursor: pointer;
}
.sort-btn:hover { color: var(--text); }
/* Sort arrows: a faint up-and-down mark on every sortable header, one dark arrow on the sorted one. */
.sort-btn::after {
  content: ''; width: 10px; height: 10px; flex: none; opacity: .45;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='%23525252'%3E%3Cpath d='M5 0l3.5 4h-7zM5 10l3.5-4h-7z'/%3E%3C/svg%3E") no-repeat center / contain;
}
.sort-btn:hover::after { opacity: .8; }
.rt th[aria-sort] .sort-btn { color: var(--text); }
.rt th[aria-sort] .sort-btn::after { opacity: 1; }
.rt th[aria-sort="ascending"] .sort-btn::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='%231a1a1a'%3E%3Cpath d='M5 1l4 5H1z'/%3E%3C/svg%3E"); }
.rt th[aria-sort="descending"] .sort-btn::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='%231a1a1a'%3E%3Cpath d='M5 9l4-5H1z'/%3E%3C/svg%3E"); }
.rt td { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 0; border: none; text-align: right; font-variant-numeric: tabular-nums; }
.rt td::before { content: attr(data-label); color: var(--text-2); font-size: 13px; font-weight: 500; text-align: left; flex: none; }
.rt td.name { display: block; text-align: left; font-size: 16px; font-weight: 600; padding: 0 0 6px; }
.rt td.name::before { display: none; }
.rt td.muted { color: var(--text-2); }
.rt td .field { align-items: flex-end; }
.rt .empty-row td { display: block; text-align: center; color: var(--text-2); padding: 24px 0; }
.rt .empty-row td::before { display: none; }
.rt a { color: inherit; text-underline-offset: 3px; }
.rt td.name a { text-decoration: none; }
.rt tbody tr:has(td.name a):hover td.name a { text-decoration: underline; }
.rt tbody tr:has(td.name a):hover { background: var(--neutral-50); }
.rt td.name a:focus-visible { outline: none; }
.rt tbody tr:has(td.name a:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }
.rt .input { width: 150px; max-width: 100%; text-align: right; }
.rt .input.wide { width: 170px; text-align: left; }
.rt .row-error { outline: 2px solid var(--error-700); }
/* Receiving a delivery: one group per product, one box per lot (js/purchase-order.js). Fields sit side by side when the group is wide enough. */
.rt td.lot-cell { display: block; padding: 0; text-align: left; }
.rt td.lot-cell::before { display: none; }
.rt-wrap.is-table .rt td.lot-cell { display: table-cell; padding: 14px 16px; }
.lot-group { container-type: inline-size; display: flex; flex-direction: column; gap: 10px; }
.lot-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 12px; }
.lot-name { font-size: 16px; font-weight: 600; }
.lot-tally { font-size: 14px; color: var(--text-2); }
.lot-tally.is-off { color: var(--warning-800); font-weight: 500; }
.lot-row { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 12px; background: var(--neutral-50); border: 1px solid var(--border); border-radius: var(--radius); }
.lot-top { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; margin: -8px 0 -6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.lot-top .link-btn { font-size: 14px; }
.lot-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; font-weight: 500; color: var(--text-2); }
.lot-field.is-exp { grid-column: 1 / -1; }
.rt .lot-field .input { width: 100%; text-align: left; }
.lot-group > .link-btn { align-self: flex-start; font-size: 14px; }
.lot-plain { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
@container (min-width: 440px) {
  .lot-row { grid-template-columns: 90px minmax(0, 1fr) 170px; }
  .lot-field.is-exp { grid-column: auto; }
}
.table-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.table-foot .grow { flex: 1 1 100%; }
.table-foot .btn { flex: 1 1 0; }

/* ---------- Variants ----------
   The variant grid: first option down the side, second across the top, one cell per variant, with totals.
   It scrolls sideways inside its own box; the side column stays put. Built by js/variant-grid.js. */
.variant-grid { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.variant-grid table { border-collapse: separate; border-spacing: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.variant-grid table { min-width: 100%; }
.variant-grid th, .variant-grid td { height: 44px; min-width: 60px; padding: 4px 2px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.variant-grid thead th { font-size: 13px; font-weight: 600; color: var(--text-2); background: var(--neutral-50); }
.variant-grid tfoot th, .variant-grid tfoot td { border-bottom: none; }
.variant-grid .vg-side { position: sticky; left: 0; z-index: 1; min-width: 52px; padding: 4px 8px; text-align: left; font-weight: 600; color: var(--text); background: var(--surface); border-right: 1px solid var(--border); }
.variant-grid thead .vg-side { font-weight: 600; color: var(--text-2); background: var(--neutral-50); }
.variant-grid .vg-total { font-weight: 600; background: var(--neutral-50); }
.variant-grid .vg-grand { font-size: 16px; }
.variant-grid td .input { width: 60px; min-width: 0; height: 44px; padding: 0 4px; text-align: center; }
.variant-grid td.is-off, .variant-grid td.is-zero { color: var(--neutral-400); }
.variant-grid td.is-low { color: var(--warning-700); font-weight: 600; }
.variant-grid td.is-diff .input { border-color: var(--warning-700); background: var(--warning-50); }
.variant-grid td small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--text-2); line-height: 1.2; }
dialog.variant-dialog #vg-body { margin-bottom: 16px; }
/* Small grey tags after a product name: the values of a variant, or how many variants a product has. */
.variant-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; vertical-align: middle; }
.variant-tags span { padding: 1px 8px; border-radius: 6px; background: var(--neutral-100); color: var(--neutral-700); font-size: 12px; font-weight: 500; }
/* Product form: one option per row (its name, then its values). */
.option-row { display: grid; grid-template-columns: 1fr; gap: 8px 16px; }

/* ---------- 640px and up ---------- */
@media (min-width: 640px) {
  .topbar { padding: 6px 24px 6px 16px; gap: 12px; }
  .branch-chip { display: flex; }
  .top-brand, .top-sep { display: flex; }
  .account-btn { padding: 0 10px 0 4px; }
  .account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--neutral-100); }
  .account-btn:hover .avatar, .account-btn[aria-expanded="true"] .avatar { box-shadow: none; }
  .account-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; text-align: left; }
  .account-name strong { font-size: 14px; font-weight: 600; }
  .account-name span { font-size: 12px; color: var(--text-2); }
  .account-btn > svg { display: block; width: 16px; height: 16px; color: var(--text-2); }
  .content { padding: 24px; gap: 24px; }
  .page-head { flex-direction: row; align-items: center; gap: 24px; padding-bottom: 20px; }
  .page-head h1 { font-size: 28px; }
  .page-head .titles.has-icon { grid-template-columns: 48px minmax(0, 1fr); column-gap: 16px; }
  .page-icon { width: 48px; height: 48px; border-radius: 12px; }
  .page-icon svg { width: 24px; height: 24px; }
  .page-head .actions { flex: 0 0 auto; }
  .page-head .actions .btn { flex: 0 0 auto; }
  .stat, .stat.is-wide { flex-basis: 180px; padding: 18px 20px; }
  .stat .value { font-size: 28px; }
  .card { padding: 24px; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; }
  .app-tile { gap: 10px; padding: 24px 16px; }
  .app-tile .icon { width: 64px; height: 64px; }
  .status-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
  .filters { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .filters .search-box { flex: 1 1 260px; max-width: 420px; }
  .filters .search-box .input { width: 100%; }
  .filters .select { width: auto; min-width: 180px; }
  .filters .pill-row { margin-left: auto; }
  .pill-row { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .option-row { grid-template-columns: 200px minmax(0, 1fr); }
  .form-grid.tight { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-row { flex-direction: row; }
  .add-row .input { flex: 1 1 260px; }
  /* Wide screens: Save and Cancel simply end the form column; nothing floats over the fields. */
  .actionbar {
    position: static; margin: 0; padding: 4px 0 0; justify-content: flex-end;
    background: transparent; border: none; box-shadow: none;
  }
  /* Forms read best at about 760 px; the side note sits right next to them. */
  form .split-main { max-width: 760px; }
  .form-section { padding: 20px 24px 24px; }
  .actionbar .btn { flex: 0 0 auto; }
  .table-foot { flex-wrap: nowrap; }
  .table-foot .grow { flex: 1 1 auto; }
  .table-foot .btn { flex: 0 0 auto; }
}

/* ---------- 720px and up: tables become real tables ---------- */
@media (min-width: 720px) {
}

/* ---------- 960px and up: the side navigation becomes a column ---------- */
@media (min-width: 960px) {
  .icon-btn.menu-btn { display: none; }
  .scrim { display: none !important; }
  body.nav-open { overflow: visible; }
  .nav-title, .nav-foot { display: none; }
  .sidenav {
    position: sticky; top: var(--topbar-h); align-self: flex-start;
    height: calc(100vh - var(--topbar-h)); flex: 0 0 248px; width: 248px; max-width: none;
    padding: 24px 12px; transform: none; visibility: visible; z-index: auto; transition: none; box-shadow: none;
  }
  .sidenav a { min-height: 40px; font-size: 14px; }
  .content { padding: 32px; }
  .kv.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Main column and side column go next to each other only when the main column keeps room to breathe. */
@media (min-width: 1240px) {
  .split { flex-direction: row; align-items: flex-start; gap: 24px; }
  .split-main { flex: 1 1 0; }
  .split-side { flex: 0 0 380px; }
  .split-side.is-sticky { position: sticky; top: calc(var(--topbar-h) + 24px); }
}

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

label.btn:has(+ input:focus-visible) { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Form errors ---------- */
.field .error { font-size: 13px; color: var(--error-700); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--error-700); border-width: 2px;
}

/* ---------- Avatar menu ---------- */
.avatar-wrap { position: relative; flex: none; }
button.avatar { border: none; cursor: pointer; padding: 0; font-family: inherit; width: 44px; height: 44px; flex-basis: 44px; font-size: 15px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; min-width: 230px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 10px 15px -3px var(--ink-12);
}
.menu[hidden] { display: none; }
.menu { min-width: 260px; }
.menu .who { display: flex; align-items: center; gap: 12px; padding: 8px 12px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.menu .who .avatar { width: 40px; height: 40px; flex: 0 0 40px; }
.menu .who > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.menu .who strong { font-size: 15px; color: var(--text); }
.menu .who .email { overflow-wrap: anywhere; }
.menu .who .role { margin-top: 2px; font-size: 12px; }
.menu a svg { flex: none; margin-right: 12px; color: var(--text-2); }
.menu a.sign-out { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); color: var(--error-700); }
.menu a.sign-out svg { color: var(--error-700); }
.menu a, .menu button {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 12px;
  border: none; border-radius: var(--radius); background: transparent; color: var(--neutral-800);
  font-size: 15px; text-align: left; text-decoration: none; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--neutral-100); }

/* ---------- Success panel, pairing code ---------- */
.success-panel { align-items: center; text-align: center; padding: 32px 16px; }
.success-panel .tick {
  width: 56px; height: 56px; border-radius: 50%; background: var(--success-50); color: var(--success-700);
  display: flex; align-items: center; justify-content: center; border: 1px solid var(--success-200);
}
.code {
  font-size: 34px; font-weight: 600; letter-spacing: .12em; font-variant-numeric: tabular-nums;
  background: var(--neutral-100); border-radius: var(--radius-lg); padding: 12px 20px;
}

/* ---------- Sign-in and setup layouts ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--primary-50), transparent 60%), var(--neutral-100);
}
.auth-card {
  width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 20px; padding: 28px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 1px 2px var(--ink-5), 0 12px 32px -12px var(--ink-12);
}
.auth-card .brand { justify-content: center; font-size: 17px; font-weight: 650; }
.auth-card h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.015em; text-align: center; }
.auth-card .lead { text-align: center; color: var(--text-2); font-size: 15px; line-height: 1.5; }
.auth-panel { display: none; }
/* Wide screens: picture panel on the left, the form on a plain white half on the right. */
@media (min-width: 960px) {
  .auth.has-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(520px, 1fr); padding: 0; background: var(--surface); }
  .auth.has-panel .auth-card { justify-self: center; align-self: center; border: none; box-shadow: none; padding: 48px 40px; }
  .auth.has-panel .auth-card .brand { display: none; }
  .auth.has-panel .auth-card h1, .auth.has-panel .auth-card .lead { text-align: left; }
  .auth.has-panel .auth-done h1, .auth.has-panel .auth-done .lead { text-align: center; }
  .auth-panel {
    display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; padding: 40px 48px;
    background-color: var(--slate-900); background-size: cover; background-position: center; color: var(--white);
  }
  .auth-panel-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 650; }
  .auth-panel-brand .brand-mark { box-shadow: 0 0 0 3px var(--white-25); }
  .auth-panel-words { max-width: 460px; display: flex; flex-direction: column; gap: 12px; }
  .auth-panel-words strong { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
  .auth-panel-words p { font-size: 16px; line-height: 1.55; color: var(--white-85); }
}
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .links { text-align: center; font-size: 14px; }
.auth-card .links a { color: var(--primary-600); font-weight: 500; }
.step-head { display: flex; flex-direction: column; gap: 8px; }
.step-head .count { font-size: 14px; color: var(--text-2); }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1 1 0; }

/* ---------- Sheet dialogs ---------- */
/* Phones: a sheet that slides up from the bottom edge. From 640 px: a card in the middle.
   shell.js adds the close button (top right) unless the dialog has data-no-close. */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none;
  max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
  border: none; border-radius: 20px 20px 0 0; padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface); color: var(--text); box-shadow: 0 -12px 40px var(--ink-18);
}
dialog.sheet[open] { animation: sheet-up .24s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::before {
  content: ''; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
  border-radius: 2px; background: var(--neutral-300);
}
dialog.sheet::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
dialog.sheet[open]::backdrop { animation: fade-in .2s ease-out; }
html:has(dialog[open]) { overflow: hidden; }
dialog.sheet h2 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 4px; padding-right: 40px; }
dialog.sheet .lead { font-size: 14px; line-height: 1.5; color: var(--text-2); margin-bottom: 16px; }
dialog.sheet form { display: flex; flex-direction: column; gap: 16px; }
dialog.sheet .btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
dialog.sheet .btns .btn { flex: 1 1 0; }
.dialog-close {
  position: absolute; top: 14px; right: 14px; z-index: 1; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius); background: none; color: var(--text-2); cursor: pointer;
}
.dialog-close:hover { background: var(--neutral-100); color: var(--text); }
.dialog-close svg { width: 18px; height: 18px; }
/* A dialog that removes or undoes something starts with a red warning mark. */
dialog.sheet.is-danger h2::before {
  content: ''; display: block; width: 44px; height: 44px; margin-bottom: 14px; border-radius: 50%;
  background: var(--error-100) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b91c1c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4L2.5 20h19L12 4z'/%3E%3Cpath d='M12 10v4M12 17v.01'/%3E%3C/svg%3E") no-repeat center / 22px;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop-in { from { transform: translateY(8px) scale(.98); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (min-width: 640px) {
  dialog.sheet {
    inset: 0; margin: auto; width: min(480px, calc(100vw - 48px)); max-height: calc(100dvh - 64px);
    border-radius: 16px; padding: 24px; box-shadow: 0 24px 48px -12px var(--ink-25), 0 0 0 1px var(--ink-5);
  }
  dialog.sheet[open] { animation-name: pop-in; animation-duration: .18s; }
  dialog.sheet::before { display: none; }
  dialog.sheet .btns { justify-content: flex-end; }
  dialog.sheet .btns .btn { flex: 0 0 auto; min-width: 104px; }
  /* Three or more buttons share the row (and wrap) instead of running off the dialog's edge. */
  dialog.sheet .btns:has(> :nth-child(3)) .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open], dialog.sheet[open]::backdrop { animation: none; }
}

/* ---------- Count sheet ---------- */
.count-list { display: flex; flex-direction: column; gap: 10px; }
.count-item { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.count-item.is-done { border-color: var(--success-200); background: var(--success-50); }
.count-item .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.count-item .name { font-size: 16px; font-weight: 600; }
.count-item .sub { font-size: 13px; color: var(--text-2); }
.count-item .input { width: 110px; text-align: right; }

@media (min-width: 640px) {
  .auth-card { padding: 32px; }
  .count-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Table mode (set by shell.js when the container is wide enough) ---------- */
.rt-wrap.is-table { overflow-x: auto; }
.rt-wrap.is-table .rt { display: table; }
.rt-wrap.is-table .rt thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: table-header-group; visibility: visible; }
.rt-wrap.is-table .rt tbody { display: table-row-group; }
.rt-wrap.is-table .rt tr { display: table-row; }
.rt-wrap.is-table .rt tbody tr { padding: 0; border-top: none; box-shadow: none; }
.rt-wrap.is-table .rt th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap;
  background: var(--neutral-50); padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.rt-wrap.is-table .rt td { display: table-cell; padding: 13px 16px; border-top: 1px solid var(--border); text-align: left; vertical-align: middle; }
.rt-wrap.is-table .rt tbody tr:first-child td { border-top: none; }
.rt-wrap.is-table .rt th:first-child, .rt-wrap.is-table .rt td:first-child { padding-left: 20px; }
.rt-wrap.is-table .rt th:last-child, .rt-wrap.is-table .rt td:last-child { padding-right: 20px; }
.rt-wrap.is-table .rt td::before { display: none; }
.rt-wrap.is-table .rt td.name { display: table-cell; font-size: 14px; padding-top: 13px; padding-bottom: 13px; margin: 0; }
.rt-wrap.is-table .rt th.num, .rt-wrap.is-table .rt td.num { text-align: right; }
.rt-wrap.is-table .rt th.num .sort-btn { flex-direction: row-reverse; }
.rt-wrap.is-table .rt td .field { align-items: stretch; }
.rt-wrap.is-table .rt .empty-row td { display: table-cell; padding: 32px; }
.card .rt-wrap.is-table .rt td { padding: 12px 16px; }

.row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.row-actions .btn { min-width: 88px; }
.rt-wrap.is-table .row-actions { justify-content: flex-start; }

/* ---------- Schedule ---------- */
.day-pills { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; }
.day-pill { flex: 0 0 auto; min-width: 64px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--neutral-800); cursor: pointer; font-size: 13px; }
.day-pill strong { font-size: 16px; font-weight: 600; }
.day-pill.is-active { background: var(--primary-50); border-color: var(--primary); color: var(--primary-700); }
.day-pill.is-today:not(.is-active) { border-color: var(--primary-300); }
.coverage { display: grid; grid-template-columns: 1fr; gap: 12px; }
.cover-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.cover-card h3 { font-size: 15px; font-weight: 600; }
.cover-card .time { font-size: 13px; color: var(--text-2); }
.cover-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.roster-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; }
.roster-row + .roster-row { border-top: 1px solid var(--border); }
.roster-row .who { flex: 1 1 160px; min-width: 0; display: flex; flex-direction: column; }
.roster-row .who strong { font-size: 15px; font-weight: 500; }
.roster-row .who span { font-size: 13px; color: var(--text-2); }
.roster-row .who span.is-changed { color: var(--warning-800); font-weight: 500; }
.roster-row .select { flex: 1 1 100%; }
@media (min-width: 640px) {
  .coverage { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .roster-row .select { flex: 0 0 220px; }
  .day-pills { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
}

/* ---------- Pagination ---------- */
.table-foot.has-pager { flex-direction: column; flex-wrap: nowrap; align-items: stretch; }
.table-foot.has-pager .grow { flex: 0 0 auto; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pager .select { flex: 1 1 100%; width: auto; }
.pager .btn { flex: 1 1 0; min-width: 44px; padding: 0 14px; }
.pager .page-info { flex: 0 0 auto; font-size: 14px; color: var(--text-2); text-align: center; }
@media (min-width: 640px) {
  .table-foot.has-pager { flex-direction: row; align-items: center; gap: 16px; }
  .table-foot.has-pager .grow { flex: 1 1 auto; }
  .pager .select { flex: 0 0 auto; }
  .pager .btn { flex: 0 0 auto; }
}

/* ---------- Searchable picker (type to find one item among thousands) ---------- */
.picker { position: relative; min-width: 0; }
.picker-box { position: relative; }
.picker-box .input { padding-right: 44px; }
.picker-clear {
  position: absolute; top: 0; right: 0; width: 44px; height: 44px;
  border: none; background: transparent; color: var(--text-2); font-size: 22px; line-height: 1; cursor: pointer; border-radius: var(--radius);
}
.picker-clear:hover { color: var(--text); background: var(--neutral-100); }
.picker-clear[hidden] { display: none; }
/* The browser's own clear (×) in search boxes is hidden: our pickers and list searches have one clear button of their own. */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-box { min-width: 0; }
.picker-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 35;
  max-height: min(60vh, 440px); overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: 0 10px 15px -3px var(--ink-12);
}
.picker.is-inline .picker-list { position: static; margin-top: 6px; box-shadow: none; max-height: 240px; }
.picker-list li[role="option"] {
  display: flex; flex-direction: column; gap: 2px; min-height: 56px; justify-content: center;
  padding: 8px 12px; border-radius: var(--radius); cursor: pointer;
}
.picker-list li[role="option"]:hover, .picker-list li.is-active { background: var(--primary-50); }
.picker-list li[aria-selected="true"] { background: var(--primary-50); outline: 2px solid var(--primary); outline-offset: -2px; }
.picker-list .p-title { font-size: 15px; font-weight: 500; }
.picker-list .p-title mark { background: var(--warning-100); color: inherit; border-radius: 2px; padding: 0 1px; }
.picker-list .p-sub { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.picker-list .picker-note { padding: 10px 12px; font-size: 13px; color: var(--text-2); }
.picker-list .picker-note a { color: var(--primary-600); font-weight: 500; }
.picker-picked { margin-top: 6px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- App switcher (top bar) ---------- */
.app-menu {
  position: fixed; top: calc(var(--topbar-h) + 4px); left: 12px; right: 12px; z-index: 60;
  padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 10px 15px -3px var(--ink-12);
}
.app-menu-title { margin: 0 4px 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.app-menu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.app-menu-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 80px; padding: 10px 4px; border-radius: var(--radius);
  color: var(--neutral-800); font-size: 13px; text-align: center; text-decoration: none;
}
.app-menu-item:hover { background: var(--neutral-100); }
.app-menu-item.is-current { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.app-menu-all {
  display: flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border); color: var(--primary-600); font-size: 14px; font-weight: 500; text-decoration: none;
}
@media (min-width: 640px) {
  .app-menu { position: absolute; top: calc(100% + 8px); left: 0; right: auto; width: 340px; }
}

/* ---------- Empty state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.empty-state[hidden], .table-foot[hidden], .rt-wrap[hidden], .stats[hidden], .filters[hidden], .page-head .actions[hidden] { display: none; }
.empty-words { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-state h2 { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.empty-state p { max-width: 440px; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.empty-state p strong { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.empty-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
/* Nothing at all yet: an inviting card with a large drawing, the reason, and the way to start. */
.empty-state.is-first {
  padding: 48px 20px 52px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.empty-state.is-first .empty-pic { width: 180px; height: auto; }
.empty-state.is-first .empty-btns .btn { flex: 1 1 100%; max-width: 280px; }
/* Nothing matches: lighter, in the place of the table, so the search above stays the focus. */
.empty-state.is-nomatch { padding: 32px 20px 36px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); }
.empty-state.is-nomatch .empty-pic { width: 112px; height: auto; }
.empty-state.is-nomatch h2 { font-size: 16px; }
.empty-state.is-nomatch p { font-size: 14px; }
@media (min-width: 640px) {
  .empty-state.is-first { padding: 64px 32px 72px; }
  .empty-state.is-first .empty-btns .btn { flex: 0 0 auto; }
}

/* ---------- Sign-in pages: steps, done panel, alert, one-time code ---------- */
.auth-step { display: flex; flex-direction: column; gap: 20px; }
.auth-step[hidden] { display: none; }
.auth-step h1:focus { outline: none; }
.auth-main { min-height: 48px; font-size: 16px; }
.auth-done { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-done .tick {
  width: 56px; height: 56px; margin-bottom: 4px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--success-50); color: var(--success-700); border: 1px solid var(--success-200);
}
.auth-done .tick.is-warn { background: var(--warning-50); color: var(--warning-700); border-color: var(--warning-200); }
.auth-alert {
  padding: 12px 14px; border: 1px solid var(--error-200); border-radius: var(--radius);
  background: var(--error-100); color: var(--error-800); font-size: 14px;
}
.auth-card .links .hint { margin-top: 8px; font-size: 13px; color: var(--text-2); }
.auth-card .links .hint:empty { display: none; }
.link-btn { display: inline-flex; align-items: center; min-height: 44px; border: none; background: none; padding: 0; font: inherit; font-weight: 500; color: var(--primary-600); text-decoration: underline; cursor: pointer; }
.code-input { text-align: center; font-size: 24px; font-weight: 600; letter-spacing: .3em; font-variant-numeric: tabular-nums; min-height: 56px; }
.code-input::placeholder { color: var(--neutral-300); }

/* ---------- Two-step sign-in setup (My account) ---------- */
.qr { width: 184px; margin: 0 auto; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.qr svg { display: block; width: 100%; height: auto; fill: currentColor; shape-rendering: crispEdges; }
.qr .qr-bg { fill: var(--surface); }
.setup-key { font-size: 15px; font-weight: 500; letter-spacing: .04em; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.recovery-codes {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; list-style: none; margin: 0;
  padding: 12px 16px; background: var(--neutral-100); border-radius: var(--radius);
  font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; text-align: center;
}
dialog.sheet .auth-step { gap: 16px; }
dialog.sheet .auth-step .lead { margin-bottom: 0; }

/* ---------- Form notice: a short message inside a page (a waiting email change, "invite sent again") ---------- */
.form-notice { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.form-notice[hidden] { display: none; }
.form-notice.is-warn { background: var(--warning-50); border-color: var(--warning-200); color: var(--warning-800); }
.form-notice.is-ok { background: var(--success-50); border-color: var(--success-200); color: var(--success-700); }
.form-notice strong { font-weight: 600; overflow-wrap: anywhere; }
.form-notice .btn { background: var(--surface); }

/* ---------- Store website (index.html): the only page for customers ---------- */
.site { background: var(--surface); }
.site-wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.site-head {
  position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px;
  min-height: 64px; padding: 8px 16px 0; background: var(--surface); border-bottom: 1px solid var(--border);
}
.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 200; padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 4px 12px var(--ink-12);
}
.skip-link:focus { top: 8px; }
.site main:focus, main.content:focus { outline: none; }
.site-head .brand { color: var(--text); text-decoration: none; min-height: 44px; }
.site-nav { order: 3; flex: 1 0 100%; display: flex; gap: 4px; margin: 0 -12px; overflow-x: auto; }
.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--radius);
  color: var(--neutral-800); font-size: 15px; font-weight: 500; text-decoration: none;
}
.site-nav a:hover { background: var(--neutral-100); }
.site-staff { font-size: 14px; }
.site-hero {
  padding: 40px 0 48px; border-bottom: 1px solid var(--border);
  background: radial-gradient(900px 420px at 0% 0%, var(--primary-50), transparent 70%), var(--neutral-50);
}
.site-hero-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center; }
.site-hero-text { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.site-cover { margin: 0; border-radius: 20px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); aspect-ratio: 16 / 9; box-shadow: 0 24px 48px -24px var(--ink-25); }
.site-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.site-logo { height: 40px; width: auto; max-width: 160px; object-fit: contain; }
.site-hero h1 { max-width: 720px; font-size: 34px; font-weight: 700; line-height: 1.12; letter-spacing: -0.025em; }
/* Quick facts under the hero buttons. */
.site-facts { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; font-weight: 500; color: var(--neutral-700); }
.site-facts li { display: flex; align-items: center; gap: 8px; }
.site-facts svg { width: 18px; height: 18px; color: var(--primary-600); flex: none; }
.site-lead { max-width: 620px; font-size: 18px; color: var(--text-2); }
.site-cta { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.site-cta .btn { flex: 1 1 200px; min-height: 48px; }
.site-section { padding: 40px 0; scroll-margin-top: 112px; }
.site-section + .site-section { border-top: 1px solid var(--border); }
.site-band { background: var(--primary-50); border-top: 1px solid var(--primary-200); border-bottom: 1px solid var(--primary-200); }
.site-band + .site-section { border-top: none; }
.site-members { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center; }
.site-members p { max-width: 620px; margin-top: 8px; font-size: 16px; color: var(--text); }
.site-members .site-cta { margin-top: 20px; }
.site-members-pic { display: none; width: 100%; max-width: 320px; height: auto; justify-self: center; }
/* Members: three numbered steps. */
.site-steps { list-style: none; counter-reset: step; margin: 20px 0 0; padding: 0; display: grid; gap: 12px; max-width: 620px; }
.site-steps li { counter-increment: step; display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 12px; align-items: start; }
.site-steps li::before {
  content: counter(step); grid-row: 1 / span 2; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--white); font-size: 14px; font-weight: 700;
}
.site-steps strong { font-size: 16px; font-weight: 650; line-height: 32px; }
.site-steps span { font-size: 15px; color: var(--neutral-700); }
.site-section-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.site-section h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.site-section-head p { font-size: 16px; color: var(--text-2); max-width: 620px; }
.site-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.site-grid .card { gap: 8px; }
.site-grid h3 { font-size: 18px; font-weight: 600; }
.site-grid p { font-size: 15px; color: var(--text-2); }
.site-deal .badge { align-self: flex-start; }
/* Deals: the picture on the left, the words on the right. */
.site-grid .site-deal { flex-direction: row; align-items: flex-start; gap: 16px; transition: box-shadow .15s, border-color .15s; }
.site-grid .site-deal:hover { border-color: var(--border-strong); box-shadow: 0 8px 24px -12px var(--ink-18); }
.site-deal-pic { flex: none; width: 88px; height: 88px; border-radius: 12px; background: var(--neutral-50); }
.site-deal-body { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.site-grid .site-deal h3 { font-size: 18px; line-height: 1.25; }
.site-grid .site-when { font-size: 14px; font-weight: 500; color: var(--text); }
.site-hours { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 15px; }
.site-hours dt { color: var(--text-2); }
.site-hours dd { margin: 0; font-variant-numeric: tabular-nums; }
.site-grid address { font-style: normal; font-size: 15px; color: var(--text-2); }
.site-branch-links { display: flex; flex-wrap: wrap; gap: 0 16px; }
.site-branch-links a, .site-contact a { display: inline-flex; align-items: center; min-height: 44px; color: var(--primary-600); font-weight: 500; }
/* Contact: large tiles, each one a link (call or email). */
.site-contact { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.site-contact li a {
  display: flex; align-items: center; gap: 14px; min-height: 72px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  color: var(--text); font-size: 16px; font-weight: 600; text-decoration: none; overflow-wrap: anywhere;
  transition: border-color .15s, box-shadow .15s;
}
.site-contact li a:hover { border-color: var(--border-strong); box-shadow: 0 8px 24px -12px var(--ink-18); }
.site-contact li a > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.site-contact .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.site-contact-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary-600); }
.site-contact-icon svg { width: 20px; height: 20px; }
.site-foot { padding: 24px 0; background: var(--neutral-100); border-top: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.site-foot-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
.site-foot-grid > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.site-foot address { font-style: normal; }
.site-foot-name { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 650; color: var(--text); }
.site-foot-name .brand-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
.site-foot-title { font-weight: 600; color: var(--text); }
.site-foot a { display: inline-flex; align-items: center; min-height: 36px; color: var(--neutral-700); font-weight: 500; text-decoration: none; }
.site-foot a:hover { color: var(--primary-600); text-decoration: underline; text-underline-offset: 3px; }
.site-foot-grid > .site-foot-base {
  grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 8px 16px; padding-top: 16px; border-top: 1px solid var(--border);
}
@media (min-width: 640px) {
  .site-cta { width: auto; }
  .site-cta .btn { flex: 0 0 auto; }
  .site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-foot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-contact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .site-wrap { padding: 0 32px; }
  .site-head { padding: 8px 32px; flex-wrap: nowrap; }
  .site-nav { order: 0; flex: 0 0 auto; margin: 0; }
  .site-section { scroll-margin-top: 64px; }
  .site-hero { padding: 64px 0; }
  .site-hero h1 { font-size: 52px; }
  .site-lead { font-size: 19px; }
  .site-hero-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
  .site-section { padding: 64px 0; }
  .site-section h2 { font-size: 32px; }
  .site-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .site-grid.is-events { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .site-members { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 48px; }
  .site-members-pic { display: block; }
}

/* ---------- Picture field (form page): preview, choose, remove ---------- */
.image-preview {
  position: relative; overflow: hidden; display: grid; place-items: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--neutral-100);
}
.image-preview.is-wide { aspect-ratio: 16 / 9; }
.image-preview.is-square { width: 128px; aspect-ratio: 1; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview.is-square img { object-fit: contain; padding: 8px; background: var(--surface); }
.image-preview img[hidden], .image-none[hidden] { display: none; }
.image-none { font-size: 13px; color: var(--text-2); text-align: center; padding: 8px; }
.image-field .btn-row { max-width: 360px; }
.image-field .btn[hidden] { display: none; }

/* Website: upcoming events */
.site-grid .site-event { padding: 0; overflow: hidden; gap: 0; }
.site-event-pic { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-bottom: 1px solid var(--border); }
.site-event-body { display: flex; align-items: flex-start; gap: 16px; padding: 16px; }
.site-grid .site-note { font-size: 14px; font-weight: 500; color: var(--warning-800); }
.site-event-body > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.site-date {
  flex: 0 0 56px; display: flex; flex-direction: column; align-items: center; padding: 6px 0 8px;
  border: 1px solid var(--primary-200); border-radius: var(--radius); background: var(--primary-50);
  color: var(--primary-700); font-size: 24px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.site-date span { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Buttons: loading ---------- */
/* The label stays (so the button keeps its width) but turns invisible under a spinner. */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid currentColor; border-radius: 50%; border-right-color: transparent; color: var(--neutral-800);
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { color: var(--white); }
.btn-danger.is-loading::after { color: var(--error-700); }
.btn.is-waiting { opacity: .5; pointer-events: none; }
/* A loading button keeps its own colours (not the grey disabled look). */
.btn.is-loading[disabled] { background: var(--surface); border-color: var(--border-strong); cursor: progress; }
.btn-primary.is-loading[disabled], .btn-primary.is-loading { background: var(--primary); border-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 100; top: calc(var(--topbar-h) + 8px); left: 12px; right: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; width: 100%; max-width: 420px; display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 12px 14px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 10px 30px var(--ink-12), 0 2px 6px var(--ink-5);
  animation: toast-in .22s ease-out;
}
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }
.toast-icon { flex: none; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; }
.toast-icon svg { width: 16px; height: 16px; stroke-width: 2.4; }
.toast.is-success .toast-icon { background: var(--success-50); color: var(--success-700); box-shadow: inset 0 0 0 1px var(--success-200); }
.toast.is-error .toast-icon { background: var(--error-100); color: var(--error-700); }
.toast.is-info .toast-icon { background: var(--slate-100); color: var(--slate-700); }
.toast-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding-top: 3px; }
.toast-body strong { font-size: 15px; font-weight: 600; color: var(--text); }
.toast-body span { font-size: 14px; line-height: 1.45; color: var(--text-2); }
.toast-action { align-self: flex-start; margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--primary-600); text-underline-offset: 3px; }
.toast-close {
  flex: none; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: -4px -2px 0 0;
  border: none; border-radius: var(--radius); background: none; color: var(--text-2); cursor: pointer;
}
.toast-close:hover { background: var(--neutral-100); color: var(--text); }
.toast-close svg { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
@media (min-width: 640px) {
  .toasts { left: auto; right: 24px; top: calc(var(--topbar-h) + 16px); align-items: flex-end; width: 400px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.is-leaving { animation: none; }
  .btn.is-loading::after { animation-duration: 1.6s; }
}

/* ---------- Launcher: Today ---------- */
a.today-card { color: var(--text); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
a.today-card:hover { border-color: var(--border-strong); box-shadow: 0 8px 24px -14px var(--ink-25); }
.today-card .value.warn { color: var(--warning-700); }
.today-note { font-size: 13px; color: var(--text-2); }
.today-note.good { color: var(--success-700); font-weight: 600; }
.today-system { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.today-system a { color: var(--primary-600); font-weight: 500; }
@media (min-width: 640px) { .today-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------- Branch switcher (top bar) ---------- */
.branch-wrap { display: none; }
button.branch-chip { font-family: inherit; cursor: pointer; position: relative; }
/* The chip looks 36 px tall but the whole 44 px around it can be tapped. */
button.branch-chip::after { content: ''; position: absolute; left: 0; right: 0; top: -4px; bottom: -4px; }
.branch-chip.is-switch:hover, .branch-chip.is-switch[aria-expanded="true"] { background: var(--neutral-100); border-color: var(--border-strong); }
.branch-chip > svg { width: 14px; height: 14px; color: var(--text-2); margin-right: -4px; }
.branch-menu { min-width: 240px; }
.menu .menu-title { padding: 6px 12px 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.menu .menu-sep { height: 1px; margin: 4px 0; background: var(--border); }
.menu .menu-option { justify-content: space-between; font-weight: 500; }
.menu .menu-option.is-current { color: var(--primary-700); font-weight: 600; }
.menu .menu-option svg { width: 18px; height: 18px; color: var(--primary-600); }
@media (min-width: 640px) { .branch-wrap { display: block; } }
.nav-branch { display: flex; flex-direction: column; gap: 6px; padding: 4px 4px 10px; }
.nav-branch label { font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ---------- Printing an app page (lists, reports, the tax summary) ----------
   Only the page's own content prints, as a plain table that fits an A4 page: no top bar, menu, buttons,
   search or paging; every row of the list (not just the page on screen); the column heads repeat on each
   page; a small header says which store and branch, when and by whom (shell.js adds it). */
.print-header { display: none; }
@media print {
  @page { size: A4; margin: 12mm 12mm 14mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: var(--white) !important; }
  body { font-size: 10pt; }
  .topbar, .sidenav, .scrim, .skip-link, .toasts, .page-head .actions, .filters, .sort-bar, .pager, .table-foot .btn,
  .actionbar, .dialog-close, .empty-btns, .page-icon, .row-actions, .row-actions-cell, .picker-clear, .menu, .app-menu,
  .btn-row, .link-btn, dialog { display: none !important; }
  .app-body { display: block !important; }
  .content, .content-narrow { padding: 0 !important; max-width: none !important; gap: 10px !important; }
  .print-header { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--neutral-400); font-size: 8.5pt; color: var(--neutral-700); }
  .page-head { padding-bottom: 6px !important; border-bottom: 1.5px solid var(--text) !important; gap: 4px !important; }
  .page-head h1 { font-size: 17pt !important; }
  .page-head p { font-size: 9.5pt !important; max-width: none !important; }
  .page-head .titles, .page-head .titles.has-icon { display: block !important; text-align: left !important; }
  .page-head .titles > * + * { margin-top: 2px; }
  .crumb { display: none !important; }
  .split { display: block !important; }
  .split-side.is-sticky, .card-note { display: none !important; }
  .split-side { margin-top: 10px; }
  .card, .stats, .stat, .rt-wrap, .form-section { box-shadow: none !important; }
  .card { border: none !important; padding: 0 !important; gap: 8px !important; break-inside: auto; }
  .card h2 { font-size: 12pt !important; }
  .stats { border-color: var(--neutral-300) !important; background: var(--neutral-300) !important; break-inside: avoid; }
  .stat { padding: 6px 10px !important; flex-basis: 0 !important; }
  .stat .label { font-size: 8pt !important; }
  .stat .value { font-size: 14pt !important; }
  /* Lists always print as a table, whatever the screen width was. */
  .rt-wrap { overflow: visible !important; border: none !important; border-radius: 0 !important; }
  .rt { display: table !important; width: 100% !important; border-collapse: collapse !important; font-size: 8.5pt !important; }
  .rt thead { position: static !important; width: auto !important; height: auto !important; overflow: visible !important; clip: auto !important; visibility: visible !important; display: table-header-group !important; }
  .rt tbody { display: table-row-group !important; }
  .rt tr { display: table-row !important; padding: 0 !important; box-shadow: none !important; break-inside: avoid; page-break-inside: avoid; }
  .rt th, .rt td { display: table-cell !important; padding: 4px 6px !important; white-space: normal !important; border-top: none !important; border-bottom: 1px solid var(--neutral-300) !important; text-align: left; vertical-align: top !important; }
  .rt th { background: var(--neutral-100) !important; border-bottom: 1.5px solid var(--text) !important; font-size: 8pt !important; color: var(--text) !important; }
  .rt th:first-child, .rt td:first-child { padding-left: 4px !important; }
  .rt th:last-child, .rt td:last-child { padding-right: 4px !important; }
  .rt th.num, .rt td.num { text-align: right !important; }
  .rt td::before { display: none !important; }
  .rt td.name { font-size: 8.5pt !important; padding-top: 4px !important; padding-bottom: 4px !important; }
  .rt .sort-btn { font-weight: 600; color: var(--text) !important; }
  .rt .sort-btn::after { display: none !important; }
  .rt a { color: inherit !important; text-decoration: none !important; }
  .rt .input, .rt .select { border: none !important; padding: 0 !important; min-height: 0 !important; background: none !important; }
  .badge { padding: 0 6px !important; font-size: 7.5pt !important; }
  .table-foot { font-size: 8pt; color: var(--neutral-700); }
  .empty-state { border: none !important; padding: 12px 0 !important; }
  .empty-pic { display: none !important; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Payroll ---------- */
/* A grey line under a name in a pay run row (position and branch, or the note of a correction). */
.pay-sub { display: block; font-size: 13px; font-weight: 400; line-height: 1.4; color: var(--text-2); }
.pay-sub.is-fixed { color: var(--warning-700); }
.rt tr.pay-total td { font-weight: 600; }
/* Tax table bands and time-off types: narrower boxes, so the columns stay a table inside the form column. */
.pay-bands .rt .input { width: 112px; }
.pay-bands .rt .input.wide { width: 150px; }
/* Buttons in a row sit above the name link, which covers the whole stacked row on narrow screens. */
.rt .row-actions { position: relative; z-index: 1; }

/* License ended: one amber bar under the top bar on every back-office page (js/license.js). */
.license-bar { padding: 10px 16px; background: var(--warning-50); border-bottom: 1px solid var(--warning-200); color: var(--warning-800); font-size: 14px; line-height: 1.5; }
.license-bar strong { font-weight: 600; }
.license-bar a { color: var(--warning-800); font-weight: 600; text-decoration: underline; }
@media (min-width: 960px) { .license-bar { padding: 10px 32px; } }
@media print { .license-bar { display: none; } }

/* A small grey second line under a product name in a table (for example "5 variants"). */
.line-sub { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--text-2); }

/* The store's logo mark (img/logo.png: cut from the picture Eliseo Pharmacy sent, img/eliseo-logo-original.jpg, not redrawn) replaces the letter mark everywhere the mark is drawn. With a real
   logo from Settings, Website the same places show that picture instead. The letter stays in the markup for screen
   readers and is only made invisible. */
.brand-mark, .pos-top .mark, .pair-brand .mark, .doc-brand .mark, .gc-brand .mark {
  background: url("../img/logo.png") center / cover no-repeat !important;
  color: transparent !important;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}

/* Where there is room, the store's whole logo (mark and words) is shown instead of the mark and the typed name:
   the sign-in pages' card and the store website's header and footer. The typed name stays in the markup for
   screen readers and is only made invisible. */
.auth-card .brand:not(.is-product), .site-head .brand, .site-foot-name { font-size: 0; gap: 0; }
.auth-card .brand:not(.is-product) .brand-mark, .site-head .brand .brand-mark, .site-foot-name .brand-mark {
  width: auto !important; height: 52px; aspect-ratio: 446 / 192; border-radius: 0; box-shadow: none;
  background: url("../img/logo-full.png") center / contain no-repeat !important;
}
.site-head .brand .brand-mark { height: 40px; }
.site-foot-name .brand-mark { height: 36px; mix-blend-mode: multiply; } /* the logo's white backdrop melts into the grey footer */
/* First-time setup comes before a store exists, so it keeps the product's own letter mark. */
.brand.is-product .brand-mark { background: var(--primary) !important; color: var(--white) !important; }
