:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e6e8ec;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

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

.side {
  background: #101828;
  color: #e5e7eb;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side .brand {
  font-weight: 700;
  font-size: 17px;
  padding: 8px 12px 18px;
  color: #fff;
}

.side a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.side a:hover { background: rgba(255, 255, 255, .08); }
.side a.active { background: var(--brand); color: #fff; }

.main { padding: 24px 28px; max-width: 1180px; width: 100%; }

.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-bottom: 16px; }
.topbar a { color: var(--brand); font-size: 14px; }
.topbar .ghost { padding: 6px 12px; font-size: 13px; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .06);
}
.login-error { color: var(--red); font-size: 13px; }

#camera-box video { border-radius: 10px; max-width: 100%; }

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 22px 0 10px; }

.sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

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

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

.stat { font-size: 30px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; }

input, select, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
}

input, select { padding: 9px 11px; width: 100%; background: #fff; }
input:focus { outline: 2px solid var(--brand); border-color: transparent; }

button {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 9px 15px;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: var(--brand-dark); }
button.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--red); }

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar input { font-size: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: #fafbfc; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2ff;
  color: var(--brand);
}
.tag.green { background: #ecfdf5; color: var(--green); }
.tag.amber { background: #fffbeb; color: var(--amber); }
.tag.red { background: #fef2f2; color: var(--red); }
.tag.gray { background: #f3f4f6; color: var(--muted); }

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

.scan-hero { padding: 24px; text-align: center; }
.scan-hero input { font-size: 20px; text-align: center; padding: 14px; max-width: 520px; margin: 0 auto; }
.scan-result { margin-top: 18px; text-align: left; }

.loc-code { font-family: "Consolas", monospace; font-weight: 700; color: var(--brand); }

.thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; background: #f3f4f6; }

.muted { color: var(--muted); }
.mono { font-family: "Consolas", monospace; }
.mt { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #101828;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: all .2s;
  z-index: 99;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; }
  .side .brand { padding: 8px 12px; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
