/*
 * PrepTrack - styles.css
 *
 * Dark "glass + neon" theme. No frameworks, no web fonts (system font stack,
 * so it works offline). Structure of this file:
 *   1.  Design tokens (CSS custom properties)
 *   2.  Base / reset
 *   3.  App shell: sidebar + main area
 *   4.  Generic components: cards, buttons, badges, chips, progress, toasts
 *   5.  Forms and dialogs
 *   6.  Charts
 *   7.  Dashboard
 *   8.  Supplies
 *   9.  People
 *   10. Plan
 *   11. Responsive + accessibility
 *
 * NOTE: the Content-Security-Policy forbids inline styles, so all dynamic
 * styling is done via CSS custom properties set from JS (--accent, --pct, --rows).
 */

/* ------------------------------------------------------------------ 1. Tokens */
:root {
  color-scheme: dark; /* native controls (date pickers, scrollbars) render dark */

  --bg: #0b1020;
  --bg-2: #0f1730;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);

  --text: #e2e8f0;
  --text-strong: #f8fafc;
  --muted: #94a3b8;

  --cyan: #22d3ee;
  --blue: #60a5fa;
  --violet: #a78bfa;
  --magenta: #e879f9;
  --green: #34d399;
  --lime: #a3e635;
  --amber: #fbbf24;
  --orange: #fb923c;
  --rose: #fb7185;

  --accent: var(--cyan); /* overridden per component with a local --accent */

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 248px;
}

/* ------------------------------------------------------------------ 2. Base */
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; } /* make the hidden attribute beat display rules */

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background-color: var(--bg);
  /* Soft neon glows in two corners, fixed so they don't scroll. */
  background-image:
    radial-gradient(900px 600px at 8% -10%, rgba(34, 211, 238, 0.13), transparent 60%),
    radial-gradient(800px 600px at 105% 105%, rgba(167, 139, 250, 0.14), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--text-strong); line-height: 1.25; }
h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: var(--cyan); }
strong { color: var(--text-strong); font-weight: 600; }

.muted { color: var(--muted); font-size: 0.88rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--cyan); color: #04121a; padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* Visible keyboard focus everywhere (glowing ring). */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

.noscript { padding: 2rem; text-align: center; }

/* ------------------------------------------------------------------ 3. Shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px;
  background: rgba(8, 12, 26, 0.72);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; text-decoration: none; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; flex: none; display: block;
  filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.45));
}
.brand-logo-sm { width: 30px; height: 30px; border-radius: 9px; }
.brand-logo-md { width: 46px; height: 46px; border-radius: 13px; }
.brand-logo-lg { width: 64px; height: 64px; border-radius: 18px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: url('../logo.svg') center / contain no-repeat;
  filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.45));
}
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--text-strong); letter-spacing: -0.01em; }
.brand-name span, .brand-dot-uk { color: var(--cyan); }
.brand-sub { font-size: 0.64rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active {
  color: var(--text-strong);
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.16), rgba(167, 139, 250, 0.08));
  border-color: rgba(34, 211, 238, 0.35);
  box-shadow: 0 0 20px -6px rgba(34, 211, 238, 0.6);
}
.nav-icon { width: 1.4em; text-align: center; }
.nav-label-sm { display: none; }

.save-status {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 12px; font-size: 0.78rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
}
.save-status .dot, .mobile-sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.save-status[data-status="saved"] .dot, .mobile-sync-dot[data-status="saved"] { background: var(--green); box-shadow: 0 0 8px var(--green); }
.save-status[data-status="saving"] .dot, .mobile-sync-dot[data-status="saving"] { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: pulse 1s infinite; }
.save-status[data-status="local"] .dot, .save-status[data-status="unauthenticated"] .dot,
.mobile-sync-dot[data-status="local"], .mobile-sync-dot[data-status="unauthenticated"] { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.save-status[data-status="maintenance"] .dot, .mobile-sync-dot[data-status="maintenance"] { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.save-status[data-status="error"], .save-status[data-status="tier-limit"] { color: var(--rose); border-color: var(--rose); }
.save-status[data-status="error"] .dot, .save-status[data-status="tier-limit"] .dot,
.mobile-sync-dot[data-status="error"], .mobile-sync-dot[data-status="tier-limit"] { background: var(--rose); box-shadow: 0 0 8px var(--rose); }

@keyframes pulse { 50% { opacity: 0.35; } }

.main-area { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.mobile-topbar { display: none; }

.sidebar-account { margin-top: auto; display: grid; gap: 8px; }
.account-pill {
  display: grid; gap: 8px; padding: 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
.account-pill-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 4px;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
  border-radius: 10px; transition: background 0.15s;
}
.account-pill-btn:hover { background: var(--surface-strong); }
.account-avatar {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: rgba(34, 211, 238, 0.14); border: 1px solid rgba(34, 211, 238, 0.35); font-size: 1.1rem;
}
.account-pill-info { min-width: 0; flex: 1; display: grid; gap: 3px; }
.account-pill-name { font-weight: 600; font-size: 0.86rem; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-pill-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.account-upgrade-btn { width: 100%; }

.system-banner-slot:empty { display: none; }
.system-banner {
  padding: 10px clamp(16px, 3vw, 44px); font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  background: rgba(34, 211, 238, 0.1); color: var(--text-strong);
}
.system-banner-warn { background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, 0.4); }
.system-banner-critical { background: rgba(251, 113, 133, 0.16); border-color: rgba(251, 113, 133, 0.45); }

.view { padding: 32px clamp(16px, 3vw, 44px) 56px; max-width: 1400px; width: 100%; outline: none; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-subtitle { color: var(--muted); margin-top: 6px; max-width: 70ch; }

/* ------------------------------------------------------------ 4. Components */
.card {
  position: relative;
  padding: 20px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  min-width: 0; /* let grid children shrink instead of overflowing */
}
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-header > :first-child { min-width: 0; flex: 1 1 200px; }
.card-title { font-size: 1.05rem; }
.card-subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 2px; overflow-wrap: anywhere; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2-wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; min-width: 0; }

/* Every page root is a vertical grid with one uniform gap between its sections. */
.view-dashboard, .view-supplies, .view-people, .view-leaderboards, .view-plan, .view-privacy, .view-admin { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; min-width: 0; }
.view-dashboard > .page-header, .view-supplies > .page-header,
.view-people > .page-header, .view-leaderboards > .page-header, .view-plan > .page-header, .view-privacy > .page-header, .view-admin > .page-header { margin-bottom: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #04121a;
  background: linear-gradient(135deg, var(--cyan), #6ee7f9);
  box-shadow: 0 0 22px -4px rgba(34, 211, 238, 0.7);
}
.btn-primary:hover { box-shadow: 0 0 30px -2px rgba(34, 211, 238, 0.95); }
.btn-ghost { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-strong); border-color: var(--cyan); }
.btn-danger { color: #1a0509; background: linear-gradient(135deg, var(--rose), #fda4af); box-shadow: 0 0 20px -4px rgba(251, 113, 133, 0.7); }
.btn-danger-ghost { color: var(--rose); background: transparent; border-color: rgba(251, 113, 133, 0.45); }
.btn-danger-ghost:hover { background: rgba(251, 113, 133, 0.12); }
.btn-small, .btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 10px; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-header .button-row, .view-header .button-row, .button-row:last-child { margin-bottom: 0; }

.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; flex: none;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-size: 1rem; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.icon-btn:hover { background: var(--surface-strong); border-color: var(--cyan); box-shadow: 0 0 12px -3px var(--cyan); }

/* Badges */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-strong); color: var(--text); border: 1px solid var(--border);
}
.badge-good { color: var(--green); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.1); }
.badge-warn { color: var(--amber); border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.1); }
.badge-bad { color: var(--rose); border-color: rgba(251, 113, 133, 0.45); background: rgba(251, 113, 133, 0.12); }
.badge-info { color: var(--blue); border-color: rgba(96, 165, 250, 0.4); background: rgba(96, 165, 250, 0.1); }

/* Chips (filters + size shortcuts) */
.chips, .filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 14px; border-radius: 999px; font: inherit; font-size: 0.85rem; font-weight: 500;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.chip:hover { border-color: var(--cyan); background: var(--surface-strong); }
.chip-active {
  color: #04121a; background: var(--cyan); border-color: var(--cyan);
  box-shadow: 0 0 18px -3px var(--cyan);
}
.chip-count { opacity: 0.7; font-size: 0.78rem; }

/* Progress bar (width from --pct, colour from --accent) */
.progress { height: 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.14); overflow: hidden; }
.progress-fill {
  height: 100%; width: calc(var(--pct, 0) * 100%); border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 35%, transparent), var(--accent));
  box-shadow: 0 0 14px var(--accent);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Empty states */
.empty { text-align: center; padding: 28px 16px; display: grid; gap: 8px; justify-items: center; }
.empty p { color: var(--muted); max-width: 52ch; }
.empty-icon { font-size: 2.4rem; filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.5)); }
.empty-actions { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

/* Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  padding: 12px 16px; border-radius: 12px; font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.95); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 22px -8px var(--cyan);
  animation: toast-in 0.25s ease-out;
}
.toast-success { border-color: rgba(52, 211, 153, 0.55); box-shadow: var(--shadow), 0 0 22px -8px var(--green); }
.toast-error { border-color: rgba(251, 113, 133, 0.6); box-shadow: var(--shadow), 0 0 22px -8px var(--rose); }
.toast-action { background: none; border: 0; color: var(--cyan); font: inherit; font-weight: 700; cursor: pointer; padding: 4px 8px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------ 5. Forms and dialogs */
input, select, textarea {
  width: 100%; min-width: 0; padding: 10px 12px;
  font: inherit; color: var(--text);
  background: rgba(8, 12, 26, 0.7);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: rgba(148, 163, 184, 0.6); }
input:hover, select:hover { border-color: rgba(148, 163, 184, 0.5); }
input:focus, select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2), 0 0 18px -4px var(--cyan); }
input:disabled, select:disabled { opacity: 0.5; }
input[type="number"] { font-variant-numeric: tabular-nums; }

.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; text-transform: uppercase; }
.field-hint { color: var(--muted); font-size: 0.78rem; }
.input-pair { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.input-pair select { width: auto; min-width: 74px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2, .form-grid .preview { grid-column: 1 / -1; }
.preview { color: var(--cyan); font-size: 0.9rem; padding: 10px 12px; border-radius: 10px; background: rgba(34, 211, 238, 0.08); border: 1px dashed rgba(34, 211, 238, 0.35); }

/* Inline "add stock" fields: a 12-column grid so rows pack neatly */
.item-fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.item-fields > .chips { grid-column: 1 / -1; margin-top: -6px; }
.f-category { grid-column: span 4; }
.f-name { grid-column: span 8; }
.field-size { grid-column: span 3; }
.f-qty { grid-column: span 2; }
.f-storage { grid-column: span 2; }
.f-kcal { grid-column: span 2; }
.f-expiry { grid-column: span 3; }
.f-location { grid-column: 1 / -1; }

.add-actions { display: flex; align-items: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.add-actions .muted { flex: 1; min-width: 240px; }

/* Native <dialog> modal */
dialog.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border-radius: 20px; color: var(--text);
  background: linear-gradient(180deg, #131b36, #0d1428);
  border: 1px solid var(--border-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 60px -20px var(--cyan);
}
dialog.modal::backdrop { background: rgba(4, 7, 16, 0.72); backdrop-filter: blur(5px); }
.modal-form { display: grid; gap: 16px; padding: 24px; }
.modal-title { font-size: 1.25rem; }
.modal-intro { color: var(--muted); margin-top: -8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form-error { color: var(--rose); background: rgba(251, 113, 133, 0.1); border: 1px solid rgba(251, 113, 133, 0.4); padding: 10px 12px; border-radius: 10px; font-size: 0.9rem; }

/* -------------------------------------------------------------- 6. Charts */
.chart-box { position: relative; width: 100%; min-width: 0; }
/* Absolute: ECharts sizes its canvas in pixels, which must never influence the
   surrounding grid layout (that causes feedback loops with ResizeObserver). */
.chart-canvas { position: absolute; inset: 0; overflow: hidden; }
.chart-gauge { height: 250px; }
.chart-md { height: 320px; }
.chart-cal { height: 380px; }
.chart-sm { height: 280px; }
.chart-rows { height: calc(var(--rows, 1) * 46px + 70px); min-height: 190px; }
.chart-empty-msg {
  position: absolute; inset: 0; display: none; place-items: center; text-align: center;
  padding: 20px; color: var(--muted); pointer-events: none;
}
.chart-box.is-empty .chart-empty-msg { display: grid; }
.chart-box.is-empty .chart-canvas { opacity: 0.12; }
.chart-error { display: grid; place-items: center; color: var(--rose); text-align: center; padding: 16px; }

/* ------------------------------------------------------------ 7. Dashboard */
.hero { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 20px; align-items: stretch; }
.hero-gauge { display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; gap: 4px; text-align: center; }
.gauge-caption { color: var(--muted); font-size: 0.9rem; min-height: 1.4em; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 16px; }
.tile {
  display: grid; gap: 10px; align-content: start; padding: 16px 18px; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  box-shadow: var(--shadow), 0 0 28px -14px var(--accent);
}
.tile-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.tile-icon { font-size: 1.15rem; }
.tile-value {
  font-size: 2rem; font-weight: 700; line-height: 1; color: var(--accent); letter-spacing: -0.02em;
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 70%, transparent);
}
.tile-line { color: var(--muted); font-size: 0.82rem; }

.advice { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 320px; overflow: auto; }
.advice-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-size: 0.9rem;
}
.advice-item .badge { margin-left: auto; }
.advice-icon { flex: none; }
.advice-critical { border-color: rgba(251, 113, 133, 0.5); background: rgba(251, 113, 133, 0.08); box-shadow: 0 0 18px -10px var(--rose); }
.advice-warn { border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.06); }
.advice-good { border-color: rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.08); }

.banner-slot { display: grid; gap: 18px; }
.banner-slot:empty { display: none; } /* an empty grid item would still add a gap */
.banner { border-color: rgba(34, 211, 238, 0.4); box-shadow: var(--shadow), 0 0 40px -16px var(--cyan); }

/* ------------------------------------------------------------- 8. Supplies */
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 10px; }
.summary-item {
  display: grid; gap: 2px; padding: 11px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  box-shadow: -6px 0 18px -10px var(--accent);
}
.summary-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.toolbar { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.filter-stack { display: grid; gap: 8px; flex: 1; min-width: 260px; }
.subfilter-chips .chip { font-size: 0.8rem; padding: 4px 10px; border-color: rgba(148, 163, 184, 0.2); }
.subfilter-chips .chip-active { background: color-mix(in srgb, var(--cyan) 85%, #fff); }
.search { width: min(320px, 100%); }

/* Modern Multi-Select Supplies Filter Toolbar */
.supplies-filter-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.supplies-filter-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(190px, 1.35fr) repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.supplies-filter-cell {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.supplies-filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

.supplies-filter-input,
.supplies-filter-select,
.ms-trigger {
  width: 100%;
  min-height: 38px;
  padding: 7px 11px;
  font-size: 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft, rgba(15, 23, 42, 0.55));
  color: var(--text-strong);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.supplies-filter-input:focus,
.supplies-filter-select:focus,
.ms-trigger:focus-visible,
.ms-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--cyan) 22%, transparent);
}

.ms-trigger-active,
.supplies-select-active {
  border-color: color-mix(in srgb, var(--cyan) 70%, transparent);
  background: color-mix(in srgb, var(--cyan) 10%, var(--bg-soft, rgba(15, 23, 42, 0.65)));
}

.ms-dropdown {
  position: relative;
  min-width: 0;
}

.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  cursor: pointer;
}

.ms-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.ms-trigger-badge {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--cyan);
  color: #06131f;
  line-height: 1.35;
}

.ms-trigger-caret {
  flex: none;
  font-size: 0.78rem;
  color: var(--muted);
}

.ms-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 45;
  width: max(280px, 100%);
  max-width: min(340px, calc(100vw - 32px));
  padding: 10px;
  border-radius: 14px;
  background: var(--bg-elev, #0f172a);
  border: 1px solid color-mix(in srgb, var(--cyan) 50%, var(--border-strong));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
}

@media (min-width: 641px) {
  .ms-popover.ms-popover-right {
    left: auto;
    right: 0;
  }
}

.ms-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 8px 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.ms-popover-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.ms-popover-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.ms-action-link,
.ms-action-done {
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.ms-action-link {
  color: var(--cyan);
  font-weight: 600;
}

.ms-action-link:hover {
  text-decoration: underline;
}

.ms-action-done {
  color: var(--text-strong);
  font-weight: 700;
}

.ms-options {
  display: grid;
  gap: 2px;
  max-height: 295px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 2px;
}

.ms-group-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cyan);
  padding: 8px 6px 3px 6px;
}

.ms-group-heading:first-child {
  padding-top: 2px;
}

.ms-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.ms-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.ms-option-checked {
  background: color-mix(in srgb, var(--cyan) 12%, transparent);
  color: var(--text-strong);
  font-weight: 500;
}

.ms-option-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ms-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-checkbox {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--cyan);
  cursor: pointer;
  flex: none;
}

.ms-option-count {
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  flex: none;
}

.ms-empty {
  padding: 10px 8px;
  font-size: 0.82rem;
  text-align: center;
}

/* Conditional Custom Date Range Row */
.supplies-custom-dates {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
  font-size: 0.82rem;
}

.supplies-custom-dates-title {
  font-weight: 600;
  color: var(--amber);
}

.supplies-date-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 500;
}

.date-filter-input {
  padding: 5px 9px;
  font-size: 0.82rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft, rgba(15, 23, 42, 0.55));
  color: var(--text-strong);
  width: 138px;
  max-width: 100%;
}

/* Active Filter Tags Strip */
.supplies-active-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

.supplies-active-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.supplies-active-label {
  color: var(--muted);
  font-size: 0.76rem;
  margin-right: 2px;
}

.supplies-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--cyan) 42%, transparent);
  color: var(--text-strong);
  font-size: 0.76rem;
  font-weight: 500;
}

.supplies-filter-tag.tag-warn {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.45);
}

.supplies-filter-tag-remove {
  background: none;
  border: 0;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.supplies-filter-tag-remove:hover {
  color: var(--text-strong);
}

.supplies-active-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  font-size: 0.78rem;
}

.supplies-reset-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.supplies-reset-link:hover {
  text-decoration: underline;
}

@media (max-width: 980px) {
  .supplies-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .supplies-filter-search {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .supplies-summary-strip {
    display: none;
  }
  .supplies-filter-card {
    padding: 12px;
    gap: 10px;
  }
  .supplies-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .supplies-filter-search {
    grid-column: 1 / -1;
  }
  /* Anchor popovers to the full width of the filter grid on mobile so they never overflow */
  .ms-dropdown {
    position: static;
  }
  .ms-popover {
    left: 0;
    right: 0;
    top: auto;
    margin-top: 6px;
    width: 100%;
    max-width: 100%;
  }
  .supplies-custom-dates {
    flex-direction: column;
    align-items: stretch;
  }
  .supplies-date-pair {
    justify-content: space-between;
  }
  .date-filter-input {
    width: 160px;
  }
  .supplies-active-meta {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }
}

.cat-table-wrap { position: relative; overflow-x: auto; max-width: 100%; margin-top: 14px; }
.cat-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.cat-table th, .cat-table td { position: relative; padding: 10px 12px; text-align: left; border-top: 1px solid var(--border); vertical-align: middle; }
.cat-table thead th { border-top: 0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.cat-badge-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 8px currentColor; }
@media (max-width: 640px) {
  .cat-table thead { display: none; }
  .cat-table, .cat-table tbody { display: block; width: 100%; }
  .cat-table tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
  }
  .cat-table tbody tr:first-child { border-top: 0; }
  .cat-table th, .cat-table td {
    border-top: 0;
    padding: 0;
    font-size: 0.84rem;
    overflow-wrap: anywhere;
  }
  .cat-table .chip { padding: 3px 8px; font-size: 0.75rem; white-space: nowrap; }
  .cat-table .cell-actions { margin-left: auto; }
}

.product-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.category-heading {
  font-size: 0.95rem; margin-top: 12px; padding-bottom: 6px; color: var(--text);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
}
.product {
  min-width: 0;
  padding: 16px 18px; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  box-shadow: var(--shadow), -10px 0 28px -16px var(--accent);
}
.product-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.product-icon {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none; font-size: 1.4rem;
  border-radius: 14px; background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: 0 0 20px -6px var(--accent);
}
.product-title { display: grid; flex: 1; min-width: 160px; }
.product-total { display: grid; justify-items: end; gap: 2px; text-align: right; }
.product-total-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); text-shadow: 0 0 16px color-mix(in srgb, var(--accent) 60%, transparent); font-variant-numeric: tabular-nums; }
.product-total-suffix { font-size: 0.8rem; font-weight: 500; color: var(--muted); text-shadow: none; margin-left: 6px; }

.table-wrap { position: relative; overflow-x: auto; max-width: 100%; margin-top: 12px; }
table.lines { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.lines th, table.lines td { position: relative; padding: 8px 10px; text-align: left; vertical-align: middle; border-top: 1px solid var(--border); }
table.lines thead th { border-top: 0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
table.lines th.num, table.lines td.num { text-align: right; }
.cell-size { font-weight: 600; color: var(--text-strong); white-space: nowrap; }
.cell-actions { white-space: nowrap; text-align: right !important; }
.cell-actions .icon-btn + .icon-btn { margin-left: 6px; }

.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper-value { min-width: 3.2ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-strong); white-space: nowrap; }
.stepper-lg .icon-btn { width: 38px; height: 38px; font-size: 1.2rem; }
.stepper-lg .stepper-value { font-size: 1.6rem; min-width: 2.5ch; }

@media (max-width: 640px) {
  table.lines thead { display: none; }
  table.lines, table.lines tbody { display: block; width: 100%; }
  table.lines tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
  }
  table.lines th, table.lines td {
    border-top: 0;
    padding: 0;
  }
  table.lines td:empty { display: none; }
  table.lines .cell-size { min-width: 54px; }
  table.lines .cell-actions { margin-left: auto; }
}

/* ----------------------------------------------------- 9. People */
.counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.counter {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: 16px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  box-shadow: 0 0 26px -14px var(--accent);
}
.counter-icon { font-size: 2.2rem; filter: drop-shadow(0 0 12px var(--accent)); }
.counter-body { display: grid; gap: 6px; }
.counter-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }

.people-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
.person { min-width: 0; border-left: 3px solid var(--accent); box-shadow: var(--shadow), -12px 0 30px -18px var(--accent); }
.person-head { display: flex; align-items: center; gap: 14px; }
.person-avatar { width: 48px; height: 48px; display: grid; place-items: center; font-size: 1.7rem; border-radius: 16px; background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: 0 0 20px -6px var(--accent); }
.person-title { flex: 1; display: grid; }
.person-actions { display: flex; gap: 6px; }

.person-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.stat { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); align-content: start; }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--accent); text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 60%, transparent); font-variant-numeric: tabular-nums; }

.meds { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.meds-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.med-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.med {
  display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(220px, 1.4fr) auto auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
}
.med-name { font-weight: 600; color: var(--text-strong); }
.med-cover { display: grid; gap: 6px; }
.med-cover-text { font-size: 0.85rem; }
.med-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.med-actions { display: flex; gap: 6px; }

/* ------------------------------------------------------------ 10. Plan */
.settings-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; min-width: 0; }
.settings-group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.settings-group h3 { font-size: 0.95rem; color: var(--text); }
.plan-summary { display: grid; gap: 4px; min-width: 0; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; flex-wrap: wrap; }
.summary-row span { color: var(--muted); }
.summary-row:last-child { border-bottom: 0; }

.prose { display: grid; gap: 10px; max-width: 85ch; }
.prose h3 { margin-top: 10px; color: var(--cyan); }
.bullets { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--text); }
.callout { padding: 12px 14px; border-radius: 12px; background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.35); color: var(--text); }
.error-detail { overflow: auto; font-size: 0.8rem; color: var(--rose); }

/* ------------------------------------------- 10b. SaaS Auth, Tiers & Admin */
dialog.modal-wide { width: min(740px, calc(100vw - 32px)); }
.upgrade-header { display: grid; gap: 8px; justify-items: start; }
.upgrade-brand-row { display: flex; align-items: center; gap: 12px; }
.tier-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tier-card {
  display: grid; gap: 12px; align-content: start; padding: 18px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border-strong);
}
.tier-card-pro {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.12), rgba(167, 139, 250, 0.06));
  border-color: var(--cyan);
  box-shadow: 0 0 28px -10px rgba(34, 211, 238, 0.55);
}
.tier-card-head { display: grid; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.tier-pro-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tier-price { font-size: 1.65rem; font-weight: 700; color: var(--text-strong); }

.tier-upsell-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  border-color: rgba(251, 191, 36, 0.45);
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.1), rgba(34, 211, 238, 0.06));
}
.tier-upsell-text { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; min-width: 0; }
.tier-upsell-banner > .btn { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 680px) {
  .tier-upsell-banner { flex-direction: column; align-items: stretch; }
  .tier-upsell-banner > .btn { width: 100%; justify-content: center; }
}

.auth-hero { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 8px 0; }
.auth-providers { display: grid; gap: 10px; }
.auth-btn { width: 100%; justify-content: center; }

.account-summary-box {
  display: grid; gap: 8px; padding: 14px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
}
.account-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.9rem; }
.dev-persona-box {
  display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px;
  background: rgba(167, 139, 250, 0.08); border: 1px dashed rgba(167, 139, 250, 0.4);
}

.admin-toolbar { margin-bottom: 12px; }
.admin-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-filters select { width: auto; min-width: 150px; }
.plan-badge-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stripe-link-row { margin-top: 5px; }
.stripe-dashboard-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--cyan);
  text-decoration: none;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.stripe-dashboard-link:hover {
  background: rgba(6, 182, 212, 0.22);
  border-color: rgba(6, 182, 212, 0.6);
  text-decoration: none;
}
.toggle-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border); cursor: pointer;
}
.checkbox-inline { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--cyan); }

/* ------------------------------------------------ 11. Responsive + a11y */
@media (max-width: 1100px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .grid-2, .grid-2-wide-left, .tier-grid { grid-template-columns: minmax(0, 1fr); }
  .med { grid-template-columns: minmax(0, 1fr); }
  .med-badges, .med-actions { justify-content: flex-start; }
}

/* Phones/tablets: sidebar becomes a bottom tab bar with a sticky top bar. */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); overflow-x: clip; }
  .sidebar {
    position: fixed; inset: auto 0 0 0; top: auto; height: auto; z-index: 50;
    flex-direction: row; padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); gap: 0;
    max-width: 100vw; overflow-x: auto;
    border-right: 0; border-top: 1px solid var(--border);
    background: rgba(8, 12, 26, 0.96);
    backdrop-filter: blur(12px);
  }
  .brand, .sidebar-account, .save-status { display: none; }
  .nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    width: 100%;
    min-width: 0;
    gap: 2px;
  }
  .nav a {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 3px;
    padding: 6px 1px;
    font-size: 0.6rem;
    letter-spacing: -0.02em;
    min-height: 48px;
  }
  .nav-label-lg { display: none; }
  .nav-label-sm { display: inline; }

  .mobile-topbar {
    position: sticky; top: 0; z-index: 45;
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
    background: rgba(8, 12, 26, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-brand { display: flex; align-items: center; gap: 8px; }
  .brand-mark-sm { width: 28px; height: 28px; border-radius: 9px; }
  .mobile-actions { display: flex; align-items: center; gap: 8px; }

  .view { padding: 20px 14px calc(96px + env(safe-area-inset-bottom, 0px)); }
  h1 { font-size: 1.5rem; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .f-category, .f-name, .field-size, .f-expiry, .f-location { grid-column: 1 / -1; }
  .f-qty, .f-storage, .f-kcal { grid-column: span 6; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .product-total { justify-items: start; text-align: left; }
  .admin-filters { width: 100%; }
  .admin-filters select { flex: 1; }
}

/* Printable emergency binder summary (hidden on screen, shown in @media print). */
.print-summary { display: none; }

@media print {
  body { background: #fff !important; color: #000 !important; font-size: 10pt; line-height: 1.35; }
  .sidebar, .toasts, dialog, .no-print { display: none !important; }
  .app { display: block !important; min-height: auto !important; }
  .view { padding: 0 !important; max-width: 100% !important; }
  .view-dashboard > :not(.print-summary) { display: none !important; }
  .print-summary { display: block !important; color: #000; }
  .print-header { border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .print-header h1, .print-header .print-title { font-size: 16pt; color: #000 !important; text-shadow: none !important; margin: 0 0 4px; border: none; padding: 0; }
  .print-header p { margin: 0; color: #222; font-size: 9.5pt; }
  .print-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; border: 1px solid #888; padding: 8px 12px; margin-bottom: 14px; border-radius: 4px; }
  .print-kpi { font-size: 9.5pt; color: #000; }
  .print-summary h2 { font-size: 12pt; color: #000 !important; text-shadow: none !important; margin: 14px 0 6px; border-bottom: 1px solid #444; padding-bottom: 2px; }
  .print-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 9pt; }
  .print-table th, .print-table td { border: 1px solid #999; padding: 4px 6px; text-align: left; color: #000 !important; }
  .print-table th.num, .print-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
  .print-table thead th { background: #eee !important; font-weight: 700; }
  .print-total-row td { background: #f5f5f5 !important; border-top: 2px solid #000; }
  .print-advice { margin: 0 0 12px; padding-left: 18px; font-size: 9.5pt; }
  .print-advice li { margin-bottom: 3px; color: #000; }
}

/* Respect users who prefer less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}


/* ---------------------------------------------------------------------------
   Native Authentication Tabs, OTP Input, GDPR Consent & Cookie Banner
   --------------------------------------------------------------------------- */
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: rgba(8, 12, 26, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.auth-tab {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.auth-tab-active {
  background: rgba(34, 211, 238, 0.16);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.35);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-link-row {
  display: flex;
  justify-content: flex-end;
}

.btn-link {
  appearance: none;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.otp-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
}

.gdpr-consent-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: rgba(8, 12, 26, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.checkbox-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.danger-zone-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: 10px;
}

.cookie-banner-slot {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.cookie-banner-card {
  pointer-events: auto;
  max-width: 920px;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  background: rgba(13, 19, 38, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  font-size: 0.88rem;
}

.cookie-banner-text {
  flex: 1 1 420px;
  line-height: 1.45;
}

.cookie-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

@media (max-width: 860px) {
  .cookie-banner-slot {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    right: 10px;
  }

  .nav a {
    min-width: 0;
    text-align: center;
    line-height: 1.15;
    font-size: 0.6rem;
    letter-spacing: -0.02em;
    gap: 3px;
    padding: 6px 1px;
    min-height: 48px;
  }

  .view {
    padding: 20px 14px calc(124px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------------------------------------------------------------------------
   Static UK SEO Guides & Interactive Calculator Layout (.view-guide)
   --------------------------------------------------------------------------- */
.view-guide {
  display: grid;
  gap: 20px;
  align-content: start;
  min-width: 0;
}

.view-guide > .view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.view-guide .view-sub {
  color: var(--muted);
  margin-top: 6px;
  max-width: 72ch;
}

.view-guide .card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.view-guide .button-row {
  margin-bottom: 0;
  margin-top: 4px;
}

#calc-results {
  margin: 6px 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.data-table thead th {
  border-top: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  white-space: nowrap;
}

.leaderboard-col-rank {
  width: 64px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .data-table th,
  .data-table td {
    padding: 8px 8px;
    font-size: 0.82rem;
  }
  .leaderboard-col-rank {
    width: 48px;
  }
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
}

/* ---------------------------------------------------------------------------
   Household Pro Barcode Scanner Modal (.barcode-modal)
   --------------------------------------------------------------------------- */
.barcode-scan-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.barcode-pro-pill {
  font-size: 0.68rem;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.barcode-modal {
  width: min(520px, calc(100vw - 24px));
}

.barcode-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.barcode-viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 260px;
  background: #060a12;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.barcode-viewfinder-inactive {
  aspect-ratio: auto;
  min-height: 76px;
  padding: 16px;
}

.barcode-viewfinder-inactive .barcode-video,
.barcode-viewfinder-inactive .barcode-reticle {
  display: none;
}

.barcode-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.barcode-reticle {
  position: absolute;
  inset: 18% 12%;
  border: 2px solid rgba(34, 211, 238, 0.7);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(6, 10, 18, 0.42);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.barcode-laser {
  width: 92%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #22d3ee, #34d399, #22d3ee, transparent);
  box-shadow: 0 0 10px #22d3ee;
  animation: barcodeLaserSweep 2.1s ease-in-out infinite;
}

@keyframes barcodeLaserSweep {
  0%, 100% {
    transform: translateY(-38px);
    opacity: 0.65;
  }
  50% {
    transform: translateY(38px);
    opacity: 1;
  }
}

.barcode-status-pill {
  position: absolute;
  bottom: 10px;
  left: 12px;
  right: 12px;
  padding: 6px 12px;
  background: rgba(10, 16, 29, 0.86);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text);
  text-align: center;
  backdrop-filter: blur(8px);
}

.barcode-viewfinder-inactive .barcode-status-pill {
  position: static;
  width: 100%;
}

.barcode-samples-wrap {
  display: grid;
  gap: 8px;
}

.barcode-camera-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.barcode-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------------------------------------------------------------------
   Theme Switcher Control & Light / Accessible High Contrast Themes
   --------------------------------------------------------------------------- */
.theme-switcher {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.theme-switcher-compact {
  gap: 2px;
  padding: 3px;
}

.theme-seg-btn {
  appearance: none;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.theme-switcher-compact .theme-seg-btn {
  gap: 4px;
  padding: 6px 5px;
  font-size: 0.73rem;
}

.theme-seg-btn:hover {
  color: var(--text-strong);
  background: var(--surface-strong);
}

.theme-seg-active {
  color: var(--text-strong);
  background: color-mix(in srgb, var(--cyan) 18%, var(--surface-strong));
  border-color: color-mix(in srgb, var(--cyan) 50%, transparent);
}

.theme-cycle-btn {
  padding: 6px 10px;
  min-width: 36px;
}

.mobile-account-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 140px;
}

.mobile-account-name {
  display: inline-block;
  max-width: 95px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------------
   ☀️ Light Theme (:root[data-theme="light"])
   --------------------------------------------------------------------------- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f1f5f9;
  --bg-2: #e2e8f0;
  --surface: rgba(15, 23, 42, 0.04);
  --surface-strong: rgba(15, 23, 42, 0.08);
  --border: rgba(15, 23, 42, 0.12);
  --border-strong: rgba(15, 23, 42, 0.24);

  --text: #1e293b;
  --text-strong: #0f172a;
  --muted: #475569;

  --cyan: #0284c7;
  --blue: #2563eb;
  --violet: #7c3aed;
  --magenta: #c026d3;
  --green: #059669;
  --lime: #4d7c0f;
  --amber: #b45309;
  --orange: #c2410c;
  --rose: #e11d48;

  --shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
}

:root[data-theme="light"] body {
  background-image:
    radial-gradient(900px 600px at 8% -10%, rgba(2, 132, 199, 0.08), transparent 60%),
    radial-gradient(800px 600px at 105% 105%, rgba(124, 58, 237, 0.07), transparent 60%);
}

:root[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.92);
}

:root[data-theme="light"] .mobile-topbar {
  background: rgba(255, 255, 255, 0.94);
}

:root[data-theme="light"] .card,
:root[data-theme="light"] .tile,
:root[data-theme="light"] .product {
  background: #ffffff;
  box-shadow: var(--shadow);
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  background: #ffffff;
  color: var(--text-strong);
}

:root[data-theme="light"] input::placeholder {
  color: #64748b;
}

:root[data-theme="light"] dialog.modal {
  background: #ffffff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
}

:root[data-theme="light"] dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

:root[data-theme="light"] .toast {
  background: #ffffff;
  color: var(--text-strong);
}

:root[data-theme="light"] .cookie-banner-card {
  background: rgba(255, 255, 255, 0.97);
  border-color: var(--border-strong);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

:root[data-theme="light"] .auth-tabs,
:root[data-theme="light"] .gdpr-consent-box {
  background: #f8fafc;
}

:root[data-theme="light"] .btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

:root[data-theme="light"] .btn-danger {
  color: #ffffff;
  background: linear-gradient(135deg, #e11d48, #be123c);
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.28);
}

:root[data-theme="light"] .chip-active,
:root[data-theme="light"] .subfilter-chips .chip-active {
  color: #ffffff;
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: none;
}

:root[data-theme="light"] .supplies-filter-input,
:root[data-theme="light"] .supplies-filter-select,
:root[data-theme="light"] .ms-trigger,
:root[data-theme="light"] .date-filter-input {
  background: #ffffff;
  color: var(--text-strong);
  border-color: var(--border-strong);
}

:root[data-theme="light"] .ms-trigger-active,
:root[data-theme="light"] .supplies-select-active {
  background: rgba(2, 132, 199, 0.08);
  border-color: var(--cyan);
}

:root[data-theme="light"] .ms-trigger-badge {
  color: #ffffff;
}

:root[data-theme="light"] .ms-popover {
  background: #ffffff;
  border-color: var(--border-strong);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
}

:root[data-theme="light"] .ms-option:hover {
  background: rgba(15, 23, 42, 0.05);
}

:root[data-theme="light"] .ms-option-checked {
  background: rgba(2, 132, 199, 0.1);
}

:root[data-theme="light"] .tile-value,
:root[data-theme="light"] .product-total-value,
:root[data-theme="light"] .stat-value,
:root[data-theme="light"] .category-heading {
  text-shadow: none;
}

:root[data-theme="light"] .progress-fill {
  box-shadow: none;
}

:root[data-theme="light"] .barcode-status-pill {
  color: #f8fafc;
}

:root[data-theme="light"] .barcode-viewfinder-inactive .barcode-status-pill {
  background: #f1f5f9;
  color: var(--text-strong);
}

/* ---------------------------------------------------------------------------
   👁️ Accessible / High Contrast Theme (:root[data-theme="contrast"] — WCAG AAA)
   --------------------------------------------------------------------------- */
:root[data-theme="contrast"] {
  color-scheme: dark;

  --bg: #000000;
  --bg-2: #000000;
  --surface: #0a0a0a;
  --surface-strong: #171717;
  --border: #ffffff;
  --border-strong: #ffffff;

  --text: #ffffff;
  --text-strong: #ffffff;
  --muted: #e2e8f0;

  --cyan: #00ffff;
  --blue: #66b2ff;
  --violet: #d8b4fe;
  --magenta: #ff80ff;
  --green: #00ff88;
  --lime: #ccff00;
  --amber: #ffdd00;
  --orange: #ff9933;
  --rose: #ff6677;

  --shadow: none;
}

:root[data-theme="contrast"] body {
  background-color: #000000;
  background-image: none;
}

:root[data-theme="contrast"] :focus-visible,
:root[data-theme="contrast"] input:focus,
:root[data-theme="contrast"] select:focus,
:root[data-theme="contrast"] textarea:focus {
  outline: 3px solid #ffdd00 !important;
  outline-offset: 2px;
  border-color: #ffdd00 !important;
  box-shadow: none !important;
}

:root[data-theme="contrast"] .sidebar,
:root[data-theme="contrast"] .mobile-topbar {
  background: #000000;
  backdrop-filter: none;
  border-color: #ffffff;
}

:root[data-theme="contrast"] .card,
:root[data-theme="contrast"] .tile,
:root[data-theme="contrast"] .product,
:root[data-theme="contrast"] .counter,
:root[data-theme="contrast"] .stat,
:root[data-theme="contrast"] .med,
:root[data-theme="contrast"] .account-pill,
:root[data-theme="contrast"] .save-status,
:root[data-theme="contrast"] .theme-switcher,
:root[data-theme="contrast"] .toast,
:root[data-theme="contrast"] .cookie-banner-card,
:root[data-theme="contrast"] dialog.modal {
  background: #050505;
  border: 2px solid #ffffff;
  box-shadow: none;
  backdrop-filter: none;
}

:root[data-theme="contrast"] .product,
:root[data-theme="contrast"] .person,
:root[data-theme="contrast"] .summary-item {
  border-left: 5px solid var(--accent);
}

:root[data-theme="contrast"] input,
:root[data-theme="contrast"] select,
:root[data-theme="contrast"] textarea {
  background: #000000;
  color: #ffffff;
  border: 2px solid #ffffff;
}

:root[data-theme="contrast"] input::placeholder {
  color: #cbd5e1;
}

:root[data-theme="contrast"] .btn,
:root[data-theme="contrast"] .chip,
:root[data-theme="contrast"] .icon-btn {
  border-width: 2px;
  box-shadow: none;
}

:root[data-theme="contrast"] .btn-primary,
:root[data-theme="contrast"] .chip-active,
:root[data-theme="contrast"] .theme-seg-active {
  color: #000000;
  background: #00ffff;
  border-color: #ffffff;
  font-weight: 700;
}

:root[data-theme="contrast"] .nav a.active {
  color: #000000;
  background: #00ffff;
  border: 2px solid #ffffff;
  box-shadow: none;
  font-weight: 700;
}

:root[data-theme="contrast"] .tile-value,
:root[data-theme="contrast"] .product-total-value,
:root[data-theme="contrast"] .stat-value,
:root[data-theme="contrast"] .category-heading {
  text-shadow: none;
}

:root[data-theme="contrast"] .progress {
  background: #262626;
  border: 1px solid #ffffff;
  height: 10px;
}

:root[data-theme="contrast"] .progress-fill {
  background: var(--accent);
  box-shadow: none;
}

/* ------------------------------------------------------------ 11. Community Percentile & Leaderboards */
.leaderboard-content {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.gauge-benchmark {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  width: 100%;
}

.benchmark-box {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.22);
  text-align: left;
}

.benchmark-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.benchmark-rank-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(34, 211, 238, 0.14);
  color: var(--accent);
  border: 1px solid rgba(34, 211, 238, 0.3);
}

.benchmark-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.benchmark-link:hover {
  text-decoration: underline;
}

.benchmark-headline {
  font-size: 0.92rem;
  color: var(--text-strong);
  margin: 0;
}

.benchmark-pct {
  color: var(--accent);
  font-size: 1.05rem;
}

.benchmark-meta {
  font-size: 0.8rem;
}

.leaderboard-standing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.35fr);
  gap: 20px;
  align-items: center;
}

.leaderboard-standing-main {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.leaderboard-pct-title {
  font-size: 1.3rem;
  margin: 2px 0;
}

.leaderboard-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.leaderboard-mini-tile {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  display: grid;
  gap: 4px;
}

.leaderboard-mini-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-strong);
}

.leaderboard-mini-rank {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.leaderboard-profile-form {
  display: grid;
  gap: 16px;
}

.leaderboard-optin-toggle {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.22);
}

.leaderboard-profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.leaderboard-callsign-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  min-height: 44px;
}

.leaderboard-callsign-badge {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-strong);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
}

.emoji-pick-btn {
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 1.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, border-color 0.15s, background 0.15s;
}

.emoji-pick-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.emoji-pick-btn.active {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.18);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.25);
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.leaderboard-tab-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.leaderboard-tab-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-strong);
}

.leaderboard-tab-btn.active {
  background: rgba(34, 211, 238, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}

.leaderboard-callsign-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.leaderboard-emoji {
  font-size: 1.2rem;
}

.leaderboard-row-me {
  background: rgba(34, 211, 238, 0.1) !important;
}

.leaderboard-primary-metric {
  color: var(--accent);
  font-size: 0.98rem;
}

.leaderboard-footnote {
  margin-top: 12px;
  font-size: 0.82rem;
}

@media (max-width: 820px) {
  .leaderboard-standing-hero,
  .leaderboard-profile-grid {
    grid-template-columns: 1fr;
  }
  .hide-sm {
    display: none;
  }
}

:root[data-theme="light"] .benchmark-box,
:root[data-theme="light"] .leaderboard-optin-toggle {
  background: rgba(8, 145, 178, 0.06);
  border-color: rgba(8, 145, 178, 0.25);
}

:root[data-theme="light"] .leaderboard-mini-tile,
:root[data-theme="light"] .leaderboard-callsign-preview,
:root[data-theme="light"] .emoji-pick-btn,
:root[data-theme="light"] .leaderboard-tab-btn {
  background: #f8fafc;
}

:root[data-theme="contrast"] .benchmark-box,
:root[data-theme="contrast"] .leaderboard-mini-tile,
:root[data-theme="contrast"] .leaderboard-optin-toggle,
:root[data-theme="contrast"] .leaderboard-callsign-preview,
:root[data-theme="contrast"] .emoji-pick-btn,
:root[data-theme="contrast"] .leaderboard-tab-btn {
  background: #000000;
  border: 2px solid #ffffff;
}

:root[data-theme="contrast"] .leaderboard-tab-btn.active,
:root[data-theme="contrast"] .emoji-pick-btn.active {
  background: #00ffff;
  color: #000000;
  border-color: #ffffff;
}

/* ------------------------------------------------------------------ 12. MFA Styles */
.mfa-card {
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0.5rem 0;
}

.mfa-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.mfa-icon-badge {
  font-size: 1.5rem;
  padding: 0.5rem;
  border-radius: 10px;
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mfa-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mfa-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-strong);
}

.mfa-desc {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.mfa-active-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.mfa-active-info {
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mfa-actions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.3);
  margin: 0.75rem auto;
  width: fit-content;
  max-width: 100%;
}

.qr-container svg {
  width: 200px;
  height: 200px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
}

.secret-key-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.secret-key-input {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
  text-align: center;
  background: var(--surface-strong);
  color: var(--text-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  user-select: all;
}

.backup-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

@media (min-width: 480px) {
  .backup-codes-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.backup-code-item {
  padding: 0.5rem;
  border-radius: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  text-align: center;
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: 0.05em;
}

.backup-codes-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.mfa-wizard-step {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cyan);
}

.auth-link-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  text-align: center;
}

.mfa-hero-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.75rem;
  font-size: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mfa-checkbox-row {
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

:root[data-theme="light"] .mfa-card {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.25);
}
:root[data-theme="light"] .secret-key-input,
:root[data-theme="light"] .backup-code-item {
  background: #f8fafc;
  color: #0f172a;
}
:root[data-theme="light"] .qr-container {
  border-color: rgba(148, 163, 184, 0.4);
}

:root[data-theme="contrast"] .mfa-card {
  background: #000000;
  border: 2px solid #ffffff;
}
:root[data-theme="contrast"] .mfa-icon-badge {
  background: #000000;
  border: 2px solid #00ffff;
  color: #00ffff;
}
:root[data-theme="contrast"] .secret-key-input,
:root[data-theme="contrast"] .backup-code-item {
  background: #000000;
  color: #ffffff;
  border: 2px solid #ffffff;
}
:root[data-theme="contrast"] .qr-container {
  border: 3px solid #000000;
}
