/* ─── Reset & Tokens ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand tokens - drawn from the card game itself, not generic branding.
     --brand is the Pokemon TCG rulebook indigo (not poke-ball red, which
     would collide visually with the --fire alert color). --fire/--grass/
     --spark are real Energy-type colors, used only as semantic UI state -
     never decoratively. */
  --ink:   #14172a;
  --paper: #f6f5fb;
  --brand: #445fd2;
  --fire:  #e4572e;
  --grass: #3f8f5c;
  --spark: #c98f22;

  --bg: var(--paper);
  --bg-elevated: #ffffff;
  --bg-sunken: #ececf3;
  --bg-modal: #ffffff;
  --border: #dcdaea;
  --border-lit: #c3c1dc;
  --text: var(--ink);
  --text-muted: #5b5d78;
  --text-dim: #9496b0;
  --brand-on: #ffffff;
  --overlay: rgba(20, 23, 42, 0.55);
  --shadow: 0 20px 60px -12px rgba(20, 23, 42, 0.3);
  --focus-ring: 0 0 0 3px rgba(68, 95, 210, 0.3);
  --fire-dim: rgba(228, 87, 46, 0.12);
  --grass-dim: rgba(63, 143, 92, 0.12);
  --spark-dim: rgba(201, 143, 34, 0.12);
  --brand-dim: rgba(68, 95, 210, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 0.15s ease;

  --font-display: 'Sora', ui-rounded, 'Segoe UI Semibold', system-ui, sans-serif;
  --font-body: 'Manrope', ui-sans-serif, 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14172a;
    --bg-elevated: #1b1f38;
    --bg-sunken: #0f1120;
    --bg-modal: #1b1f38;
    --border: #2d3155;
    --border-lit: #3c4270;
    --text: #f1f1fa;
    --text-muted: #a7a9c9;
    --text-dim: #6f7295;
    --overlay: rgba(6, 7, 15, 0.7);
    --shadow: 0 20px 60px -12px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(122, 145, 255, 0.4);
    --fire-dim: rgba(228, 87, 46, 0.16);
    --grass-dim: rgba(63, 143, 92, 0.18);
    --spark-dim: rgba(201, 143, 34, 0.18);
    --brand-dim: rgba(122, 145, 255, 0.15);
  }
}
:root[data-theme="dark"] {
  --bg: #14172a;
  --bg-elevated: #1b1f38;
  --bg-sunken: #0f1120;
  --bg-modal: #1b1f38;
  --border: #2d3155;
  --border-lit: #3c4270;
  --text: #f1f1fa;
  --text-muted: #a7a9c9;
  --text-dim: #6f7295;
  --overlay: rgba(6, 7, 15, 0.7);
  --shadow: 0 20px 60px -12px rgba(0, 0, 0, 0.6);
  --focus-ring: 0 0 0 3px rgba(122, 145, 255, 0.4);
  --fire-dim: rgba(228, 87, 46, 0.16);
  --grass-dim: rgba(63, 143, 92, 0.18);
  --spark-dim: rgba(201, 143, 34, 0.18);
  --brand-dim: rgba(122, 145, 255, 0.15);
}
:root[data-theme="light"] {
  --bg: var(--paper);
  --bg-elevated: #ffffff;
  --bg-sunken: #ececf3;
  --bg-modal: #ffffff;
  --border: #dcdaea;
  --border-lit: #c3c1dc;
  --text: var(--ink);
  --text-muted: #5b5d78;
  --text-dim: #9496b0;
  --overlay: rgba(20, 23, 42, 0.55);
  --shadow: 0 20px 60px -12px rgba(20, 23, 42, 0.3);
  --focus-ring: 0 0 0 3px rgba(68, 95, 210, 0.3);
  --fire-dim: rgba(228, 87, 46, 0.12);
  --grass-dim: rgba(63, 143, 92, 0.12);
  --spark-dim: rgba(201, 143, 34, 0.12);
  --brand-dim: rgba(68, 95, 210, 0.1);
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ─── Theme toggle (global, visible on every screen) ────────────────────── */
.theme-toggle {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 500;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), transform 0.1s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-lit); }
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ─── Screens ────────────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ─── Brandmark (abstract two-tone badge, not a literal logo copy) ──────── */
.brandmark {
  --sz: 34px;
  width: var(--sz);
  height: var(--sz);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  display: inline-block;
  background:
    linear-gradient(var(--brand), var(--brand)) top / 100% 46% no-repeat,
    linear-gradient(var(--spark), var(--spark)) bottom / 100% 54% no-repeat;
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.18);
}
.brandmark::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  height: 3px;
  background: var(--bg-elevated);
}
.brandmark::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 34%; height: 34%;
  border-radius: 50%;
  background: var(--bg-elevated);
  box-shadow: inset 0 0 0 2px var(--ink);
}
.brandmark.small { --sz: 22px; }

/* ─── Auth Screen ─────────────────────────────────────────────────────────── */
/* verify-screen reuses the same centered-card layout (.auth-container/.auth-bg). */
#auth-screen, #verify-screen {
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 0%, var(--brand-dim) 0%, transparent 70%);
  pointer-events: none;
}

.auth-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 2.5rem 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: fadeSlideUp 0.35s ease;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo-block { text-align: center; margin-bottom: 2rem; }
.logo-block .brandmark { margin-bottom: 0.9rem; }

.logo-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.logo-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  flex: 1;
  padding: 0.65rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.auth-form { display: none; flex-direction: column; gap: 1rem; }
.auth-form.active { display: flex; }

/* Same layout as .auth-form but always visible by default (toggled only via
   .hidden, never .active) - used outside the login/register tab pair so it
   isn't swept up by the tab-switch handler's global .auth-form reset. */
.stacked-form { display: flex; flex-direction: column; gap: 1rem; }

.field-group { display: flex; flex-direction: column; gap: 0.4rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

label {
  font-size: 0.8rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-muted);
}

/* Groups of related checkboxes (e.g. card conditions) use <fieldset>/<legend>
   instead of a plain <label> - a <label> only associates with one control,
   but a fieldset's legend is the correct way to label a whole group for
   screen readers. Stripped of the browser's default fieldset chrome so it
   still matches the plain .field-group look. */
.conditions-fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
.conditions-fieldset legend {
  padding: 0;
  font-size: 0.8rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-muted);
}

/* Visually hidden but still readable by screen readers - for labels needed
   only for accessibility where the visual design already conveys the same
   thing another way (e.g. an adjacent heading-style prompt). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.required { color: var(--fire); }
.optional { color: var(--text-dim); font-weight: 400; font-style: italic; }

.field-hint { font-size: 0.78rem; color: var(--text-dim); font-style: italic; }

/* Condition filters as toggle chips rather than plain checkboxes. */
.condition-checkboxes { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.32rem 0.7rem;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.checkbox-inline:has(input:checked) {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-dim);
}
.checkbox-inline input[type="checkbox"] { accent-color: var(--brand); cursor: pointer; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  appearance: none;
}
input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
input::placeholder { color: var(--text-dim); }
select option { background: var(--bg-elevated); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
/* One consistent keyboard-focus indicator for every button/link in the app,
   themed to match (inputs get their own :focus treatment above since they
   use a border-color change instead of a ring). */
button:focus-visible, a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  color: var(--brand-on);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.7rem 1.4rem;
  transition: background var(--transition), box-shadow var(--transition), transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: #3a51ba; box-shadow: 0 4px 18px var(--brand-dim); }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  transition: border-color var(--transition), color var(--transition);
}
.btn-ghost:hover { border-color: var(--border-lit); color: var(--text); }
.btn-ghost.danger { border-color: transparent; }
.btn-ghost.danger:hover { border-color: var(--fire); color: var(--fire); }

.btn-icon { font-size: 1rem; margin-right: 0.25rem; }

.form-error {
  background: var(--fire-dim);
  border: 1px solid rgba(228, 87, 46, 0.3);
  border-radius: var(--radius-sm);
  color: var(--fire);
  font-size: 0.85rem;
  padding: 0.6rem 0.9rem;
}
.form-success {
  background: var(--grass-dim);
  border: 1px solid rgba(63, 143, 92, 0.3);
  border-radius: var(--radius-sm);
  color: var(--grass);
  font-size: 0.85rem;
  padding: 0.6rem 0.9rem;
}
.hidden { display: none !important; }

/* ─── App Header ─────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 2rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 0.55rem; }
.header-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; letter-spacing: -0.005em; }

.logo-home-btn {
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0.2rem;
  margin: -0.2rem;
  border-radius: var(--radius-sm);
  opacity: 1;
  transition: opacity var(--transition);
}
.logo-home-btn:hover { opacity: 0.75; }
.header-right { display: flex; align-items: center; gap: 0.75rem; padding-right: 3rem; }
.header-user { font-size: 0.85rem; color: var(--text-muted); }

/* ─── Dashboard ──────────────────────────────────────────────────────────── */
.dashboard { flex: 1; padding: 2rem; max-width: 1100px; width: 100%; margin: 0 auto; }
.dashboard-narrow { max-width: 560px; display: flex; flex-direction: column; gap: 1.25rem; }

/* ─── Settings ───────────────────────────────────────────────────────────── */
.settings-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
}
.settings-section h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1rem;
}
.settings-current-email { margin-bottom: 1rem; }
.verify-resend-hint { text-align: center; margin-top: 0.4rem; }
.verify-resend-hint a { color: var(--brand); text-decoration: none; }
.verify-resend-hint a:hover { text-decoration: underline; }

/* ─── Admin ──────────────────────────────────────────────────────────────── */
.admin-table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }

.admin-table th {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0;
  border-bottom: 1px solid var(--border);
}

/* Real <button> inside each <th> (not the <th> itself) so the column header
   is keyboard-focusable/operable, with sort state conveyed via aria-sort on
   the <th> rather than a custom class. */
.admin-sort-btn {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  padding: 0.85rem 1rem;
  transition: color var(--transition);
}
.admin-sort-btn:hover { color: var(--text); }
.admin-sort-btn::after {
  content: "↕";
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.9em;
  opacity: 0.35;
}
th[aria-sort="ascending"] .admin-sort-btn,
th[aria-sort="descending"] .admin-sort-btn { color: var(--brand); }
th[aria-sort="ascending"] .admin-sort-btn::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .admin-sort-btn::after { content: "↓"; opacity: 1; }
.admin-col-num .admin-sort-btn { justify-content: flex-end; }

.admin-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
}

.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--bg-sunken); }

.admin-user-cell, .admin-email-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
}

.admin-col-num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
}

.badge-admin { background: var(--brand-dim); color: var(--brand); }
.badge-verified { background: var(--grass-dim); color: var(--grass); }
.badge-pending { background: var(--fire-dim); color: var(--fire); }

/* ─── Trends ─────────────────────────────────────────────────────────────── */
.trends-window-group { max-width: 200px; }

.trends-section-title { margin: 1.75rem 0 0.75rem; }
.trends-section-title:first-of-type { margin-top: 0; }
.trends-section-title h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.trends-table-wrap { margin-bottom: 0.5rem; }

.trend-thumb {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  flex-shrink: 0;
}

.sparkline { display: block; }

.trend-positive { color: var(--grass); }
.trend-negative { color: var(--fire); }

.dashboard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-header { display: flex; align-items: center; gap: 0.75rem; }
.section-title { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; letter-spacing: -0.005em; }

.item-count-badge {
  background: var(--bg-sunken);
  border-radius: 20px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  padding: 0.15rem 0.6rem;
}

/* ─── Items Grid ─────────────────────────────────────────────────────────── */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 4rem 2rem; color: var(--text-dim); }
.empty-icon { font-size: 2.6rem; color: var(--border-lit); margin-bottom: 1rem; }
.empty-sub { font-size: 0.9rem; margin-top: 0.4rem; }

/* ─── Item Card ──────────────────────────────────────────────────────────── */
.item-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: fadeSlideUp 0.3s ease;
}
.item-card:hover { border-color: var(--border-lit); box-shadow: var(--shadow); }
.item-card.triggered { border-color: rgba(201, 143, 34, 0.5); box-shadow: 0 0 0 3px var(--spark-dim); }
.item-card.inactive { opacity: 0.55; }

.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.7rem; margin-bottom: 0.9rem; }
.card-title-group { display: flex; align-items: flex-start; gap: 0.6rem; flex: 1; min-width: 0; }

.card-thumb-wrap { position: relative; flex-shrink: 0; }
.card-thumb {
  width: 64px; height: 64px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  display: block;
  transition: border-color var(--transition);
}
.card-thumb-wrap:hover .card-thumb { border-color: var(--brand); }

.card-thumb-zoom {
  position: absolute;
  top: 0; left: 0;
  width: 260px; height: 260px;
  object-fit: contain;
  background: var(--bg-elevated);
  border: 1px solid var(--border-lit);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition);
}
.card-thumb-wrap:hover .card-thumb-zoom { opacity: 1; visibility: visible; transition-delay: 0.1s; }

.card-title { font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; color: var(--text); line-height: 1.3; flex: 1; padding-right: 0.5rem; }
.card-id { font-size: 0.72rem; color: var(--text-dim); font-family: var(--font-mono); margin-top: 0.25rem; }
.card-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }

.card-badges { display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-end; }

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.16rem 0.5rem;
  border-radius: 20px;
  border: 1px solid transparent;
  white-space: nowrap;
  font-family: var(--font-body);
}
.badge-active    { background: var(--grass-dim); color: var(--grass); }
.badge-inactive  { background: var(--bg-sunken); color: var(--text-dim); }
.badge-foil      { background: var(--spark-dim); color: var(--spark); }
.badge-condition { background: var(--brand-dim); color: var(--brand); cursor: help; }

.card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 1rem; }
.stat { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 0.5rem 0.7rem; }
.stat-label { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em; color: var(--text-dim); text-transform: uppercase; display: block; margin-bottom: 0.15rem; }
.stat-value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.05rem; color: var(--spark); font-weight: 700; }

.card-result {
  font-size: 0.83rem;
  color: var(--text-muted);
  padding: 0.55rem 0.7rem;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  margin-bottom: 0.9rem;
  min-height: 2.2rem;
  transition: all var(--transition);
}
.card-result.alert { color: var(--spark); background: var(--spark-dim); font-weight: 700; }
.card-result.error { color: var(--fire); background: var(--fire-dim); }

.card-actions { display: flex; gap: 0.5rem; }
.card-actions .btn-ghost { flex: 1; font-size: 0.72rem; padding: 0.45rem 0.5rem; text-align: center; }

.check-spinner { display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Product Search ─────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 2.3rem; }
.search-icon {
  position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-dim); pointer-events: none;
}

.search-results {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-sunken);
}

.search-result {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-elevated); }

.search-result img {
  width: 56px; height: 56px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.search-result-info { flex: 1; min-width: 0; }
.search-result-name { font-size: 0.87rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-sub { font-size: 0.74rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-price { font-family: var(--font-mono); font-size: 0.8rem; color: var(--spark); font-weight: 700; white-space: nowrap; flex-shrink: 0; }

.picked-product {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--brand);
  border-radius: var(--radius-md);
  background: var(--brand-dim);
  margin-bottom: 0.7rem;
}
.picked-product-img { width: 48px; height: 48px; object-fit: contain; border-radius: var(--radius-sm); background: var(--bg-elevated); flex-shrink: 0; display: block; }
.picked-product-info { flex: 1; min-width: 0; }
.picked-product-name { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.picked-product-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ─── Staged modal sections ──────────────────────────────────────────────── */
.stage-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.stage-label .n {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg-sunken);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 0.6rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.adv-summary {
  width: 100%;
  list-style: none;
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-sunken);
  border: none;
  text-align: left;
}
.adv-summary .chev { transition: transform var(--transition); color: var(--text-dim); flex-shrink: 0; }
.adv-summary[aria-expanded="true"] .chev { transform: rotate(90deg); }
.adv-body { padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Fixed viewport-relative height + internal scroll: search results (or any
   long content) scroll within the modal instead of pushing it past the
   viewport. */
.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: min(88vh, 780px);
  box-shadow: var(--shadow);
  animation: fadeSlideUp 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; }
.modal-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 1rem; padding: 0.3rem 0.5rem; border-radius: 50%;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-sunken); }

.modal-body {
  padding: 1.3rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-lit);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  padding: 0.75rem 1.2rem;
  z-index: 300;
  box-shadow: var(--shadow);
  animation: fadeSlideUp 0.25s ease;
  max-width: 320px;
}
.toast.success { border-color: rgba(63, 143, 92, 0.5); color: var(--grass); }
.toast.error   { border-color: rgba(228, 87, 46, 0.5); color: var(--fire); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .dashboard { padding: 1rem; }
  .app-header { padding: 0.8rem 1rem; }
  .header-right { padding-right: 2.75rem; }
  .header-user { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .items-grid { grid-template-columns: 1fr; }
  .theme-toggle { top: 0.7rem; right: 0.7rem; }
}
