:root {
  --bg: #0d1017;
  --surface: #161b25;
  --surface-2: #1e2532;
  --border: #2a3140;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --primary: #d4a017;
  --primary-ink: #1a1400;
  --danger: #e5484d;
  --warn: #f2a900;
  --ok: #46b26b;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 40px;
}

/* ------------------------------- Top bar -------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 1.15rem; margin: 0; }
.stats { display: flex; gap: 14px; font-size: .85rem; color: var(--muted); }
.stat b { color: var(--text); font-size: 1rem; }
.stat.warn b { color: var(--warn); }

/* --------------------------------- Tabs --------------------------------- */
.tabs {
  display: flex; gap: 4px; padding: 10px 16px 0;
  max-width: 720px; margin: 0 auto;
}
.tab {
  flex: 1; padding: 12px; border: none; cursor: pointer;
  background: transparent; color: var(--muted);
  font-size: .95rem; font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; max-width: 720px; margin: 0 auto; padding: 16px; }
.tab-panel.active { display: block; }

/* ------------------------------- Buttons -------------------------------- */
.btn {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); padding: 12px 18px; border-radius: var(--radius);
  font-size: 1rem; cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.big { padding: 16px 20px; font-size: 1.05rem; }
.btn:active { transform: translateY(1px); }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }

/* ----------------------------- Scan section ----------------------------- */
.scan-controls { display: flex; gap: 8px; margin-bottom: 12px; }
.scan-controls .btn { flex: 1; }
.reader { border-radius: var(--radius); overflow: hidden; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: .85rem; text-align: center; margin: 8px 0; }

.manual-form label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.two { gap: 12px; }
.row.two > label { flex: 1; }
input, select {
  width: 100%; padding: 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1rem;
}
.manual-form .row input { flex: 1; }

/* ------------------------------ Result cards ---------------------------- */
.result-card {
  margin-top: 18px; padding: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.result-head { display: flex; justify-content: space-between; align-items: center; }
.result-card h2 { margin: 6px 0; }
.muted { color: var(--muted); font-size: .9rem; }
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: var(--surface-2);
  color: var(--primary); border: 1px solid var(--border);
}
.badge.new { color: var(--ok); }
.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.qty-row .btn { flex: 1; }
.qty { font-size: 2rem; font-weight: 800; min-width: 60px; text-align: center; }

#new-form label, #edit-form label { display: block; margin-top: 12px; color: var(--muted); font-size: .85rem; }
#new-form input, #new-form select { margin-top: 4px; }

/* ------------------------------- Inventory ------------------------------ */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.checkbox { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.checkbox input { width: auto; }
#filter-type { flex: 1; }

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.card.low { border-color: var(--warn); }
.card-main { flex: 1; min-width: 0; }
.card-main .name { font-weight: 700; }
.card-main .meta { color: var(--muted); font-size: .8rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.low-tag { color: var(--warn); font-weight: 700; }
.card-qty { display: flex; align-items: center; gap: 8px; }
.card-qty .num { font-weight: 800; font-size: 1.2rem; min-width: 26px; text-align: center; }
.round { width: 34px; height: 34px; border-radius: 50%; padding: 0; font-size: 1.2rem; line-height: 1; }
.card-actions { display: flex; gap: 4px; }

/* -------------------------------- Modal --------------------------------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px;
}
.modal-actions { margin-top: 18px; justify-content: flex-end; }

/* -------------------------------- Toast --------------------------------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); color: var(--text);
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--border);
  font-size: .9rem; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

.hidden { display: none !important; }
