/* ==========================================================================
   IamFamous Stock Management System — design system
   BRAND NOTE: Deep Charcoal/Black with Metallic Gold accents.
   ========================================================================== */
:root {
  /* [BRAND] Updated to Premium Charcoal & Gold */
  --brand-dark: #121212;        /* Almost black (app icon background) */
  --brand-dark-2: #1E1E1E;      /* Raised dark surface */
  --brand-accent: #D4AF37;      /* Metallic Gold */
  --brand-accent-ink: #121212;  /* Dark text placed ON the gold */
  --brand-accent-soft: #FDF6E3; /* Soft gold tint for backgrounds */
  --brand-on-dark: #F5F2EA;     /* Warm text on dark surfaces */

  --bg: #F7F4EE;
  --surface: #FFFFFF;
  --text: #17171A;
  --muted: #6A665E;
  --line: #E6E1D6;
  --focus: #D4AF37;             /* Focus rings match the gold */

  --ok: #1B7A45;   --ok-soft: #E1F4E8;
  --low: #B54708;  --low-soft: #FDEBD8;
  --out: #B42318;  --out-soft: #FBE3E1;
  --info: #175CD3; --info-soft: #E3EDFD;

  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18,18,18,.06), 0 6px 18px rgba(18,18,18,.06);
  --font-display: 'Archivo', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --side-w: 248px; --tab-h: 64px;
  color-scheme: light dark;
}

/* Dark mode: attribute-driven so users can override the OS preference */
:root[data-theme="dark"] {
  --bg: #090909; --surface: #141414; --text: #F2EFE8; --muted: #A5A097; --line: #2B2B2B;
  --brand-dark: #000000; --brand-dark-2: #1E1E1E; --focus: #E5C76B; /* Brighter gold for dark mode */
  --ok-soft: #12301F; --low-soft: #3A2412; --out-soft: #3B1714; --info-soft: #14243F;
  --ok: #55D08A; --low: #F2A65A; --out: #FF8A80; --info: #8DB4FF;
  --brand-accent-soft: #2A2412;
  --shadow: 0 1px 2px rgba(0,0,0,.7), 0 6px 18px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090909; --surface: #141414; --text: #F2EFE8; --muted: #A5A097; --line: #2B2B2B;
    --brand-dark: #000000; --brand-dark-2: #1E1E1E; --focus: #E5C76B;
    --ok-soft: #12301F; --low-soft: #3A2412; --out-soft: #3B1714; --info-soft: #14243F;
    --ok: #55D08A; --low: #F2A65A; --out: #FF8A80; --info: #8DB4FF;
    --brand-accent-soft: #2A2412;
    --shadow: 0 1px 2px rgba(0,0,0,.7), 0 6px 18px rgba(0,0,0,.5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; margin: 0; line-height: 1.15; }
h1 { font-size: 1.7rem; font-weight: 800; } h2 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0; } button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted, .sub { color: var(--muted); } .sub { font-size: .9rem; margin-top: 4px; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; transition: transform .15s; }

/* Prevent double-tap zoom on mobile */
button, a, input, select {
  touch-action: manipulation;
}

/* ---------- Shell ---------- */
.shell { min-height: 100dvh; }
.side { display: none; }
.main { padding: 16px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); max-width: 100%; width: 100%; margin: 0 auto; position: relative; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); background: var(--brand-dark); color: var(--brand-on-dark); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; text-decoration: none; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-accent); color: var(--brand-accent-ink); display: grid; place-items: center; }
.brand .logo svg { width: 18px; height: 18px; fill: currentColor; }
.brand small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; opacity: .65; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-dark-2); border: 1px solid #ffffff22; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }

.tabbar { position: fixed; inset: auto 0 0 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--brand-dark); display: grid; grid-template-columns: repeat(5, 1fr); z-index: 30; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #ffffff99; text-decoration: none; font-size: .68rem; font-weight: 600; transition: transform .12s, color .15s; }
.tabbar a[aria-current="page"] { color: var(--brand-accent); }
.tabbar a.scan span.fab { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-accent); color: var(--brand-accent-ink); display: grid; place-items: center; margin-top: -26px; box-shadow: 0 6px 16px rgba(245,184,0,.45); border: 4px solid var(--bg); transition: transform .15s, box-shadow .15s; }
.tabbar a.scan { color: #ffffff99; }
.tabbar a:active .fab { transform: scale(.92); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side-w) 1fr; }
  .topbar, .tabbar { display: none; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; background: var(--brand-dark); color: var(--brand-on-dark); padding: 22px 14px; }
  .side .brand { padding: 0 10px 22px; }
  .side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .side nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #ffffffb3; text-decoration: none; font-weight: 600; transition: transform .12s, background .15s, color .15s; }
  .side nav a:hover { background: var(--brand-dark-2); color: #fff; }
  .side nav a[aria-current="page"] { background: var(--brand-accent); color: var(--brand-accent-ink); }
  .side nav a[aria-current="page"] .icon { transform: scale(1.1); }
  .side .me { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-top: 1px solid #ffffff1f; }
  .side .me .who { flex: 1; min-width: 0; line-height: 1.25; } .side .me .who b, .side .me .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side .me small { opacity: .6; text-transform: capitalize; }
  .main { padding: 32px 36px 48px; width: 100%;}
}

/* ---------- Page pieces ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h2 { margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; margin-top: 2px; }
.stat.hero { background: var(--brand-dark); color: var(--brand-on-dark); border-color: transparent; grid-column: 1 / -1; }
.stat.hero .k { color: var(--brand-accent); } .stat.warn .v { color: var(--low); } .stat.bad .v { color: var(--out); }
.cols { display: grid; gap: 16px; } @media (min-width: 900px) { .cols { grid-template-columns: 1.1fr .9fr; } .stats { grid-template-columns: repeat(4, 1fr); } .stat.hero { grid-column: auto; } }

.row-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); transition: background .15s; }
.row-item:last-child { border-bottom: 0; } .row-item .grow { flex: 1; min-width: 0; }
.row-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .row-item .s { color: var(--muted); font-size: .82rem; }
.row-item:hover { background: color-mix(in srgb, var(--brand-accent) 4%, transparent); }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .12s, background .15s, color .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: var(--muted); } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand-accent); color: var(--brand-accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(.95); }
.btn.primary:focus-visible { outline-color: var(--brand-accent-ink); }
.btn.dark { background: var(--brand-dark); color: var(--brand-on-dark); border-color: transparent; }
.btn.danger { color: var(--out); border-color: var(--out); background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .85rem; } .btn.block { width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .lbl { font-size: .82rem; font-weight: 700; }
.field .hint { font-size: .78rem; color: var(--muted); }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { 
  border-color: var(--brand-accent); 
  outline: none; 
  box-shadow: 0 0 0 4px var(--brand-accent-soft); 
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toolbar { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; } @media (min-width: 600px) { .toolbar { grid-template-columns: 1fr 220px; } }
.chips { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: .85rem; cursor: pointer; white-space: nowrap; transition: transform .12s, background .15s, color .15s, border-color .15s; }
.chip:active { transform: scale(.95); }
.chip.active { background: var(--brand-dark); color: var(--brand-on-dark); border-color: var(--brand-dark); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: var(--bg); padding: 5px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 14px; }
.seg input { position: absolute; opacity: 0; } .seg label { text-align: center; padding: 10px 6px; border-radius: 9px; font-weight: 700; cursor: pointer; }
.seg input:checked + label { background: var(--brand-dark); color: var(--brand-on-dark); } .seg input:focus-visible + label { outline: 3px solid var(--focus); }
.stepper { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; } .stepper button { min-height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 1.4rem; font-weight: 800; cursor: pointer; } .stepper input { text-align: center; font-size: 1.4rem; font-weight: 800; min-height: 52px; }

/* ---------- Product cards & badges ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pcard { display: flex; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; cursor: pointer; width: 100%; transition: transform .12s, border-color .15s, box-shadow .15s; }
.pcard:hover { border-color: var(--brand-accent); box-shadow: var(--shadow); }
.pcard:active { transform: scale(.985); }
.thumb { width: 64px; height: 64px; border-radius: 12px; background: var(--brand-accent-soft); color: var(--brand-accent-ink); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; overflow: hidden; flex: none; }
:root[data-theme="dark"] .thumb { color: var(--brand-accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; } .thumb.lg { width: 84px; height: 84px; }
.pcard .info { flex: 1; min-width: 0; } .pcard .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .78rem; color: var(--muted); cursor: pointer; }
.code[data-copied]::after { content: '✓'; color: var(--ok); margin-left: 6px; animation: fadeOut 1.2s forwards; }
@keyframes fadeOut { to { opacity: 0; } }
.qty { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; line-height: 1; text-align: right; } .qty small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .7rem; color: var(--muted); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; margin-top: 4px; transition: transform .15s; }
.badge.ok, .badge.IN { background: var(--ok-soft); color: var(--ok); } .badge.low { background: var(--low-soft); color: var(--low); }
.badge.out, .badge.OUT { background: var(--out-soft); color: var(--out); } .badge.ADJUST { background: var(--info-soft); color: var(--info); }

/* ---------- Table ---------- */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 640px; } th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .88rem; vertical-align: middle; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--bg); } tr:last-child td { border-bottom: 0; } td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); font-weight: 700; } .neg { color: var(--out); font-weight: 700; }

/* ---------- Chart ---------- */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; }
.bars .day { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.bars .b { width: 40%; max-width: 22px; border-radius: 5px 5px 0 0; min-height: 3px; } .bars .b.in { background: var(--brand-accent); } .bars .b.out { background: var(--brand-dark); }
:root[data-theme="dark"] .bars .b.out { background: #8d8a82; }
.bars small { font-size: .7rem; color: var(--muted); } .legend { display: flex; gap: 14px; font-size: .78rem; color: var(--muted); margin-top: 10px; } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ---------- Scanner ---------- */
#reader { width: 100%; max-width: 420px; margin: 0 auto 12px; border-radius: var(--radius); overflow: hidden; background: #000; position: relative; }
#reader:empty { display: none; }
#reader.scanning::before {
  content: '';
  position: absolute; left: 8%; right: 8%; top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-accent), transparent);
  animation: scan-line 1.6s ease-in-out infinite;
  z-index: 2;
  border-radius: 2px;
  box-shadow: 0 0 12px var(--brand-accent);
  pointer-events: none;
}
@keyframes scan-line {
  0%, 100% { top: 15%; opacity: 0; }
  20%      { opacity: 1; }
  80%      { opacity: 1; }
  50%      { top: 85%; }
}
@media (prefers-reduced-motion: reduce) { #reader.scanning::before { animation: none; opacity: .3; top: 50%; } }
.selected { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.results { margin-top: 8px; display: grid; gap: 8px; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 100; }
.sheet { 
  background: var(--surface); width: 100%; max-width: 560px; 
  max-height: 92dvh; overflow-y: auto; 
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); 
  animation: sheet-up .3s cubic-bezier(.22,1,.36,1);
}
@media (min-width: 700px) { 
  .overlay { align-items: center; } 
  .sheet { border-radius: 20px; animation: sheet-fade .25s cubic-bezier(.22,1,.36,1); } 
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes sheet-fade {
  from { transform: scale(.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.sheet .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; } .x { background: none; border: 0; font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 4px 10px; }
.actions { display: flex; gap: 10px; margin-top: 8px; } .actions .btn { flex: 1; }

/* ---------- Toasts ---------- */
.toasts { 
  position: fixed; left: 50%; transform: translateX(-50%); 
  bottom: calc(var(--tab-h) + 22px + env(safe-area-inset-bottom)); 
  display: grid; gap: 8px; z-index: 200; width: min(92vw, 420px); 
  pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: 24px; } }

.toast { 
  pointer-events: auto;
  background: var(--surface); color: var(--text); 
  padding: 12px 16px; border-radius: 12px; 
  font-weight: 600; font-size: .9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.15), 0 2px 6px rgba(0,0,0,.1);
  border: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; 
  animation: toast-in .3s cubic-bezier(.22,1,.36,1);
}

/* Unique Colors for Toast Types */
.toast.ok { border-left: 4px solid var(--ok); }
.toast.ok .toast-icon { color: var(--ok); background: var(--ok-soft); }

.toast.err { border-left: 4px solid var(--out); }
.toast.err .toast-icon { color: var(--out); background: var(--out-soft); }

.toast.info { border-left: 4px solid var(--info); }
.toast.info .toast-icon { color: var(--info); background: var(--info-soft); }

.toast-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
}
.toast-icon svg { width: 14px; height: 14px; }

.toast-action { 
  margin-left: auto; background: transparent; border: 0; 
  color: var(--brand-accent); font-weight: 700; cursor: pointer; 
  padding: 4px 8px; border-radius: 6px; text-decoration: underline; 
  font-size: .85rem;
}

.toast.out { animation: toast-out .2s forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.95); } }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; } @media (min-width: 900px) { .login { grid-template-columns: 1.1fr 1fr; } }
.login .hero { background: var(--brand-dark); color: var(--brand-on-dark); padding: 40px 28px; display: flex; flex-direction: column; justify-content: space-between; min-height: 38dvh; position: relative; overflow: hidden; }
.login .hero::after { content: ''; position: absolute; width: 380px; height: 380px; right: -120px; bottom: -140px; border-radius: 50%; background: radial-gradient(circle, var(--brand-accent) 0%, transparent 68%); opacity: .5; }
.login .hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 900; max-width: 12ch; position: relative; z-index: 1; } .login .hero h1 em { font-style: normal; color: var(--brand-accent); }
.login .hero p { opacity: .75; max-width: 34ch; margin-top: 12px; position: relative; z-index: 1; }
.login form { padding: 32px 24px; max-width: 420px; width: 100%; margin: 0 auto; align-self: center; } .login form h2 { font-size: 1.5rem; margin-bottom: 4px; } .login .err { color: var(--out); font-weight: 600; min-height: 1.4em; margin-bottom: 8px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand-accent); animation: spin .8s linear infinite; margin: 40px auto; } @keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } * { scroll-behavior: auto !important; } }

/* ---------- QR labels / print ---------- */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 6mm; padding: 8mm; background: #fff; color: #000; }
  .label { border: 1px dashed #999; padding: 4mm; text-align: center; break-inside: avoid; font-family: Arial, sans-serif; }
  .label svg { width: 34mm; height: 34mm; } .label b { display: block; font-size: 10pt; } .label span { font-size: 8pt; font-family: monospace; }
}

/* ============================================================
   UI/UX UPGRADE — appended
   ============================================================ */

/* ---------- Splash ---------- */
.splash {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 20px;
  text-align: center;
  background: var(--brand-dark);
  color: var(--brand-on-dark);
  animation: fadeIn .2s ease;
}
.splash-wordmark {
  font-family: var(--font-display); font-weight: 900;
  font-size: 1.6rem; letter-spacing: -.02em;
  animation: fadeIn .4s .15s both;
}
.splash-wordmark span {
  display: block; font-family: var(--font-body);
  font-weight: 500; font-size: .7rem; letter-spacing: .18em;
  text-transform: uppercase; opacity: .55;
}
.splash-bar {
  width: 180px; height: 3px; margin: 0 auto;
  background: #ffffff1a; border-radius: 999px; overflow: hidden;
}
.splash-bar-fill {
  height: 100%; width: 0%;
  background: var(--brand-accent); border-radius: 999px;
  transition: width .4s cubic-bezier(.22,1,.36,1);
}
.splash-status {
  font-size: .78rem; color: #ffffff80; letter-spacing: .04em;
  min-height: 1.2em;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { transform: scale(.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ---------- Skeletons ---------- */
.skeleton { position: relative; overflow: hidden; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
:root[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; border-radius: 6px; background: var(--line); margin: 8px 0; }
.sk-line.tall { height: 28px; }
.sk-line.w40 { width: 40%; } .sk-line.w50 { width: 50%; }
.sk-line.w70 { width: 70%; } .sk-line.w90 { width: 90%; }
.sk-thumb { width: 64px; height: 64px; border-radius: 12px; background: var(--line); flex: none; }
.sk-chart { height: 150px; border-radius: 10px; background: var(--line); margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }

/* ---------- Global progress bar ---------- */
.progress-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  background: transparent; z-index: 300; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
.progress-bar.active { opacity: 1; }
.progress-bar::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--brand-accent), transparent);
  animation: progress-slide 1.2s infinite;
}
@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---------- View transitions ---------- */
::view-transition-old(root) {
  animation: fade-out .18s cubic-bezier(.22,1,.36,1);
}
::view-transition-new(root) {
  animation: slide-in .22s cubic-bezier(.22,1,.36,1);
}
@keyframes fade-out { to { opacity: 0; } }
@keyframes slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ---------- Empty / error states ---------- */
.empty-state {
  display: grid; place-items: center; gap: 10px;
  padding: 48px 20px; text-align: center;
  color: var(--muted);
}
.empty-icon {
  width: 64px; height: 64px; border-radius: 20px;
  background: var(--bg); display: grid; place-items: center;
  color: var(--muted); margin-bottom: 4px;
}
.empty-icon svg { width: 30px; height: 30px; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.1rem; color: var(--text); }
.empty-state p { font-size: .9rem; max-width: 40ch; }

/* ---------- Pull-to-refresh ---------- */
.ptr-indicator {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%) translateY(-40px);
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-dark); color: var(--brand-on-dark);
  display: grid; place-items: center; font-size: 1rem;
  opacity: 0; transition: transform .15s, opacity .15s;
  z-index: 5; pointer-events: none;
}

/* ---------- Stagger in ---------- */
@keyframes stagger-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main.stagger .grid > *,
.main.stagger .stats > *,
.main.stagger .row-item {
  animation: stagger-in .32s cubic-bezier(.22,1,.36,1) both;
}
.main.stagger .grid > *:nth-child(1)  { animation-delay: 0ms; }
.main.stagger .grid > *:nth-child(2)  { animation-delay: 30ms; }
.main.stagger .grid > *:nth-child(3)  { animation-delay: 60ms; }
.main.stagger .grid > *:nth-child(4)  { animation-delay: 90ms; }
.main.stagger .grid > *:nth-child(5)  { animation-delay: 120ms; }
.main.stagger .grid > *:nth-child(6)  { animation-delay: 150ms; }
.main.stagger .grid > *:nth-child(7)  { animation-delay: 180ms; }
.main.stagger .grid > *:nth-child(8)  { animation-delay: 210ms; }
.main.stagger .grid > *:nth-child(n+9) { animation-delay: 240ms; }
.main.stagger .stats > * { animation-delay: calc(var(--i, 0) * 60ms); }
@media (prefers-reduced-motion: reduce) { .main.stagger * { animation: none !important; } }

/* ---------- Command palette ---------- */
.cmdk-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: grid; place-items: start center; padding-top: 12vh; z-index: 250;
  animation: fadeIn .15s;
}
.cmdk {
  width: min(92vw, 560px); background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden;
  animation: cmdk-in .2s cubic-bezier(.22,1,.36,1);
}
@keyframes cmdk-in { from { transform: scale(.96) translateY(-6px); opacity: 0; } }
.cmdk input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: 16px 18px; font-size: 1rem;
  border-radius: 0; outline: none; min-height: 56px;
}
.cmdk input:focus { box-shadow: none; border-color: var(--line); }
.cmdk-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; background: transparent; text-align: left;
  border-radius: 10px; cursor: pointer; font-weight: 500;
}
.cmdk-item:hover, .cmdk-item.active { background: var(--bg); }
.cmdk-item .ico { width: 20px; height: 20px; color: var(--muted); flex: none; display: grid; place-items: center; }
.cmdk-item .lbl { flex: 1; }
.cmdk-item .hint { color: var(--muted); font-size: .78rem; }
.cmdk-empty { padding: 24px; text-align: center; color: var(--muted); }
.cmdk-footer {
  display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line);
  font-size: .72rem; color: var(--muted); background: var(--bg);
}
.cmdk-footer kbd {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 6px; font-family: ui-monospace, monospace; font-size: .7rem;
}

/* ---------- Offline banner ---------- */
.offline-banner {
  position: fixed; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--low); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-weight: 600; font-size: .85rem; z-index: 190;
  transition: transform .3s cubic-bezier(.22,1,.36,1), opacity .3s, visibility .3s;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
  opacity: 0; visibility: hidden;
}
.offline-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1; visibility: visible;
}
.offline-banner .dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 50% { opacity: .3; } }
@media (min-width: 900px) { .offline-banner { bottom: 24px; } }

/* ---------- Global Route Loader ---------- */
.route-loader {
  position: fixed; inset: 0; 
  z-index: 9999; 
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid; place-items: center;
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}

@media (min-width: 900px) {
  .route-loader { left: 0; }
}

.route-loader.active {
  opacity: 1; visibility: visible;
}

/* The NEW Dual-Ring Spinner */
.route-spinner {
  width: 48px; height: 48px;
  position: relative;
  display: flex; justify-content: center; align-items: center;
}
.route-spinner::before,
.route-spinner::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--brand-accent);
  animation: spin 1s cubic-bezier(.5,0,.5,1) infinite;
}
.route-spinner::before {
  width: 100%; height: 100%;
}
.route-spinner::after {
  width: 70%; height: 70%;
  border-top-color: var(--brand-dark);
  animation-direction: reverse;
  animation-duration: .7s;
}
:root[data-theme="dark"] .route-spinner::after {
  border-top-color: var(--brand-on-dark);
}

@keyframes spin { 
  100% { transform: rotate(360deg); } 
}

::view-transition-group(route-loader) {
  display: none !important;
}

/* ---------- Native-feel Interactions ---------- */
.btn, .pcard, .row-item, .tabbar a {
  -webkit-tap-highlight-color: transparent;
}

/* Slight press-down for cards and rows */
.pcard:active, .row-item:active {
  transform: scale(0.985);
  background: var(--bg);
}

/* Make sure the scan FAB gets a deeper press effect */
.tabbar a:active .fab {
  transform: scale(0.9);
  box-shadow: 0 2px 8px rgba(245,184,0,.3);
}

/* Make html5-qrcode fit perfectly inside the custom card */
#reader video {
  object-fit: cover !important;
  border-radius: 16px;
}
#reader__dashboard_section {
  display: none !important; /* Hides the ugly default HTML5 buttons */
}