/* Look and feel follows the BTC Racing site (btcracing/frontend/src/styles/globals.css):
   cream paper, navy anchor, gold accent; Playfair Display / DM Sans / DM Mono.
   The ticket card (_ticket_card.html) keeps its own inline styles to match the printed ticket. */
:root {
  --navy: #0c1f3f; --navy-light: #1a3a6b;
  --gold: #b8860b; --gold-light: #d4a017; --gold-deep: #8a6508; --gold-ink: #7d5b07; --gold-pale: #f5e6c0;
  --claret: #8e1a38; --grass-deep: #187343;
  --cream: #faf8f4; --cream2: #f3f0ea; --white: #fff;
  --text: var(--navy); --text2: #4a4a6a; --text3: #64678c;
  --border: rgba(0,0,0,.09); --border2: rgba(0,0,0,.14);
  --shadow: 0 2px 10px rgba(0,0,0,.06); --shadow-lg: 0 8px 50px rgba(0,0,0,.12);
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'DM Sans', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, monospace;
  --fs-label: .8125rem; --fs-data: .875rem;
  /* names used by templates' inline styles and older rules */
  --bg: var(--cream); --card: var(--white); --ink: var(--text); --muted: var(--text3); --line: var(--border);
  --brand: var(--navy); --accent: var(--navy);
  --ok: var(--grass-deep); --ok-bg: #e6f3ec; --bad: var(--claret); --bad-bg: #f8e8ec;
}
* { box-sizing: border-box; }
/* The audience is mostly over fifty (see the btcracing notes): nothing under --fs-label. */
html { font-size: 17px; }
body { margin: 0; font-family: var(--font-sans); font-size: .9375rem; line-height: 1.6; background: var(--cream); color: var(--text); }

/* ── Header: navy masthead with a gold rule, like the site's block headers ── */
header {
  background: var(--navy); color: #fff; border-bottom: 2px solid var(--gold);
  padding: 12px 24px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; align-items: center;
}
header nav { display: flex; flex-wrap: wrap; gap: 4px 22px; }
header nav a {
  color: rgba(255,255,255,.72); text-decoration: none; font-size: .8125rem; font-weight: 500;
  letter-spacing: .02em; transition: color .2s;
}
header nav a:hover { color: var(--gold-light); }
header .brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
header .brand img { height: 34px; }
header .brand > span { display: flex; flex-direction: column; }
.brand-name { font-family: var(--font-serif); font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; line-height: 1.15; }
.brand-sub {
  font-family: var(--font-mono); font-size: var(--fs-label); color: var(--gold-light);
  letter-spacing: .14em; text-transform: uppercase; margin-top: 2px;
}

main { max-width: 1100px; margin: 32px auto; padding: 0 16px; }
.narrow { max-width: 580px; }

h1, h2 { font-family: var(--font-serif); color: var(--navy); font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
h1 { font-size: 1.75rem; margin: 0 0 18px; }
h2 { font-size: 1.2rem; margin: 0 0 14px; }

/* ── Cards; a leading h2 becomes the navy masthead of .btc-block ── */
.card {
  background: var(--white); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 24px; margin-bottom: 22px; overflow: hidden;
}
.card > h2:first-child {
  margin: -24px -24px 18px; padding: .85rem 1.2rem; background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 10px;
}
.card > h2:first-child::before { content: ''; width: 18px; height: 1px; background: var(--gold-light); flex-shrink: 0; }

/* ── Forms ── */
label {
  display: block; font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--text2); margin: 14px 0 5px;
}
input, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border2); border-radius: 5px;
  font: inherit; color: var(--text); background: var(--white); transition: border-color .2s;
}
input:hover, select:hover { border-color: rgba(0,0,0,.24); }
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: -1px; border-color: transparent; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

/* ── Buttons: .btn-navy and .btn-outline-nav ── */
button, .btn {
  display: inline-block; background: var(--navy); color: #fff; border: 0; border-radius: 5px;
  padding: 11px 22px; font: inherit; font-size: .875rem; font-weight: 700; letter-spacing: .04em;
  cursor: pointer; text-decoration: none; transition: background .2s, transform .2s, box-shadow .2s, border-color .2s, color .2s;
}
button:hover, .btn:hover { background: var(--navy-light); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(12,31,63,.25); }
button:focus-visible, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button.secondary, .btn.secondary { background: var(--white); color: var(--text2); border: 1px solid var(--border2); font-weight: 500; }
button.secondary:hover, .btn.secondary:hover { border-color: var(--navy); color: var(--navy); box-shadow: none; }
button.danger { background: var(--claret); }
button.danger:hover { background: #74152e; }
button.small, .btn.small { padding: 6px 12px; font-size: var(--fs-label); }
.full { width: 100%; margin-top: 22px; padding: 13px 22px; }

/* ── Messages ── */
.errors { background: var(--bad-bg); color: var(--claret); border-left: 3px solid var(--claret); border-radius: 5px; padding: 10px 14px; margin-bottom: 14px; }
.errors ul { margin: 0; padding-left: 18px; }
.notice { background: var(--cream2); color: var(--navy); border-left: 3px solid var(--gold); border-radius: 5px; padding: 10px 14px; margin-bottom: 16px; }
.muted { color: var(--text3); font-size: var(--fs-data); }
.static-field { margin: 0; padding: 10px 0; font-weight: 600; color: var(--navy); }

/* ── Tables: mono uppercase headings, faint navy hover ── */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-data); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(0,0,0,.06); vertical-align: middle; }
th {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text3); background: var(--cream); border-bottom-color: var(--border);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(29,51,100,.04); }
td b { color: var(--navy); }
tr.past td { color: var(--text3); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ── Stats ── */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--white); border: 1px solid var(--border); border-top: 2px solid var(--gold); border-radius: 10px; box-shadow: var(--shadow); padding: 14px 16px; }
.stat .v { font-size: 1.5rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums lining-nums; line-height: 1.3; }
.stat .k { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: .1em; text-transform: uppercase; color: var(--text3); }

/* ── Badges (.btc-badge) ── */
.pill {
  display: inline-block; font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: .08em;
  text-transform: uppercase; padding: 2px 9px; border-radius: 2px; white-space: nowrap;
  background: var(--cream2); border: 1px solid var(--border); color: var(--text2);
}
.pill.PAID, .pill.SUCCESS { background: var(--ok-bg); border-color: rgba(24,115,67,.3); color: var(--grass-deep); }
.pill.FAILED, .pill.CANCELLED { background: var(--bad-bg); border-color: rgba(142,26,56,.3); color: var(--claret); }
.pill.PENDING, .pill.INITIATED { background: rgba(184,134,11,.12); border-color: rgba(184,134,11,.3); color: var(--gold-ink); }

/* ── Checkout ── */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: .08em; text-transform: uppercase; color: var(--text3); padding-top: 2px; }
.kv dd { margin: 0; font-weight: 600; color: var(--navy); }
@media (max-width: 420px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; } }
.total { font-family: var(--font-serif); font-size: 1.75rem; font-weight: 700; color: var(--navy); font-variant-numeric: lining-nums; }
.gateways { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.gateways label {
  border: 1px solid var(--border2); border-radius: 5px; padding: 14px; margin: 0; cursor: pointer;
  font-family: var(--font-sans); font-size: .9375rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--navy);
  display: flex; gap: 10px; align-items: center; transition: border-color .2s, background .2s;
}
.gateways label:hover { border-color: var(--navy); }
.gateways input { width: auto; accent-color: var(--navy); }
.gateways label:has(input:checked) { border-color: var(--gold); background: rgba(184,134,11,.07); box-shadow: inset 0 0 0 1px var(--gold); }

/* ── Admin forms ── */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.filters label { margin-top: 0; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input[type=number], .inline-form input[type=text] { width: 100px; padding: 6px 8px; }
.inline-form input[type=checkbox] { width: auto; accent-color: var(--navy); }

.qr { display: block; margin: 16px auto; width: 220px; height: 220px; }
.center { text-align: center; }
/* ticket card on the web page: undo the admin table styles */
.tcard table { width: auto; }
.tcard td { border-bottom: 0; }
.tcard tbody tr:hover td { background: none; }
.tcard td b { color: inherit; }

/* ── Scanner ── */
.scan-result { border-radius: 10px; padding: 24px; text-align: center; margin-top: 18px; border: 1px solid transparent; }
.scan-result.ok { background: var(--ok-bg); color: var(--grass-deep); border-color: rgba(24,115,67,.3); }
.scan-result.bad { background: var(--bad-bg); color: var(--claret); border-color: rgba(142,26,56,.3); }
.scan-result .big { font-family: var(--font-serif); font-size: 2rem; font-weight: 800; line-height: 1.2; }
#reader { width: 100%; max-width: 420px; margin: 0 auto; border-color: var(--border) !important; border-radius: 10px; overflow: hidden; }

@media (max-width: 560px) {
  header { padding: 10px 16px; }
  main { margin: 20px auto; }
  .card { padding: 18px; }
  .card > h2:first-child { margin: -18px -18px 16px; }
  h1 { font-size: 1.5rem; }
}
