@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500..700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --navy-950: #0D1B2E;
  --navy-900: #12294B;
  --navy-700: #1C3A63;
  --navy-500: #2C557E;
  --gold-600: #B8860B;
  --gold-500: #C99A3D;
  --gold-100: #F3E6C6;
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --line: #E1E5EC;
  --text: #1B222C;
  --text-muted: #5B6472;
  --success: #1F8A57;
  --success-bg: #E7F6EC;
  --danger: #C0392B;
  --danger-bg: #FBEAE8;
  --warning: #B9750C;
  --warning-bg: #FCF0DC;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(13,27,46,0.06), 0 8px 24px -12px rgba(13,27,46,0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  color: var(--navy-950);
  margin: 0;
}

a { color: var(--navy-700); }

/* ---------- Letterhead / top bar ---------- */
.letterhead {
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: #fff;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.letterhead .emblem {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-500), var(--gold-600));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--navy-950);
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.5);
}

.letterhead .titles { flex: 1; min-width: 0; }
.letterhead .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--gold-100);
  opacity: 0.85;
}
.letterhead h1 { color: #fff; font-size: 19px; }
.letterhead .sub { font-size: 12.5px; color: #C7D2E0; margin-top: 2px; }

.letterhead .actions { display: flex; gap: 10px; align-items: center; }
.letterhead .actions .who { font-size: 13px; color: #DCE4EF; }

/* ---------- Layout ---------- */
.shell { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.shell.narrow { max-width: 480px; }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px) {
  .grid.cols-4, .grid.cols-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .grid.cols-4, .grid.cols-2 { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 18px; }

.stat-card { padding: 18px 20px; }
.stat-card .label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-bottom: 6px;
}
.stat-card .value { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 600; color: var(--navy-950); }
.stat-card .value.gold { color: var(--gold-600); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.success { color: var(--success); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--navy-900); margin-bottom: 6px; }
input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--navy-500);
  outline-offset: 1px;
  border-color: var(--navy-500);
}
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

button, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
button:active { transform: scale(0.98); }
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-gold { background: var(--gold-600); color: #fff; }
.btn-gold:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--navy-900); border-color: var(--line); }
.btn-ghost:hover { background: #F0F2F6; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { opacity: 0.85; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 20px; font-size: 16px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th {
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 700; background: #F7F8FB;
}
tr:hover td { background: #FAFBFD; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: #EDEFF3; color: var(--text-muted); }
.badge-gold { background: var(--gold-100); color: var(--gold-600); }
.time-select { display: flex; align-items: center; gap: 4px; }
.time-select select { flex: 1; min-width: 0; }

/* ---------- Nav tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs a {
  padding: 10px 16px; font-weight: 600; font-size: 14px; color: var(--text-muted);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.active { color: var(--navy-900); border-bottom-color: var(--gold-600); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-info { background: #E9F0FA; color: var(--navy-700); }

.muted { color: var(--text-muted); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--navy-700); margin-bottom: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Scan page specific ---------- */
.scan-shell { min-height: 100vh; background: linear-gradient(180deg, var(--navy-950), var(--navy-900) 40%, var(--bg) 40%); }
.step-pill {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--gold-500);
  color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
#qr-reader { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#qr-reader video { border-radius: var(--radius); }

.qr-preview-box {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 20px; border: 1px dashed var(--line); border-radius: var(--radius); background: #FAFBFD;
}
.qr-preview-box img { width: 220px; height: 220px; }

@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; top: 0; left: 0; width: 100%; }
}