/* Fonts are served from this app (latin subset, SIL Open Font License), so first paint does not wait on another site. */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 500; font-display: swap; src: url("/fonts/newsreader-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/newsreader-latin-600-normal.woff2") format("woff2"); }

/* Payroll — Apple iOS inspired design system */
:root {
  /* Crisp, calming Apple canvas: soft light slate */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #edf2f7;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0b1526;
  --text-2: #334155;
  --text-3: #64748b;
  --primary: #0071e3;
  --primary-2: #005bb5;
  --primary-soft: rgba(0, 113, 227, 0.09);
  --primary-text: #005bb5;
  --accent: #b47814;
  --accent-soft: rgba(212, 165, 60, 0.14);
  --gold: #d4a53c;
  --success: #1b803a;
  --success-soft: rgba(27, 128, 58, 0.1);
  --warning: #b25e02;
  --warning-soft: rgba(200, 115, 10, 0.12);
  --danger: #d70015;
  --danger-soft: rgba(215, 0, 21, 0.1);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.1);
  --sidebar: #ffffff;
  --sidebar-2: rgba(0, 113, 227, 0.06);
  --sidebar-text: #334155;
  --sidebar-muted: #64748b;
  --chart-1: #0071e3;
  --chart-2: #d4a53c;
  --chart-3: #38bdf8;
  --chart-4: #10b981;
  --chart-5: #8b5cf6;
  --hero-bg: linear-gradient(145deg, #e6f0fd 0%, #cce3fc 100%);
  --hero-text: #0b1526;
  --hero-chip-bg: rgba(255, 255, 255, 0.88);
  --hero-track: rgba(255, 255, 255, 0.65);
  --hero-fill: #b47814;
  --hero-shadow: rgba(0, 113, 227, 0.25);
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow: 0 3px 10px -2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 18px 40px -8px rgba(15, 23, 42, 0.14), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-pill: 9999px;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-blur: saturate(180%) blur(20px);
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "IBM Plex Sans", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "SF Mono", "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
/* Dark theme (iOS Dark Mode aesthetic) */
:root[data-theme="dark"] {
  --bg: #090e18;
  --surface: #121927;
  --surface-2: #182236;
  --surface-3: #202d45;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --text-3: #8a9bb5;
  --primary: #409cff;
  --primary-2: #6cb0ff;
  --primary-soft: rgba(64, 156, 255, 0.16);
  --primary-text: #9ec9fa;
  --accent: #f0c563;
  --accent-soft: rgba(240, 197, 99, 0.14);
  --gold: #f0c563;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.14);
  --sidebar: #0c121f;
  --sidebar-2: rgba(255, 255, 255, 0.06);
  --sidebar-text: #e2e8f0;
  --sidebar-muted: #8a9bb5;
  --chart-1: #409cff;
  --chart-2: #f0c563;
  --chart-3: #38bdf8;
  --chart-4: #34d399;
  --chart-5: #a78bfa;
  --hero-bg: linear-gradient(145deg, #162a4a 0%, #101c33 100%);
  --hero-text: #ffffff;
  --hero-chip-bg: rgba(0, 0, 0, 0.35);
  --hero-track: rgba(255, 255, 255, 0.22);
  --hero-fill: #f0c563;
  --hero-shadow: rgba(0, 0, 0, 0.55);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.6);
  --glass-bg: rgba(18, 25, 39, 0.85);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; vertical-align: -3px; flex-shrink: 0; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
:where(#view) h2 { font-size: 1.17em; }
h1, h2, .card-head h3, .kpi .value, .brand-name { font-family: var(--font-display); font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.neg { color: var(--danger); }
.pos { color: var(--success); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border); background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 20px 20px 16px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px;
  background: linear-gradient(135deg, #0071e3 0%, #004fb0 100%);
  box-shadow: 0 3px 8px rgba(0, 113, 227, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.brand-name { color: var(--text); font-size: 16px; font-weight: 650; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); margin-top: 1px; }
.nav { padding: 8px 12px 20px; flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 18px 12px 6px; font-weight: 650; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius); color: var(--sidebar-text);
  font-weight: 500; font-size: 14px; text-decoration: none; position: relative;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s, opacity .15s cubic-bezier(.16, 1, .3, 1);
}
.nav a:hover { background: var(--sidebar-2); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--primary-soft); color: var(--primary-text); font-weight: 650;
}
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .count {
  margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: var(--radius-pill); padding: 2px 8px; line-height: 16px; font-variant-numeric: tabular-nums;
}
.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--sidebar-muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 24px;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}
.topbar .menu-btn { display: inline-flex; }
.topbar .title { font-size: 18px; font-weight: 700; }
.topbar .crumb { font-size: 12px; color: var(--text-3); }
.topbar .spacer { flex: 1; }
.period-picker {
  display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2px; transition: border-color .15s ease, background-color .15s ease;
}
.period-picker:hover { border-color: var(--border-strong); }
.period-picker button { border: 0; background: none; padding: 6px 8px; color: var(--text-2); cursor: pointer; display: grid; place-items: center; border-radius: calc(var(--radius) - 3px); transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s, transform .12s, opacity .12s ease; }
.period-picker button:hover { background: var(--surface); color: var(--primary); }
.period-picker select { border: 0; background: none; font: 600 13px var(--font); color: var(--text); padding: 6px 2px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.period-picker select:focus-visible { outline: 2px solid var(--primary); border-radius: 4px; }
.period-picker input { border: 0; background: none; font: 600 13px var(--font); color: var(--text); padding: 6px 2px; width: 138px; text-align: center; }

.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; position: relative;
  box-shadow: var(--shadow-xs); transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s, opacity .15s cubic-bezier(.16, 1, .3, 1);
}
.user-chip:hover { background: var(--surface-2); border-color: var(--border-strong); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: var(--primary); flex-shrink: 0; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.user-chip .who { line-height: 1.15; }
.user-chip .who b { display: block; font-size: 13px; font-weight: 650; }
.user-chip .who span { font-size: 11px; color: var(--text-3); text-transform: capitalize; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); min-width: 210px; padding: 6px; z-index: 50;
  animation: pane-in .15s cubic-bezier(.16, 1, .3, 1);
}
.menu button, .menu a { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 12px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; border-radius: calc(var(--radius) - 3px); cursor: pointer; text-decoration: none; transition: background-color .12s ease; }
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

.content { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: 32px; font-weight: 650; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards / Grid (Apple iOS Widgets & Containers) ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), box-shadow .2s cubic-bezier(.16, 1, .3, 1), border-color .2s ease;
  overflow: hidden;
}
.card:hover { border-color: var(--border-strong); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 16px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.card-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 22px; }
.card-body.flush { padding: 0; }
/* Tables inside a card line up with the card's own 22px padding. */
.card-body.flush .table th:first-child, .card-body.flush .table td:first-child { padding-left: 22px; }
.card-body.flush .table th:last-child, .card-body.flush .table td:last-child { padding-right: 22px; }
.card-body.flush > .table-wrap:last-child, .card-body.flush > .table:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-foot { padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.two { grid-template-columns: 2fr 1fr; }
.grid.halves { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }

/* Apple iOS Widget KPI Cards */
.kpi {
  padding: 20px 22px; position: relative; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), box-shadow .2s cubic-bezier(.16, 1, .3, 1), border-color .2s ease;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.kpi .label { font-size: 13px; color: var(--text-2); font-weight: 550; display: flex; align-items: center; gap: 10px; }
.kpi .icon {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); flex-shrink: 0;
  transition: transform .15s ease;
}
.kpi:hover .icon { transform: scale(1.05); }
.kpi .icon.blue { background: var(--info-soft); color: var(--info); }
.kpi .icon.green { background: var(--success-soft); color: var(--success); }
.kpi .icon.amber, .kpi .icon.coins { background: var(--warning-soft); color: var(--warning); }
.kpi .icon.red { background: var(--danger-soft); color: var(--danger); }
.kpi .icon svg { width: 18px; height: 18px; }
.kpi .value { font-size: 32px; font-weight: 650; margin-top: 10px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .value small { font-size: 15px; color: var(--text-3); font-weight: 600; margin-right: 3px; font-family: var(--font); }
.kpi .foot { font-size: 12.5px; color: var(--text-3); margin-top: 6px; line-height: 1.4; }
/* ---------- Buttons (Apple iOS Tactile Style) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 13.5px var(--font);
  cursor: pointer; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-xs);
  transition: transform .12s cubic-bezier(.2, .8, .2, 1), background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: linear-gradient(180deg, #196dc9 0%, #13539f 100%);
  border-color: rgba(19, 83, 159, 0.4);
  color: #fff;
  box-shadow: 0 2px 6px rgba(19, 83, 159, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #2076d6 0%, #155bb0 100%);
  box-shadow: 0 3px 10px rgba(19, 83, 159, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.btn.success {
  background: linear-gradient(180deg, #22934c 0%, #17753b 100%);
  border-color: rgba(23, 117, 59, 0.4);
  color: #fff;
  box-shadow: 0 2px 6px rgba(23, 117, 59, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.btn.danger {
  background: linear-gradient(180deg, #cb2929 0%, #aa1c1c 100%);
  border-color: rgba(170, 28, 28, 0.4);
  color: #fff;
  box-shadow: 0 2px 6px rgba(170, 28, 28, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger-ghost { border-color: transparent; background: transparent; color: var(--danger); box-shadow: none; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: calc(var(--radius) - 3px); }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn.loading { pointer-events: none; opacity: .7; }

/* ---------- Forms (Apple iOS Inset & Aura Focus) ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .field .lbl { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: -.01em; }
.field .hint { font-size: 13px; color: var(--text-3); line-height: 1.4; }
.input, select.input, textarea.input {
  height: 42px; padding: 0 13px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font: 15px var(--font); width: 100%; box-shadow: var(--shadow-xs);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
textarea.input { height: auto; padding: 10px 13px; resize: vertical; min-height: 84px; }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px var(--primary-soft); background: var(--surface); }
.input:disabled { background: var(--surface-2); color: var(--text-3); border-color: var(--border); }
.input.sm { height: 34px; font-size: 13.5px; border-radius: calc(var(--radius) - 3px); padding: 0 10px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 6px; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search .input { padding-left: 36px; border-radius: var(--radius-pill); background: var(--surface-2); }
.search .input:focus { background: var(--surface); }

/* ---------- Apple iOS Segmented Control ---------- */
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--radius); padding: 3px; gap: 3px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04); }
.seg button {
  border: 0; background: none; padding: 6px 14px; border-radius: calc(var(--radius) - 3px); font: 600 13px var(--font); color: var(--text-2);
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s, opacity .15s cubic-bezier(.2, .8, .2, 1); white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04); }

/* ---------- Tables (Apple Clean Inset) ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 12.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
  padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; transition: background-color .12s ease; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .c { text-align: center; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); padding: 12px 16px; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table .who { display: flex; align-items: center; gap: 10px; }
.table .who .avatar { width: 32px; height: 32px; font-size: 12px; }
.table .who b { display: block; font-weight: 600; }
.table .who span { font-size: 12px; color: var(--text-3); }
.table.compact td { padding: 8px 12px; }

/* Spreadsheet-like entry grid */
.sheet td { padding: 4px 6px; }
.sheet th.name { padding: 6px 14px; text-align: left; text-transform: none; letter-spacing: 0; font-size: 13.5px; color: var(--text); white-space: nowrap; }
.sheet input { width: 100%; min-width: 88px; height: 34px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); font: 14px var(--font); text-align: right; padding: 0 8px; font-variant-numeric: tabular-nums; transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s, transform .12s, opacity .12s ease; }
.sheet input.text { text-align: left; min-width: 120px; }
.sheet input:hover { border-color: var(--border); }
.sheet input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.sheet tr.dirty td { background: color-mix(in srgb, var(--warning-soft) 70%, transparent); }
.sheet tr.dirty th.name::before { content: "●"; color: var(--warning); margin-right: 6px; font-size: 10px; }
.sheet tr.error td { background: var(--danger-soft); }
.sheet .calc { text-align: right; padding-right: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet input:disabled { color: var(--text-3); }

/* ---------- Badges / pills (Apple iOS Capsule Tags) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; background: var(--surface-3); color: var(--text-2);
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge.green, .badge.auto_approved, .badge.approved, .badge.finalized, .badge.active { background: var(--success-soft); color: var(--success); }
.badge.amber, .badge.pending_review, .badge.open { background: var(--warning-soft); color: var(--warning); }
.badge.red, .badge.rejected, .badge.inactive, .badge.disabled { background: var(--danger-soft); color: var(--danger); }
.badge.blue, .badge.manager { background: var(--info-soft); color: var(--info); }
.badge.indigo, .badge.guy, .badge.admin { background: var(--primary-soft); color: var(--primary-text); }
.flag { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-size: 14px; margin-bottom: 8px; border: 1px solid rgba(197, 34, 34, 0.16); }
.flag b { font-weight: 700; white-space: nowrap; }
.flag span { color: var(--text); }
.chip { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--danger-soft); color: var(--danger); margin: 1px 2px 1px 0; }

/* ---------- Alerts / Empty ---------- */
.alert { display: flex; gap: 12px; padding: 13px 16px; border-radius: var(--radius); border: 1px solid; font-size: 13.5px; align-items: flex-start; box-shadow: var(--shadow-xs); }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--text); }
.alert.info svg { color: var(--info); }
.alert.warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert.warn svg { color: var(--warning); }
.alert.ok { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert.ok svg { color: var(--success); }
.alert.err { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.err svg { color: var(--danger); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .ico { display: grid; place-items: center; margin: 0 auto 10px; color: var(--text-3); }
.empty .ico svg { width: 24px; height: 24px; }
.empty h4, .empty .empty-title { color: var(--text); font-size: 15px; font-weight: 650; margin: 0 0 4px; }

/* ---------- Stepper ---------- */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; position: relative; }
.step + .step { border-left: 1px solid var(--border); }
.step .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; background: var(--surface-3); color: var(--text-3); border: 2px solid var(--border); transition: background-color .2s, border-color .2s, color .2s, box-shadow .2s, transform .2s, opacity .2s ease; }
.step.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.current .dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.step.warn .dot { background: var(--warning); border-color: var(--warning); color: #fff; }
.step .t { font-weight: 650; font-size: 13.5px; }
.step .d { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- Progress / bars ---------- */
.progress { height: 6px; background: var(--surface-3); border-radius: var(--radius-sm); overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; border-radius: var(--radius-sm); background: var(--primary); }
.progress.green > span { background: var(--success); }
.progress.amber > span { background: var(--warning); }
.progress.red > span { background: var(--danger); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow b { display: block; font-weight: 600; font-size: 13.5px; }
.list-item .grow span { font-size: 12px; color: var(--text-3); }

/* ---------- Charts ---------- */
.chart { width: 100%; display: block; }
.chart text { fill: var(--text-3); font: 11px var(--font); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis { stroke: var(--border-strong); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-tip {
  position: fixed; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 12px; line-height: 1.35; z-index: 100; box-shadow: var(--shadow-md); white-space: nowrap;
}

/* ---------- Overlays (Apple Sheet & Modal) ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  z-index: 60; animation: fade .18s ease-out;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  z-index: 61; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: drawerSlide .24s cubic-bezier(.16, 1, .3, 1);
}
.drawer-head, .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-head h3, .modal-head h3 { font-size: 17px; font-weight: 650; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.drawer-foot, .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  z-index: 61; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.04);
  animation: modalPop .22s cubic-bezier(.16, 1, .3, 1);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { width: min(980px, calc(100vw - 32px)); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes modalPop { from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes drawerSlide { from { transform: translateX(100%); } to { transform: translateX(0); } }

.toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  display: flex; gap: 12px; align-items: center; min-width: 280px; max-width: 460px;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 16px;
  box-shadow: var(--shadow-lg); animation: toastPop .25s cubic-bezier(.16, 1, .3, 1); font-size: 13.5px;
}
@keyframes toastPop { from { transform: translateY(16px) scale(0.95); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.toast.err { border-color: rgba(197, 34, 34, 0.4); background: color-mix(in srgb, var(--danger-soft) 40%, var(--glass-bg)); }
.toast.warn { border-color: rgba(160, 90, 6, 0.4); background: color-mix(in srgb, var(--warning-soft) 40%, var(--glass-bg)); }
.toast.ok { border-color: rgba(27, 128, 58, 0.4); background: color-mix(in srgb, var(--success-soft) 40%, var(--glass-bg)); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.ok svg { color: var(--success); } .toast.err svg { color: var(--danger); } .toast.warn svg { color: var(--warning); }

/* ---------- Tabs (Apple iOS Segmented Pill Strip) ---------- */
.tabs {
  display: flex; gap: 6px; border-bottom: 0; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 1px solid transparent; background: var(--surface-2); border-radius: var(--radius-pill);
  padding: 8px 16px; font: 600 13.5px var(--font); color: var(--text-2); cursor: pointer;
  white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s ease;
}
.tabs button:hover { background: var(--surface-3); color: var(--text); }
.tabs button.on {
  background: var(--surface); color: var(--primary); border-color: var(--border-strong);
  box-shadow: var(--shadow-sm); font-weight: 650;
}

/* ---------- Profile ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; padding: 20px; flex-wrap: wrap; }
.profile-head h1, .profile-head h2 { font-size: 20px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.breakdown { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.breakdown td { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown tr.total td { border-bottom: 0; border-top: 2px solid var(--border-strong); font-weight: 700; padding-top: 9px; }
.diff s { color: var(--danger); text-decoration: line-through; }
.diff ins { color: var(--success); text-decoration: none; font-weight: 600; }
.diff div { margin: 1px 0; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 5fr) 7fr; }
.auth-art { background: var(--surface-2); border-right: 1px solid var(--border); padding: 40px 40px 32px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.art-title { font-size: 34px; line-height: 1.15; letter-spacing: -.3px; max-width: 14em; }
.auth-art p { color: var(--text-2); max-width: 30em; font-size: 15px; margin: 14px 0 0; }
.auth-art ol { list-style: none; counter-reset: s; padding: 0; margin: 28px 0 0; max-width: 30em; border-top: 1px solid var(--border-strong); }
.auth-art li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: 14px; }
.auth-art li::before { content: counter(s) "."; font-family: var(--mono); color: var(--text-3); }
.auth-art .note { font-size: 13px; color: var(--text-3); }
.auth-form { display: flex; align-items: center; padding: 32px clamp(24px, 8vw, 120px); }
.auth-card { width: min(380px, 100%); }
.auth-card h1.auth-title { font-size: 30px; margin-bottom: 6px; }
.auth-card form { display: grid; gap: 16px; margin-top: 24px; }
.auth-card .btn { height: 42px; }

.loading-screen { min-height: 60vh; display: grid; place-items: center; color: var(--text-3); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: var(--surface-3); border-radius: var(--radius-sm); height: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid.two, .grid.halves, .grid.three { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .step + .step { border-left: 0; border-top: 1px solid var(--border); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar .user-chip .who { display: none; }
  .content { padding: 16px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media print {
  .sidebar, .topbar, .actions, .btn { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; }
}

/* ======================================================================
   Accessibility & responsive fixes (UI audit, Oct 2026)
   ====================================================================== */

/* Visible keyboard focus everywhere (2.4.7) */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav a:focus-visible { outline-offset: -2px; }
.sheet input:focus-visible { outline: 2px solid var(--primary); }
.table-wrap:focus-visible { outline-offset: -2px; }

/* Skip link (2.4.1) */
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 12px; text-decoration: none; }
#view:focus { outline: none; }
.page-head h1:focus, #view h1:focus { outline: none; }

/* Grid children may shrink so wide tables scroll inside their card instead of the page (1.4.10) */
.grid > *, .stack > * { min-width: 0; }
.kpi .value { overflow-wrap: anywhere; }

/* Sortable headers are buttons (2.1.1) with a visible direction */
.th-sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }
th.r .th-sort { justify-content: flex-end; width: 100%; }
.sort-ind::after { content: "↕"; opacity: .45; font-size: 11px; }
th[aria-sort="ascending"] .sort-ind::after { content: "▲"; opacity: 1; font-size: 9px; }
th[aria-sort="descending"] .sort-ind::after { content: "▼"; opacity: 1; font-size: 9px; }
.row-act { width: 1%; white-space: nowrap; }
.row-act .btn svg { width: 14px; height: 14px; }

/* Toasts: dismiss button; errors persist */
.toast { align-items: center; }
.toast-msg { flex: 1; }
.toast-x { border: 0; background: none; color: var(--text-2); cursor: pointer; padding: 4px; border-radius: 6px; display: grid; place-items: center; }
.toast-x:hover { background: var(--surface-3); }
.toast-x svg { width: 14px; height: 14px; }
@media (max-width: 860px) { .toasts { left: 12px; right: 12px; bottom: 12px; } .toast { min-width: 0; max-width: none; } }

/* Sheet validation (3.3.1) */
.sheet input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.sheet tr.error td { background: var(--danger-soft); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 2px; }
.sheet-errors { margin: 0 18px 14px; }

/* Sheets: keep the name column visible while scrolling sideways; sticky save bar */
.sheet thead th:first-child, .sheet tbody th.name, .sheet tfoot th:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
.sheet thead th:first-child { background: var(--surface-2); z-index: 3; }
.sheet tr.dirty th.name { background: color-mix(in srgb, var(--warning-soft) 100%, var(--surface)); }
.sheet tr.error th.name { background: var(--danger-soft); }
.savebar {
  position: sticky; bottom: 0; z-index: 4;
  background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.savebar.has-changes { box-shadow: 0 -8px 24px -6px rgba(15, 23, 42, .18); border-top-color: var(--border-strong); }
.scroll-hint { font-size: 12px; color: var(--text-3); padding: 6px 18px 0; display: none; }
@media (max-width: 860px) { .scroll-hint { display: block; } }

/* Month picker built from selects (works in every browser) */
.period-picker select { border: 0; background: none; font: 600 13px var(--font); color: var(--text); padding: 6px 2px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.period-picker select:focus-visible { outline: 2px solid var(--primary); border-radius: 4px; }
.period-picker .sep { width: 4px; }

/* Breadcrumb in the top bar (the page's own h1 is the title) */
.topbar .crumbs { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; min-width: 0; }
.topbar .crumbs b { color: var(--text); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .filters { display: flex; gap: 10px; align-items: center; }
.filterbar { display: none; }

/* User menu as a disclosure button */
.user-chip { font: inherit; color: inherit; text-align: left; }
.menu[hidden] { display: none; }

/* Read-only / hint banners */
.readonly-note { margin-bottom: 16px; }
.btn-hint { font-size: 12px; color: var(--text-2); }

/* Mobile: compact sticky header, filters scroll with the page, slide-out menu with backdrop */
.sidebar-close { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  .topbar { flex-wrap: nowrap; padding: 8px 12px; gap: 8px; min-height: 56px; }
  .topbar .crumbs { font-size: 14px; }
  .topbar .crumbs .crumb-group, .topbar .crumbs .crumb-sep { display: none; }
  .topbar .filters { display: none; }
  .filterbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px 0; }
  .filterbar .filters { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  .filterbar select.input { flex: 1; min-width: 140px; }
  .sidebar { z-index: 70; width: min(280px, 85vw); visibility: hidden; transition: transform .2s, visibility 0s .2s; }
  .sidebar.open { visibility: visible; transition: transform .2s; }
  .sidebar-close { display: inline-flex; position: absolute; top: 14px; right: 10px; color: var(--sidebar-text); }
  .sidebar-close:hover { background: var(--sidebar-2); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(8, 19, 41, .5); z-index: 65; }
  .page-head h1 { font-size: 21px; }
}

/* Desktop icons-only sidebar */
.shell { transition: grid-template-columns .15s; }
.shell.rail { grid-template-columns: 64px 1fr; }
.shell.rail .brand { padding: 18px 15px 14px; }
.shell.rail .brand > div:last-child, .shell.rail .nav-group, .shell.rail .sidebar-foot { display: none; }
.shell.rail .nav { padding: 6px 10px 16px; }
.shell.rail .nav a { justify-content: center; padding: 9px 0; }
.shell.rail .nav a > span:not(.count) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.shell.rail .nav .count { position: absolute; top: 2px; right: 2px; margin: 0; padding: 0 5px; font-size: 10px; line-height: 15px; }
.shell.rail .nav a.active::before { left: -10px; }

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .spinner { animation: spin 1.5s linear infinite !important; }
}



/* Keep the top bar on one line when the sheet area is narrow */
.topbar .crumbs { flex-shrink: 0; white-space: nowrap; }
.topbar .crumbs b { max-width: 14ch; }
.user-chip .who { white-space: nowrap; }
@media (max-width: 1180px) and (min-width: 861px) { .user-chip .who { display: none; } }

/* Employees list: one line per row; phone number only when there is room */
.table.people td, .table.people th { white-space: nowrap; }
.table.people td { padding: 9px 12px; }
.table.people .row-act { width: 1%; padding-left: 4px; }
.table.people .phone { display: none; }
@media (min-width: 1500px) { .table.people .phone { display: inline; } }
@media (max-width: 1279px) {
  .table.people th:nth-child(4), .table.people td:nth-child(4),
  .table.people th:nth-child(7), .table.people td:nth-child(7) { display: none; }
}

/* Dark theme: the primary is a light green, so text on it must be dark */
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .avatar,
:root[data-theme="dark"] .step.current .dot, :root[data-theme="dark"] .step.done .dot, :root[data-theme="dark"] .skip-link { color: #0b1630; }
:root[data-theme="dark"] .nav .count { color: #1a0f08; }

/* Phones and touch: controls at least 40px tall so they are easy to hit */
@media (max-width: 860px) {
  .period-picker { min-height: 40px; }
  .period-picker button { min-width: 40px; min-height: 40px; }
  .period-picker select { min-height: 40px; padding: 0 4px; }
  .btn.sm, .btn.sm.icon { min-height: 40px; }
  .btn.sm.icon { min-width: 40px; }
  .input.sm { height: 40px; }
  .seg button { min-height: 44px; padding: 6px 14px; }
  .th-sort, .user-chip { min-height: 44px; }
  .period-picker select { font-size: 16px; }
  .btn, .btn.sm, .btn.sm.icon, .period-picker, .period-picker button, .period-picker select { min-height: 44px; }
  .btn.icon, .btn.sm.icon, .period-picker button { min-width: 44px; }
  .input, .input.sm { height: auto; min-height: 44px; font-size: 16px; }
  .sheet input { height: 44px; font-size: 16px; }
  .nav a { min-height: 44px; }
  .tabs button { min-height: 44px; }
  .table tbody td:first-child, .table thead th:first-child, .table tfoot td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
  .table thead th:first-child { background: var(--surface-2); z-index: 2; }
}

/* ---------- Polish: brand sidebar, richer cards, matching sign-in ---------- */
.sidebar { border-right: 1px solid var(--border); }
.brand-name { color: var(--text); }
.brand-mark { background: var(--gold); color: #0f2749; }
.nav a:hover { background: var(--sidebar-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav a.active::before { background: var(--gold); }
.nav a:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sidebar-foot { border-top: 1px solid var(--border); }

.topbar {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.card { border-radius: var(--radius-lg); }
.table th { letter-spacing: .04em; }

/* Summary cards (Apple iOS Widget style) */
.kpi {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  transition: transform .18s cubic-bezier(.16, 1, .3, 1), box-shadow .18s cubic-bezier(.16, 1, .3, 1), border-color .18s ease;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.kpi .icon { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.kpi .icon.blue { background: var(--info-soft); color: var(--info); }
.kpi .icon.green { background: var(--success-soft); color: var(--success); }
.kpi .icon.amber { background: var(--warning-soft); color: var(--warning); }
.kpi .icon.red { background: var(--danger-soft); color: var(--danger); }
.kpi .value { font-size: 30px; letter-spacing: -.3px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Sign-in: a light blue panel, matching the app. */
.auth-art { background: var(--primary-soft); border-right: 1px solid var(--border); color: var(--text); }
.auth-art .brand-name { color: var(--text); }
.auth-art .brand-sub { color: var(--text-3); }
.auth-art .art-title, .auth-art h2.art-title { color: var(--text); }
.auth-art p { color: var(--text-2); }
.auth-art ol { border-top-color: var(--border-strong); }
.auth-art li { border-bottom-color: var(--border); color: var(--text); }
.auth-art li::before { color: var(--accent); }
.auth-art .note { color: var(--text-3); }

/* ---------- Layout and utilities (replace one-off inline styles) ---------- */
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mt-4 { margin-top: var(--sp-4); }
.text-sm { font-size: 12px; }
.fw-400 { font-weight: 400; }
.stat-lg { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.sub-head { margin: var(--sp-5) 0 var(--sp-2); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); }
.page-head { margin-bottom: var(--sp-5); }
.grid { gap: var(--sp-4); }
.stack { gap: var(--sp-4); }
@media (min-width: 1280px) { .content { padding: 28px 32px; } }

/* A negative figure on a summary card reads as a warning. */
.kpi:has(.icon.red) .value { color: var(--danger); }
/* Cards that open something respond to hover and keyboard focus. */
.card[data-href], .card.clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.card[data-href]:hover, .card.clickable:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: var(--sp-2); }
.card-head .sub { margin-top: 2px; }
/* A person's name is the row's anchor: keep it on one line where it can. */
.card-body.flush .table td:first-child b { white-space: nowrap; }

/* ---------- Phone polish: readable text, safe areas, steadier forms ---------- */
html.modal-open, html.modal-open body { overflow: hidden; }
.drawer-body, .modal-body { overscroll-behavior: contain; }
.lbl-sm { }
.hide-sm { }
.portal-tabs .tab-ic, .portal-tabs .sm { display: none; }
.portal-tabs .cnt { margin-left: 4px; font-weight: 500; opacity: .8; }
.tabs.fade-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.tabs.fade-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); }
.tabs.fade-l.fade-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 18px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { font-size: 15px; font-weight: 650; }
details.fold > summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2); transform: rotate(45deg); transition: transform .15s; margin-right: 4px; }
details.fold[open] > summary::after { transform: rotate(-135deg); }
details.fold > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.auth-brand { display: none; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 48px; }
.pw-toggle { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none; color: var(--text-2); border-radius: var(--radius); cursor: pointer; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.input[aria-invalid="true"] { border-color: var(--danger); }

@media (max-width: 860px) {
  /* Readable text. Nothing the person has to read is smaller than 13px, body copy is 15px. */
  body { font-size: 15px; }
  select.input, select.input.sm, textarea.input { font-size: 16px; min-height: 44px; }
  table.table, .breakdown, .kv, .alert, .sheet th.name, .list-item .grow b, .step .t, .menu a, .menu button { font-size: 15px; }
  .table thead th, .th-sort { font-size: 12.5px; }
  .card-head .sub, .kpi .foot, .kpi .label, .field .hint, .field-error, .list-item .grow span, .step .d, .table .who span, .text-sm, .legend,
  .btn-hint, .scroll-hint, .topbar .crumb, .sidebar-foot, .user-chip .who span, .brand-sub, .badge, .chip, .form-section, .field label, .field .lbl,
  .sub-head, .kpi .value small, .nav .count { font-size: 13px; }
  .nav-group { font-size: 12px; }
  /* Captions that pages size inline (11px to 12.5px) also come up to 13px on a phone */
  [style*="font-size:11px"]:not(.avatar), [style*="font-size:11.5px"]:not(.avatar), [style*="font-size:12px"]:not(.avatar), [style*="font-size:12.5px"]:not(.avatar) { font-size: 13.5px !important; }
  .nav a { font-size: 15px; }
  .btn { font-size: 14.5px; }
  .card-head h2, .card-head h3, details.fold > summary h2 { font-size: 16px; }
  .tabs button { font-size: 14.5px; }

  /* Safe areas: notch, rounded corners and the home bar */
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .content { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .savebar { padding: 8px max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .toasts { bottom: max(12px, env(safe-area-inset-bottom)); }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }

  /* Two cards per row: a phone shows the whole summary in one screen instead of four */
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid.kpis .kpi { padding: 12px; min-width: 0; }
  .grid.kpis .kpi .value { font-size: 26px; }

  /* Daily sheet: shorter header so the first row is near the top, three columns on screen */
  .hide-sm { display: none; }
  .lbl-sm { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .btn:has(> .lbl-sm) { min-width: 44px; padding: 0 12px; }
  .page-head { margin-bottom: 12px; gap: 10px; }
  .page-head .actions { flex-wrap: nowrap; }
  .card-head { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .card-head .row { gap: 6px; }
  .card-head .row h2 { font-size: 15px; margin-left: 2px; }
  .sheet td { padding: 4px 2px; }
  .sheet th.name { padding: 6px 8px; white-space: nowrap; width: 132px; max-width: 132px; overflow: hidden; text-overflow: ellipsis; }
  .sheet th.name b { font-size: 14.5px; }
  .sheet input { min-width: 88px; padding: 0 4px; }
  .sheet .calc { padding-right: 10px; }
  .savebar { gap: 8px; }
  .savebar #dirty-info { font-size: 13px; line-height: 1.25; max-width: 38%; }
  .savebar .btn { min-height: 44px; padding: 0 14px; }

  /* Sign-in: brand on top, since the side panel is hidden on a phone */
  .auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
  .auth-brand .brand-name { color: var(--text); font-size: 18px; }
  .auth-brand .brand-sub { color: var(--text-3); }
  .auth-brand .brand-mark { width: 44px; height: 44px; font-size: 22px; }
  .auth-form { padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }

  /* Staff portal: a bottom tab bar, the way phone apps work (Apple iOS Frosted Glass) */
  .portal-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0; overflow: visible; gap: 0;
    background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border); border-bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
  }
  .portal-tabs button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 6px 2px; margin: 0;
    border: 0; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--text-3); cursor: pointer;
    transition: transform .12s cubic-bezier(.2, .8, .2, 1), color .12s ease;
  }
  .portal-tabs button.on { color: var(--primary); font-weight: 650; }
  .portal-tabs .tab-ic { display: block; line-height: 0; }
  .portal-tabs .tab-ic svg { width: 22px; height: 22px; }
  .portal-tabs .lg, .portal-tabs .cnt { display: none; }
  .portal-tabs .sm { display: inline; }
  .has-bottom-tabs { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  body:has(.portal-tabs) .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  details.fold > summary { padding: 0 14px; min-height: 52px; }
}

/* ---------- Apple iOS Segmented Deck Switcher ---------- */
.month-deck-nav {
  display: flex; width: 100%; margin-bottom: 16px; background: var(--surface-3);
  padding: 3px; border-radius: var(--radius); gap: 3px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.month-deck-nav button {
  flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 6px 10px; border-radius: calc(var(--radius) - 3px);
  font: 600 13px var(--font); color: var(--text-2); border: 0; background: none;
  cursor: pointer; white-space: nowrap; transition: all .15s cubic-bezier(.16, 1, .3, 1);
}
.month-deck-nav button svg { width: 16px; height: 16px; flex-shrink: 0; }
.month-deck-nav button:hover { color: var(--text); }
.month-deck-nav button.on {
  background: var(--surface); color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04); font-weight: 650;
}
.month-deck-nav button .badge { margin-left: 2px; font-size: 11px; padding: 1px 6px; }
#month-deck-body { min-height: 120px; }
#month-deck-body > div[hidden] { display: none !important; }

/* Approvals category pill filter */
#app-filters { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 3px; width: 100%; }
#app-filters::-webkit-scrollbar { display: none; }
#app-filters button { white-space: nowrap; font-size: 13px; padding: 8px 14px; min-height: 40px; }

/* ---------- App feel: hero card, grouped lists, skeletons, motion ---------- */
html { -webkit-tap-highlight-color: transparent; }
.hero { position: relative; overflow: hidden; color: var(--hero-text); border-radius: 22px; padding: 20px 20px 18px; margin-bottom: 14px;
  background: var(--hero-bg); box-shadow: 0 14px 28px -16px var(--hero-shadow); }
.hero::before { content: ""; position: absolute; right: -60px; top: -70px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0)); pointer-events: none; }
.hero .h-top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; color: var(--hero-text); }
.hero .h-chip { background: var(--hero-chip-bg); color: var(--hero-text); padding: 3px 11px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.hero .h-label { margin-top: 16px; font-size: 14.5px; color: var(--hero-text); }
.hero .h-amount { font: 600 44px/1.1 var(--font-display); letter-spacing: -.5px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; word-break: break-word; }
.hero .h-amount small { font: 600 20px var(--font); margin-right: 6px; color: var(--hero-text); letter-spacing: 0; }
.hero .h-foot { font-size: 14px; color: var(--hero-text); }
.hero .h-bar { height: 9px; border-radius: 99px; background: var(--hero-track); overflow: hidden; margin-top: 18px; }
.hero .h-bar span { display: block; height: 100%; background: var(--hero-fill); border-radius: 99px; animation: grow .8s cubic-bezier(.2, .8, .2, 1); }
.hero .h-bar + .h-foot { margin-top: 8px; }
@keyframes grow { from { width: 0 !important; } }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.stat .s-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.stat .s-ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.stat .s-ic svg { width: 16px; height: 16px; }
.stat.blue .s-ic { background: var(--info-soft); color: var(--info); }
.stat.green .s-ic { background: var(--success-soft); color: var(--success); }
.stat.amber .s-ic { background: var(--warning-soft); color: var(--warning); }
.stat .s-value { font: 600 26px/1.15 var(--font-display); margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat .s-value small { font: 600 13px var(--font); color: var(--text-3); margin-right: 3px; }
.stat .s-sub { font-size: 13px; color: var(--text-3); margin-top: 3px; }

/* Apple Inset Grouped List (Settings style) */
.glist { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.g-group + .g-group { border-top: 8px solid var(--bg); }
.g-head { padding: 14px 18px 6px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.g-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 18px; min-height: 52px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; transition: background-color .15s ease; }
.g-group > .g-row:last-child { border-bottom: 0; }
.g-l { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.g-l small, .g-v small { display: block; font-size: 13px; font-weight: 400; color: var(--text-3); margin-top: 1px; }
.g-v { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.g-v small.neg { color: var(--danger); }
.g-v.neg, .g-v.neg small { color: var(--danger); }
.g-v.pos, .g-v.pos small { color: var(--success); }
.g-row.strong { font-weight: 700; background: var(--surface-2); }
.g-row.link { cursor: pointer; padding-right: 36px; position: relative; }
.g-row.link:hover { background: var(--surface-2); }
.g-row.link::after { content: ""; position: absolute; right: 18px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--text-3); border-top: 2px solid var(--text-3); transform: translateY(-50%) rotate(45deg); }
.g-row.link:active { background: var(--surface-3); }
.glist .card-head + .g-group { border-top: 0; }
.show-sm { display: none; }

/* loading skeletons and screen changes */
.sk { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; border-radius: 12px; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.pane-in { animation: pane-in .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes pane-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* press feedback */
.btn, .tabs button, .g-row.link, summary, .period-picker button, .user-chip { transition: transform .12s ease, background-color .12s ease; }
.btn:active:not(:disabled), .period-picker button:active { transform: scale(.96); }
.portal-tabs button:active { transform: scale(.94); background: var(--surface-3); }
.stat:active, .hero:active { transform: none; }

/* pull to refresh */
.ptr { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 8px); width: 40px; height: 40px; border-radius: 50%; background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-lg); display: grid; place-items: center; z-index: 60; opacity: 0; transform: translate(-50%, -64px); pointer-events: none; transition: opacity .15s; border: 1px solid var(--border); }
.ptr.ready { color: var(--primary); }
.ptr.spin svg { animation: spin .8s linear infinite; }
html:has(.portal-tabs) { overscroll-behavior-y: contain; }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; }
  .show-lg { display: none; }
  .show-sm { display: block; }
  .glist { overflow: hidden; }
  .hero { margin-top: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .sk, .pane-in, .hero .h-bar span, .ptr.spin svg { animation: none !important; }
  .btn:active, .portal-tabs button:active { transform: none; }
}


/* ---------- Easy to read: bigger text at every screen size ---------- */
body { font-size: 16px; line-height: 1.5; }
table.table, .kv, .alert, .breakdown, .sheet th.name, .list-item .grow b, .step .t { font-size: 15px; }
.table thead th, .th-sort { font-size: 13.5px; }
.nav a, .menu a, .menu button { font-size: 15.5px; }
.btn { font-size: 15px; }
.btn.sm { font-size: 14px; }
.input.sm { font-size: 15px; }
.card-head h2, .card-head h3 { font-size: 17px; }
.card-head .sub, .kpi .foot, .kpi .label, .field .hint, .field-error, .list-item .grow span, .step .d, .table .who span, .text-sm, .legend, .btn-hint,
.topbar .crumb, .sidebar-foot, .user-chip .who span, .brand-sub, .form-section, .field label, .field .lbl, .sub-head, .kpi .value small, .nav .count { font-size: 14px; }
.badge, .chip { font-size: 13px; }
.nav-group { font-size: 12.5px; }
.chart text { font-size: 14px; }
.table thead th, .th-sort { font-size: 13.5px; }
.flag { font-size: 15px; }
/* Text that pages size inline (11px to 12.5px) comes up to 13.5px */
[style*="font-size:11px"]:not(.avatar), [style*="font-size: 11px"]:not(.avatar), [style*="font-size:11.5px"]:not(.avatar), [style*="font-size: 11.5px"]:not(.avatar),
[style*="font-size:12px"]:not(.avatar), [style*="font-size: 12px"]:not(.avatar), [style*="font-size:12.5px"]:not(.avatar), [style*="font-size: 12.5px"]:not(.avatar) { font-size: 13px !important; }

/* ---------- Apple iOS Bottom Tab Bar ---------- */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 6px 2px; border: 0; background: none;
    color: var(--text-3); font: 600 12.5px var(--font); text-decoration: none; cursor: pointer; position: relative;
    transition: transform .12s cubic-bezier(.2, .8, .2, 1), color .12s ease;
  }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav a[aria-current="page"] { color: var(--primary); font-weight: 650; }
  .bottom-nav a:active, .bottom-nav button:active { transform: scale(.92); }
  .bottom-nav a:focus-visible, .bottom-nav button:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }
  .bottom-nav .dot { position: absolute; top: 8px; left: calc(50% + 6px); width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
  .shell.has-bnav .topbar .menu-btn { display: none; }
  .shell.has-bnav .content { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .shell.has-bnav .savebar { bottom: calc(58px + env(safe-area-inset-bottom)); padding-bottom: 8px; }
  body:has(.bottom-nav) .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}


/* ---------- Page changes: no spinner flash on a quick load, a short fade when the page arrives ---------- */
#view > .loading-screen { opacity: 0; animation: fade-in .2s .2s both; }
#view.page-in { animation: view-in .18s ease-out; } /* opacity only: a transform would break the fixed bottom bars inside the page */
@keyframes view-in { from { opacity: 0; } }
@keyframes fade-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #view > .loading-screen, #view.page-in { animation: none; opacity: 1; } }

.more-rows { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }


/* ---------- Phone: one thing at a time ---------- */
[data-step-off="1"] { display: none !important; }
.stepper-head { grid-column: 1 / -1; display: grid; gap: 6px; margin: 0 0 4px; }
.stepper-head .step-count { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-2); }
.stepper-head .step-title { font: 600 22px/1.25 var(--font-display); margin: 0; outline: none; }
.stepper-head .step-title:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 4px; }
.step-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.step-bar span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .25s ease; }
.step-errors { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); font-size: 14.5px; margin-top: 4px; }
.step-errors ul { margin: 4px 0 0; padding-left: 18px; }
.step-errors a { color: inherit; font-weight: 600; text-decoration: underline; }
.step-review { grid-column: 1 / -1; }
.stepper-foot { display: flex; gap: 8px; }
.stepper-foot .btn.primary { flex: 1; }
.stepper-foot [data-close] { margin-right: auto; }
.m-card .chev, .fold-btn .chev { width: 12px; height: 12px; background: var(--text-3); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4 1.5 8.5 6 4 10.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4 1.5 8.5 6 4 10.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; flex-shrink: 0; }
/* Apple iOS Inset Grouped list (Settings style) */
.sec-menu ul {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.sec-menu li { border-bottom: 1px solid var(--border); }
.sec-menu li:last-child { border-bottom: 0; }
.sec-menu .m-card {
  width: 100%; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; min-height: 58px; background: transparent; border: 0; border-radius: 0; box-shadow: none;
  font: inherit; color: var(--text); cursor: pointer; transition: background-color .15s ease;
}
.sec-menu .m-card:hover { background: var(--surface-2); }
.sec-menu .m-card:active { background: var(--surface-3); }
.sec-menu .m-card small { display: block; color: var(--text-3); font-size: 13px; font-weight: 400; margin-top: 2px; }
.sec-bar { margin: 0 0 14px; }
.fold-head { cursor: pointer; }
.fold-btn { margin-left: auto; width: 44px; height: 44px; border: 0; background: none; border-radius: var(--radius); display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.fold-btn .chev { transform: rotate(90deg); transition: transform .15s; }
.is-open > .fold-head .fold-btn .chev { transform: rotate(-90deg); }
.fold-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

@media (max-width: 860px) {
  /* A focused field must never hide under the sticky bars (WCAG 2.2, Focus Not Obscured) */
  html { scroll-padding-top: 76px; scroll-padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
  .drawer-body, .modal-body { scroll-padding-bottom: 24px; }
  .drawer-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .step-bar span, .fold-btn .chev { transition: none; } }

@media (max-width: 860px) {
  /* One card per row. The real table stays underneath, so screen readers still get rows, columns and headers. */
  .table.stack { display: block; }
  .table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table.stack tbody, .table.stack tfoot { display: block; padding: 0 12px 12px; }
  .table.stack tr { display: block; margin-top: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 6px 0; box-shadow: var(--shadow); }
  .table.stack tfoot tr { background: var(--surface-2); box-shadow: none; }
  .table.stack tr.dirty { border-color: var(--warning); }
  .table.stack td, .table.stack th { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; border: 0; padding: 6px 16px; text-align: right;
    position: static !important; box-shadow: none !important; background: transparent !important; max-width: none; white-space: normal; }
  .table.stack tbody th.name, .table.stack tbody th[scope="row"] { font: 600 17px var(--font-display); text-transform: none; letter-spacing: 0; color: var(--text); text-align: left; padding-top: 10px; padding-bottom: 4px; justify-content: flex-start; flex-wrap: wrap; }
  .table.stack td[data-label]::before { content: attr(data-label); flex: 0 0 40%; text-align: left; font-weight: 600; font-size: 13.5px; color: var(--text-2); }
  .table.stack td > input, .table.stack td > select { flex: 1; min-width: 0; text-align: right; border-color: var(--border-strong); background: var(--surface); }
  .table.stack td.calc { font-weight: 600; }
  .table.stack td:empty { display: none; }
  .table.stack td .row { flex-wrap: wrap; justify-content: flex-end; }
  .table-wrap:has(> .table.stack) { overflow: visible; }
  #sf .table-wrap { overflow: visible; }
}

.person-nav { padding: 12px 12px 0; }
.person-nav .step-count { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.person-row { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: center; }
@media (max-width: 860px) {
  .table.stack.grid2 tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 12px 14px; }
  .table.stack.grid2 td, .table.stack.grid2 th { flex-direction: column; align-items: stretch; justify-content: flex-start; text-align: left; padding: 6px 0; }
  .table.stack.grid2 td[data-label]::before { flex: none; margin-bottom: 4px; }
  .table.stack.grid2 td > input, .table.stack.grid2 td > select { width: 100%; text-align: right; }
  .table.stack.grid2 tbody th.name, .table.stack.grid2 tbody th[scope="row"] { grid-column: 1 / -1; }
  .table.stack.grid2[data-wide-first="2"] td:nth-child(-n+2) { grid-column: 1 / -1; }
  .table.stack.grid2 td.calc { align-items: flex-start; }
  .table.stack.grid2 td:has(> [data-del]) { grid-column: 1 / -1; align-items: flex-end; }
}
@media (max-width: 860px) {
  .table.stack.grid2 tr { gap: 0 14px; padding: 10px 14px 12px; }
  .table.stack.grid2 td, .table.stack.grid2 th { padding: 4px 0; }
  .table.stack.grid2 td[data-label]::before { font-size: 13px; margin-bottom: 3px; }
  /* Stock count: the person is chosen above, so each card starts with the product as its title */
  .table.stack.grid2[data-wide-first="2"] td:nth-child(1) { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); padding: 0; }
  .table.stack.grid2[data-wide-first="2"] td:nth-child(2) { font: 600 18px var(--font-display); padding: 2px 0 8px; display: block; }
  .table.stack.grid2[data-wide-first="2"] td:nth-child(2)::before { display: none; }
  .table.stack.grid2 td:has(> [data-del]) { padding-top: 0; }
}

/* ---------- A list of cards instead of a wide table ---------- */
.m-list ul { list-style: none; margin: 0; padding: 8px 12px 12px; display: grid; gap: 10px; }
.m-summary { margin: 0; padding: 12px 16px 0; color: var(--text-2); font-size: 14px; font-weight: 500; }
.m-list .m-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 14px 16px; min-height: 68px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); font: inherit; color: var(--text); }
.m-list button.m-card { cursor: pointer; transition: transform .12s ease, background-color .12s ease; }
.m-list button.m-card:active { transform: scale(.985); background: var(--surface-3); }
.m-list button.m-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.m-card .mc-main { display: grid; gap: 2px; min-width: 0; flex: 1; }
.m-card .mc-main b { font-size: 16px; overflow-wrap: anywhere; }
.m-card .mc-sub { color: var(--text-3); font-size: 14px; overflow-wrap: anywhere; }
.m-card .mc-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.m-card .mc-end { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; display: grid; gap: 4px; justify-items: end; }
.m-card .mc-end b { font-size: 16px; }
.m-list .m-card .chev { margin-left: 2px; }

/* ---------- One person at a time (daily entry) ---------- */
.quick { padding: 14px 14px 18px; display: grid; gap: 10px; }
.quick .step-count { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-2); }
.quick .step-title { font: 600 22px/1.25 var(--font-display); margin: 4px 0 0; outline: none; }
.quick .step-title:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 4px; }
.quick .q-diff { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-size: 14.5px; }
.quick .q-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 4px; }
.quick .q-actions .btn { min-height: 48px; }
.quick form { display: grid; gap: 12px; }

.m-card .mc-kv {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px;
  padding-top: 6px; margin-top: 4px; border-top: 1px solid var(--border);
}
.m-card .mc-kv .k { color: var(--text-3); font-size: 13px; }
.m-card .mc-kv .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.m-list .m-card:has(.mc-kv) { align-items: flex-start; }

/* ---------- Sign-in: a ledger page is the one thing worth remembering ---------- */
.auth-art .ledger { margin: 28px 0 0; max-width: 26em; position: relative; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 4px;
  box-shadow: 0 18px 30px -22px var(--hero-shadow); padding: 12px 18px 10px 56px; transform: rotate(-1.2deg);
  background-image: repeating-linear-gradient(to bottom, transparent 0 35px, var(--border) 35px 36px); background-position: 0 44px; background-repeat: repeat-y; }
.auth-art .ledger::before { content: ""; position: absolute; top: 0; bottom: 0; left: 40px; width: 2px; background: var(--gold); opacity: .85; }
.auth-art .ledger figcaption { font: 600 13px var(--font); color: var(--text-2); height: 32px; display: flex; align-items: center; margin-bottom: 4px; }
.auth-art .ledger dl { margin: 0; }
.auth-art .ledger dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; height: 36px; line-height: 35px; }
.auth-art .ledger dt { color: var(--text-2); font-size: 14.5px; }
.auth-art .ledger dd { margin: 0; font: 600 20px var(--font-display); font-variant-numeric: tabular-nums; color: var(--text); }
.auth-art .ledger .short dt { color: var(--accent); font-weight: 600; }
.auth-art .ledger .short dd { color: var(--accent); position: relative; }
.auth-art .ledger .short dd::after { content: ""; position: absolute; left: 0; right: 0; bottom: 3px; height: 2px; background: var(--gold); transform-origin: left; animation: inkline .7s .4s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes inkline { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.auth-art p.flow { margin-top: 22px; font-size: 14px; color: var(--text-3); max-width: 26em; }
@media (prefers-reduced-motion: reduce) { .auth-art .ledger .short dd::after { animation: none; } }

/* ---------- Home: where the month stands, on ruled ledger paper ---------- */
.month-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: center; padding: 22px 24px; margin-bottom: 16px; position: relative; }
.month-card h2 { font: 600 28px/1.2 var(--font-display); margin: 0 0 6px; }
.month-card p { margin: 0 0 14px; max-width: 34em; color: var(--text-2); font-size: 15px; }
.month-card .mc-right { margin: 0; display: grid; gap: 10px; text-align: right; }
.month-card dt { font-size: 14px; color: var(--text-3); }
.month-card dd { margin: 0; font: 600 30px/1.15 var(--font-display); font-variant-numeric: tabular-nums; word-break: break-word; }
.month-card dd small { font: 600 15px var(--font); margin-right: 5px; color: var(--accent); }
@media (max-width: 860px) {
  .month-card { grid-template-columns: 1fr; padding: 18px 20px; gap: 14px; }
  .month-card h2 { font-size: 24px; }
  .month-card .mc-right { text-align: left; }
  .month-card dd { font-size: 24px; word-break: normal; white-space: nowrap; }
  .month-card .btn { width: 100%; min-height: 48px; justify-content: center; }
}

/* A price that is still missing is marked in the sheet */
.sheet input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
.sheet input[data-f="unit_price"]::placeholder { color: var(--text-3); }

/* ---------- Phone fixes from the 2026-11-11 audit ---------- */
@media (max-width: 860px) {
  /* Sheet fields in stacked cards were 22px tall: make them a real tap target. */
  .table.stack.grid2 td > input, .table.stack.grid2 td > select { height: 44px; min-height: 44px; }
  /* 16px stops iPhones zooming in when a field is focused. */
  .input, .input.sm, input.input, select.input, textarea.input, .period-picker select, .period-picker input { font-size: 16px; }
  /* A long value must wrap inside its card, not stretch the page. */
  .m-card .mc-main { grid-template-columns: minmax(0, 1fr); }
  .m-card .mc-main > *, .m-card .mc-kv { min-width: 0; }
  .m-card .mc-kv .k { flex: none; }
  .m-card .mc-kv .v { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
}
@media (max-width: 480px) {
  /* Header buttons wrap onto a second line instead of pushing the page wider. */
  .page-head { flex-wrap: wrap; }
  .page-head .actions { flex-wrap: wrap; }
}
/* Dynamic viewport units: no jump when the phone's browser bar shows or hides. Older browsers keep the 100vh above. */
.shell, .auth-wrap { min-height: 100dvh; }
/* Approvals flags: long reasons wrap inside the row. */
.flag, .flag > div { min-width: 0; overflow-wrap: anywhere; }
.flag b { white-space: normal; }


/* Table sort buttons and other small controls keep at least a 24 px target (WCAG 2.2 SC 2.5.8). */
.th-sort { min-height: 24px; }

/* Column chooser and the action under an empty list. */
.colpick { position: relative; margin-left: auto; }
.colpick > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; }
.colpick > summary::-webkit-details-marker { display: none; }
.colpick-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 190px; display: grid; gap: 2px; padding: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.14)); }
.colpick-menu label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; min-height: 28px; border-radius: var(--radius-sm); cursor: pointer; }
.colpick-menu label:hover { background: var(--surface-3); }
.empty-actions { display: flex; justify-content: center; padding: 0 0 20px; }
/* On a phone the list is cards, which have no columns to choose. */
@media (max-width: 860px) { .colpick { display: none; } }

/* Group headings inside a list: a row in a table, an item in the phone card list. */
.table tr.group-row th { text-align: left; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 14px; padding: 10px 14px; background: var(--surface-3); color: var(--text); border-top: 1px solid var(--border-strong); }
.group-link { margin-left: 10px; font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; min-height: 24px; }
@media (max-width: 860px) { .group-link { min-height: 44px; } }
.m-list li.m-group { list-style: none; padding: 10px 14px 4px; font-size: 14px; color: var(--text); background: var(--surface-3); position: sticky; top: 0; z-index: 1; }

/* Global search in the top bar - Apple Spotlight style */
.gsearch { position: relative; flex: 0 1 340px; min-width: 180px; }
.gsearch .input {
  width: 100%;
  height: 38px;
  padding-left: 36px;
  padding-right: 38px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-size: 13.5px;
  transition: background-color .18s, border-color .18s, color .18s, box-shadow .18s, transform .18s, opacity .18s cubic-bezier(.16, 1, .3, 1);
}
.gsearch .input:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.gsearch .input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring), var(--shadow-sm);
}
.gsearch .gs-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: grid; color: var(--text-3); pointer-events: none; }
.gsearch .gs-ico svg { width: 16px; height: 16px; }
.gsearch .gs-key {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font: 600 11px var(--mono);
  color: var(--text-3);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--surface);
  pointer-events: none;
  box-shadow: var(--shadow-xs);
}
.gsearch input:focus ~ .gs-key, .gsearch input:not(:placeholder-shown) ~ .gs-key { display: none; }
#gs-list {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: max(100%, 400px);
  max-height: min(65vh, 460px);
  overflow: auto;
  z-index: 40;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: modalPop .18s cubic-bezier(.16, 1, .3, 1);
}
#gs-list .gs-head { padding: 8px 12px 4px; font: 700 11px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
#gs-list .gs-opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s ease;
}
#gs-list .gs-opt span { font-size: 12.5px; color: var(--text-2); }
#gs-list .gs-opt[aria-selected="true"], #gs-list .gs-opt:hover {
  background: var(--primary-soft);
  color: var(--primary-deep, var(--primary));
}
#gs-list .gs-opt[aria-selected="true"] span, #gs-list .gs-opt:hover span {
  color: var(--primary-text);
}
#gs-list .gs-none { padding: 18px 14px; color: var(--text-2); font-size: 14px; text-align: center; }
@media (max-width: 860px) { .topbar { flex-wrap: wrap; } .gsearch { order: 10; flex: 1 1 100%; min-width: 0; } #gs-list { width: 100%; } .gsearch .gs-key { display: none; } }

/* Quick wins from the accessibility audit */
/* Check boxes and radio buttons: at least 24 px (WCAG 2.2 SC 2.5.8). */
input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; accent-color: var(--primary); }
/* Text links inside lists keep a 24 px tall target. */
.list-item a[data-link], .card-body .grow a[data-link] { display: inline-block; min-height: 24px; line-height: 24px; }
/* Required fields */
.req { color: var(--danger); font-weight: 700; }
.req-note { grid-column: 1 / -1; margin: 0 0 4px; font-size: 13px; }
/* The screen shown when the app cannot start */
.boot-fail { max-width: 520px; margin: 12vh auto 0; padding: 0 24px; font-family: var(--font, system-ui); color: var(--text); }
.boot-fail h1 { font-size: 24px; margin: 0 0 12px; }
.boot-fail details { margin-top: 18px; color: var(--text-2); font-size: 13.5px; }

/* Plain-word glossary on the seller's page */
.glossary { margin: 0; }
.glossary dt { font-weight: 650; margin-top: 12px; }
.glossary dt:first-child { margin-top: 0; }
.glossary dd { margin: 2px 0 0; color: var(--text-2); }

/* Hub cards on the dashboard: Apple iOS Widget Tile */
.section-title { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.hub-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 46px 20px 22px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), box-shadow .2s cubic-bezier(.16, 1, .3, 1), border-color .15s ease;
}
.hub-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.hub-tile:active {
  transform: scale(.985);
}
.hub-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.hub-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hub-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.hub-count { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.hub-head { font-size: 14px; color: var(--text-2); }
.hub-nums { display: flex; gap: 20px; flex-wrap: wrap; }
.hub-nums span { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.hub-nums small { color: var(--text-3); font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.hub-chips { display: flex; gap: 6px; flex-wrap: wrap; min-height: 28px; }
.hub-go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--primary); min-height: 24px; transition: transform .15s ease; }
.hub-tile:hover .hub-go { transform: translateX(2px); }
.hub-go svg { width: 16px; height: 16px; }
.hub-chev {
  position: absolute; top: 22px; right: 18px; color: var(--text-3); display: flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; transition: transform .15s ease, color .15s ease;
}
.hub-chev svg { width: 18px; height: 18px; }
.hub-tile:hover .hub-chev { transform: translateX(3px); color: var(--primary); }
@media (max-width: 860px) { .hub-go { min-height: 44px; } }

/* ---------- Critique fixes (Nov 2026) ---------- */
/* Icon buttons never shrink below a usable target, even inside a crowded top bar. */
.btn.icon { flex-shrink: 0; min-width: 36px; }
.btn.sm.icon { min-width: 30px; }
.topbar { min-width: 0; }
.topbar .spacer { min-width: 0; }
.main { min-width: 0; }
/* Salaries: how the bank total adds up, and the grouped secondary views. */
.reconcile { margin: 0 0 var(--sp-4); color: var(--text-2); font-size: 14px; max-width: 70ch; }
.more-menu { position: relative; }
.more-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 240px; display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.more-list a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: 14px; }
.more-list a:hover { background: var(--surface-3); }
/* Dashboard: secondary figures stay folded until asked for. */
.more-figures > summary { list-style: none; cursor: pointer; display: inline-flex; }
.more-figures > summary::-webkit-details-marker { display: none; }
.mt-3 { margin-top: var(--sp-3); }
/* Phones: header export buttons keep their words so two download icons are never ambiguous. */
@media (max-width: 860px) {
  .page-head .actions .lbl-sm { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .page-head .actions .btn:has(> .lbl-sm) { min-width: 0; }
}
/* Laptop widths: the top bar wraps instead of pushing the user menu off the page. */
@media (max-width: 1240px) and (min-width: 861px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .gsearch { flex: 1 1 200px; min-width: 160px; max-width: 320px; }
  .topbar .filters { flex-wrap: wrap; }
}

/* Stock sheets and phone header (P3 fixes). */
.warn-text { color: var(--warning); }
.table tr[hidden] { display: none; }
.hub-filter { width: auto; min-width: 140px; }
@media (max-width: 860px) {
  /* The hub and month filters share one row, so the data starts higher on the screen. */
  .filterbar .filters { flex-wrap: nowrap; }
  .filterbar select.hub-filter { flex: 1 1 auto; min-width: 0; }
  .filterbar .filters > .badge { flex: 1 1 auto; min-width: 0; }
  .filterbar .period-picker { flex: none; }
}
/* Salaries cards on a phone: the exact amount stays, the long explanation goes. */
@media (max-width: 860px) { .kpi .kpi-note { display: none; } }
/* Small phones: a long button label keeps its first words so the header buttons fit on one line. */
@media (max-width: 480px) { .lbl-long { display: none; } }
/* ---------- Audit fixes (Nov 17): sideways scroll, slimmer top bar, contrast ---------- */
/* A long segmented control scrolls inside itself instead of widening the page. */
.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.card-head > .seg, .card-head > div:has(> .seg) { min-width: 0; max-width: 100%; }
/* Laptop and half-screen widths: one row, search shrinks first. */
@media (max-width: 1240px) and (min-width: 861px) {
  .topbar { flex-wrap: nowrap; padding: 10px 16px; gap: 10px; }
  .topbar .gsearch { flex: 1 1 140px; min-width: 120px; max-width: 260px; }
  .topbar .filters { flex-wrap: nowrap; flex-shrink: 0; }
  .topbar .gsearch .gs-key { display: none; }
  .hub-filter { min-width: 110px; }
}
/* Phones: search sits in the header row instead of taking a second one. */
@media (max-width: 860px) {
  .topbar { flex-wrap: nowrap; }
  .topbar .gsearch { order: 0; flex: 1 1 0; min-width: 0; }
  .topbar .gsearch .input { padding-right: 10px; text-overflow: ellipsis; }
  .topbar .spacer { display: none; }
  .btn.icon, .btn.sm.icon, .sidebar-close { min-width: 44px; }
}
/* Live sales target bar and Approvals queue rows (were inline styles) */
.target-bar { gap: 8px; flex-wrap: nowrap; min-width: 120px; }
.target-bar .progress { width: 70px; }
.queue-item { align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); gap: 14px; }
.queue-main { flex: 1; min-width: 0; }
/* Low findings (Nov 17): hub name link, and text links in lists are full-size targets on phones */
.hub-link { color: inherit; display: inline-block; min-height: 24px; padding: 2px 0; }
@media (max-width: 860px) {
  .hub-link, .list-item a[data-link], .card-body .grow a[data-link] { display: inline-flex; align-items: center; min-height: 44px; }
  .more-list a { min-height: 44px; }
}

/* =========================================================================
   Apple iOS / iPadOS Premium Typography & Finish
   ========================================================================= */
:root {
  --t-sm: 13.5px; --t-base: 15px; --t-lg: 19px; --t-fig: 28px; --t-display: 32px;
}

/* ---- Apple iOS Typography ---- */
.table th, .table thead th, .th-sort { text-transform: none; letter-spacing: 0; font-size: var(--t-sm); font-weight: 600; color: var(--text-2); }
.nav-group { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--sidebar-muted); padding: 18px 10px 6px; }
.form-section, .sub-head, #gs-list .gs-head { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.page-head h1 { font-size: var(--t-display); line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
.page-head p { max-width: 65ch; color: var(--text-2); font-size: 15px; }
@media (max-width: 860px) {
  .page-head h1 { font-size: 22px; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .portal-head h1 { font-size: 20px; }
  .portal-head p { font-size: 13px; }
  .hero .h-amount { font-size: 32px; }
  .hero .h-amount small { font-size: 16px; }
}

/* ---- Month card: Apple squircle widget with ambient elevation ---- */
.month-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  transition: transform .18s cubic-bezier(.16, 1, .3, 1), box-shadow .18s cubic-bezier(.16, 1, .3, 1);
}
.month-card:hover {
  box-shadow: var(--shadow-md);
}

/* ---- Sign-in additions used by login.js ---- */
.auth-steps { list-style: none; margin: 24px 0 0; padding: 0; max-width: 28em; border-top: 1px solid var(--border); counter-reset: s; }
.auth-steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; color: var(--text); }
.auth-steps li::before { content: counter(s) "."; font-family: var(--mono); font-weight: 600; color: var(--primary); }
.auth-lead { margin: 0 0 16px; color: var(--text-2); font-size: 14.5px; }
.auth-foot { display: flex; gap: 8px; align-items: flex-start; margin: 20px 0 0; color: var(--text-2); font-size: 13.5px; }
.auth-foot svg { margin-top: 2px; flex-shrink: 0; color: var(--primary); }
.caps-warn { display: flex; gap: 6px; align-items: center; color: var(--warning); font-size: 13.5px; font-weight: 500; }
.btn .btn-label { display: inline; }

/* ---------- The till: Apple iOS POS (Fast, tactile, thumb-friendly) ---------- */
.till { display: flex; flex-direction: column; gap: 12px; max-width: 680px; margin: 0 auto; width: 100%; }
.till .card { margin: 0; }

/* Till Header: Compact iOS Status Card */
.till-head {
  padding: 14px 18px;
  background: linear-gradient(135deg, #196dc9 0%, #104a8b 100%);
  color: #fff;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(16, 74, 139, 0.22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.th-left { display: flex; flex-direction: column; gap: 2px; }
.th-date { font-size: 13px; font-weight: 500; opacity: .88; letter-spacing: .01em; }
.th-total { font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 3px; }
.th-total small { font-size: 14px; font-weight: 600; opacity: .82; }
.th-sub { font-size: 12px; opacity: .85; }
.th-right { display: flex; align-items: center; }
.eod-jump-btn {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #fff;
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  cursor: pointer;
  transition: all .15s ease;
}
.eod-jump-btn:hover { background: rgba(255, 255, 255, 0.26); }
.eod-jump-btn span { font-size: 11px; opacity: .88; text-transform: uppercase; letter-spacing: .04em; }
.eod-jump-btn b { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.eod-jump-btn b.neg { color: #fca5a5; }
.till-lock { width: 100%; margin-top: 6px; padding: 6px 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, .15); display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.till-lock svg { width: 14px; height: 14px; }

/* Sub-Navigation: iOS Segmented Control */
.till-nav-wrap { width: 100%; }
.till-nav {
  display: flex;
  width: 100%;
  background: var(--surface-3);
  padding: 3px;
  border-radius: var(--radius);
  gap: 3px;
}
.till-nav button {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  border: 0;
  background: none;
  border-radius: calc(var(--radius) - 3px);
  cursor: pointer;
  transition: all .14s cubic-bezier(.16, 1, .3, 1);
  white-space: nowrap;
}
.till-nav button svg { width: 14px; height: 14px; opacity: .75; }
.till-nav button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
.till-nav button.on svg { color: var(--primary); opacity: 1; }
.till-nav .badge { font-size: 11px; padding: 1px 6px; border-radius: 999px; }

/* Search bar on till */
.till-search { position: relative; width: 100%; margin-bottom: 12px; }
.till-search > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); display: grid; color: var(--text-3); pointer-events: none; }
.till-search > span svg { width: 16px; height: 16px; }
.till-search .input { height: 40px; padding-left: 36px; padding-right: 32px; font-size: 14.5px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.till-search .input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.ts-clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 4px; display: grid; place-items: center; }
.ts-clear svg { width: 14px; height: 14px; }

/* Product Grid & Cards */
.till-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 10px; }
.till-prod {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 84px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: var(--text);
  font: inherit;
  transition: transform .12s cubic-bezier(.16, 1, .3, 1), box-shadow .12s ease, border-color .12s ease;
}
.till-prod:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.till-prod:active { transform: scale(.97); }
.till-prod.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.till-prod.out { opacity: .5; cursor: not-allowed; background: var(--surface-3); }
.tp-name { font-weight: 650; font-size: 14.5px; line-height: 1.25; color: var(--text); }
.tp-bottom { display: flex; width: 100%; justify-content: space-between; align-items: baseline; margin-top: auto; padding-top: 4px; gap: 4px; }
.tp-price { font-size: 13.5px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tp-badge { font-size: 11px; font-weight: 600; padding: 1.5px 7px; border-radius: 999px; }
.tp-badge.ok { background: var(--success-soft); color: var(--success); }
.tp-badge.low { background: var(--warning-soft); color: var(--warning); }
.tp-badge.none { background: var(--surface-3); color: var(--text-3); }

/* Bottom Action Sheet (Selling modal) */
.till-sheet {
  position: sticky;
  bottom: calc(64px + env(safe-area-inset-bottom));
  z-index: 50;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 32px -4px rgba(15, 23, 42, 0.22);
  animation: modalPop .18s cubic-bezier(.16, 1, .3, 1);
}
.ts-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto 8px; }
.ts-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.ts-name { font-size: 16px; font-weight: 700; color: var(--text); }
.ts-meta { font-size: 13px; color: var(--text-2); margin-top: 1px; }
.ts-controls { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.ts-qty { display: grid; grid-template-columns: 46px 1fr 46px; gap: 8px; align-items: stretch; }
.ts-step {
  display: grid; place-items: center; height: 46px; width: 46px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text); cursor: pointer;
  transition: transform .08s ease, background-color .1s ease;
}
.ts-step svg { width: 18px; height: 18px; }
.ts-step:active:not(:disabled) { transform: scale(.95); }
.ts-step:disabled { opacity: .35; cursor: not-allowed; }
.ts-qty .input { height: 46px; text-align: center; font-size: 20px; font-weight: 700; border-radius: 12px; padding: 0; font-variant-numeric: tabular-nums; }
.ts-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  height: 32px; min-width: 38px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font: 600 13px var(--font); cursor: pointer; transition: all .1s ease;
}
.chip-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-btn:active { transform: scale(.96); }

/* Main Sell Action Button */
.till-sell {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #22934c 0%, #17753b 100%);
  color: #fff;
  font: 700 15px var(--font);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(23, 117, 59, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform .08s ease, filter .1s ease;
}
.till-sell b { font-size: 16px; font-variant-numeric: tabular-nums; }
.till-sell:hover { filter: brightness(1.04); }
.till-sell:active { transform: scale(.98); }
.till-sell:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.till-sell.loading, .till-sell:disabled { opacity: .65; pointer-events: none; }

/* Quick Bar at bottom of Sell tab */
.till-quick-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 4px;
  box-shadow: var(--shadow-xs);
}

.till-stock { width: 100%; border-collapse: collapse; font-size: 14px; }
.till-stock th, .till-stock td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); }
.till-stock thead th { font-size: 12px; color: var(--text-2); font-weight: 650; }
.till-stock th:first-child, .till-stock td:first-child { text-align: left; padding-left: 14px; }
.till-stock tbody th { font-weight: 600; color: var(--text); }
.till-stock .ts-sub { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); margin-top: 2px; }
.till-stock td.left { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.till-stock td.left.low b { color: var(--warning); }
.till-stock .tag { margin-left: 6px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); vertical-align: middle; }
.till-stock tr.none td, .till-stock tr.none th { color: var(--text-3); }
.till-lines { list-style: none; margin: 0; padding: 0; }
.till-lines li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.till-lines li:last-child { border-bottom: 0; }
.tl-main { display: flex; flex-direction: column; min-width: 0; }
.tl-main b { font-size: 15px; font-weight: 650; }
.tl-main .muted { font-size: 12.5px; color: var(--text-3); }
.tl-amt { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.eod-sum { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-3); font-size: 14px; }
.eod-sum b { text-align: right; font-variant-numeric: tabular-nums; }
.eod-sum b.neg { color: var(--danger); }

@media (max-width: 860px) {
  /* On mobile Sell tab: hide monthly filterbar and reduce clutter */
  body:has(#view[data-tab="sell"]) #filterbar,
  body:has(#view[data-tab="sell"]) .filterbar { display: none !important; }
  #view[data-tab="sell"] .portal-head { display: none; }
  #view[data-tab="sell"] { padding-top: 10px; }
  .till-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .till-sheet { bottom: calc(60px + env(safe-area-inset-bottom)); border-radius: 18px; }
}
@media (max-width: 420px) {
  .till-nav button { padding: 7px 2px; font-size: 12px; gap: 3px; }
  .till-nav button svg { width: 13px; height: 13px; }
}
@media (prefers-reduced-motion: reduce) { .till-prod, .till-sell, .ts-step { transition: none; } .till-prod:active, .till-sell:active, .ts-step:active { transform: none; } }

/* Document list Apple Inset styling */
.doc-list { display: flex; flex-direction: column; }
.doc-item { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: 0; }
.doc-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.doc-head b { font-weight: 650; color: var(--text); }
.doc-desc { font-size: 13px; }
.doc-file { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-top: 4px; }
.doc-file a { color: var(--primary); text-decoration: none; font-weight: 500; display: inline-flex; align-items: center; gap: 5px; }
.doc-file a svg { width: 15px; height: 15px; }
.doc-sub { font-size: 12px; color: var(--text-3); }
.doc-btn { flex-shrink: 0; }

/* Security deposit status card in portal */
.sec-held-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  margin-bottom: 14px;
}
.sec-held-card svg { width: 22px; height: 22px; color: var(--primary); flex-shrink: 0; }
.sec-held-card div { display: flex; flex-direction: column; gap: 1px; }
.sec-held-card span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.sec-held-card b { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- Morning stock: one card per seller ---------- */
.mcard { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; margin: 0; }
.mc-top { display: flex; align-items: center; gap: 12px; }
.mc-who { display: flex; flex-direction: column; min-width: 0; }
.mc-who b { font-size: 17px; }
.mc-block { display: flex; flex-direction: column; gap: 6px; }
.mc-label { font-size: 12.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-2); }
.mc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mc-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--surface-3); font-size: 14.5px; font-weight: 600; }
.mc-chip.given { background: var(--success-soft); color: var(--success); }
.mc-x { display: grid; place-items: center; width: 28px; height: 28px; margin: -2px -6px -2px 0; border: 0; background: none; color: inherit; border-radius: 50%; cursor: pointer; }
.mc-x:hover { background: rgba(0,0,0,.08); }
.mc-x:focus-visible { outline: 2px solid var(--primary); }
.mc-x svg { width: 14px; height: 14px; }
.mc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 4px; }
.give-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.give-list li { display: grid; grid-template-columns: 1fr 92px; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; }
.give-list li[hidden] { display: none; }
.give-list label { display: flex; flex-direction: column; min-width: 0; }
.give-list .input { height: 52px; text-align: center; font-size: 20px; font-weight: 700; }
@media (max-width: 860px) { .mc-foot .btn { min-height: 44px; } .mc-x { width: 36px; height: 36px; } }

/* ---------- Hub workspace: the open hub's name, its sections and their pages ---------- */
.ws { padding: 10px 24px 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
.ws-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ws-hub { font-size: 20px; font-weight: 700; color: var(--text); }
.ws-top > select { width: auto; margin-left: auto; min-width: 160px; }
.ws-tabs { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; background: var(--surface-3); padding: 4px; border-radius: var(--radius); }
.ws-tabs::-webkit-scrollbar { display: none; }
.ws-tabs a { flex: 1 1 auto; padding: 8px 12px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; font-size: 13.5px; font-weight: 600; color: var(--text-2); text-decoration: none; border-radius: calc(var(--radius) - 3px); border: 0; transition: all .14s cubic-bezier(.16, 1, .3, 1); white-space: nowrap; }
.ws-tabs a:hover { color: var(--text); }
.ws-tabs a[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
.ws-tabs a:focus-visible, .ws-sub a:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 6px; }
.ws-sub { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 12px; scrollbar-width: none; }
.ws-sub::-webkit-scrollbar { display: none; }
.ws-sub a { flex: 0 0 auto; padding: 7px 14px; min-height: 36px; display: inline-flex; align-items: center; border-radius: 999px; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: 14.5px; font-weight: 600; text-decoration: none; }
.ws-sub a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (max-width: 860px) { .ws { padding: 8px 14px 10px; } .ws-sub a { min-height: 44px; } .ws-top > select { margin-left: 0; width: 100%; } }

/* ---------- Daily sheet: totals strip and one card per manager ---------- */
.dsum { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; padding: 16px 18px; background: var(--surface-3); border-bottom: 1px solid var(--border); }
.dstat { display: flex; flex-direction: column; gap: 2px; min-width: 130px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.dstat span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.dstat b { font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text); }
.dstat b.neg { color: var(--danger); }
.dsum-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dgrp { margin: 14px 18px 0; overflow: hidden; }
.dgrp:last-of-type { margin-bottom: 14px; }
.dgrp > summary { display: flex; align-items: center; gap: 12px; padding: 12px 18px; min-height: 64px; cursor: pointer; list-style: none; background: var(--surface); }
.dgrp > summary::-webkit-details-marker { display: none; }
.dgrp > summary:hover { background: var(--surface-3); }
.dgrp > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.dg-chev { display: grid; color: var(--text-3); transition: transform .15s ease; }
.dg-chev svg { width: 18px; height: 18px; }
.dgrp[open] .dg-chev { transform: rotate(90deg); }
.dg-title { display: flex; flex-direction: column; min-width: 0; }
.dg-title b { font-size: 17px; }
.dg-title small { font-size: 13.5px; color: var(--text-2); }
.dg-nums { margin-left: auto; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: flex-end; }
.dg-nums > span { display: flex; flex-direction: column; text-align: right; }
.dg-nums small { font-size: 12.5px; color: var(--text-2); }
.dg-nums b { font-variant-numeric: tabular-nums; font-size: 16px; }
.dg-nums b.neg { color: var(--danger); }
.dg-nums .dg-prog { flex-direction: row; padding: 4px 12px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.dg-prog.done { background: var(--success-soft); color: var(--success); }
.dg-prog.part { background: var(--warning-soft); color: var(--warning); }
.dgrp .table-wrap { border-top: 1px solid var(--border); }
@media (max-width: 860px) { .dgrp { margin: 12px 10px 0; } .dgrp > summary { flex-wrap: wrap; } .dg-nums { margin-left: 30px; justify-content: flex-start; width: 100%; } .dsum { padding: 12px 10px; } .dstat { flex: 1 1 130px; } }

/* ---------- Morning stock: one card per manager, one Save for everyone ---------- */
.msheet .mq { width: 74px; text-align: right; }
.mc-chip.over { background: var(--danger-soft, #fde8e8); color: var(--danger, #b42318); }

.give-pick { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.give-pick:hover:not([disabled]) { border-color: var(--primary); }
.give-pick[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Dashboard: touch-size actions, readable small text, month progress ---------- */
.dash .btn, .dash .btn.sm { min-height: 44px; }
.dash .btn.sm { padding-inline: 14px; }
.dash .kpi .foot, .dash .kpi .label, .dash .hub-nums small, .dash .list-item .grow span, .dash .card-head .sub { font-size: 14px; }
.dash .list-item .grow b { font-size: 15px; }
.dash .list-item a[data-link] { display: inline-flex; align-items: center; min-height: 44px; }
.dash .kpi .value { font-size: 28px; }
.dash .grid.kpis { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.dash section + section, .dash .grid + section { margin-top: 24px; }
.mstep { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 6px; margin: 16px 0 0; padding: 0; font-size: 14px; color: var(--text-3); }
.mstep li { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; }
.mstep li + li::before { content: ""; width: 14px; height: 2px; background: var(--border-strong); margin-right: 6px; margin-left: -4px; }
.mstep .mdot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; border: 2px solid var(--border-strong); background: var(--surface); }
.mstep .done { color: var(--text-2); }
.mstep .done .mdot { background: var(--success); border-color: var(--success); color: #fff; }
.mstep .now { color: var(--text); font-weight: 650; background: var(--primary-soft); }
.mstep .now .mdot { border-color: var(--primary); color: var(--primary); }
@media (prefers-reduced-motion: no-preference) { .dash .hub-tile, .dash .kpi { transition: transform .18s ease-out, box-shadow .18s ease-out; } }

/* ---------- Hubs page: one card per hub ---------- */
.hubs-page .btn { min-height: 44px; }
.hubs-empty { grid-column: 1 / -1; }
.hubc { display: flex; flex-direction: column; padding: 0; }
.hubc-head { display: flex; align-items: center; gap: 12px; padding: 20px 24px 12px; }
.hubc-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.hubc-title { flex: 1; min-width: 0; }
.hubc-title h2 { font-size: 18px; margin: 0; }
.hubc-title .sub { font-size: 14px; color: var(--text-3); overflow-wrap: anywhere; }
.hubc-body { padding: 4px 24px 8px; flex: 1; }
.hubc-people { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.hubc-people b { font-size: 22px; font-family: var(--font-display); }
.hubc-people .muted, .hubc-levels, .hubc-month { font-size: 14px; }
.hubc-levels { margin: 2px 0 16px; }
.hubc-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; padding: 12px 0; border-block: 1px solid var(--border); }
.hubc-nums.one { grid-template-columns: 1fr; }
.hubc-nums dt { font-size: 14px; color: var(--text-3); font-weight: 500; }
.hubc-nums dd { margin: 2px 0 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.hubc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hubc-month { margin-top: 12px; }
.hubc-foot { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 24px 20px; }
.hubc-foot .btn { flex: 1 1 auto; justify-content: center; }
.hubc-foot .btn.primary { flex: 2 1 140px; }
@media (max-width: 860px) { .hubc-head, .hubc-body, .hubc-foot { padding-inline: 16px; } }
.hubc-foot .btn, .hubc .hub-link { min-height: 44px; }
.hubc .hub-link { display: inline-flex; align-items: center; }

/* ---------- Hub overview: the chain and the member list ---------- */
.hubpage .btn, .page-head .btn { min-height: 44px; }
/* The date-range filter used on pages about days: presets, then From and To when Custom is chosen. */
.range-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.range-bar .seg { flex-wrap: wrap; max-width: 100%; }
.range-bar .seg button { min-height: 44px; flex: 0 0 auto; }
.range-select { display: none; }
.range-quick { flex-wrap: wrap; }
.range-custom { display: flex; flex-wrap: wrap; gap: 10px; }
.range-custom label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.range-custom .input { min-height: 44px; width: auto; }
/* Phone: one dropdown instead of a row of buttons; From and To sit side by side when Custom is chosen. */
@media (max-width: 760px) {
  .range-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .range-bar .seg { display: none; }
  .range-select { display: block; width: 100%; min-height: 44px; font-size: 16px; font-weight: 600; }
  .range-text { font-size: 13px; }
  .range-custom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .range-custom label { display: flex; flex-direction: column; align-items: stretch; gap: 4px; font-size: 13px; }
  .range-custom .input { width: 100%; min-width: 0; font-size: 16px; padding-inline: 10px; }
  /* the quick buttons on the Audit page become one swipeable row */
  .range-quick { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .range-quick::-webkit-scrollbar { display: none; }
  .range-quick button { flex: 0 0 auto; }
}
.range-text { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-3); }
.range-text svg { width: 16px; height: 16px; }
.dr-head { flex-wrap: wrap; gap: 12px 16px; align-items: center; justify-content: space-between; }
.grid.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* The org chart: a tree that grows downward. Each <li> is a person with their branch (<ul>) underneath; the lines are drawn with borders. */
.org-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.org-tools .btn { min-width: 44px; justify-content: center; }
.org-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; font-size: 14px; color: var(--text-3); }
.org-key { display: inline-flex; align-items: center; gap: 6px; }
.org-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lv, var(--primary)); display: inline-block; }
.org-scroll { overflow-x: auto; overflow-y: hidden; padding: 4px 4px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); -webkit-overflow-scrolling: touch; }
.org-scroll:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.org { width: max-content; min-width: 100%; padding: 16px 12px; --line: color-mix(in srgb, var(--text-3) 55%, transparent); }
.org ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; position: relative; }
.org-root { align-items: flex-start; gap: 24px; }
.org-kids { padding-top: 26px; }
.org-item { position: relative; display: flex; flex-direction: column; align-items: center; padding: 26px 5px 0; }
.org-root > .org-item { padding: 0; }
/* the line down from a person to their branch */
.org-kids::before { content: ""; position: absolute; top: 0; left: 50%; height: 26px; border-left: 2px solid var(--line); }
/* the bar across the children and the short drop to each child */
.org-kids > .org-item::before, .org-kids > .org-item::after { content: ""; position: absolute; top: 0; width: 50%; height: 26px; border-top: 2px solid var(--line); }
.org-kids > .org-item::before { right: 50%; }
.org-kids > .org-item::after { left: 50%; border-left: 2px solid var(--line); }
.org-kids > .org-item:only-child { padding-top: 26px; }
.org-kids > .org-item:only-child::before { display: none; }
.org-kids > .org-item:only-child::after { border-top: 0; }
.org-kids > .org-item:first-child::before, .org-kids > .org-item:last-child::after { border-top-color: transparent; }
.org-kids > .org-item:last-child::before { border-right: 2px solid var(--line); border-radius: 0 10px 0 0; }
.org-kids > .org-item:first-child::after { border-radius: 10px 0 0 0; }
.org-kids > .org-item:only-child::after { border-radius: 0; }
.org-item.folded > .org-kids { display: none; }
.org-card { width: 136px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px 10px; text-align: center; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--lv, var(--primary)); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0, 0, 0, .06); transition: box-shadow .15s, transform .15s, border-color .15s; }
.org-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .14); transform: translateY(-2px); border-color: var(--lv, var(--primary)); }
.org-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.org-av { width: 48px; height: 48px; font-size: 17px; background: var(--lv, var(--primary)); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--lv, var(--primary)); margin-bottom: 8px; }
.org-name { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.org-id { font-size: 14px; color: var(--text-3); }
.org-role { font-size: 14px; font-weight: 600; color: var(--lv, var(--primary)); }
.org-sales { margin-top: 4px; font-size: 14px; color: var(--text-3); }
.org-sales b { color: var(--text); font-variant-numeric: tabular-nums; }
.org-toggle { min-width: 44px; min-height: 44px; margin-top: -2px; margin-bottom: -6px; padding: 0; background: none; border: 0; cursor: pointer; display: grid; place-items: center; position: relative; z-index: 2; }
.org-toggle-dot { display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px; font-size: 14px; font-weight: 600; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 999px; }
.org-toggle:hover .org-toggle-dot { border-color: var(--primary); color: var(--primary); }
.org-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 0; border-radius: 999px; }
.org-item.folded > .org-toggle { margin-bottom: 0; }
.lv-coacher { --lv: #7c3aed; } .lv-promoting_manager { --lv: #4f46e5; } .lv-manager { --lv: #0f766e; } .lv-supervisor { --lv: #b45309; } .lv-distributor { --lv: #0071e3; }
:root[data-theme="dark"] .lv-coacher { --lv: #a78bfa; } :root[data-theme="dark"] .lv-promoting_manager { --lv: #818cf8; } :root[data-theme="dark"] .lv-manager { --lv: #2dd4bf; } :root[data-theme="dark"] .lv-supervisor { --lv: #fbbf24; } :root[data-theme="dark"] .lv-distributor { --lv: #409cff; }
:root[data-theme="dark"] .org-av { color: #0b1526; }
/* Phone: the tree grows downward instead of sideways. Each person is a full-width card; the people below them are indented under a line. */
@media (max-width: 900px) {
  .org-zoom { display: none; }
  .org-scroll { overflow: visible; border: 0; background: none; padding: 0; }
  .org { width: auto !important; min-width: 0; padding: 0; }
  .org ul, .org-root { display: block; }
  .org-item { display: block; padding: 10px 0 0; }
  .org-root > .org-item { padding: 0; }
  .org .org-kids { padding: 0 0 0 10px; margin: 0 0 0 8px; }
  .org .org-kids::before { display: none; }
  .org .org-kids > .org-item { padding-top: 10px; }
  /* the vertical line down the left of the branch, and the elbow into each card */
  .org .org-kids > .org-item::before { display: block; content: ""; position: absolute; top: 0; bottom: 0; left: -10px; right: auto; width: 0; height: auto; border: 0; border-left: 2px solid var(--line); border-radius: 0; }
  .org .org-kids > .org-item:last-child::before { bottom: auto; height: 44px; border-right: 0; }
  .org .org-kids > .org-item::after { display: block; content: ""; position: absolute; top: 44px; left: -10px; right: auto; width: 10px; height: 0; border: 0; border-top: 2px solid var(--line); border-radius: 0; }
  .org-card { width: 100%; display: grid; grid-template-columns: 44px 1fr; grid-template-areas: "av name" "av role" "av sales"; column-gap: 12px; row-gap: 0; align-items: center; text-align: left; justify-items: start; padding: 10px 52px 10px 12px; }
  .org-av { grid-area: av; margin: 0; align-self: center; width: 44px; height: 44px; font-size: 16px; }
  .org-name { grid-area: name; }
  .org-role { grid-area: role; }
  .org-sales { grid-area: sales; margin: 0; }
  .org-id { display: none; }
  .org-toggle { position: absolute; right: 0; top: 14px; margin: 0; z-index: 3; }
  .org-root > .org-item > .org-toggle { top: 4px; }
  .org-item.folded > .org-toggle { margin: 0; }
}
@media (prefers-reduced-motion: reduce) { .org-card { transition: none; } .org-card:hover { transform: none; } }
.hubpage .table-wrap { max-height: 70vh; overflow: auto; }
.hubpage .table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2, var(--surface)); }
.hubpage .table td .btn.sm, .hubpage .table td a.btn { min-height: 44px; }

/* ---------- Employees: touch-size filters and row actions, readable small text ---------- */
.emp-page .btn, .emp-page .btn.sm, .emp-page .input.sm, .emp-page .seg button, .emp-page .colpick summary { min-height: 44px; }
.emp-page .seg button { padding-inline: 14px; }
.emp-page .group-link { display: inline-flex; align-items: center; min-height: 44px; }
.emp-page .colpick-menu label { min-height: 44px; display: flex; align-items: center; gap: 10px; }
.emp-page .table .who span, .emp-page .mc-sub, .emp-page .badge { font-size: 14px; }
.emp-page .table td .btn { padding-inline: 12px; }

/* ---------- Employee profile: touch-size actions and tabs, readable detail text ---------- */
.emp-profile .btn, .emp-profile .btn.sm { min-height: 44px; }
.emp-profile .mb-3 > a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 15px; }
.emp-profile .tabs button { min-height: 44px; font-size: 15px; }
.emp-profile .kv dt, .emp-profile .kv dd, .emp-profile .faint.text-sm, .emp-profile .card-head .sub { font-size: 14.5px; }
.emp-profile .kv a { display: inline-block; padding: 12px 0; margin: -12px 0; }
.emp-profile .stat-lg { font-variant-numeric: tabular-nums; }
.emp-profile .profile-head { gap: 16px 28px; }

/* ---------- Daily sheet: roomy entry cells, touch-size controls, readable small text ---------- */
.daily-page .btn, .daily-page .btn.sm, .daily-page .seg button, .daily-page .input, .daily-page .sheet input.text { min-height: 44px; }
.daily-page .sheet td, .daily-page .sheet th.name { padding-block: 6px; }
.daily-page .sheet td input { font-variant-numeric: tabular-nums; }
.daily-page .dstat span, .daily-page .dg-title small, .daily-page .dg-nums small, .daily-page .sheet .faint, .daily-page .badge, .daily-page .dg-prog { font-size: 14px; }
.daily-page .dg-nums b, .daily-page .dstat b { font-variant-numeric: tabular-nums; }
.daily-page details.dgrp > summary { min-height: 56px; }
.daily-page .savebar .btn { min-width: 120px; }
.daily-page .sheet input { height: 44px; min-height: 44px; font-size: 16px; border-color: var(--border); background: var(--surface); }
.daily-page .sheet input:disabled { background: transparent; border-color: transparent; }
.daily-page .sheet input:focus { border-color: var(--primary); }
.daily-page .seg button { padding-inline: 14px; }

/* ---------- Live sales: names stay on one line, touch-size controls, readable small text ---------- */
.live-page .btn, .live-page .btn.sm, .live-page .tabs button { min-height: 44px; }
.live-page .tabs button { font-size: 15px; }
.live-page .table td:first-child { min-width: 150px; white-space: nowrap; }
.live-page .table td:nth-child(2) { min-width: 220px; }
.live-page .table .text-sm, .live-page .table .faint, .live-page .badge { font-size: 14px; }
.live-page .table td .num, .live-page .table td b { font-variant-numeric: tabular-nums; }
.live-page .pager .btn, .live-page .table-more .btn { min-height: 44px; }

/* ---------- Weekly sheet: roomy entry cells, touch-size week buttons, readable small text ---------- */
.weekly-page .btn, .weekly-page .btn.sm, .weekly-page .seg button, .weekly-page .tabs button { min-height: 44px; }
.weekly-page .seg button { padding-inline: 14px; font-size: 15px; }
.weekly-page .sheet input { height: 44px; min-height: 44px; font-size: 16px; border-color: var(--border); background: var(--surface); font-variant-numeric: tabular-nums; }
.weekly-page .sheet input:disabled { background: transparent; border-color: transparent; }
.weekly-page .sheet input:focus { border-color: var(--primary); }
.weekly-page .faint, .weekly-page .text-sm, .weekly-page .badge, .weekly-page .card-head .sub, .weekly-page .seg small { font-size: 14px; }
.weekly-page .table td, .weekly-page .table th { font-variant-numeric: tabular-nums; }

/* ---------- Stock count: roomy entry cells, touch-size controls, readable small text ---------- */
.stockc-page .btn, .stockc-page .btn.sm, .stockc-page .btn.icon, .stockc-page .input { min-height: 44px; }
.stockc-page .btn.icon { min-width: 44px; }
.stockc-page .sheet input { height: 44px; min-height: 44px; font-size: 16px; border-color: var(--border); background: var(--surface); font-variant-numeric: tabular-nums; }
.stockc-page .sheet input:disabled { background: transparent; border-color: transparent; }
.stockc-page .sheet input:focus { border-color: var(--primary); }
.stockc-page .sheet th { white-space: nowrap; }
.stockc-page .faint, .stockc-page .text-sm, .stockc-page .badge, .stockc-page .muted { font-size: 14px; }

/* ---------- Hub stock sheet: roomy entry cells, touch-size controls, readable small text ---------- */
.hubsheet-page .btn, .hubsheet-page .btn.sm, .hubsheet-page .btn.icon, .hubsheet-page .input { min-height: 44px; }
.hubsheet-page .btn.icon { min-width: 44px; }
.hubsheet-page .sheet input { height: 44px; min-height: 44px; font-size: 16px; border-color: var(--border); background: var(--surface); font-variant-numeric: tabular-nums; }
.hubsheet-page .sheet input:disabled { background: transparent; border-color: transparent; }
.hubsheet-page .sheet input:focus { border-color: var(--primary); }
.hubsheet-page .sheet th { white-space: nowrap; }
.hubsheet-page .faint, .hubsheet-page .text-sm, .hubsheet-page .badge, .hubsheet-page .muted { font-size: 14px; }

/* ---------- Allowances: touch-size row actions, readable small text ---------- */
.allow-page .btn, .allow-page .btn.sm, .allow-page .btn.icon, .allow-page .input { min-height: 44px; }
.allow-page .btn.icon, .allow-page .btn.sm.ghost { min-width: 44px; }
.allow-page .table .who span, .allow-page .muted, .allow-page .badge { font-size: 14px; }
.allow-page .table td, .allow-page .table th { font-variant-numeric: tabular-nums; }
/* Side panels (add and edit forms) are shared by many pages: touch-size controls everywhere */
.drawer .btn, .drawer .btn.icon, .drawer .input, .drawer select.input { min-height: 44px; }
.drawer .btn.icon { min-width: 44px; }
.drawer .field label { font-size: 15px; }
.drawer .field .hint, .drawer .field-error { font-size: 14px; }
.req { font-weight: 400; color: var(--text-3); font-size: 14px; }

/* ---------- Stock to hubs: touch-size actions, readable small text ---------- */
.hsup-page .btn, .hsup-page .btn.sm, .hsup-page .mc-x { min-height: 44px; }
.hsup-page .mc-x { min-width: 44px; }
.hsup-page .muted, .hsup-page .faint, .hsup-page .text-sm, .hsup-page small, .hsup-page th { font-size: 14px; }
.hsup-page td, .hsup-page th { font-variant-numeric: tabular-nums; }
.give-list .mc-x { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; }

/* ---------- Every page: touch-size controls and readable small text (one rule set, so all pages match) ---------- */
#view[data-page] .btn, #view[data-page] .btn.sm, #view[data-page] .seg button, #view[data-page] .tabs button,
#view[data-page] select.input, #view[data-page] .input.sm, #view[data-page] .colpick summary, #view[data-page] .more-figures > summary { min-height: 44px; }
#view[data-page] .btn.icon { min-width: 44px; }
#view[data-page] .seg button { padding-inline: 14px; }
#view[data-page] .tabs button { font-size: 15px; }
#view[data-page] .muted, #view[data-page] .faint, #view[data-page] .text-sm, #view[data-page] .badge, #view[data-page] .card-head .sub,
#view[data-page] .table .who span, #view[data-page] .hint, #view[data-page] .legend, #view[data-page] .kv dt { font-size: 14px; }
#view[data-page] .table td a[data-link], #view[data-page] .list-item a[data-link] { display: inline-flex; align-items: center; min-height: 44px; }
#view[data-page] .table td, #view[data-page] .table th { font-variant-numeric: tabular-nums; }
#view[data-page] .chip, #view[data-page] .menu a, #view[data-page] .menu button { font-size: 14px; }
#view[data-page] .menu a, #view[data-page] .menu button, #view[data-page] .dropdown a, #view[data-page] .dropdown button { min-height: 44px; display: flex; align-items: center; }
#view[data-page] .more-list a, #view[data-page] .more-list button { min-height: 44px; display: flex; align-items: center; font-size: 15px; }
#view[data-page] input.input, #view[data-page] select.input { min-height: 44px; }
@media (max-width: 520px) {
  .grid.kpis .kpi .value, .dash .kpi .value { font-size: 21px; overflow-wrap: normal; white-space: nowrap; }
  .grid.kpis .kpi .value small { font-size: 13px; }
  .page-head .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  .page-head .actions > .row {
    flex: 1 1 auto;
    display: flex;
  }
  .page-head .actions > .row .btn {
    flex: 1;
  }
  .seg {
    display: flex;
    width: 100%;
  }
  .seg button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 4px !important;
    text-align: center;
    font-size: 12.5px !important;
  }
}
/* second pass: table headers, small print and chips read at 14px on every page */
#view[data-page] .table th, #view[data-page] .sheet th, #view[data-page] small, #view[data-page] .dg-prog, #view[data-page] .seg button,
#view[data-page] .hub-nums small, #view[data-page] .dg-nums small, #view[data-page] .num.faint, #view[data-page] .faint { font-size: 14px; }
#view[data-page] .h-chip, #view[data-page] .s-sub, #view[data-page] .g-head, #view[data-page] .hub-top span, #view[data-page] .hub-nums span,
#view[data-page] .hub-chips .badge, #view[data-page] .list-item .num { font-size: 14px; }
/* day picker on a phone: previous, the date, next, in one line */
.daynav { flex-wrap: wrap; width: 100%; }
.daynav > div { flex: 1 1 140px; min-width: 0; text-align: center; }
.daynav b { font-size: 16px; }
@media (min-width: 861px) { .daynav { width: auto; } .daynav > div { flex: none; text-align: left; } }
.daynav #d-today { flex: none; }

/* Morning stock on a phone: each seller is a card, with the Give stock button always in view */
@media (max-width: 700px) {
  .msheet thead { display: none; }
  .msheet, .msheet tbody, .msheet tr, .msheet td, .msheet th { display: block; width: 100%; }
  .msheet tr { padding: 14px 16px; border-top: 1px solid var(--border); }
  .msheet th.name { padding: 0 0 8px; position: static; background: none; }
  .msheet td { padding: 6px 0; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .msheet td[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: 14px; flex: none; text-align: left; }
  .msheet td .mc-chips { justify-content: flex-end; }
  .msheet .give-cell { padding-top: 10px; }
  .msheet .give-cell .btn { width: 100%; justify-content: center; }
}
@media (max-width: 700px) { .msheet th.name { border: 0; box-shadow: none; min-width: 0; } }
#view[data-page] th, #view[data-page] .tp-left { font-size: 14px; }

/* Add product: the profit preview keeps one shape; only its numbers change as you type */
.pprev { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2, var(--surface)); padding: 16px 18px; }
.pprev h3 { font-size: 15px; margin: 0 0 10px; }
.pprev dl { margin: 0; display: grid; gap: 2px; }
.pprev dl > div { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.pprev dl > div:first-child { border-top: 0; }
.pprev dt { color: var(--text-2); font-size: 15px; }
.pprev dd { margin: 0; text-align: right; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pprev dd.sub { grid-column: 1 / -1; font-size: 14px; font-weight: 400; color: var(--text-3); text-align: right; min-height: 20px; }
.pprev .total dd:not(.sub) { font-size: 20px; }
.pprev .neg { color: var(--danger); }
.pprev .alert { margin-top: 10px; }

/* Product form: stock in the office */
.ostock { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); }
.ostock h3 { font-size: 15px; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ostock-now { font-weight: 400; font-size: 14px; color: var(--text-2); }
.ostock-now b { font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.ostock-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ostock-form .full { grid-column: 1 / -1; }
.os-list { list-style: none; margin: 14px 0 0; padding: 0; }
.os-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 15px; }
.os-list .mc-x { min-width: 44px; min-height: 44px; }

/* Stock overview */
.stockv-page .btn { min-height: 44px; }
.stockv-list li { padding-inline: 20px; }
.stockv-list li > span:last-child { white-space: nowrap; }
@media (max-width: 860px) { .stockv-list li { flex-wrap: wrap; } }

/* Give stock: a plain day row, and a calm "Nothing" tag */
.daybar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mc-chip.out { background: var(--warning-soft); color: var(--warning); }

/* Seller's phone: the bottom tabs keep their small labels, and "My stock today" reads as cards instead of a cramped table */
.ts-sub { display: none; }
@media (max-width: 860px) {
  #view[data-page] .portal-tabs button { font-size: 12px; min-height: 56px; padding-inline: 2px; overflow: hidden; text-overflow: ellipsis; }
  #view[data-page] .portal-tabs .tab-lb { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
}
@media (max-width: 560px) {
  .till-stock thead, .till-stock td:not(.left) { display: none; }
  .till-stock, .till-stock tbody { display: block; width: 100%; }
  .till-stock tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
  .till-stock tbody th { display: block; padding: 0; border: 0; text-align: left; font-size: 17px; }
  .till-stock .ts-sub { display: block; font-size: 14px; font-weight: 400; color: var(--text-3); margin-top: 2px; }
  .till-stock td.left { display: block; grid-column: 2; grid-row: 1; padding: 0; border: 0; font-size: 24px; text-align: right; }
}

/* Colour contrast: found by the mobile audit tool. Light theme only; these keep small coloured text at 4.5:1 or better on its tinted background. */
:root:not([data-theme="dark"]) { --text-3: #586579; --success: #17702f; --warning: #8a4a00; --info: #0369a1; --primary: #0066cc; }
.mc-x { min-width: 44px; flex: none; }
.stockc-page .sheet td, .stockc-page .sheet tfoot th { overflow: visible; text-overflow: clip; }
.mc-chip .mc-x { min-height: 44px; margin-block: -6px; }

/* ---------- Payslip (a seller's phone screen): purpose is to answer "how much, why, what carries forward" in plain words ---------- */
.slip { max-width: 640px; margin: 0 auto; padding: 0 0 112px; }
.sl-top { margin: 4px 0 4px; }
.sl-back { display: inline-flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 12px 0 4px; font-size: 16px; font-weight: 600; color: var(--primary); text-decoration: none; }
.sl-back svg, .sl-nav svg { width: 20px; height: 20px; }
.sl-months { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 0 0 16px; }
.sl-months h1 { margin: 0; font-size: 24px; line-height: 1.2; text-align: center; }
.sl-nav { display: inline-flex; align-items: center; gap: 4px; min-height: 48px; padding: 0 8px; font-size: 15px; font-weight: 600; color: var(--text-2); text-decoration: none; border-radius: 12px; }
.sl-nav:first-child { justify-self: start; } .sl-nav:last-child { justify-self: end; }
.sl-nav:hover { background: var(--surface-2, var(--primary-soft)); }
.sl-nav.off { visibility: hidden; }
.sl-hero { background: var(--primary-soft); border: 1px solid var(--border); border-radius: 20px; padding: 22px 20px 20px; margin: 0 0 12px; text-align: center; }
.sl-kicker { margin: 0; font-size: 16px; color: var(--text-2); font-weight: 600; }
.sl-big { margin: 6px 0 12px; font: 700 40px/1.1 var(--font-display, inherit); font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--text); overflow-wrap: anywhere; }
.sl-big small { font-size: 18px; font-weight: 600; color: var(--text-2); margin-right: 4px; }
.sl-status { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 10px; font-size: 15px; color: var(--text-2); }
.sl-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--success-soft); color: var(--success); font-weight: 700; font-size: 14px; }
.sl-chip svg { width: 16px; height: 16px; }
.sl-eq { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 4px; margin: 0 0 20px; padding: 14px 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); text-align: center; }
.sl-eq span { display: block; font-size: 14px; color: var(--text-2); }
.sl-eq b { display: block; margin-top: 2px; font-size: 16px; font-variant-numeric: tabular-nums; }
.sl-eq .op { font-size: 20px; color: var(--text-3); padding: 0 2px; }
.sl-card { padding: 18px 16px 8px; margin: 0 0 16px; border-radius: 16px; }
.sl-card h2 { margin: 0 0 8px; font-size: 18px; }
.sl-list { list-style: none; margin: 0; padding: 0; }
.sl-line { border-top: 1px solid var(--border); }
.sl-line:first-child { border-top: 0; }
.sl-plain, .sl-help summary { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; min-height: 52px; padding: 12px 0; font-size: 16px; }
.sl-help summary { cursor: pointer; list-style: none; }
.sl-help summary::-webkit-details-marker { display: none; }
.sl-help summary .sl-label::after { content: " ⓘ"; color: var(--primary); font-size: 14px; white-space: nowrap; }
.sl-help summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }
.sl-help p { margin: -4px 0 12px; font-size: 15px; line-height: 1.5; color: var(--text-2); }
.sl-label { flex: 1; min-width: 0; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 2px; }
.sl-sub { font-size: 13px; color: var(--text-2); font-weight: 400; }
.sl-amt, .sl-dl dd, .sl-total b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; text-align: right; }
.sl-total, .sl-dl > div { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 12px 0; font-size: 16px; }
.sl-total { border-top: 2px solid var(--border-strong, var(--border)); font-weight: 700; }
.sl-dl { margin: 0; } .sl-dl > div { border-top: 1px solid var(--border); } .sl-dl > div:first-child { border-top: 0; }
.sl-dl dt { color: var(--text-2); } .sl-dl dd { margin: 0; }
.sl-none, .sl-note { margin: 4px 0 8px; font-size: 15px; color: var(--text-2); }
.sl-meter { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 10px 0 6px; }
.sl-meter span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.sl-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--glass-bg, var(--bg)); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
.sl-actions .btn { display: flex; width: 100%; max-width: 640px; margin: 0 auto; min-height: 52px; justify-content: center; font-size: 17px; }
@media (min-width: 861px) { .sl-actions { left: var(--sidebar-w, 0); } }
@media (max-width: 360px) { .sl-big { font-size: 34px; } .sl-eq { grid-template-columns: 1fr; } .sl-eq .op { display: none; } }
@media (prefers-reduced-motion: no-preference) { .slip { animation: slIn .2s ease-out; } @keyframes slIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } } }
@media print { .sl-actions, .sl-top, .sl-months a { display: none; } }

/* The payslip has its own month switcher, so the top bar's month picker is hidden there (two month controls would confuse) */
body[data-page="payslip"] .period-picker { display: none; }
.sl-nav span { white-space: nowrap; }
.sl-chip { color: #14602a; }
.sl-empty-h { font-size: 24px; margin: 8px 0 16px; }

/* UI audit fixes: 44px link targets inside alerts, readable secondary text */
.alert a { display: inline-flex; align-items: center; min-height: 44px; }
.kv dt, .kv dd { font-size: 14px; }
.mono { font-size: 14px; }
.avatar { font-size: 13px; }
.table .who span, .list-item .grow span, .field .hint { font-size: 14px; }

/* Sidebar links: 44px tall */
.nav a { min-height: 44px; }
.topbar .crumb, .topbar .crumbs { font-size: 14px; }

/* Top bar controls: 44px on every screen size */
.topbar .btn, .topbar .btn.sm, .topbar .menu-btn, .topbar #theme-btn { min-height: 44px; }
.topbar .btn.icon, .topbar .menu-btn, .topbar #theme-btn { min-width: 44px; }
.topbar .input, .topbar .input.sm, .topbar select, .topbar #gs-input { min-height: 44px; }
.topbar .period-picker, .topbar .period-picker select, .topbar .period-picker input { min-height: 44px; }
.topbar .period-picker button { min-width: 44px; min-height: 44px; }
.user-chip, #ws-switch, .row-act .btn { min-height: 44px; }
.row-act .btn { min-width: 44px; }
a.crumb-group { display: inline-flex; align-items: center; min-height: 44px; }
a.crumb-group { min-width: 44px; justify-content: center; }
.ws-sub a, .ws-tabs a, .ws-sub button, .ws-tabs button { min-height: 44px; display: inline-flex; align-items: center; }

/* ===== Dark mode: first paint follows the device until the script applies the saved choice ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; }
  :root:not([data-theme]) body { background: #090e18; color: #f1f5f9; }
}

/* ===== Reduced transparency: solid panels instead of blurred glass ===== */
@media (prefers-reduced-transparency: reduce) {
  :root, :root[data-theme="dark"] { --glass-blur: none; }
  :root { --glass-bg: var(--surface); --hero-chip-bg: var(--surface); }
  :root[data-theme="dark"] { --glass-bg: #121927; --hero-chip-bg: #121927; }
}

/* ===== High contrast (device "increase contrast"): stronger text, borders and focus, no blur ===== */
@media (prefers-contrast: more) {
  :root {
    --border: rgba(11, 21, 38, 0.6); --border-strong: #0b1526;
    --text-2: #0b1526; --text-3: #1e293b; --sidebar-muted: #1e293b; --sidebar-text: #0b1526;
    --primary: #004a9f; --primary-2: #003a7e; --primary-text: #003a7e;
    --success: #0f5f27; --warning: #8a4500; --danger: #a8000f; --info: #01577f; --accent: #7a4f00;
    --glass-bg: var(--surface); --glass-blur: none; --hero-chip-bg: #fff;
    --shadow-xs: none; --shadow-sm: none; --shadow: none; --shadow-md: 0 0 0 1px #0b1526; --shadow-lg: 0 0 0 2px #0b1526;
  }
  :root[data-theme="dark"] {
    --border: rgba(255, 255, 255, 0.6); --border-strong: #ffffff;
    --text: #ffffff; --text-2: #ffffff; --text-3: #e2e8f0; --sidebar-muted: #e2e8f0; --sidebar-text: #ffffff;
    --primary: #8ec5ff; --primary-2: #b8dbff; --primary-text: #b8dbff;
    --success: #6ee7b7; --warning: #fcd34d; --danger: #fca5a5; --info: #7dd3fc; --accent: #fcd34d;
    --glass-bg: #121927; --hero-chip-bg: #000;
    --shadow-md: 0 0 0 1px #fff; --shadow-lg: 0 0 0 2px #fff;
  }
  :focus-visible, .btn:focus-visible, .nav a:focus-visible { outline: 3px solid var(--text) !important; outline-offset: 2px; }
  .btn, .input, select, textarea, .card, .badge, .chip, .alert, .menu, .sheet, .m-card, .period-picker { border: 1px solid var(--border-strong); }
  .btn.ghost { border-color: var(--border-strong); }
  a { text-decoration: underline; }
  .nav a.active, .nav a[aria-current="page"] { outline: 2px solid var(--text); outline-offset: -2px; }
  .table th, .table td { border-bottom-color: var(--border-strong); }
}

/* ===== Windows High Contrast / forced colours: let the system palette draw, keep shapes visible ===== */
@media (forced-colors: active) {
  .btn, .input, select, textarea, .card, .badge, .chip, .alert, .menu, .sheet, .m-card, .period-picker, .user-chip, .avatar, .kpi { border: 1px solid CanvasText; forced-color-adjust: auto; }
  .btn.primary, .btn.danger { border-width: 2px; }
  :focus-visible { outline: 3px solid Highlight !important; outline-offset: 2px; }
  .nav a.active, .nav a[aria-current="page"], .tabs .active, .tabs [aria-selected="true"], .seg .on { outline: 2px solid Highlight; outline-offset: -2px; font-weight: 700; }
  .step .dot, .badge::before { forced-color-adjust: none; }
  .chart rect, .chart path, .chart circle { forced-color-adjust: none; }
  svg.i { fill: currentColor; }
  .btn:disabled { border-style: dashed; color: GrayText; }
}

/* Dark mode: white text on the bright dark-theme blue failed contrast, so filled blue pills use the deep blue of the primary button, and avatars use dark text */
.step.current .dot, .skip-link, .chip-btn.on, .ws-sub a[aria-current="page"] { background: #13539f; border-color: #13539f; color: #fff; }
:root[data-theme="dark"] .avatar { color: #0b1526; }
/* The dark-theme primary button keeps its deep-blue gradient, so its text must stay white */
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .step.current .dot, :root[data-theme="dark"] .skip-link { color: #fff; }

/* Final audit pass: last small captions at 14px, and the amber count pill keeps 4.5:1 with white text */
.text-sm, .mc-label, .mstep .mdot, .user-chip .who b, .gsearch .gs-key, .num.text-sm { font-size: 14px; }
.nav .count { background: color-mix(in srgb, var(--accent) 78%, #000); font-size: 12px; }
:root[data-theme="dark"] .nav .count { background: var(--accent); }

/* Phones and touch screens: any field under 16px makes iOS zoom the page when it is focused */
@media (pointer: coarse), (max-width: 860px) {
  .gsearch input, .input.sm, select.input.sm, .period-picker select, .period-picker input, .filterbar select, .filterbar input { font-size: 16px; }
}
@media (pointer: coarse), (max-width: 860px) { .sheet input, .sheet td input, table input { font-size: 16px; } }
.empty .empty-hint { margin: 0; color: var(--text-2); font-size: 14px; }

/* ===== Touch and gestures audit ===== */
/* Quick repeated taps (the till's + and -, next/previous day) must never turn into a double-tap zoom. Pinch-zoom still works. */
html, body, a, button, input, select, textarea, label, summary, [role="button"], [role="tab"], .btn, .till-prod, .ts-step, .m-card, .g-row { touch-action: manipulation; }

/* Phones: main buttons are 48px tall and at least 120px wide (the easy-to-hit size for a thumb) */
@media (max-width: 860px), (pointer: coarse) {
  .btn.primary, .btn.sm.primary, #view[data-page] .btn.primary, #view[data-page] .btn.sm.primary { min-height: 48px; min-width: 120px; }
  /* Neighbouring controls are at least 8px apart */
  .row, .card-head .row, .daynav, .filterbar, .ws-top { gap: 8px; }
  .ws-top { margin-bottom: 8px; }
  .card-head .row > * + *, .daynav > * + * { margin-left: 0; }
  .search + .input, .search + select { margin-left: 2px; }
}

/* Pressed feedback on tappable rows and filter buttons (under 100 ms) */
.table tr.clickable:active td, .list-item:active, .seg button:active, .tabs button:active, .chip-btn:active, .menu a:active, .menu button:active, .nav a:active { background: var(--surface-3); }
@media (prefers-reduced-motion: no-preference) { .seg button:active, .chip-btn:active { transform: scale(.97); } }

/* A coacher or manager opening My page on a phone has one bottom bar (the main menu). The page's own sections (Month, Team, Payslips...) are a strip of text tabs under the heading, like the hub sections, not a second bar. */
@media (max-width: 860px) {
  .shell.has-bnav .portal-tabs {
    position: static; display: flex; grid-auto-flow: row; overflow-x: auto; scrollbar-width: none; gap: 0; margin: 0 0 14px; padding: 0;
    background: none; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; border-top: 0; border-bottom: 1px solid var(--border);
  }
  .shell.has-bnav .portal-tabs::-webkit-scrollbar { display: none; }
  .shell.has-bnav #view[data-page] .portal-tabs button {
    flex: 0 0 auto; flex-direction: row; min-height: 44px; padding: 0 14px; padding-inline: 14px; font-size: 14.5px; overflow: visible; border-top: 0; border-bottom: 3px solid transparent; color: var(--text-2);
  }
  .shell.has-bnav #view[data-page] .portal-tabs button.on { color: var(--primary); border-bottom-color: var(--primary); border-top-color: transparent; }
  .shell.has-bnav .portal-tabs .tab-ic { display: none; }
  .shell.has-bnav .portal-tabs .cnt { display: none; }
  .shell.has-bnav .has-bottom-tabs { padding-bottom: 0; }
  body:has(.has-bnav .portal-tabs) .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
.print-links a, .actions a.btn + a.btn { margin-left: 0; }
/* Lists of links in menus and stacked folds keep a gap between tap targets */
.more-list { display: flex; flex-direction: column; gap: 8px; }
.more-list a { display: flex; align-items: center; gap: 8px; min-height: 44px; }
details.fold + details.fold { margin-top: 8px; }

/* ---------- Admin on a phone: fewer stacked bars, so the data starts higher ---------- */
@media (max-width: 860px) {
  /* Hub name and hub switcher share one row. */
  .ws-top { flex-wrap: nowrap; margin-bottom: 2px; }
  .ws-hub { font-size: 18px; white-space: nowrap; }
  .ws-top .faint { white-space: nowrap; }
  .ws-top > select { width: auto; flex: 1 1 0; min-width: 0; margin-left: auto; max-width: 190px; }
  /* The five hub sections fit across the screen without sideways scrolling. */
  .ws-tabs { gap: 3px; padding: 3px; border-radius: var(--radius); background: var(--surface-3); }
  .ws-tabs a { flex: 1 1 auto; justify-content: center; padding: 6px 8px; font-size: 13px; min-height: 36px; border: 0; }
  .ws-tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
  /* Pages inside a section: smaller pills that fit three across. */
  .ws-sub { gap: 6px; padding: 8px 0 10px; }
  .ws-sub a { padding: 0 10px; font-size: 13.5px; }
  /* A long page introduction shows two lines; "Read more" opens the rest. */
  .page-head p.clamp:not(.open) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .more-link { border: 0; background: none; padding: 0 0 4px; min-height: 44px; margin-top: -6px; color: var(--primary); font: 600 14px var(--font); cursor: pointer; }
}
@media (min-width: 861px) { .more-link { display: none; } }

/* Inside a hub on a phone: hub switcher and month picker share one row (the switcher already shows the hub's name). */
@media (max-width: 860px) {
  .ws-top:has(#ws-switch) .ws-hub, .ws-top:has(#ws-switch) .faint { display: none; }
  .ws-top > select { margin-left: 0; max-width: none; }
  .ws-top .period-picker { flex: none; margin-left: auto; }
}

/* ===== Minimal home page ===== */
.dash-min { max-width: 1120px; }
.dash-min .page-head { margin-bottom: 20px; }
.dash-min .page-head h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.02em; line-height: 1.1; }
.dash-min .page-head p { margin-top: 6px; color: var(--text-2); }
.dash-min .month-card { border-radius: 18px; padding: 28px 32px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); background: var(--surface); }
.dash-min .month-card h2 { font-size: 30px; }
.dash-min .mc-right dt { font-size: 14px; color: var(--text-3); font-weight: 550; letter-spacing: .01em; }
.dash-min .mc-right dd { font: 600 34px/1.1 var(--font-display); margin: 4px 0 0; font-variant-numeric: tabular-nums; }
.dash-min .mc-right dd small { font: 600 16px var(--font); color: var(--text-3); margin-right: 4px; }
.dash-min .grid.kpis { gap: 14px; margin-bottom: 8px; }
.dash-min .kpi { padding: 22px 24px; border-radius: 16px; box-shadow: none; border: 1px solid var(--border); background: var(--surface); }
.dash-min .kpi .label { font-size: 14px; color: var(--text-3); font-weight: 550; }
.dash-min .kpi .value { font-size: 36px; margin-top: 8px; font-weight: 600; }
.dash-min .kpi .foot { font-size: 14px; margin-top: 8px; }
.dash-min .section-title { font: 600 22px var(--font-display); margin: 0; letter-spacing: -.01em; }
.dash-min .mt-5 { margin-top: 32px; }
.dash-min .hub-tile { display: grid; gap: 4px; padding: 22px 24px; border-radius: 16px; box-shadow: none; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: inherit; transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.dash-min .hub-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }
.dash-min .hub-tile .hub-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dash-min .hub-tile .hub-name { font: 600 20px var(--font-display); }
.dash-min .hub-tile .hub-count { color: var(--text-2); font-size: 14px; }
.dash-min .hub-tile .hub-nums { display: flex; gap: 28px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.dash-min .hub-tile .hub-nums small { display: block; font-size: 14px; color: var(--text-3); font-weight: 550; }
.dash-min .hub-tile .hub-nums b { font: 600 22px var(--font-display); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .dash-min .month-card { padding: 22px 20px; }
  .dash-min .kpi { padding: 16px; }
  .dash-min .grid.kpis .kpi .value { font-size: 26px; }
  .dash-min .hub-tile { padding: 18px; }
}

/* Keep touch targets and captions at the audited sizes after the latest card and tab styling */
@media (max-width: 860px) {
  .ws-tabs a, .ws-sub a, .eod-jump-btn { min-height: 44px; }
}
.m-card .mc-kv .k, .m-card .mc-kv .v, .m-card .mc-kv span, .tp-price, .tp-badge, .th-date, .th-sub, .seg button, .seg button.on { font-size: 14px; }
#view .seg button, #view .seg button.on { font-size: 14px; }
.eod-jump-btn { min-height: 44px; }
.tag, span.tag { font-size: 14px; }

/* =====================================================================================================================
   Motion: pages slide in, cards rise one after another, glows on hover, numbers count up.
   Everything here is under html.fx, which public/js/fx.js switches on only when the device allows it (not reduced-motion, not a
   weak phone, not data-saver; or when My account says On). With fx off nothing below applies and the pages simply appear.
   Only transform and opacity are animated (the cheap ones for a phone), and entrances run just on a page change (#view.page-in),
   so a page that redraws part of itself later does not flicker.
   ===================================================================================================================== */
:root { --ease-out: cubic-bezier(.2, .8, .2, 1); --glow: color-mix(in srgb, var(--primary) 42%, transparent); --glow-soft: color-mix(in srgb, var(--primary) 16%, transparent); }

/* a lighter glass on weak devices and phones: the blur behind the bars is the most expensive thing the browser draws here */
html.lite { --glass-blur: none; --glass-bg: var(--surface); }
@media (max-width: 860px) { :root { --glass-blur: saturate(150%) blur(10px); } }

@keyframes rise { from { opacity: 0; transform: translate(var(--sx, 0px), 18px) scale(.985); } }
@keyframes slide-title { from { opacity: 0; transform: translate(var(--sx, 0px), 8px); } }
@keyframes glow-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--glow); } 60% { box-shadow: 0 0 0 7px transparent; } }
@keyframes line-draw { from { transform: scaleY(0); } }
@keyframes fade-in-only { from { opacity: 0; } }

/* ---- a new page: the title slides, then the cards rise in one after another (the stagger counts the position among siblings) */
html.fx #view.page-in .page-head { animation: slide-title .4s var(--ease-out) backwards; }
html.fx #view.page-in :is(.card, .kpi, .hub-tile, .stat, .hero, .glist, .alert, .org-scroll, .range-bar, .tabs) {
  animation: rise .55s var(--ease-out) backwards; animation-delay: calc(var(--i, 0) * 55ms + 70ms);
}
html.fx #view.page-in :is(#view, .grid, .stack, .dash, [class$="-page"]) > :nth-child(2) { --i: 1; }
html.fx #view.page-in :is(#view, .grid, .stack, .dash, [class$="-page"]) > :nth-child(3) { --i: 2; }
html.fx #view.page-in :is(#view, .grid, .stack, .dash, [class$="-page"]) > :nth-child(4) { --i: 3; }
html.fx #view.page-in :is(#view, .grid, .stack, .dash, [class$="-page"]) > :nth-child(5) { --i: 4; }
html.fx #view.page-in :is(#view, .grid, .stack, .dash, [class$="-page"]) > :nth-child(6) { --i: 5; }
html.fx #view.page-in :is(#view, .grid, .stack, .dash, [class$="-page"]) > :nth-child(7) { --i: 6; }
html.fx #view.page-in :is(#view, .grid, .stack, .dash, [class$="-page"]) > :nth-child(n+8) { --i: 7; }
/* the org chart: the boss first, then each level a little later (the depth is set on each person) */
html.fx #view.page-in .org-card { animation: rise .6s var(--ease-out) backwards; animation-delay: calc(var(--d, 0) * 140ms + 200ms); }
html.fx #view.page-in .org-kids { animation: fade-in-only .5s ease backwards; animation-delay: calc(var(--d, 0) * 140ms + 260ms); }

/* ---- a panel or tab that changes inside a page slides in too */
html.fx .pane-in { animation: pane-in .3s var(--ease-out); }

/* ---- hover: a soft glow in the brand colour, and the small cards lift (only where there is a mouse) */
@media (hover: hover) {
  html.fx .card { transition: box-shadow .3s var(--ease-out), border-color .3s var(--ease-out), transform .3s var(--ease-out); }
  html.fx .card:hover { border-color: color-mix(in srgb, var(--primary) 32%, var(--border-strong, var(--border))); box-shadow: var(--shadow-md), 0 0 0 1px var(--glow-soft), 0 16px 46px -18px var(--glow); }
  html.fx :is(.kpi, .hub-tile, .stat):hover { transform: translateY(-3px); }
  html.fx a.card:active, html.fx .hub-tile:active { transform: translateY(-1px) scale(.99); }
  html.fx .org-card:hover { box-shadow: 0 12px 34px -10px var(--lv), 0 0 0 1px color-mix(in srgb, var(--lv) 40%, transparent); }
  html.fx .nav a { transition: background-color .2s, color .2s, transform .2s var(--ease-out); }
  html.fx .nav a:not(.active):hover { transform: translateX(3px); }
}
html.fx .kpi .icon, html.fx .stat .s-ic { box-shadow: 0 6px 18px -8px currentColor; }
html.fx .kpi:hover .icon { transform: scale(1.12) rotate(-4deg); }

/* ---- buttons: the main button glows, and a light sweeps across it on hover */
html.fx .btn.primary { position: relative; overflow: hidden; box-shadow: var(--shadow-sm), 0 8px 22px -10px var(--glow); transition: box-shadow .3s var(--ease-out), transform .12s ease, background-color .2s; }
html.fx .btn.primary::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 32%, rgba(255, 255, 255, .26) 50%, transparent 68%); transform: translateX(-130%); }
@media (hover: hover) {
  html.fx .btn.primary:hover { box-shadow: var(--shadow-md), 0 12px 30px -10px var(--glow); }
  html.fx .btn.primary:hover::after { transform: translateX(130%); transition: transform .7s var(--ease-out); }
}

/* ---- the current page in the menu glows; badges that need attention pulse gently */
html.fx .nav a.active::before { box-shadow: 0 0 14px 1px var(--gold, var(--primary)); }
html.fx .nav a.active { box-shadow: inset 0 0 22px -14px var(--primary); }
html.fx .bottom-nav a { transition: color .2s, transform .25s var(--ease-out); }
html.fx .bottom-nav a[aria-current="page"], html.fx .bottom-nav a.active { transform: translateY(-2px); }
html.fx .bottom-nav a[aria-current="page"] svg, html.fx .bottom-nav a.active svg { filter: drop-shadow(0 4px 8px var(--glow)); }
html.fx .nav .count, html.fx .bottom-nav .dot:not([hidden]) { animation: glow-pulse 2.4s ease-in-out infinite; }

/* ---- profile circles glow in their own colour */
html.fx .org-av { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--lv, var(--primary)), 0 8px 20px -6px var(--lv, var(--primary)); }
html.fx .profile-head .avatar, html.fx .user-chip .avatar { box-shadow: 0 0 0 2px var(--surface), 0 6px 16px -6px var(--glow); }

/* ---- segmented choices and tabs ease between states; the chosen one glows a little */
html.fx .seg button.on, html.fx .tabs button.on { box-shadow: 0 2px 8px rgba(0, 0, 0, .08), 0 0 0 1px var(--glow-soft), 0 6px 18px -8px var(--glow); }
html.fx .seg button, html.fx .tabs button { transition: background-color .25s var(--ease-out), color .2s, box-shadow .3s var(--ease-out), transform .12s ease; }

/* ---- bars and lines draw themselves */
html.fx #view.page-in .progress span { animation: grow .9s var(--ease-out) backwards; animation-delay: .25s; }
html.fx .org-kids::before { transform-origin: top; }
html.fx #view.page-in .org-kids::before { animation: line-draw .5s var(--ease-out) backwards; animation-delay: calc(var(--d, 0) * 140ms + 300ms); }

/* ---- drawers, dialogs and toasts: a little more life than the plain slide */
html.fx .drawer { animation: drawerSlide .38s var(--ease-out); }
html.fx .modal { animation: modalPop .32s var(--ease-out); }
html.fx .toast { animation: toastPop .4s cubic-bezier(.3, 1.4, .5, 1); }

/* ---- numbers hold still while they count */
.kpi .value, .stat .s-value, .hub-nums b, .dstat b, .mc-right dd { font-variant-numeric: tabular-nums; }

/* ---- with motion off, the older page fade stays out of the way as well */
html.lite #view.page-in { animation: none; }

/* touch screens: the sort buttons in table headers are finger-sized */
@media (pointer: coarse) { .th-sort { min-height: 44px; } }

/* pages that do not use the hub and month choice do not show it (the page says so with filters: false) */
body[data-filters="none"] #filters, body[data-filters="none"] #filterbar, body[data-filters="none"] .filterbar { display: none !important; }

/* Audit trail filters on a phone: two neat columns, full-size fields, one wide Filter button */
@media (max-width: 760px) {
  #af { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
  #af .input { width: 100% !important; min-width: 0; min-height: 44px; font-size: 16px; }
  #af .btn { min-height: 44px; grid-column: 1 / -1; justify-content: center; }
  .range-quick button { padding-inline: 14px; min-height: 44px; }
}

/* =====================================================================================================================
   Phone: the data comes first. Filters fold away behind one button, the page's buttons share one row, and three-number
   summaries are compact tiles, so the list or table starts near the top of the screen instead of below a wall of controls.
   ===================================================================================================================== */
.filters-toggle { display: none; }
.filter-panel { display: contents; }
.fcount { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 99px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; }
.fcount[hidden] { display: none; }
@media (max-width: 760px) {
  .filters-toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; flex: 0 0 auto; }
  /* Employees (and the People tab of a hub): search and one Filters button; the rest opens on tap */
  .emp-page .filters-row { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; align-items: center; }
  .emp-page .filters-row .search { flex: 1 1 0; min-width: 0; }
  .emp-page .filters-row .search input { width: 100% !important; }
  .filters-row .filter-panel { display: none; flex: 1 1 100%; }
  .filters-row.filters-open .filter-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .filters-row.filters-open .filter-panel .input { width: 100% !important; }
  .emp-page .colpick { display: none; } /* the column choice is for the wide table; a phone shows cards */
  /* Audit trail: the form folds behind "More filters"; the quick dates stay in view */
  .card-head[data-filters-host] > #af { display: none !important; }
  .card-head[data-filters-host].filters-open > #af { display: grid !important; }

  /* a page's buttons sit on one line: when a page has a main button, the Excel and PDF buttons shrink to icons beside it */
  #view .page-head .actions > .row { flex: 0 0 auto; }
  #view .page-head .actions > .row .btn { flex: 0 0 auto; padding-inline: 12px; }
  #view .page-head .actions:has(> .btn.primary) .row .lbl-sm { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #view .page-head .actions:has(> .btn.primary) .row .btn { min-width: 44px; justify-content: center; }

  /* three numbers (Hub stock) become compact tiles side by side */
  .grid.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpis-3 .kpi { padding: 10px; }
  .kpis-3 .kpi .label { font-size: 12px; gap: 6px; line-height: 1.25; }
  .kpis-3 .kpi .label .icon { display: none; }
  .kpis-3 .kpi .value { font-size: 22px; margin-top: 6px; }
  .kpis-3 .kpi .foot { display: none; }
  /* Dashboard: Business across, the two shortfalls side by side */
  .dash-min .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dash-min .grid.kpis .kpi:first-child { grid-column: 1 / -1; }
  .dash-min .grid.kpis .kpi:not(:first-child) .foot { display: none; }
  .dash-min .grid.kpis .kpi:not(:first-child) .value { font-size: 18px; }

  /* the date range: the dropdown and the dates on one line */
  .range-bar { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; }
  .range-text { font-size: 12px; line-height: 1.3; }
  .range-custom { grid-column: 1 / -1; }
}
@media (max-width: 760px) { #view .range-quick button { padding-inline: 14px !important; font-size: 14px !important; } }

/* Phone: long page intros (and their Read more link) are left out so the data is not pushed down; the month card is slimmer */
@media (max-width: 760px) {
  .page-head p.clamp, .page-head .more-link { display: none; }
  .month-card { padding: 14px 16px; gap: 8px; margin-bottom: 12px; }
  .month-card h2 { font-size: 20px; margin-bottom: 2px; }
  .month-card p { font-size: 14px; margin-bottom: 10px; }
  .month-card .btn { width: auto; min-height: 44px; padding-inline: 18px; }
  .month-card dd { font-size: 22px; }
  .month-card .mc-right { gap: 2px; }
}

/* Stock to hubs: a short list of the hubs; the details open on tap */
.hs-list ul { list-style: none; margin: 0; padding: 0; }
.hs-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 12px 18px; background: none; border: 0; border-bottom: 1px solid var(--border); text-align: left; color: inherit; font: inherit; cursor: pointer; transition: background-color .15s; }
.hs-list li:last-child .hs-row { border-bottom: 0; }
.hs-row:hover { background: var(--surface-2); }
.hs-row:active { background: var(--surface-3); }
.hs-row:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.hs-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hs-main b { font-size: 16px; }
.hs-main .muted { font-size: 14px; }
.hs-flags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hs-chev { width: 9px; height: 9px; flex: none; border-right: 2px solid var(--text-3); border-top: 2px solid var(--text-3); transform: rotate(45deg); margin-right: 4px; }
.hs-hint { margin: 10px 4px 0; font-size: 14px; }
@media (max-width: 760px) { .hs-row { padding-inline: 14px; } .hs-flags { flex-direction: column; align-items: flex-end; } }
@media (max-width: 760px) { #view .range-quick button { flex: 0 0 auto !important; min-width: max-content !important; } }
.m-card .mc-main .badge { align-self: flex-start; }

/* ---- Dashboard hub cards: each hub is its own card, details centred ---- */
.grid.three:has(> .hub-tile.ht) { gap: 20px; }
.dash-min .hub-tile.ht {
  position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 0 0 18px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-md);
}
.hub-tile.ht::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 86px; pointer-events: none;
  background: linear-gradient(135deg, var(--hc), color-mix(in srgb, var(--hc) 40%, transparent));
}
.hub-tile.ht::after { /* a soft light in the band */
  content: ""; position: absolute; top: -40px; right: -30px; width: 130px; height: 130px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 70%);
}
.ht-badge {
  position: relative; z-index: 1; margin-top: 46px; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--hc); font: 700 22px var(--font-display); letter-spacing: .02em;
  box-shadow: 0 0 0 5px var(--surface), 0 12px 26px -10px var(--hc);
}
.ht-name { position: relative; z-index: 1; margin-top: 8px; font: 650 21px/1.2 var(--font-display); color: var(--text); }
.ht-count { font-size: 14px; color: var(--text-2); }
.ht-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding-inline: 12px; }
.ht-nums { display: grid; grid-template-columns: 1fr 1fr; width: calc(100% - 36px); margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.ht-nums.one { grid-template-columns: 1fr; }
.ht-stat { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.ht-stat + .ht-stat { border-left: 1px solid var(--border); }
.ht-stat small { font-size: 13px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.ht-stat b { font: 650 24px/1.1 var(--font-display); font-variant-numeric: tabular-nums; color: var(--text); }
.ht-open { margin-top: 12px; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; color: var(--hc); }
.ht-open::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-top: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s var(--ease-out, ease); }
.hub-tile.ht:hover .ht-open::after { transform: rotate(45deg) translate(2px, -2px); }
.dash-min .hub-tile.ht:hover { border-color: color-mix(in srgb, var(--hc) 45%, var(--border)); box-shadow: var(--shadow-md), 0 18px 46px -18px var(--hc); }
@media (max-width: 760px) {
  .grid.three:has(> .hub-tile.ht) { gap: 16px; }
  .hub-tile.ht::before { height: 70px; }
  .ht-badge { margin-top: 36px; width: 68px; height: 68px; font-size: 20px; }
}
html.fx #view.page-in .hub-tile.ht .ht-badge { animation: pop-badge .6s cubic-bezier(.3, 1.5, .5, 1) backwards; animation-delay: calc(var(--i, 0) * 55ms + 200ms); }
@keyframes pop-badge { from { opacity: 0; transform: scale(.4); } }

/* a card that has more facts than fit: the rest fold behind "Show more" */
.mc-more { margin-top: 6px; }
.mc-more summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--primary); font-size: 14px; font-weight: 650; list-style: none; }
.mc-more summary::-webkit-details-marker { display: none; }
.mc-more[open] summary { margin-bottom: 4px; }
.mc-more[open] summary::before { content: "Show less"; }
.mc-more[open] summary { font-size: 0; }
.mc-more[open] summary::before { font-size: 14px; }

/* Seller's Sell tab: the bar under the products is one clean row (today's sales on the left, Day End on the right) */
.till-quick-bar { display: flex; gap: 10px; align-items: center; }
.till-quick-bar .btn { flex: 1 1 0; min-height: 48px; justify-content: center; }

/* Seller's phone: the greeting and its two buttons belong to the Month tab; the other tabs start with their own content */
@media (max-width: 860px) {
  #view[data-tab="payslips"] .portal-head, #view[data-tab="documents"] .portal-head, #view[data-tab="details"] .portal-head, #view[data-tab="loans"] .portal-head { display: none; }
}

/* A hub head's "To do" block on Home */
.todo-head { padding: 14px 18px 4px; font-size: 14px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.todo-row { text-decoration: none; }
.todo-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; }
.todo-ic svg { width: 22px; height: 22px; }
.todo-ic.amber { background: var(--warning-soft); color: var(--warning); }
.todo-ic.red { background: var(--danger-soft); color: var(--danger); }
.todo-ic.green { background: var(--success-soft); color: var(--success); }
.todo-done { display: flex; align-items: center; gap: 12px; padding: 14px 18px 18px; }

/* Page buttons that fold away on a phone (Daily sheet: Import / export) */
@media (max-width: 760px) {
  .actions[data-filters-host] > .filter-panel { display: none; flex: 1 1 100%; }
  .actions[data-filters-host].filters-open > .filter-panel { display: flex; flex-wrap: wrap; gap: 8px; }
  .actions[data-filters-host] > .seg { flex: 1 1 100%; }
}
.m-card .mc-main .badge { justify-self: start; width: max-content; max-width: 100%; }

/* Users on a phone: the four kinds of login are small count tiles; the people are the page */
@media (max-width: 760px) {
  .role-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .role-kpis .kpi { padding: 10px 12px; flex-direction: row; }
  .role-kpis .kpi .foot { display: none; }
  .role-kpis .kpi { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; }
  .role-kpis .kpi .value { font-size: 24px; margin: 0; }
}

/* Hubs page: every hub is listed, so the hub choice is not shown (month only) */
body[data-filters="month"] #hub-filter { display: none !important; }
.hub-kpis .v-short { display: none; }

/* Hubs page on a phone: a short summary row, then one compact card per hub */
@media (max-width: 760px) {
  .hub-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hub-kpis .kpi { padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 6px; }
  .hub-kpis .kpi .foot { display: none; }
  .hub-kpis .kpi .value { font-size: 22px; margin: 0; }
  .hub-kpis .v-full { display: none; }
  .hub-kpis .v-short { display: inline; }
  .hubs-page > div > p { display: none; }
  #cards.grid { gap: 10px; }
  .hubc-head { padding: 14px 16px 6px; gap: 10px; }
  .hubc-ic { width: 38px; height: 38px; }
  .hubc-title h2 { font-size: 17px; }
  .hubc-addr { display: none; }
  .hubc-body { padding: 2px 16px 6px; }
  .hubc-levels { display: none; }
  .hubc-people { margin-bottom: 8px; }
  .hubc-nums { margin: 0 0 10px; padding: 8px 0; gap: 8px; }
  .hubc-nums dd { font-size: 16px; }
  .hubc-month { display: none; }
  .hubc-foot { padding: 8px 16px 14px; gap: 8px; flex-wrap: nowrap; }
  .hubc-foot .btn { min-height: 44px; }
  .hubc-foot .btn:not(.primary) { flex: 0 0 auto; }
  .hubc-edit-lbl { display: none; }
}
.hub-kpis .kpi .value { white-space: nowrap; }

/* Employee profile on a phone: name and key figures first, actions in one row */
.ph-short { display: none; }
@media (max-width: 760px) {
  .emp-profile .profile-head { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; padding: 14px; align-items: center; }
  .emp-profile .profile-head > div:nth-child(2) { min-width: 0 !important; }
  .emp-profile .profile-head .avatar.lg { width: 52px; height: 52px; font-size: 18px; }
  .emp-profile .profile-head h1 { font-size: 20px; }
  .ph-stats { grid-column: 1 / -1; display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px !important; padding: 10px 0; border-block: 1px solid var(--border); }
  .ph-stats[hidden] { display: none !important; }
  .ph-stats .stat-lg { font-size: 15px; white-space: nowrap; }
  .ph-stats .text-sm { font-size: 12px; }
  .ph-pdf, .ph-acts { grid-column: 1 / -1; }
  .emp-profile .profile-head { grid-auto-flow: row; }
  .ph-pdf { grid-column: 1; grid-row: auto; }
  .ph-long { display: none; }
  .ph-short { display: inline; }
}
@media (max-width: 760px) {
  .emp-profile .ph-actions { grid-column: 1 / -1; display: flex; flex-wrap: nowrap !important; gap: 8px; }
  .emp-profile .ph-actions > div { display: contents; }
  .emp-profile .ph-actions .btn { flex: 1 1 0; justify-content: center; min-height: 44px; padding-inline: 8px; }
  .emp-profile .ph-pdf, .emp-profile .ph-acts { grid-column: auto; grid-row: auto; }
}
@media (max-width: 760px) { .ph-stats .stat-lg + .text-sm { display: none; } }
@media (max-width: 760px) {
  .emp-profile .card-head { padding: 12px 16px; }
  .emp-profile .card-body:not(.flush) { padding: 12px 16px 14px; }
  .emp-profile .kv { gap: 6px 12px; grid-template-columns: 104px minmax(0, 1fr); }
  .emp-profile .grid.halves { gap: 10px; }
}

/* Hub cards on a phone, second pass: one compact block, the whole card opens the hub */
.hn-people, .hubc-coach { display: none; }
@media (max-width: 760px) {
  .hubc { position: relative; }
  .hubc-ic { background: color-mix(in srgb, var(--accent, #4f7cff) 16%, transparent); color: var(--accent, #4f7cff); border-radius: 12px; }
  .hubc-head { padding: 14px 64px 4px 14px; align-items: center; }
  .hubc-title h2 { margin: 0; line-height: 1.25; }
  .hubc-title .sub { margin: 0; line-height: 1.25; font-size: 13px; }
  .hubc-coach { display: block; font-size: 13px; color: var(--text-3); margin-top: 2px; line-height: 1.25; }
  .hubc .hub-link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
  .hubc-people { display: none; }
  .hn-people { display: block; }
  .hubc-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 8px 0 10px; padding: 8px 0; }
  .hubc-nums.one { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hubc-nums dt { font-size: 12px; }
  .hubc-nums dd { font-size: 17px; margin: 0; }
  .hubc-body { padding: 0 14px 14px; }
  .hubc-chips { gap: 6px; }
  .hubc-foot { padding: 0; display: block; }
  .hubc-foot > a.btn { display: none; }
  .hubc-foot [data-edit] { position: absolute; top: 8px; right: 8px; z-index: 2; width: 44px; min-height: 44px; padding: 0; justify-content: center; }
}

/* Drill-down: a summary, then one card per team (or person) to open */
.drill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.drill-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; text-decoration: none; color: inherit; position: relative; }
.drill-card:hover { border-color: var(--accent, #4f7cff); }
.dc-top { display: flex; align-items: center; gap: 12px; }
.dc-top .avatar { flex: none; }
.dc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dc-main b { font-size: 16px; overflow-wrap: anywhere; }
.dc-main .muted { font-size: 13px; }
.dc-sales { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.dc-sales b { font-size: 17px; font-variant-numeric: tabular-nums; }
.dc-sales .muted { font-size: 12px; }
.dc-foot { display: flex; align-items: center; }
.dc-foot .target-bar { width: 100%; }
.dc-open { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--accent, #4f7cff); }
.dc-open::after { content: " ›"; }
.drill-crumbs { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; min-height: 44px; }
.drill-crumbs a { padding: 10px 0; }
.drill-h { margin: 6px 0 10px; }
@media (max-width: 760px) {
  .drill-grid { grid-template-columns: 1fr; gap: 10px; }
  .drill-card { padding: 14px; gap: 8px; }
  .dc-open { display: none; }
}
.drill-card, .drill-card:hover, .drill-card * { text-decoration: none !important; }

/* Dashboard on a phone: hubs are compact cards, the company figures are three short rows */
@media (max-width: 760px) {
  .dash-min .hub-tile.ht { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-areas: "b n" "b c" "x x" "m m"; column-gap: 12px; row-gap: 2px; align-items: center; text-align: left; padding: 14px; border-radius: 16px; }
  .hub-tile.ht::before, .hub-tile.ht::after { display: none; }
  .hub-tile.ht .ht-badge { grid-area: b; margin: 0; width: 44px; height: 44px; font-size: 15px; box-shadow: none; background: color-mix(in srgb, var(--hc) 18%, transparent); }
  .hub-tile.ht .ht-name { grid-area: n; margin: 0; font-size: 17px; }
  .hub-tile.ht .ht-count { grid-area: c; }
  .hub-tile.ht .ht-chips { grid-area: x; justify-content: flex-start; padding: 8px 0 0; }
  .hub-tile.ht .ht-nums { grid-area: m; width: 100%; margin-top: 10px; padding-top: 10px; }
  .hub-tile.ht .ht-stat { align-items: flex-start; }
  .hub-tile.ht .ht-stat + .ht-stat { padding-left: 14px; }
  .hub-tile.ht .ht-stat b { font-size: 18px; }
  .hub-tile.ht .ht-open { display: none; }
  .grid.three:has(> .hub-tile.ht) { gap: 10px; }
  .dash-kpis { grid-template-columns: 1fr; gap: 8px; }
  .dash-kpis .kpi { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; padding: 12px 14px; }
  .dash-kpis .kpi .foot { grid-column: 1 / -1; font-size: 12px; }
  .dash-kpis .kpi:not(:first-child) .foot { display: none; }
  .dash-kpis .kpi .value { font-size: 20px; margin: 0; }
}
@media (max-width: 760px) { .grid.kpis.dash-kpis { grid-template-columns: 1fr; } }
.dl-daybar { padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
@media (max-width: 760px) { .dl-daybar .btn.icon { min-width: 44px; min-height: 44px; } .dl-daybar input[type="date"] { min-height: 44px; flex: 1 1 150px; } }

/* Cash handover */
.ho-item { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ho-top { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.ho-mid { display: flex; gap: 6px; flex-wrap: wrap; }
.ho-note { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.ho-actions { display: flex; gap: 8px; width: 100%; }
.ho-actions .btn { flex: 1 1 0; min-height: 44px; justify-content: center; }
.ho-form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ho-form .btn.primary { min-height: 48px; justify-content: center; }
.hint.pos { color: var(--success); }
.hint.neg { color: var(--danger); }

/* ===== World Entrepreneurs Company logo ===== */
.brand-logo { width: 44px; height: 44px; border-radius: 50%; flex: none; display: block; object-fit: cover; box-shadow: 0 0 0 1px var(--border-strong), 0 3px 10px rgba(15, 23, 42, .18); background: #1b1917; }
.brand-logo-lg { width: 76px; height: 76px; }
.auth-brand .brand-logo { width: 44px; height: 44px; }
:root[data-theme="dark"] .brand-logo { box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 3px 10px rgba(0, 0, 0, .5); }
@media (prefers-contrast: more) { .brand-logo { box-shadow: 0 0 0 2px var(--text); } }
.shell.rail .brand-logo { width: 34px; height: 34px; }
