:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f2630;
  --border: #2d333b;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #4493f8;
  --safe: #3fb950;
  --unsafe: #f85149;
  --warn: #d29922;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Brand */
.brand { font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--unsafe); display: inline-block; }
.brand-sub { color: var(--text-dim); font-weight: 400; font-size: 13px; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px;
}
.auth-card .brand { margin-bottom: 22px; }
.tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; margin-bottom: 20px; }
.tab { flex: 1; padding: 8px; border: 0; background: transparent; color: var(--text-dim); border-radius: 6px; }
.tab.active { background: var(--surface-2); color: var(--text); }
.auth-card label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 4px; }
.primary {
  width: 100%; margin-top: 18px; background: var(--accent); border: 0;
  color: #fff; font-weight: 600; padding: 11px; border-radius: 8px;
}
.primary:hover { filter: brightness(1.1); }
.error { color: var(--unsafe); font-size: 13px; margin-top: 10px; }
.hint { color: var(--text-dim); font-size: 13px; margin-top: 10px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar select { width: auto; padding: 7px 10px; }
.user-email { color: var(--text-dim); font-size: 13px; }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 7px 14px; border-radius: 8px; }
.ghost:hover { background: var(--surface-2); }

/* Library grid */
main { padding: 24px; max-width: 1200px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card video { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: #000; display: block; pointer-events: none; }
.card-body { padding: 12px 14px; }
.card-title { font-size: 13px; color: var(--text-dim); }
.badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.4px; }
.badge.unsafe { background: rgba(248, 81, 73, 0.18); color: var(--unsafe); }
.badge.safe { background: rgba(63, 185, 80, 0.15); color: var(--safe); }
.badge.review { background: rgba(210, 153, 34, 0.15); color: var(--warn); }
.badge.unanalyzed { background: var(--surface-2); color: var(--text-dim); }
.badge.no_vehicles { background: var(--surface-2); color: var(--text-dim); }
.badge.plate { background: rgba(68, 147, 248, 0.15); color: var(--accent); font-family: ui-monospace, monospace; }
.badge.tag { background: var(--surface-2); color: var(--text); font-weight: 500; }
.vehicle-row .makemodel { color: var(--text); font-weight: 500; }
.badge.reviewed { background: var(--surface-2); color: var(--text-dim); }
.score { font-size: 12px; color: var(--text-dim); font-family: ui-monospace, monospace; }
.empty { color: var(--text-dim); text-align: center; margin-top: 80px; }

/* Detail */
.detail { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
.detail-title { color: var(--text-dim); font-size: 14px; }
.player-col video { width: 100%; border-radius: var(--radius); background: #000; }
.meta-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.meta-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.meta-label { font-size: 11px; color: var(--text-dim); }
.meta-value { font-size: 19px; font-weight: 600; margin-top: 2px; }
.meta-value.small { font-size: 13px; word-break: break-all; }
#vehicle-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.vehicle-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; display: flex; align-items: center; gap: 12px; font-size: 13px;
}
.vehicle-row .plate { font-family: ui-monospace, monospace; color: var(--accent); font-weight: 700; }
.vehicle-thumb { width: 88px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; }
.vehicle-thumb-empty { display: inline-flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 11px; background: var(--surface-2); }
.badge.human-safe { background: #123c2a; color: #4ade80; }
.badge.human-unsafe { background: #4a1518; color: #ff9c9f; }
.vehicle-row .behaviors { color: var(--warn); }
.vehicle-row .speeds { color: var(--text-dim); margin-left: auto; font-family: ui-monospace, monospace; }

/* Review column */
.review-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; position: sticky; top: 80px; }
.review-col h3 { font-size: 13px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin: 18px 0 8px; }
.review-col h3:first-child { margin-top: 0; }
.plate-candidates { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.plate-chip {
  font-family: ui-monospace, monospace; font-size: 13px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 4px 10px; border-radius: 6px;
}
.plate-chip:hover, .plate-chip.selected { border-color: var(--accent); color: var(--accent); }
#plate-input { font-family: ui-monospace, monospace; letter-spacing: 1px; text-transform: uppercase; }
.verdict-row { display: flex; gap: 8px; }
.verdict { flex: 1; padding: 12px 6px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); font-weight: 600; }
.verdict.selected.unsafe, .verdict.unsafe:hover { background: rgba(248,81,73,0.18); border-color: var(--unsafe); color: var(--unsafe); }
.verdict.selected.safe, .verdict.safe:hover { background: rgba(63,185,80,0.15); border-color: var(--safe); color: var(--safe); }
.verdict.selected.inconclusive, .verdict.inconclusive:hover { background: rgba(210,153,34,0.15); border-color: var(--warn); color: var(--warn); }
.existing-review { margin-top: 16px; padding: 12px; background: var(--surface-2); border-radius: 8px; font-size: 13px; color: var(--text-dim); }

@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .review-col { position: static; }
  .meta-cards { grid-template-columns: repeat(2, 1fr); }
}
