/* APSB QR — admin styles. Navy + gold, built around the QR "plate" on the detail page. */
:root {
  --navy: #0F2547;
  --navy-deep: #0A1A33;
  --gold: #C9A24A;
  --gold-soft: #F3E9CF;
  --paper: #F4F6FA;
  --surface: #FFFFFF;
  --ink: #1A2333;
  --muted: #5F6B80;
  --line: #D9DFE8;
  --ok: #23704F;
  --ok-soft: #E3F2EA;
  --danger: #A8322A;
  --danger-soft: #FBE9E7;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--font); }
h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 14px; }
a { color: var(--navy); }
code { font-size: 0.9em; background: var(--gold-soft); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); margin: 6px 0 0; }
.small { font-size: 0.875rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar { background: var(--navy); border-bottom: 3px solid var(--gold); }
.topbar__inner { max-width: 1160px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.0625rem; }
.brand__mark { width: 22px; height: 22px; border: 3px solid var(--gold); border-radius: 4px; position: relative; }
.brand__mark::after { content: ""; position: absolute; inset: 4px; background: var(--gold); border-radius: 1px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav__signout { color: #C8D1E0; text-decoration: none; font: 500 0.9375rem var(--font); padding: 6px 12px; border-radius: 6px; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav__signout:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.is-active { color: #fff; box-shadow: inset 0 -2px 0 var(--gold); border-radius: 0; }
.nav form { margin: 0; }

.page { max-width: 1160px; margin: 0 auto; padding: 32px 24px 64px; }

/* ---------- Notices ---------- */
.notice { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border-left: 4px solid; }
.notice--success { background: var(--ok-soft); border-color: var(--ok); color: #164A34; }
.notice--error { background: var(--danger-soft); border-color: var(--danger); color: #6E1F19; }

/* ---------- Forms & buttons ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.875rem; }
input, select { font: 400 1rem var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(201,162,74,.35); }
.field-hint { font-weight: 400; color: var(--muted); font-size: 0.8125rem; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row form { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; font: 600 0.9375rem var(--font); padding: 10px 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--navy); }
.btn--primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-deep); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--danger); border-color: #E7C2BE; background: var(--surface); }
.btn--danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- Auth pages ---------- */
.auth { max-width: 400px; margin: 40px auto 0; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 10px; padding: 32px; }
.auth h1 { margin-bottom: 4px; }
.auth form { margin-top: 24px; }

/* ---------- Dashboard ---------- */
.create { display: grid; gap: 24px; margin-bottom: 32px; }
.create__form { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px 24px; }
.create__fields { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(240px, 1.6fr) auto; gap: 14px; align-items: end; }

.search { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; max-width: 420px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.codes { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.codes th { text-align: left; font-weight: 600; font-size: 0.8125rem; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); background: #FAFBFD; }
.codes th.num { text-align: right; }
.codes td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.codes tr:last-child td { border-bottom: 0; }
.codes tbody tr:hover { background: #FAFBFD; }
.codes__title { font-weight: 600; text-decoration: none; display: block; }
.codes__title:hover { text-decoration: underline; }
.codes__dest { display: block; color: var(--muted); font-size: 0.8125rem; max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }

.pill { display: inline-block; font-size: 0.8125rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.pill--on { background: var(--ok-soft); color: var(--ok); }
.pill--off { background: #ECEFF4; color: var(--muted); }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 32px; text-align: center; color: var(--muted); }

/* ---------- Detail page ---------- */
.back { display: inline-block; margin-bottom: 20px; font-weight: 500; text-decoration: none; }
.back::before { content: "‹ "; }
.back:hover { text-decoration: underline; }

.detail { display: grid; grid-template-columns: 340px 1fr; gap: 28px; align-items: start; }

/* The plate: the one bold element — the QR framed in navy and gold */
.plate { position: sticky; top: 24px; background: var(--navy); color: #fff; border-radius: 14px; padding: 24px; }
.plate__qr { background: #fff; padding: 0; border-radius: 6px; box-shadow: 0 0 0 3px var(--gold); aspect-ratio: 1; }
.plate__qr svg { display: block; width: 100%; height: auto; }
.plate.is-paused .plate__qr { opacity: .45; }
.plate__link { margin: 18px 0 20px; font-size: 1.125rem; font-weight: 700; text-align: center; word-break: break-all; color: var(--gold-soft); }
.plate__options { display: grid; gap: 12px; margin-bottom: 18px; }
.plate__options label { color: #C8D1E0; font-weight: 500; }
.plate__options select { background: var(--navy-deep); color: #fff; border-color: #2A4170; }
.plate__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.plate__actions .btn { min-width: 0; padding-left: 8px; padding-right: 8px; }
.plate__actions .btn--primary { background: var(--gold); border-color: var(--gold); color: var(--navy-deep); }
.plate__actions .btn--primary:hover { background: #D8B566; }
.plate__actions .btn:not(.btn--primary) { background: transparent; color: #fff; border-color: #2A4170; }
.plate__actions .btn:not(.btn--primary):hover { border-color: var(--gold); }
.plate__actions [data-copy] { grid-column: 1 / -1; }
.plate__hint { margin: 12px 0 0; font-size: 0.8125rem; color: #9AA8C0; text-align: center; }

.detail__main { display: grid; gap: 20px; min-width: 0; }
.detail__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px 24px; }
.panel--quiet { background: transparent; }

.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.figures div { display: flex; flex-direction: column; }
.figures__n { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); }
.figures__n--small { font-size: 1rem; padding-top: 10px; }
.figures__l { font-size: 0.8125rem; color: var(--muted); }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 110px; border-bottom: 1px solid var(--line); }
.bars__bar { flex: 1; background: var(--navy); border-radius: 2px 2px 0 0; min-width: 2px; }
.bars__bar:hover { background: var(--gold); }
.bars__axis { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); margin-top: 6px; }

.devices { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px; font-size: 0.875rem; }
.devices li { display: grid; grid-template-columns: 70px 1fr 44px; gap: 12px; align-items: center; }
.devices__track { height: 8px; background: #ECEFF4; border-radius: 4px; overflow: hidden; }
.devices__track span { display: block; height: 100%; background: var(--gold); }

.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; font-size: 0.875rem; }
.history li { border-left: 3px solid var(--gold-soft); padding-left: 12px; }
.history__when { color: var(--muted); display: block; }
.history__urls { display: grid; word-break: break-all; }
.history__urls s { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .plate { position: static; max-width: 420px; }
  .create__fields { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .page { padding: 24px 16px 48px; }
  .figures { grid-template-columns: 1fr 1fr; }
  .codes th:nth-child(4), .codes td:nth-child(4) { display: none; }
  .auth { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
