:root {
  --bg: #0b0f14;
  --surface: #131a22;
  --surface-2: #1a232d;
  --border: #232e3a;
  --text: #e8edf2;
  --text-dim: #8b9aab;
  --accent: #22d3ee;
  --accent-2: #6366f1;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overscroll-behavior-y: none;
}

#app { display: flex; flex-direction: column; min-height: 100%; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, rgba(11,15,20,0.98), rgba(11,15,20,0.85));
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand-dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
}

main { flex: 1; padding: 8px 16px 90px; max-width: 640px; margin: 0 auto; width: 100%; }

.hero {
  border-radius: var(--radius);
  padding: 22px;
  margin: 8px 0 18px;
  background: radial-gradient(120% 140% at 10% 0%, rgba(99,102,241,0.35), transparent 60%),
              radial-gradient(120% 140% at 100% 0%, rgba(34,211,238,0.25), transparent 55%),
              var(--surface);
  border: 1px solid var(--border);
}
.hero h1 { margin: 0 0 6px; font-size: 22px; }
.hero p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.5; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2, .card h3 { margin-top: 0; }

.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input, select, textarea, button {
  font: inherit; color: inherit;
}
input, select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 8px 10px;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.deal-item, .list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  gap: 10px;
}
.deal-item:last-child, .list-item:last-child { border-bottom: none; }
.deal-title { font-weight: 600; font-size: 14px; }
.deal-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.discount-badge {
  background: rgba(52, 211, 153, 0.15); color: var(--good);
  font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
}

.scan-area {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
  background: #000;
  position: relative;
}
#qr-reader { width: 100%; height: 100%; }

.empty-state { text-align: center; color: var(--text-dim); padding: 30px 10px; font-size: 14px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: rgba(19,26,34,0.95); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 20;
}
.tab-btn {
  background: none; border: none; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; padding: 6px 10px; border-radius: 10px;
}
.tab-btn.active { color: var(--accent); }
.tab-btn svg { width: 22px; height: 22px; }

.hidden { display: none !important; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + var(--safe-bottom));
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 999px; font-size: 13px;
  z-index: 30; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.tag { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }

@media (prefers-color-scheme: light) {
  /* App is intentionally dark-themed only (retail floor / low-light friendly) */
}

/* ── Theme variants ────────────────────────────────────────────────────
   Named after what's actually happening in the app: Aurora is the
   original cool default; Rescue borrows the orange/red of a Danish
   "nedsat" clearance sticker — the exact thing the Deals tab is built
   around; Nightshift is for whoever's doing markdowns before opening. */
:root[data-theme="rescue"] {
  --accent: #fb923c;
  --accent-2: #ef4444;
}
:root[data-theme="nightshift"] {
  --accent: #a78bfa;
  --accent-2: #7c3aed;
}

.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-swatch {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.theme-swatch.active { color: var(--text); border-color: var(--accent); }
.swatch-dot { width: 26px; height: 26px; border-radius: 50%; display: block; }

/* ── Small tactile feedback + one deliberate transition ─────────────────
   Buttons answer a tap with a slight press; switching tabs cross-fades
   the new view in. No looping or on-load animation elsewhere. */
button:not(:disabled):active { transform: scale(0.97); }
.tab-btn { transition: color 0.15s ease; }
.view { animation: view-in 0.18s ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Enough tabs now (Manager is conditional) that small phones need this
   to scroll rather than crush every label. */
.tabbar { overflow-x: auto; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tab-btn { flex: 0 0 auto; min-width: 58px; }
