:root {
  --bg: #0b0d12;
  --bg-soft: #11141b;
  --panel: #161a23;
  --panel-2: #1c2230;
  --border: #242a38;
  --border-strong: #323a4d;
  --text: #ecf0f8;
  --muted: #8b94aa;
  --muted-2: #5a6175;
  --accent: #6aa6ff;
  --accent-2: #b48bff;
  --accent-grad: linear-gradient(135deg, #6aa6ff 0%, #b48bff 100%);
  --ok: #4adf9a;
  --warn: #ffc857;
  --err: #ff6b7a;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.02) inset;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; line-height: 1.45; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem;
  background: linear-gradient(180deg, rgba(11,13,18,0.95) 0%, rgba(11,13,18,0.75) 100%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 600; letter-spacing: .01em; flex: 1; }
.logo-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent-grad); box-shadow: 0 0 12px rgba(106, 166, 255, 0.6); }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .65rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; font-size: .78rem; color: var(--muted);
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); transition: background .25s, box-shadow .25s; }
.pill.ok { color: var(--ok); border-color: rgba(74, 223, 154, 0.4); }
.pill.ok .pill-dot { background: var(--ok); box-shadow: 0 0 10px rgba(74, 223, 154, 0.6); }
.pill.bad { color: var(--err); border-color: rgba(255, 107, 122, 0.4); }
.pill.bad .pill-dot { background: var(--err); }
.iconbtn {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
}
.iconbtn:hover { color: var(--text); border-color: var(--border-strong); }
form { margin: 0; }

/* ── Layout ────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: calc(1rem + var(--safe-bottom));
}
@media (min-width: 880px) {
  .layout { grid-template-columns: 360px 1fr; align-items: start; }
  .controls { position: sticky; top: 70px; }
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1rem .9rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: .9rem; }
.card h2 { margin: 0 0 .65rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }

/* ── Segmented radios ──────────────────────────────────── */
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg label { position: relative; display: flex; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span {
  flex: 1; text-align: center; padding: .65rem .35rem;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 500; color: var(--muted);
  transition: all .15s ease;
}
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg input:checked + span {
  color: var(--text); background: var(--panel-2);
  border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, 0 4px 12px rgba(106, 166, 255, 0.18);
}

/* ── Action card ───────────────────────────────────────── */
.actions { display: flex; flex-direction: column; gap: .65rem; }
.btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  width: 100%; padding: .95rem 1rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text);
  font-weight: 600; cursor: pointer; transition: transform .05s ease, filter .15s ease, box-shadow .15s ease;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(.99); }
.btn.primary {
  background: var(--accent-grad); border: none; color: white;
  box-shadow: 0 8px 24px rgba(106, 166, 255, 0.28);
}
.btn.primary:not(:disabled):hover { filter: brightness(1.07); box-shadow: 0 10px 28px rgba(106, 166, 255, 0.38); }
.btn .btn-label { font-size: 1.02rem; letter-spacing: .01em; }
.btn .btn-sub { font-size: .72rem; opacity: .75; font-weight: 500; }
.btn.ghost { background: transparent; }
.btn.ghost:not(:disabled):hover { border-color: var(--accent); color: var(--accent); }

.or { display: flex; align-items: center; gap: .6rem; color: var(--muted-2); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.upload-drop {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: 1.1rem;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.upload-drop:hover { border-color: var(--accent); background: rgba(106, 166, 255, 0.04); }
.upload-icon { width: 32px; height: 32px; color: var(--muted); }
.upload-drop:hover .upload-icon { color: var(--accent); }
.upload-text { font-size: .9rem; color: var(--muted); }
.upload-file { font-size: .78rem; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Results ───────────────────────────────────────────── */
.results { display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.results-head { display: flex; align-items: center; justify-content: space-between; padding: 0 .25rem; }
.results-head h2 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .8rem; padding: .25rem .4rem; }
.link:hover { color: var(--text); }

.results-list { display: flex; flex-direction: column; gap: .9rem; }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: .7rem;
  padding: 2.5rem 1.2rem;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.empty-icon { width: 72px; height: auto; color: var(--accent); opacity: .9; filter: drop-shadow(0 4px 12px rgba(106, 166, 255, 0.25)); }

/* ── Result card ───────────────────────────────────────── */
.result-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: card-in .3s ease both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-plate {
  display: grid;
  grid-template-columns: 1fr;
  gap: .9rem;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(106, 166, 255, 0.06), rgba(180, 139, 255, 0.04));
  border-bottom: 1px solid var(--border);
}
@media (min-width: 520px) {
  .result-plate { grid-template-columns: minmax(160px, 38%) 1fr; align-items: center; }
}
.plate-crop {
  width: 100%; height: auto; max-height: 160px; object-fit: contain;
  background: #000; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
}
.plate-text-wrap { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
.plate-text {
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--text);
  word-break: break-all;
  line-height: 1.1;
}
.plate-meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .22rem .55rem;
  border-radius: 999px;
  font-size: .72rem; font-weight: 600;
  background: var(--bg-soft); color: var(--muted);
  border: 1px solid var(--border);
}
.badge.country { color: var(--accent); border-color: rgba(106, 166, 255, 0.4); }
.badge.pos    { color: var(--ok);    border-color: rgba(74, 223, 154, 0.4); }
.badge.char   { color: var(--warn);  border-color: rgba(255, 200, 87, 0.4); }

.result-source {
  display: flex; flex-direction: column; gap: .65rem;
  padding: .9rem 1rem 1rem;
}
.source-img {
  width: 100%; height: auto; max-height: 420px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #000; object-fit: contain;
  cursor: zoom-in;
  transition: filter .15s ease;
}
.source-img:hover { filter: brightness(1.05); }
.source-meta { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.tag {
  font-size: .72rem; padding: .18rem .5rem;
  background: var(--bg-soft); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.tag.time { color: var(--text); }
.noplate-msg { font-weight: 600; color: var(--err); width: 100%; margin-bottom: .2rem; }
.result-card.noplate { border-color: rgba(255, 107, 122, 0.35); }
.result-card.noplate .result-source { padding-top: 1rem; }

/* ── Login ────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top right, rgba(106,166,255,0.12), transparent 50%), radial-gradient(circle at bottom left, rgba(180,139,255,0.10), transparent 50%), var(--bg); padding: 1rem; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem 1.75rem; width: min(380px, 100%); box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 1.4rem; font-size: 1.3rem; }
.login-card label { display: block; margin-bottom: 1rem; color: var(--muted); font-size: .85rem; }
.login-card input {
  display: block; width: 100%; margin-top: .35rem;
  padding: .7rem .8rem;
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(106, 166, 255, 0.2); }
.login-card button {
  width: 100%; padding: .8rem;
  background: var(--accent-grad); color: white; border: none; border-radius: var(--radius-sm);
  font-weight: 600; cursor: pointer; font-size: 1rem;
  box-shadow: 0 8px 20px rgba(106, 166, 255, 0.25);
}
.login-card button:hover { filter: brightness(1.08); }

/* ── Plate crop clickable ──────────────────────────────── */
.plate-crop { cursor: zoom-in; transition: filter .15s ease; }
.plate-crop:hover { filter: brightness(1.07); }

/* ── Lightbox ──────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center; justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  cursor: zoom-out;
  animation: fade-in .18s ease both;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.lightbox-close {
  position: absolute; top: 1rem; right: 1rem;
  background: rgba(255,255,255,0.1); color: white;
  border: none; width: 40px; height: 40px; border-radius: 50%;
  font-size: 1.4rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.2); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Mobile niceties ───────────────────────────────────── */
@media (max-width: 879px) {
  .layout { padding: .75rem; gap: .75rem; }
  .card { padding: .9rem; }
  .card + .card { margin-top: .75rem; }
  .topbar { padding: .65rem .85rem; }
  .pill { padding: .26rem .55rem; }
}
