:root {
  --bg: #0b1120;
  --bg-soft: #0f172a;
  --card: #131c31;
  --card-2: #1b2540;
  --border: #25324f;
  --text: #e6edf7;
  --muted: #93a1bd;
  --primary: #4f8cff;
  --primary-700: #2f6ae0;
  --accent: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #16203a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.92rem; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px calc(14px);
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(11,17,32,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: 0.2px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 4px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 16px rgba(79,140,255,0.6);
}
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-email { font-size: 0.8rem; color: var(--muted); max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout */
main { max-width: 680px; margin: 0 auto; padding: 16px; }
.view { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card-head h2 { margin: 0; font-size: 1.15rem; }

/* Banner */
.banner { padding: 12px 16px; font-size: 0.88rem; text-align: center; }
.banner-warn { background: rgba(251,191,36,0.12); color: var(--warn); border-bottom: 1px solid rgba(251,191,36,0.3); }
.banner code { background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 5px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer;
  font-size: 0.95rem; font-weight: 600; border-radius: 12px;
  padding: 11px 16px; color: var(--text); background: var(--card-2);
  transition: transform 0.05s ease, filter 0.15s ease, background 0.15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-700)); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--card-2); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248,113,113,0.4); }
.btn-sm { padding: 7px 11px; font-size: 0.83rem; }
.btn-lg { padding: 14px 18px; font-size: 1.02rem; }
.row { display: flex; gap: 10px; margin-top: 14px; }
.row .btn { flex: 1; }
.file-btn { cursor: pointer; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 11px; padding: 11px 13px; font-size: 1rem; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.msg { font-size: 0.85rem; min-height: 1em; margin: 4px 0 0; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--accent); }

/* Auth */
.auth-card { max-width: 420px; margin: 8vh auto 0; }
.auth-title { margin: 0 0 4px; font-size: 1.5rem; }

/* Camera */
.camera-wrap {
  position: relative; width: 100%; aspect-ratio: 3/4; max-height: 60vh;
  background: #060a14; border-radius: 14px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
#camera, .preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-overlay {
  position: absolute; inset: 0; background: rgba(6,10,20,0.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--text); backdrop-filter: blur(2px);
}
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.18); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pills & lists */
.pill { background: var(--card-2); color: var(--muted); border-radius: 999px; padding: 3px 11px; font-size: 0.8rem; font-weight: 600; }
.item-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.review-row {
  display: grid; grid-template-columns: 1fr 64px 40px; gap: 8px; align-items: center;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 11px; padding: 8px 10px;
}
.review-row input { background: transparent; border: none; color: var(--text); font-size: 0.95rem; width: 100%; }
.review-row input:focus { outline: none; }
.review-row .qty { text-align: center; border-left: 1px solid var(--border); }
.review-row .rm { background: transparent; border: none; color: var(--danger); font-size: 1.1rem; cursor: pointer; }
.conf-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:6px; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; margin: 12px 0; }
.toolbar input, .toolbar select {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 11px; padding: 10px 12px; font-size: 0.95rem;
}
.toolbar input { flex: 1; }

.summary-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.stat { background: var(--card-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; flex: 1; min-width: 90px; }
.stat .num { font-size: 1.3rem; font-weight: 700; }
.stat .lbl { font-size: 0.75rem; color: var(--muted); }

/* Inventory list grouped */
.inv-list { display: flex; flex-direction: column; gap: 18px; }
.inv-group-title { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 2px 8px; }
.inv-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
  transition: border-color 0.15s ease;
}
.inv-item:hover { border-color: var(--primary); }
.inv-thumb { width: 44px; height: 44px; border-radius: 10px; background: var(--card-2); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.inv-main { flex: 1; min-width: 0; }
.inv-name { font-weight: 600; }
.inv-sub { font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-meta { text-align: right; font-size: 0.82rem; color: var(--muted); }
.inv-qty { font-weight: 700; color: var(--text); }

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* Bottom nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: center; gap: 40px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: rgba(11,17,32,0.9); backdrop-filter: blur(12px); border-top: 1px solid var(--border);
}
.nav-btn { background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 0.72rem; cursor: pointer; }
.nav-btn.active { color: var(--primary); }
.nav-ico { font-size: 1.3rem; }
.nav-fab .nav-ico {
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin-top: -22px; box-shadow: 0 6px 18px rgba(79,140,255,0.5); color: #fff;
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(4,8,16,0.7); display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); }
.modal-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px 18px 0 0; padding: 20px; width: 100%; max-width: 520px; box-shadow: var(--shadow); animation: slideup 0.2s ease; }
@media (min-width: 560px) { .modal { align-items: center; } .modal-card { border-radius: 18px; } }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-card h3 { margin: 0 0 14px; }

/* Toast */
.toast { position: fixed; bottom: calc(110px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--card-2); color: var(--text); border: 1px solid var(--border); padding: 11px 18px; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); font-size: 0.9rem; animation: fade 0.2s ease; }

/* Export dropdown */
.export-menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 25; overflow: hidden; min-width: 230px; }
.export-menu button { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text); padding: 11px 14px; font-size: 0.9rem; cursor: pointer; }
.export-menu button:hover { background: var(--card-2); }

.export-sep{height:1px;background:var(--border);margin:5px 0}
.export-label{font-size:.7rem;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);padding:8px 14px 4px}

/* bottomnav 4-tab layout */
.bottomnav{gap:20px}
.bottomnav .nav-btn{min-width:54px}
@media(max-width:420px){.bottomnav{gap:10px}.nav-btn{font-size:.66rem}}

.report-bar{display:flex;align-items:center;justify-content:space-between;gap:10px;background:var(--card-2);border:1px solid var(--border);border-radius:12px;padding:8px 10px 8px 14px;margin-bottom:12px;font-size:.85rem;color:var(--muted)}
.report-bar b{color:var(--text)}
