/* Event Tickets — mobile first. Every rule below is the phone layout; the two media
   queries widen it. Built that way round because the scanner lives on a phone at a
   door, which is the least forgiving screen this app has. */

:root {
  --bg:      #f4f5f9;
  --surface: #ffffff;
  --ink:     #101425;
  --muted:   #5b6478;
  --line:    #dfe2ec;
  --brand:   #30386d;
  --accent:  #0075e3;
  --ok:      #1c7a44;
  --warn:    #9a6300;
  --bad:     #b3261e;
  --radius:  10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0f1117;
    --surface: #171a23;
    --ink:     #e8eaf2;
    --muted:   #9aa3b8;
    --line:    #2a2f3d;
    --brand:   #8b95d8;
    --accent:  #4da3ff;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .6rem .9rem;
  background: var(--brand); color: #fff;
}
.nav-logo { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: -.2px; }
.nav-links { display: flex; gap: .25rem; margin-left: auto; order: 3; width: 100%; }
.nav-link {
  color: #fff; text-decoration: none; padding: .35rem .6rem;
  border-radius: 6px; font-size: .95rem; opacity: .85;
}
.nav-link.active, .nav-link:hover { background: rgba(255,255,255,.16); opacity: 1; }

.nav-acct { margin-left: auto; position: relative; }
.nav-acct summary { list-style: none; cursor: pointer; }
.nav-acct summary::-webkit-details-marker { display: none; }
.nav-avatar {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 50%; background: rgba(255,255,255,.2); font-weight: 700;
}
.nav-acct-menu {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20;
  min-width: 240px; padding: .75rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
}
.nav-acct-who { display: grid; gap: .15rem; margin-bottom: .6rem; }
.nav-acct-who span { color: var(--muted); font-size: .85rem; }

/* ── Environment banner ──────────────────────────────────────────────────── */
/* A test event and a real one look identical; this is the only thing on the page
   that says which Core instance is behind it. */
.env-banner {
  padding: .5rem .9rem; text-align: center;
  background: #ffe9b8; color: #4a3600;
  border-bottom: 1px solid #e3c477; font-size: .9rem;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.wrap { max-width: 62rem; margin: 0 auto; padding: 1.1rem .9rem 3rem; }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; letter-spacing: -.3px; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.fine  { color: var(--muted); font-size: .85rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem; margin: 0 0 1.1rem;
}
.card.centered { max-width: 30rem; margin: 3rem auto; text-align: center; }

.btn {
  display: inline-block; padding: .6rem 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.small   { padding: .3rem .6rem; font-size: .85rem; }

/* ── Tables: scroll the table, never the page ────────────────────────────── */
.grid { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.grid th, .grid td {
  padding: .6rem .5rem; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line); font-size: .95rem;
}
.grid th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.grid tr.inactive { opacity: .55; }

.pill {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  background: var(--line); font-size: .8rem; font-weight: 600;
}
.pill.armed  { background: #cdeacf; color: var(--ok); }
.pill.closed { background: var(--line); color: var(--muted); }

form.row { display: grid; gap: .7rem; }
form.row label { display: grid; gap: .2rem; font-size: .9rem; color: var(--muted); }
input, select {
  padding: .55rem .6rem; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}

.changelog { white-space: pre-wrap; font-size: .9rem; line-height: 1.6; }
.foot {
  display: flex; gap: 1rem; justify-content: center;
  padding: 1.5rem .9rem 2.5rem; color: var(--muted); font-size: .85rem;
}
.foot a { color: var(--muted); }

/* iPad portrait and up */
@media (min-width: 768px) {
  .nav-links { order: 0; width: auto; margin-left: 1rem; }
  .nav-acct  { order: 3; }
  h1 { font-size: 1.7rem; }
  form.row { grid-template-columns: 2fr 1fr auto; align-items: end; }
}

@media (min-width: 1100px) {
  .wrap { padding-inline: 1.25rem; }
}

/* ── Phase 1: events ─────────────────────────────────────────────────────── */
.head-row { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-row h1 { margin: 0; }
.head-row .btn { margin-left: auto; }

.crumbs { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 1rem; font-size: .9rem; }
.crumbs span { color: var(--muted); }

/* Reserved for the things that genuinely are dangerous: a cross-environment event, and a
   refusal to arm. Nothing decorative gets this treatment. */
.card.danger { border-left: 4px solid var(--bad); }
.card.danger h2 { color: var(--bad); }
.pill.warn { background: #ffe1b8; color: var(--warn); }

.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; padding: .4rem .6rem .4rem 0; color: var(--muted); font-weight: 600;
         white-space: nowrap; vertical-align: top; font-size: .9rem; }
.kv td { padding: .4rem 0; }

form.inline { display: inline; }
.row2 { display: grid; gap: .8rem; }
.row2 label, label.narrow { display: grid; gap: .2rem; font-size: .9rem; color: var(--muted); }
label.narrow { max-width: 16rem; margin-top: .8rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
ul.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
ul.plain li { padding: .15rem 0; }
code { font-size: .9em; background: var(--bg); padding: .05rem .3rem; border-radius: 4px; }

@media (min-width: 768px) {
  .row2 { grid-template-columns: 1fr 1fr; }
}

.bigcode { font-family: 'Courier New', Courier, monospace; font-size: 1.4rem; letter-spacing: .12em; }

/* ── The door ────────────────────────────────────────────────────────────────
   Phone-first and deliberately blunt: at a door, color is the message and the words are
   confirmation. Sized so a verdict is readable at arm's length on a bright evening. */
.scanwrap { max-width: 40rem; }
.scanhead { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: .9rem; }
.scanhead h1 { font-size: 1.2rem; margin: 0 0 .2rem; }
.scanhead .btn { margin-left: auto; flex: 0 0 auto; }

.verdict {
  display: grid; gap: .2rem; padding: 1.1rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line);
  margin-bottom: .9rem; min-height: 6.2rem; align-content: center;
}
.verdict strong { font-size: 2rem; line-height: 1.05; letter-spacing: -.5px; }
.verdict span  { font-size: 1rem; }
.verdict.ok   { background: #d8f2de; border-color: #2f9c58; color: #10422a; }
.verdict.warn { background: #ffe9b8; border-color: #d99400; color: #4a3600; }
.verdict.bad  { background: #ffdad6; border-color: #c0392b; color: #5b1712; }

.camwrap { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4 / 3; }
.camwrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanroot:not(.live) .camwrap { display: none; }

.manual { display: grid; gap: .6rem; margin: .9rem 0; }
.manual label { display: grid; gap: .2rem; font-size: .9rem; color: var(--muted); }
.manual input {
  font-family: 'Courier New', Courier, monospace; font-size: 1.3rem;
  letter-spacing: .12em; text-transform: uppercase;
}

@media (min-width: 768px) {
  .manual { grid-template-columns: 1fr auto; align-items: end; }
}

/* ── Orders and attendance ───────────────────────────────────────────────── */
tr.needsattention { background: color-mix(in srgb, var(--warn) 8%, transparent); }
.err { color: var(--bad); }
.actions-cell form { display: inline-block; margin: 0 .25rem .25rem 0; }
.fixform { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; }
.fixform input[type="email"] { width: 12rem; }
.fixform input[type="number"] { width: 4.5rem; }

.tiles { display: grid; gap: .7rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1.1rem; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; display: grid; gap: .1rem;
}
.tile strong { font-size: 1.9rem; line-height: 1; letter-spacing: -.5px; }
.tile span { color: var(--muted); font-size: .85rem; }

@media (min-width: 768px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

/* ── Readiness, at the top where the decision is made ────────────────────── */
.statuscard { border-left: 4px solid var(--line); }
.statuscard.ready    { border-left-color: var(--ok); }
.statuscard.notready { border-left-color: var(--warn); }
.statushead { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.statushead h2 { margin: 0 0 .15rem; }
.statushead .actions { margin-left: auto; }

.checklist { list-style: none; padding: 0; margin: .8rem 0 .4rem; display: grid; gap: .3rem; }
.checklist li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .5rem; font-size: .92rem; }
.checklist .mark { font-weight: 700; text-align: center; }
.checklist li.ok   .mark { color: var(--ok); }
.checklist li.todo .mark { color: var(--warn); }
.checklist li.todo { color: var(--ink); }
.checklist li.ok   { color: var(--muted); }

button[disabled] { opacity: .45; cursor: not-allowed; }
