/* ──────────────────────────────────────────────────────────────────────────
   COMPONENTS — buttons, cards, nav, inputs, chips, modals, charts, loaders
   ────────────────────────────────────────────────────────────────────────── */

/* ─── BUTTONS ─── */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 600; font-size: 14px;
  letter-spacing: -0.005em;
  text-transform: none;
  color: #0b0b0d;
  background: var(--accent);
  border: 1px solid transparent;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
  box-shadow: 0 1px 0 rgba(0,0,0,0.20);
  overflow: hidden;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; box-shadow: none; }

/* System-theme button styling — restore the cyan glow and display font */
:root[data-theme="system"] .btn {
  font-family: var(--font-display);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: #02050a;
  border-color: rgba(77, 204, 255, 0.5);
  box-shadow: var(--shadow-glow);
}
:root[data-theme="system"] .btn:hover { box-shadow: 0 0 32px rgba(77, 204, 255, 0.55); }

.btn-block { width: 100%; }
.btn-lg { padding: 17px 22px; font-size: 16px; border-radius: 16px; }
.btn-xl { padding: 20px 24px; font-size: 17px; border-radius: 18px; }

.btn-ghost {
  background: var(--surface-1);
  color: var(--accent);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--surface-2); box-shadow: 0 0 12px rgba(77, 204, 255, 0.15); border-color: var(--border-strong); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--border-strong);
  box-shadow: none;
}
.btn-outline:hover { background: var(--accent-soft); border-color: var(--accent); }

.btn-bad {
  background: var(--bad); color: white;
  border-color: rgba(255, 90, 90, 0.5);
  box-shadow: 0 0 20px rgba(255, 90, 90, 0.30);
}
.btn-bad:hover { background: #ff7470; }

.btn-violet {
  background: var(--violet); color: white;
  border-color: rgba(153, 112, 255, 0.5);
  box-shadow: var(--shadow-violet);
}
.btn-violet:hover { background: var(--violet-2); }

.btn-warm { background: var(--grad-warm); color: #1a0e00; border-color: rgba(255, 170, 60, 0.5); }

.btn-premium {
  background: var(--grad-premium);
  color: #1a1000;
  border-color: rgba(255, 206, 0, 0.5);
  box-shadow: var(--shadow-gold);
  font-weight: 700;
}
.btn-premium:hover { transform: translateY(-1px); box-shadow: 0 0 36px rgba(255, 206, 0, 0.45); }

.btn-legendary {
  background: var(--grad-legendary);
  color: #02050a;
  border-color: rgba(153, 112, 255, 0.6);
  box-shadow: var(--shadow-violet);
  font-weight: 700;
}

.btn-mini {
  padding: 6px 12px; font-size: 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.btn-mini:hover { background: var(--surface-3); border-color: var(--border-strong); }
:root[data-theme="system"] .btn-mini {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--accent);
}
:root[data-theme="system"] .btn-mini:hover { background: var(--accent-soft); border-color: var(--accent); }

.btn-mini.danger { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 90, 90, 0.3); }
.btn-mini.danger:hover { background: var(--bad); color: white; }

/* Icon-only button */
.btn-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: none;
}
.btn-icon:hover { background: var(--surface-3); }

/* ─── CARDS ─── */
.card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.card + .card { margin-top: 10px; }
.card-strong {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.card-glow {
  border: 1px solid rgba(77, 204, 255, 0.35);
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(77, 204, 255, 0.10) 0%, transparent 60%),
    var(--surface-1);
  box-shadow: 0 0 24px rgba(77, 204, 255, 0.12);
}

/* ─── SYSTEM WINDOW — the signature bracket-corner card ─── */
.sys-window {
  position: relative;
  background: linear-gradient(180deg, rgba(5, 10, 20, 0.85), rgba(10, 18, 31, 0.85));
  border: 1px solid var(--border-strong);
  padding: 20px 18px;
  margin: 12px 0;
}
.sys-window::before,
.sys-window::after,
.sys-window > .corner-tl,
.sys-window > .corner-tr,
.sys-window > .corner-bl,
.sys-window > .corner-br {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
  filter: drop-shadow(0 0 4px var(--accent));
}
.sys-window::before { /* top-left */
  top: -1px; left: -1px;
  border-top-width: 2px; border-left-width: 2px;
}
.sys-window::after { /* bottom-right */
  bottom: -1px; right: -1px;
  border-bottom-width: 2px; border-right-width: 2px;
}
.sys-window > .corner-tr {
  top: -1px; right: -1px;
  border-top-width: 2px; border-right-width: 2px;
}
.sys-window > .corner-bl {
  bottom: -1px; left: -1px;
  border-bottom-width: 2px; border-left-width: 2px;
}

.sys-window.violet { border-color: rgba(153, 112, 255, 0.50); }
.sys-window.violet::before, .sys-window.violet::after,
.sys-window.violet > .corner-tr, .sys-window.violet > .corner-bl {
  border-color: var(--violet); filter: drop-shadow(0 0 4px var(--violet));
}

.sys-window.gold { border-color: rgba(255, 206, 0, 0.50); }
.sys-window.gold::before, .sys-window.gold::after,
.sys-window.gold > .corner-tr, .sys-window.gold > .corner-bl {
  border-color: var(--gold); filter: drop-shadow(0 0 4px var(--gold));
}

/* Window header */
.sys-window-title {
  font-family: var(--font-sans);
  font-size: 12px; font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.10em;
  margin: 0 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.sys-window-title::after {
  content: "";
  flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
  margin-left: 8px;
}
:root[data-theme="system"] .sys-window-title {
  font-family: var(--font-display);
  color: var(--accent);
  letter-spacing: 0.22em;
}
:root[data-theme="system"] .sys-window-title::before { content: "[ "; opacity: 0.7; }
:root[data-theme="system"] .sys-window-title::after {
  background: linear-gradient(90deg, var(--accent-soft) 0%, transparent 100%);
}
.sys-window.violet .sys-window-title { color: var(--violet); }
.sys-window.gold .sys-window-title   { color: var(--gold); }

/* Calm-theme: sys-window loses the bracket corners; just a soft card */
:root[data-theme="calm"] .sys-window,
:root:not([data-theme]) .sys-window {
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}
:root[data-theme="calm"] .sys-window::before,
:root[data-theme="calm"] .sys-window::after,
:root[data-theme="calm"] .sys-window > .corner-tl,
:root[data-theme="calm"] .sys-window > .corner-tr,
:root[data-theme="calm"] .sys-window > .corner-bl,
:root[data-theme="calm"] .sys-window > .corner-br {
  display: none;
}
.card-tap { cursor: pointer; transition: transform var(--t-fast) var(--ease), background var(--t-fast); }
.card-tap:hover { background: var(--surface-3); transform: translateY(-1px); }
.card-tap:active { transform: scale(0.99); }

/* Stat grid (general use) */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-grid.three { grid-template-columns: repeat(3, 1fr); }
.stat-grid.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 480px) { .stat-grid.four { grid-template-columns: repeat(4, 1fr); } }

.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
  opacity: 0.7;
  box-shadow: 0 0 8px var(--accent);
}
.stat.warm::after { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.stat.bad::after { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.stat.violet::after { background: var(--violet); box-shadow: 0 0 8px var(--violet); }
.stat.gold::after { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.stat-label {
  color: var(--text-mute); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em;
  font-family: var(--font-display);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 32px; font-weight: 700; margin-top: 4px; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(77, 204, 255, 0.25);
}
.stat-sub { color: var(--text-mute); font-size: 11px; margin-top: 4px; }

/* ─── PILLAR STAT — hexagon-ish card with a number + label ─── */
.pstat {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  overflow: hidden;
}
.pstat::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(77, 204, 255, 0.04), transparent 60%);
  pointer-events: none;
}
.pstat:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(77, 204, 255, 0.25);
}
.pstat-key {
  font-family: var(--font-display);
  font-size: 10px; font-weight: 600;
  color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.22em;
  margin-bottom: 4px;
}
.pstat-num {
  font-family: var(--font-display);
  font-size: 36px; font-weight: 700;
  line-height: 1;
  margin: 2px 0 6px;
  font-variant-numeric: tabular-nums;
  background: var(--grad-system);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.pstat-name { font-size: 11px; color: var(--text-dim); font-weight: 500; }

/* Mini XP bar inside pstat */
.pstat-bar {
  margin-top: 8px;
  height: 3px;
  background: rgba(77, 204, 255, 0.10);
  border-radius: 3px;
  overflow: hidden;
}
.pstat-bar > div {
  height: 100%;
  background: var(--grad-system);
  transition: width 800ms var(--ease);
}

/* ─── XP BAR — for the hunter level on Status ─── */
.xpbar {
  position: relative;
  height: 12px;
  background: rgba(77, 204, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.xpbar > .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  border-radius: 999px;
  box-shadow: 0 0 16px rgba(77, 204, 255, 0.50);
  transition: width 800ms var(--ease);
  position: relative;
}
.xpbar > .fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.30), transparent);
  background-size: 200% 100%;
  animation: shimmer 2.4s linear infinite;
}
.xpbar-labels {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 10px; letter-spacing: 0.16em;
  color: var(--text-mute);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

/* ─── QUEST CARD ─── */
.quest {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: all var(--t-fast);
}
.quest:hover { background: var(--surface-2); border-color: var(--border-strong); border-left-color: var(--accent-2); }
.quest.done { opacity: 0.55; border-left-color: var(--good); }
.quest.done .quest-title { text-decoration: line-through; }

.quest-head {
  display: flex; align-items: center; gap: 10px;
}
.quest-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.quest-title { flex: 1; font-size: 14px; font-weight: 600; }
.quest-reward {
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}
.quest-meta {
  margin-top: 6px;
  font-size: 11px; color: var(--text-mute);
  display: flex; align-items: center; gap: 8px;
}
.quest-progress {
  margin-top: 8px;
  height: 4px;
  background: rgba(77, 204, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.quest-progress > div {
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  transition: width 500ms var(--ease);
}
.quest-desc { margin-top: 6px; font-size: 12px; color: var(--text-dim); line-height: 1.4; }
.quest-cta-row { margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.quest-gen-empty {
  text-align: center; padding: 18px 16px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: rgba(255,255,255,0.02); margin-bottom: 8px;
}
.quest-gen-empty p { color: var(--text-mute); font-size: 13px; margin: 0 0 12px; }
.quest-gen-empty p:only-child { margin-bottom: 0; }

/* Collapsed "Completed" quests */
.quest-done { margin: 4px 0 0; }
.quest-done-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: rgba(255,255,255,0.02);
  font-size: 12px; font-weight: 600; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .04em;
}
.quest-done-summary::-webkit-details-marker { display: none; }
.quest-done-summary:hover { color: var(--text-dim); }
.quest-done .qd-chev { transition: transform .15s; font-size: 11px; }
.quest-done[open] .qd-chev { transform: rotate(180deg); }
.quest-done-body { padding-top: 8px; }

/* ─── INPUTS ─── */
.input {
  display: block; width: 100%;
  background: rgba(0,0,0,0.30);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast);
  font-size: 15px;
}
.input::placeholder { color: var(--text-faint); }
.input:focus {
  border-color: var(--gold);
  background: rgba(0,0,0,0.40);
}

.input-pill {
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  background: var(--surface-2);
}

.input-num {
  text-align: right; width: 80px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; color: var(--text);
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.input-num:focus { outline: none; border-color: var(--gold); }

.label { display: block; color: var(--text-dim); font-size: 12px; margin-bottom: 6px; font-weight: 500; }

/* ─── ROWS (list items) ─── */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.row + .row { margin-top: 8px; }
.row-tap { cursor: pointer; }
.row-tap:hover { background: var(--surface-3); }
.row-urgent { border-color: rgba(230, 96, 90, 0.45); background: rgba(230, 96, 90, 0.05); }
.row-warn { border-color: rgba(240, 177, 74, 0.35); }

.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; }
.row-meta { color: var(--text-mute); font-size: 12px; margin-top: 3px; }
.row-trailing { text-align: right; flex-shrink: 0; }

/* ─── BOTTOM NAV ─── */
.bnav {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 10;
  padding: 10px 12px calc(10px + var(--safe-bot));
  background: rgba(2, 5, 10, 0.92);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 24px rgba(77, 204, 255, 0.08);
}
.bnav-inner {
  max-width: 580px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  align-items: end;
}
.nb {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px;
  color: var(--text-mute); font-size: 10px; font-weight: 600;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
:root[data-theme="system"] .nb {
  font-family: var(--font-display);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
}
.nb .ic { font-size: 22px; line-height: 1; transition: transform var(--t-fast); }
.nb.active { color: var(--accent); }
.nb.active .ic { transform: scale(1.12); filter: drop-shadow(0 0 6px var(--accent)); }
.nb:hover { color: var(--text); }
.nb:active { transform: scale(0.92); }

/* Center [+] button — floating "log" portal */
.nb.scan {
  position: relative;
  background: var(--bg-2);
  color: var(--accent);
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  align-self: center; justify-self: center;
  transform: translateY(-14px);
  box-shadow: 0 0 24px rgba(77, 204, 255, 0.35), inset 0 0 12px rgba(77, 204, 255, 0.20);
  font-size: 0;
}
.nb.scan .ic {
  font-size: 28px; transform: none;
  filter: drop-shadow(0 0 6px var(--accent));
}
.nb.scan:hover {
  transform: translateY(-16px) scale(1.05);
  box-shadow: 0 0 32px rgba(77, 204, 255, 0.55), inset 0 0 12px rgba(77, 204, 255, 0.30);
}
.nb.scan:active { transform: translateY(-12px) scale(0.96); }
.nb.scan::after {
  content: ""; position: absolute; inset: -6px;
  border-radius: 50%; border: 1.5px solid rgba(77, 204, 255, 0.4);
  animation: pulse 2.4s ease-in-out infinite;
  pointer-events: none;
}

/* ─── CHIPS ─── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  color: var(--text-dim);
  border: 1px solid transparent;
}
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad  { background: var(--bad-soft);  color: var(--bad); }
.chip.muted { background: var(--surface-2); color: var(--text-mute); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Filter pill */
.fchip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.fchip:hover { color: var(--text); border-color: var(--border-strong); }
.fchip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
}
.fchip-row {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
  margin: 0 -4px;
}
.fchip-row::-webkit-scrollbar { display: none; }

/* Category badge (in pantry rows) */
.cat-badge {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── TOAST — system-notification style ─── */
.toast {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%; transform: translateX(-50%) translateY(-100px);
  background: rgba(20, 20, 22, 0.95);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  z-index: 1000;
  transition: transform 380ms var(--ease-spring);
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.good { border-color: var(--good); color: var(--good); }
.toast.bad  { border-color: var(--bad);  color: var(--bad); }
.toast.xp   { border-color: var(--gold); color: var(--gold); }

/* System theme: brings back the bracket prefixes + display font */
:root[data-theme="system"] .toast {
  font-family: var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 4px;
  background: rgba(5, 10, 20, 0.92);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}
:root[data-theme="system"] .toast::before { content: "[ SYSTEM ] "; opacity: 0.6; }
:root[data-theme="system"] .toast.good { box-shadow: 0 0 24px rgba(76, 224, 168, 0.35); }
:root[data-theme="system"] .toast.bad  { box-shadow: 0 0 24px rgba(255, 90, 90, 0.35); }
:root[data-theme="system"] .toast.good::before { content: "[ COMPLETE ] "; }
:root[data-theme="system"] .toast.bad::before  { content: "[ ERROR ] "; }
:root[data-theme="system"] .toast.xp           { box-shadow: var(--shadow-gold); }
:root[data-theme="system"] .toast.xp::before   { content: "[ XP GAINED ] "; opacity: 1; }

/* ─── OVERLAYS / SHEETS ─── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 200ms var(--ease);
}
.sheet {
  background: linear-gradient(180deg, rgba(10, 18, 31, 0.95), rgba(5, 10, 20, 0.98));
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 24px 20px calc(24px + var(--safe-bot));
  width: 100%; max-width: 580px;
  border-top: 1.5px solid var(--accent);
  animation: slideUp 320ms var(--ease);
  box-shadow: 0 -20px 60px rgba(0,0,0,0.7), 0 -2px 24px rgba(77, 204, 255, 0.15);
}
.sheet h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--accent);
}
.sheet-grab {
  width: 40px; height: 4px; border-radius: 4px;
  background: var(--border-strong);
  margin: -8px auto 16px;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet h3 { margin: 0 0 8px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.sheet p { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }

/* Action list (used by UI.actionSheet) */
.action-list {
  display: flex; flex-direction: column; gap: 6px;
  margin: 4px 0 0;
}
.action-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  transition: background var(--t-fast), transform var(--t-fast);
}
.action-item:hover { background: var(--surface-3); }
.action-item:active { transform: scale(0.99); }
.action-item.danger .action-label { color: var(--bad); }
.action-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.action-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.action-label { font-size: 15px; font-weight: 600; color: var(--text); }
.action-sub { font-size: 12px; color: var(--text-mute); line-height: 1.35; }
.action-chev { color: var(--text-faint); font-size: 22px; line-height: 1; }

/* Centered modal for success */
.overlay.center { align-items: center; }
.modal {
  background: linear-gradient(180deg, rgba(10, 18, 31, 0.96), rgba(5, 10, 20, 0.96));
  border-radius: 4px;
  border: 1.5px solid var(--accent);
  padding: 32px 28px;
  width: calc(100% - 40px); max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(77, 204, 255, 0.25);
  animation: pop 380ms var(--ease-spring);
}
.modal-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
  margin: 0 auto 18px;
}

/* ─── LOADERS ─── */
.spinner {
  display: inline-block;
  width: 22px; height: 22px;
  border: 2.5px solid rgba(255,255,255,0.12);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.spinner.lg { width: 32px; height: 32px; border-width: 3px; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius);
}
.skeleton-row {
  height: 64px; margin-bottom: 8px;
}

/* Scanning animation — overlay on the receipt during extraction */
.scan-anim {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.scan-anim::after {
  content: "";
  position: absolute; left: 0; right: 0; top: 0;
  height: 30%;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(232, 196, 120, 0.55) 50%,
    transparent 100%);
  filter: blur(8px);
  animation: scanLine 2.2s ease-in-out infinite;
}
@keyframes scanLine {
  0%   { transform: translateY(-20%); opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(320%); opacity: 0; }
}

/* ─── PROGRESS BAR ─── */
.progress {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 8px 0 0;
}
.progress > div {
  height: 100%;
  background: var(--grad-premium);
  border-radius: var(--radius-pill);
  transition: width 600ms var(--ease);
}
.progress.warn > div { background: var(--grad-warm); }
.progress.bad > div { background: var(--bad); }

/* ─── BANNER (trial/upgrade nudge) ─── */
.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(90deg, rgba(232, 196, 120, 0.14), rgba(232, 196, 120, 0.04));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.banner:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.banner-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.banner-text { flex: 1; }
.banner-text strong { color: var(--text); display: block; font-weight: 700; }
.banner-text span { color: var(--text-dim); }
.banner-arrow { color: var(--gold); font-size: 18px; }

/* ─── CONFETTI dots (after successful save) ─── */
.confetti {
  position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden;
}
.confetti span {
  position: absolute; top: -10px;
  width: 8px; height: 8px; border-radius: 2px;
  animation: confetti 1.4s ease-out forwards;
}
@keyframes confetti {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--dx, 0), 100vh, 0) rotate(720deg); opacity: 0; }
}
