/*
 * 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 & medication
 *   10. Plan & data
 *   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); 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; }
.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-sub { font-size: 0.75rem; color: var(--muted); }

.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; }

.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; }
.card-title { font-size: 1.05rem; }
.card-subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.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; gap: 20px; align-content: start; }

/* Every page root is a vertical grid with one uniform gap between its sections. */
.view-dashboard, .view-supplies, .view-people, .view-plan, .view-admin { display: grid; gap: 20px; align-content: start; min-width: 0; }
.view-dashboard > .page-header, .view-supplies > .page-header,
.view-people > .page-header, .view-plan > .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 { padding: 6px 12px; font-size: 0.85rem; border-radius: 10px; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.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-kcal { grid-column: span 2; }
.f-expiry { grid-column: span 2; }
.f-location { grid-column: span 3; }

.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-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: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(150px, 1fr)); gap: 12px; }
.summary-item {
  display: grid; gap: 2px; padding: 12px 16px; 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%); }

.cat-table-wrap { overflow-x: auto; margin-top: 14px; }
.cat-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.cat-table th, .cat-table td { 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; }

.product-list { display: grid; gap: 16px; }
.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 {
  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 { overflow-x: auto; margin-top: 12px; }
table.lines { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.lines th, table.lines td { 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); }
.stepper-lg .icon-btn { width: 38px; height: 38px; font-size: 1.2rem; }
.stepper-lg .stepper-value { font-size: 1.6rem; min-width: 2.5ch; }

/* ----------------------------------------------------- 9. People & medication */
.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; gap: 20px; }
.person { 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 & data */
.settings-form { display: grid; gap: 22px; }
.settings-group { display: grid; gap: 12px; }
.settings-group h3 { font-size: 0.95rem; color: var(--text); }
.plan-summary { display: grid; gap: 4px; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.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; flex-wrap: wrap;
  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; }

.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; }
.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: 1fr; }
  .grid-2, .grid-2-wide-left, .tier-grid { grid-template-columns: 1fr; }
  .med { grid-template-columns: 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: 1fr; }
  .sidebar {
    position: fixed; inset: auto 0 0 0; top: auto; height: auto; z-index: 50;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); gap: 0;
    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 { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 0.7rem; min-height: 44px; justify-content: center; }

  .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-kcal { grid-column: span 6; }
  .form-grid { grid-template-columns: 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 { font-size: 16pt; color: #000 !important; text-shadow: none !important; margin: 0 0 4px; }
  .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(74px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    right: 10px;
  }
}
