:root {
  --bg: #0f1420;
  --surface: #ffffff;
  --ink: #1a2233;
  --muted: #6b7688;
  --line: #e4e8ef;
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --pending: #b45309;
  --pending-bg: #fef3c7;
  --verified: #15803d;
  --verified-bg: #dcfce7;
  --rejected: #b91c1c;
  --rejected-bg: #fee2e2;
  --qualified: #4338ca;
  --qualified-bg: #e0e7ff;
  --disqualified: #9f1239;
  --disqualified-bg: #ffe4e6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f3f5f9;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; }

/* ---- Top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #101a2e; color: #fff; padding: 0 22px; height: 56px;
}
.brand { color: #fff; font-weight: 700; font-size: 17px; display: flex; align-items: baseline; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { color: #4f83f7; }
.brand-mark.big { font-size: 34px; display: block; }
.brand-sub { font-weight: 400; font-size: 12px; color: #9fb0cc; }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a { color: #d5deee; }
.who { color: #9fb0cc; font-size: 12px; }
.inline { display: inline; margin: 0; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 22px 60px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card-title { margin: 0 0 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.stage-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: #eef1f6; border-radius: 999px; padding: 2px 8px; margin-left: 8px; vertical-align: middle; }
.center-card { max-width: 460px; margin: 60px auto; text-align: center; }
.stack > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 18px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 16px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.back { display: inline-block; margin-bottom: 4px; font-size: 13px; }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
  border-left: 4px solid var(--muted); transition: transform .06s ease;
}
.stat-card:hover { text-decoration: none; transform: translateY(-1px); }
.stat-card.active { outline: 2px solid var(--brand); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--ink); }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-pending { border-left-color: var(--pending); }
.stat-verified { border-left-color: var(--verified); }
.stat-rejected { border-left-color: var(--rejected); }
.stat-qualified { border-left-color: var(--qualified); }
.stat-disqualified { border-left-color: var(--disqualified); }

/* ---- Filters ---- */
.filters { padding: 16px 18px; }
/* Even, responsive grid so fields align in tidy columns and never wrap into a
   lopsided second row. Actions sit on their own full-width row, right-aligned. */
.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  align-items: end;
}
.filter-row label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.filter-row input, .filter-row select { width: 100%; min-width: 0; }
.filter-actions {
  grid-column: 1 / -1;
  display: flex; gap: 8px; justify-content: flex-end;
  padding-top: 4px; border-top: 1px solid var(--line);
}

/* ---- Forms ---- */
label { font-size: 13px; color: var(--ink); }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); min-width: 140px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
textarea { width: 100%; resize: vertical; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.stack input, .stack select, .stack textarea { width: 100%; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; padding: 9px 16px;
  font-size: 13px; font-weight: 600; background: #eef1f6; color: var(--ink);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-verify { background: var(--verified); color: #fff; }
.btn-reject { background: var(--rejected); color: #fff; }

/* ---- Table ---- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
table.data th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #f7f9fc; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }
.thumb { width: 74px; height: 40px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); background:#eee; }
.plate {
  font-family: "SF Mono", ui-monospace, Menlo, monospace; font-weight: 700;
  letter-spacing: .04em; background: #f1c40f22; border: 1px solid #d4ac0d55;
  padding: 2px 7px; border-radius: 5px; display: inline-block;
}
.plate-cell .was { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.link { font-weight: 600; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-pending  { background: var(--pending-bg);  color: var(--pending); }
.badge-verified { background: var(--verified-bg); color: var(--verified); }
.badge-rejected { background: var(--rejected-bg); color: var(--rejected); }
.badge-qualified    { background: var(--qualified-bg);    color: var(--qualified); }
.badge-disqualified { background: var(--disqualified-bg); color: var(--disqualified); }
.badge-muted    { background: #eef1f6; color: var(--muted); }

/* ---- Pager ---- */
.pager { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; margin-top: 6px; border-top: 1px solid var(--line); }
.pager-btns { display: flex; gap: 8px; }

/* ---- Detail ---- */
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.photos figcaption { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.photo { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photo.placeholder { display: flex; align-items: center; justify-content: center; height: 130px; color: var(--muted); background: #f3f5f9; }
table.kv { width: 100%; border-collapse: collapse; }
table.kv th { text-align: left; color: var(--muted); font-weight: 500; width: 42%; padding: 7px 8px; vertical-align: top; font-size: 13px; }
table.kv td { padding: 7px 8px; border-bottom: 1px solid #f0f2f6; }
.raw { margin-top: 12px; }
.raw pre { background: #0f1420; color: #cbd5e1; padding: 12px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 240px; }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.review-summary { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; background: #f7f9fc; border: 1px solid var(--line); color: var(--ink); }
.review-summary .note { margin: 6px 0 0; font-style: italic; }
.review-summary.badge-pending { background: var(--pending-bg); border-color: #f3d38a; }
.rs-status { margin-bottom: 10px; }
table.kv.tight th, table.kv.tight td { padding: 4px 6px; font-size: 13px; }

/* Verifier remarks */
.remarks { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.remarks-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.remarks-text { margin: 0; font-style: italic; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }

/* Read-only field inside a form (e.g. camera-owned location) */
.locked-field { display: flex; flex-direction: column; gap: 3px; padding: 9px 10px;
  border: 1px dashed var(--line); border-radius: 8px; background: #f7f9fc; }
.locked-field-label { font-size: 12px; color: var(--muted); }
.locked-field-value { font-weight: 600; color: var(--ink); }
.locked-field-hint { font-size: 11px; color: var(--muted); }

/* Corrections made to camera data */
.edits { border: 1px solid #f3d38a; background: #fffdf6; border-radius: 8px; padding: 10px 12px; }
.edits-title { margin: 0 0 6px; font-size: 13px; color: var(--pending); }
.edits .from { color: var(--rejected); text-decoration: line-through; }
.edits .to { color: var(--verified); font-weight: 700; }
.edits .arrow { color: var(--muted); margin: 0 4px; }
.small { font-size: 12px; }

/* ---- Login ---- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--surface); width: 360px; padding: 32px; border-radius: 16px; box-shadow: 0 10px 40px rgba(16,24,40,.15); }
.login-head { text-align: center; margin-bottom: 20px; }
.login-head h1 { margin: 8px 0 0; }
.login-head p { color: var(--muted); margin: 2px 0 0; }
.login-hint { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); text-align: center; }
.login-hint code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--rejected-bg); color: var(--rejected); }
.alert-success { background: var(--verified-bg); color: var(--verified); }

/* ---- Camera master ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.form-inline-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-inline-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1 1 160px; }
.form-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.btn-danger { background: var(--rejected); color: #fff; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; }

/* ---- Autocomplete (backend location search) ---- */
.ac-wrap { position: relative; width: 100%; }
.ac-wrap input[type=text] { width: 100%; }
.ac-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px);
  margin: 0; padding: 4px; list-style: none; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  max-height: 260px; overflow-y: auto; display: none;
}
.ac-list.open { display: block; }
.ac-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item.active, .ac-item:hover { background: #eef3ff; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
}
