/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2e3350;
  --green:     #22c55e;
  --green-dim: #166534;
  --red:       #ef4444;
  --red-dim:   #7f1d1d;
  --blue:      #3b82f6;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --radius:    10px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 2rem;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green);
}

.logo svg { width: 28px; height: 28px; }

.header-time {
  font-size: .95rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── Stats bar ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.2rem 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  text-align: center;
  transition: border-color .2s;
}

.stat-card:hover { border-color: var(--blue); }

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
}

.stat-label {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .4rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Video feeds ── */
.feeds {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0 2rem 1rem;
}

.feed-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.feed-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.dot.green { background: var(--green); box-shadow: 0 0 0 0 var(--green); }
.dot.red   { background: var(--red);   box-shadow: 0 0 0 0 var(--red); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.6); }
  70%  { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.video-feed {
  width: 100%;
  display: block;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: #000;
}

/* ── Manual panel ── */
.manual-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0 2rem 1rem;
}

.manual-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}

.manual-card h3 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .7rem;
}

.input-row {
  display: flex;
  gap: .5rem;
}

.input-row input {
  flex: 1;
  padding: .5rem .8rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .95rem;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.input-row input:focus {
  outline: none;
  border-color: var(--blue);
}

.btn {
  padding: .5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}

.btn:hover { opacity: .85; }

.btn.green  { background: var(--green);  color: #fff; }
.btn.red    { background: var(--red);    color: #fff; }
.btn.yellow { background: #f59e0b;       color: #fff; }

.feed-wrap {
  position: relative;
}

.exit-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.65);
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  pointer-events: none;
}

.cam-controls-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.cam-status-pill {
  margin-left: auto;
  padding: .25rem .85rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  background: #22c55e;
  color: #fff;
}

.manual-msg {
  margin-top: .5rem;
  font-size: .82rem;
  min-height: 1.2rem;
  color: var(--muted);
}

/* ── Tables ── */
.tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0 2rem;
}

/* active vehicles spans full width */
.tables > .table-box:first-child {
  grid-column: 1 / -1;
}

.table-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .7rem 1rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  font-weight: 600;
}

.badge {
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
}

.badge.green { background: var(--green-dim); color: var(--green); }
.badge.red   { background: var(--red-dim);   color: var(--red); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}

th {
  padding: .55rem .9rem;
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: .55rem .9rem;
  border-bottom: 1px solid rgba(46,51,80,.5);
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

.plate-cell {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  color: var(--green);
  letter-spacing: .1em;
}

.status-pill {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 700;
}

.pill-in  { background: var(--green-dim); color: var(--green); }
.pill-out { background: #1e293b;          color: var(--muted); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem !important;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .stats-bar, .feeds, .manual-panel { grid-template-columns: 1fr 1fr; }
  .tables { grid-template-columns: 1fr; }
  .tables > .table-box:first-child { grid-column: 1; }
}

@media (max-width: 560px) {
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .feeds, .manual-panel { grid-template-columns: 1fr; }
}
