/* ============================================================
   BarcodeDesk — inventory & barcode console
   Design: industrial equipment-panel aesthetic. Dark console body,
   amber LED accent (echoes the datasheet stickers this tool reads),
   monospace for codes/numbers, clean grotesque for UI chrome.
   ============================================================ */

:root {
  --bg: #15181c;
  --panel: #1c2026;
  --panel-raised: #23282f;
  --line: #333a42;
  --line-soft: #272d34;
  --text: #e8e6df;
  --text-dim: #9aa0a8;
  --text-faint: #5b626b;
  --amber: #e8a23d;
  --amber-dim: #a97524;
  --green: #5fb87a;
  --red: #d9634f;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
  --sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.025) 1px, transparent 0);
  background-size: 22px 22px;
}

a { color: var(--amber); text-decoration: none; }

::selection { background: var(--amber); color: #15181c; }

/* ---------- Layout shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 8px 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.brand .mark {
  width: 10px;
  height: 10px;
  background: var(--amber);
  border-radius: 1px;
  box-shadow: 0 0 8px rgba(232,162,61,0.6);
  flex-shrink: 0;
}

.brand .name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand .name small {
  display: block;
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 400;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: var(--panel-raised); color: var(--text); }

.nav-item.active {
  background: var(--panel-raised);
  color: var(--amber);
  border-left-color: var(--amber);
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--line-soft);
  line-height: 1.6;
}

.main {
  padding: 28px 36px 60px;
  max-width: 1180px;
}

.view { display: none; }
.view.active { display: block; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.page-head .sub {
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: border-color 0.12s, background 0.12s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--text-faint); background: #282e36; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #1a1407;
  font-weight: 600;
}
.btn-primary:hover { background: #f0ad52; border-color: #f0ad52; }

.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel-raised); }

.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------- Cards / panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.panel + .panel { margin-top: 16px; }

.panel-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin: 0 0 16px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ---------- Stat tiles ---------- */

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat-tile .label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.stat-tile .value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.stat-tile .value.amber { color: var(--amber); }
.stat-tile .value.green { color: var(--green); }
.stat-tile .value.red { color: var(--red); }

/* ---------- Forms ---------- */

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: var(--sans);
  margin-bottom: 14px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--amber-dim);
}

input::placeholder { color: var(--text-faint); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.mono-input { font-family: var(--mono); }

/* ---------- Upload / photo zone ---------- */

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  color: var(--text-dim);
  font-size: 13px;
}

.dropzone:hover { border-color: var(--amber-dim); background: rgba(232,162,61,0.03); }
.dropzone.has-image { padding: 10px; }

.dropzone svg { width: 28px; height: 28px; margin-bottom: 10px; opacity: 0.6; }

.preview-img {
  max-width: 100%;
  max-height: 260px;
  border-radius: var(--radius);
  display: block;
  margin: 0 auto;
}

.cam-video, .cam-canvas {
  width: 100%;
  border-radius: var(--radius);
  background: #000;
}

/* ---------- Table ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,0.015); }
.table-wrap { overflow-x: auto; }

.mono-cell { font-family: var(--mono); font-size: 13px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
}
.badge.ok { background: rgba(95,184,122,0.15); color: var(--green); }
.badge.low { background: rgba(217,99,79,0.15); color: var(--red); }
.badge.mid { background: rgba(232,162,61,0.15); color: var(--amber); }

/* ---------- Barcode display ---------- */

.barcode-stage {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.barcode-stage svg { max-width: 100%; height: auto; }

/* ---------- Matches list (tally search results) ---------- */

.match-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.match-item:hover { border-color: var(--amber-dim); background: rgba(232,162,61,0.04); }
.match-item .mname { font-weight: 600; font-size: 13.5px; }
.match-item .mmeta { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); margin-top: 3px; }
.match-item .mqty { text-align: right; font-family: var(--mono); color: var(--amber); font-size: 13px; }

/* ---------- Toast ---------- */

#toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  min-width: 240px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  animation: toast-in 0.18s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10,11,13,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
}
.modal-box h3 { margin-top: 0; font-size: 16px; }

/* ---------- Wizard steps ---------- */

.steps-row {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.step-pill {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-raised);
  color: var(--text-faint);
  border: 1px solid var(--line);
}
.step-pill.active { color: var(--amber); border-color: var(--amber-dim); }
.step-pill.done { color: var(--green); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-faint);
  font-size: 13.5px;
}
.empty-state svg { width: 36px; height: 36px; opacity: 0.4; margin-bottom: 12px; }

.scanner-wrap {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
}
.scanner-wrap video { width: 100%; border-radius: var(--radius); }
.scan-reticle {
  position: absolute;
  top: 40%; left: 10%; right: 10%;
  height: 20%;
  border: 2px solid var(--amber);
  border-radius: 4px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);
}

.hint { font-size: 12px; color: var(--text-faint); margin-top: -8px; margin-bottom: 14px; }

.kv-list { font-size: 13px; }
.kv-list .row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.kv-list .row .k { color: var(--text-dim); }
.kv-list .row .v { font-family: var(--mono); color: var(--text); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-direction: row; overflow-x: auto; padding: 10px; }
  .brand { display: none; }
  .nav-item { white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .nav-item.active { border-bottom-color: var(--amber); }
  .main { padding: 18px; }
  .field-row, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
