:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --border: #2c3640;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #2f81f7;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

h1 { font-size: 1.2rem; }
h2 { font-size: 1rem; color: var(--muted); margin-bottom: 8px; }

.badge {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.badge.off { color: var(--muted); }
.badge.on { color: var(--ok); border-color: var(--ok); }
.badge.busy { color: var(--warn); border-color: var(--warn); }

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.video-wrap {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
video, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#flash {
  position: absolute;
  inset: 0;
  background: var(--ok);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
#flash.active { opacity: 0.35; transition: none; }

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.controls select { flex: 1; min-width: 160px; }

select, input, button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
}
button { cursor: pointer; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); }

.settings {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.settings summary { cursor: pointer; color: var(--muted); }
.settings label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.settings input, .settings select { max-width: 200px; }

.log ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.log li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
}
.plate {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  background: #fff;
  color: #111;
  border: 2px solid #111;
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
}
.log .meta { flex: 1; color: var(--muted); }
.log .meta strong { color: var(--text); }
.tag { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; }
.tag.saved { background: rgba(63, 185, 80, 0.15); color: var(--ok); }
.tag.dup { background: rgba(210, 153, 34, 0.15); color: var(--warn); }
.tag.err { background: rgba(248, 81, 73, 0.15); color: var(--err); }

.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 6px 12px;
  font-size: 0.9rem;
}
.tab.active {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
}

.history-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.history-actions { display: flex; gap: 8px; }
.history-status { color: var(--muted); padding: 12px 0; }

.history-list { list-style: none; display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.history-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.history-list img {
  width: 110px;
  height: 74px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  flex-shrink: 0;
  cursor: pointer;
}
.history-list .no-photo {
  width: 110px;
  height: 74px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.4rem;
  flex-shrink: 0;
}
.history-list .info { flex: 1; min-width: 0; }
.history-list .line1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.history-list .vehicle { font-weight: 600; }
.history-list .line2 {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 6px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 12px;
  border-top: 1px solid var(--border);
}
