/* CraftStock — mobile-first */
:root {
  --bg: #14161f;
  --panel: #1e2130;
  --panel2: #262a3d;
  --text: #e8eaf2;
  --muted: #9aa0b5;
  --accent: #5eead4;
  --accent-dark: #14b8a6;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #4ade80;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 12px calc(76px + env(safe-area-inset-bottom));
}
h1 { font-size: 1.3rem; margin: 8px 0 12px; }
h2 { font-size: 1.05rem; margin: 18px 0 8px; color: var(--muted); }
a { color: var(--accent); text-decoration: none; }

/* bottom nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: var(--panel);
  border-top: 1px solid #2e3350;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
}
.bottomnav a {
  color: var(--muted); font-size: 0.72rem; text-align: center;
  display: flex; flex-direction: column; gap: 2px; min-width: 64px;
  padding: 4px 0;
}
.bottomnav a.active { color: var(--accent); }
.nav-ico { font-size: 1.25rem; line-height: 1; }

/* cards, panels */
.card {
  background: var(--panel); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 0.85rem; }
.right { text-align: right; }

/* forms */
label { display: block; font-size: 0.8rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid #333952; background: var(--panel2);
  color: var(--text); font-size: 1rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-dark); }
.field-pair { display: flex; gap: 8px; }
.field-pair > div { flex: 1; }

/* buttons */
button, .btn {
  display: inline-block; border: 0; border-radius: 10px;
  padding: 12px 18px; font-size: 1rem; font-weight: 600;
  background: var(--accent-dark); color: #04211c; cursor: pointer;
}
button.secondary, .btn.secondary { background: var(--panel2); color: var(--text); }
button.danger { background: var(--danger); color: #2b0606; }
button.small { padding: 6px 12px; font-size: 0.85rem; border-radius: 8px; }
button:disabled { opacity: 0.5; }
.btn-block { width: 100%; margin-top: 12px; }

/* scan screen */
.scanwrap { position: relative; border-radius: var(--radius); overflow: hidden;
  background: #000; aspect-ratio: 3 / 4; max-height: 56dvh; }
#scanner-video, #html5qr-region, #html5qr-region video {
  width: 100%; height: 100%; object-fit: cover; }
.scan-reticle {
  position: absolute; inset: 18% 12%; border: 2px solid rgba(94,234,212,.7);
  border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0,0,0,.25);
}
.modetoggle { display: flex; background: var(--panel); border-radius: 10px;
  padding: 4px; margin: 10px 0; }
.modetoggle button { flex: 1; background: transparent; color: var(--muted); }
.modetoggle button.on-add { background: var(--accent-dark); color: #04211c; }
.modetoggle button.on-use { background: var(--warn); color: #3b2a03; }
.feed-item { display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid #2b3049; }
.feed-item:last-child { border-bottom: 0; }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom));
  background: var(--panel2); color: var(--text);
  border: 1px solid #3a4062; border-radius: 10px;
  padding: 10px 16px; z-index: 100; max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); text-align: center;
}
.toast.ok { border-color: var(--ok); }
.toast.warn { border-color: var(--warn); }
.toast.err { border-color: var(--danger); }

/* catalog */
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px;
  margin-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px;
  background: var(--panel); color: var(--muted); font-size: 0.82rem;
  border: 1px solid #2e3350; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent-dark); color: #04211c; border-color: transparent; }
.thumb {
  width: 52px; height: 52px; border-radius: 8px; object-fit: cover;
  background: var(--panel2); flex: 0 0 52px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 1.4rem;
}
.qty { font-size: 1.15rem; font-weight: 700; min-width: 44px; text-align: center; }
.qty.low { color: var(--warn); }
.qty.zero { color: var(--danger); }

/* dashboard */
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--panel); border-radius: var(--radius);
  padding: 12px; text-align: center; }
.stat .num { font-size: 1.5rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.swatch { width: 16px; height: 16px; border-radius: 4px; flex: 0 0 16px;
  border: 1px solid #444; }
.offline-note { background: #3b2a03; color: var(--warn);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--panel); width: 100%; max-width: 640px;
  border-radius: 16px 16px 0 0; padding: 16px;
  max-height: 92dvh; overflow-y: auto;
}
@media (min-width: 700px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 16px; }
}
.banner {
  background: #10324b; border: 1px solid #1f6091; color: #9ed4ff;
  border-radius: 10px; padding: 10px 14px; margin: 10px 0; font-size: 0.9rem;
}
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid #3a4062; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: -4px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* transactions table */
.txlist { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.txlist td { padding: 7px 4px; border-bottom: 1px solid #2b3049; }
.delta-pos { color: var(--ok); font-weight: 700; }
.delta-neg { color: var(--danger); font-weight: 700; }

/* login */
.login-box { max-width: 380px; margin: 12dvh auto 0; }
.error { color: var(--danger); margin: 8px 0; }
