:root {
  --bg: #10141c;
  --bg-2: #171d28;
  --panel: #1d2533;
  --line: #2b3648;
  --text: #e8eef7;
  --muted: #93a0b5;
  --accent: #f0b429;
  --accent-2: #2f9e44;
  --danger: #e03131;
  --warn: #f08c00;
  --info: #4dabf7;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #243044 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: rgba(16, 20, 28, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; }
.brand span { color: var(--accent); }
.mode-pill, .status-pill {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #223049;
  color: var(--muted);
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.nav button, .btn, select, input, textarea {
  font: inherit;
}
.nav button {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.nav button.active, .nav button:hover {
  background: #2a3548;
  border-color: #3c4b64;
}
.btn {
  background: #2a3548;
  color: var(--text);
  border: 1px solid #3c4b64;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--accent); color: #1a1404; border-color: #d59b16; font-weight: 700; }
.btn.good { background: var(--accent-2); color: white; border-color: #2b8a3e; }
.btn.danger { background: var(--danger); color: white; border-color: #c92a2a; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

main { padding: 18px; max-width: 1600px; margin: 0 auto; }
.view h1 { margin: 0 0 8px; font-size: 26px; }
.hint { color: var(--muted); margin: 0 0 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 220px; }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  background: #121823;
  color: var(--text);
  border: 1px solid #334058;
  border-radius: 10px;
  padding: 11px 12px;
}
.scan-input { font-size: 22px; padding: 14px 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }

.table-wrap { overflow: auto; max-height: calc(100vh - 280px); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #2a3548; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #223049; }
tbody tr:hover { background: #243044; }
td.editable { cursor: text; background: #18202c; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.MATCH { background: #25532d; color: #b2f2bb; }
.MISSING { background: #5c1a1a; color: #ffc9c9; }
.EXCESS, .UNEXPECTED { background: #5c3b11; color: #ffec99; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.gate .card { width: min(480px, 100%); }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #132033;
  border: 1px solid #3c4b64;
  padding: 12px 14px;
  border-radius: 10px;
  max-width: 420px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: grid; place-items: center; z-index: 30; padding: 16px;
}
.modal { width: min(1100px, 100%); max-height: 90vh; overflow: auto; }

@media (max-width: 900px) {
  .nav button { padding: 6px 8px; font-size: 13px; }
  .scan-input { font-size: 18px; }
  main { padding: 12px; }
}
