:root {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --ink: #1d1c19;
  --muted: #66615a;
  --line: #e3ddd1;
  --brand: #1e4a38;
  --brand-ink: #f6f3ec;
  --brand-soft: #e4ece6;
  --ok: #1e6b3f;
  --ok-bg: #e2f1e6;
  --bad: #9b2c1f;
  --bad-bg: #f8e3df;
  --warn: #8a5a00;
  --warn-bg: #fbefd6;
  --radius: 12px;
  --pad: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; font-size: 16px; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
.wrap.wide { max-width: 1040px; }

.masthead { padding: 28px 0 20px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.masthead .eyebrow { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 10px; color: var(--muted); font-size: 0.95rem; }
.facts strong { color: var(--ink); font-weight: 600; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); }
.stack > * + * { margin-top: 16px; }

label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-top: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #cfc7b8; border-radius: 8px; padding: 12px; min-height: 48px;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; min-height: 20px; height: 20px; margin-top: 2px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; border-radius: 8px; padding: 12px 18px; min-height: 48px;
  border: 1px solid var(--brand); background: transparent; color: var(--brand); cursor: pointer;
  text-decoration: none; transition: transform 80ms ease, background-color 120ms ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.block { width: 100%; }
.btn.quiet { border-color: transparent; padding-left: 0; padding-right: 0; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }

.notice { border-radius: 8px; padding: 12px 14px; font-size: 0.95rem; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }

.summary { width: 100%; border-collapse: collapse; }
.summary td { padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.summary td:last-child { text-align: right; font-weight: 600; }
.summary tr.total td { border-bottom: 0; font-size: 1.1rem; padding-top: 14px; }

.footer { margin-top: 32px; font-size: 0.85rem; color: var(--muted); text-align: center; }
.footer a { color: var(--muted); }

/* Ticket */
.ticket { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ticket-head { background: var(--brand); color: var(--brand-ink); padding: 18px var(--pad); }
.ticket-head .eyebrow { opacity: 0.8; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.ticket-body { padding: var(--pad); text-align: center; }
.ticket canvas { width: 220px; height: 220px; image-rendering: pixelated; }
.ticket-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.3rem; font-weight: 700; letter-spacing: 0.05em; margin: 8px 0 4px; }
.ticket dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; text-align: left; margin: 18px 0 0; padding-top: 16px; border-top: 1px dashed var(--line); }
.ticket dt { color: var(--muted); }
.ticket dd { margin: 0; font-weight: 600; text-align: right; }

/* Admin */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 0; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs button { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.numbers > div { background: var(--surface); padding: 16px; }
.numbers .n { font-size: 1.5rem; font-weight: 700; }
.numbers .l { color: var(--muted); font-size: 0.85rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { font-weight: 600; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1 1 200px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.tag { display: inline-block; font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.tag.typed { background: var(--warn-bg); color: var(--warn); }

/* Gate */
.gate-video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); background: #000; }
.result { border-radius: var(--radius); padding: 20px; text-align: center; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.bad { background: var(--bad-bg); color: var(--bad); }
.result.warn { background: var(--warn-bg); color: var(--warn); }
.result .big { font-size: 1.4rem; font-weight: 700; margin-bottom: 4px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
}
