:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --ink: #1c1c1e;
  --ink-secondary: #6c6c70;
  --ink-muted: #8e8e93;
  --line: #e3e3e8;
  --in: #16794a;
  --out: #b3261e;
  --pending: #8a5a00;
  --accent: #16794a;
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --ink: #f2f2f7;
    --ink-secondary: #a1a1a6;
    --ink-muted: #8e8e93;
    --line: #2c2c2e;
    --in: #40c463;
    --out: #f85149;
    --pending: #e3a008;
    --accent: #40c463;
  }
}

* { box-sizing: border-box; }

/* An author `display` rule beats the UA stylesheet's [hidden] { display: none },
   so anything toggled via the hidden attribute needs this to actually hide. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 24px 16px 64px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 640px; margin: 0 auto; }
main.wide { max-width: 900px; }

h1 { font-size: 1.9rem; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 1rem; margin: 0 0 2px; color: var(--ink-secondary); font-weight: 600; }

.muted { color: var(--ink-muted); font-size: 0.85rem; margin: 2px 0 0; }
.error { color: var(--out); font-size: 0.85rem; }
.success { color: var(--in); font-size: 0.85rem; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.head-actions { display: flex; gap: 0.5rem; align-items: center; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: default; }

button.ghost {
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid var(--line);
  padding: 7px 14px;
  font-size: 0.85rem;
}

button.danger { color: var(--out); }
button.small { padding: 6px 12px; font-size: 0.8rem; }

.gate { min-height: 80vh; display: grid; place-items: center; }

.gate-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 0.8rem; font-weight: 600; color: var(--ink-secondary); }

.gate-card input, .card input {
  font: inherit;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.otp-input { letter-spacing: 0.4em; font-size: 1.3rem; text-align: center; font-variant-numeric: tabular-nums; }

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
}
.qr-box img { width: 200px; height: 200px; border-radius: 8px; background: #fff; padding: 8px; }
.qr-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  word-break: break-all;
  text-align: center;
  color: var(--ink-secondary);
  user-select: all;
}

/* --------------------------------------------------------------- plates */

.plate-list { display: flex; flex-direction: column; gap: 0; }

.plate-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.plate-row:last-child { border-bottom: 0; }

.plate-flag {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  background: var(--bg);
}

.plate-main { flex: 1 1 auto; min-width: 0; }

.plate-country {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

/* Vector reproductions of each country's real plate format: correct
   proportions, the actual EU band (blue, 12-star ring, national letter)
   where a country really carries one, plate-style condensed lettering, and
   a couple of bolt-holes for texture. Not photographs — real plates vary too
   much in angle/wear/lighting to read cleanly at list-row size, and photos
   scraped from random sources would be inconsistent and copyright-murky for
   no visual benefit here. */

.plate-graphic {
  display: inline-flex;
  align-items: stretch;
  height: 42px;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid #161616;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  max-width: 100%;
}

.plate-band {
  flex: 0 0 auto;
  width: 30px;
  background: #003399; /* EU flag reflex blue */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 1px;
}

.plate-band.plain {
  background: #eeeeee;
  border-right: 2px solid #161616;
}

.plate-stars { width: 15px; height: 15px; flex: 0 0 auto; }

.plate-band-code {
  color: #fff;
  font-weight: 800;
  font-size: 0.46rem;
  letter-spacing: 0.02em;
  line-height: 1;
  text-align: center;
}

.plate-band.plain .plate-band-code { color: #161616; font-size: 0.56rem; }

.plate-code-box {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-family: 'Arial Narrow', 'Helvetica Neue Condensed', 'Oswald', Impact, sans-serif;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: 0.1em;
  color: #0c0c0c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  background-color: #ffffff;
  /* Two faint bolt-holes near the top edge, like a real fixed plate. */
  background-image:
    radial-gradient(circle 1.5px at 12px 7px, rgba(0, 0, 0, 0.32), transparent 1.7px),
    radial-gradient(circle 1.5px at calc(100% - 12px) 7px, rgba(0, 0, 0, 0.32), transparent 1.7px);
}

.plate-graphic.bg-yellow .plate-code-box { background-color: #ffd200; }

.plate-checked-at {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.plate-others {
  font-size: 0.68rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

.plate-check {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.plate-check.checked { border-color: var(--in); background: color-mix(in srgb, var(--in) 15%, transparent); color: var(--in); font-weight: 800; }

.progress-line { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.progress-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); }

/* --------------------------------------------------------------- admin */

.table-scroll { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-muted); font-weight: 600; font-size: 0.8rem; }
tbody tr:last-child td { border-bottom: 0; }

.status { font-variant-caps: all-small-caps; letter-spacing: 0.04em; font-weight: 600; }
.status-active { color: var(--in); }
.status-used, .status-none { color: var(--ink-muted); }
.status-expired { color: var(--pending); }
.status-disabled { color: var(--out); }

.card.highlight { border: 1px solid var(--pending); }

.code-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  margin: 0.4rem 0 0.8rem;
  user-select: all;
}

dialog { border: none; border-radius: 16px; padding: 1.4rem; max-width: min(28rem, 92vw); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin-top: 0; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.pager { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
