/* Ticket system UI.
   Dark, high-contrast and touch-first: the counter and the gate are both
   operated on phones, often outdoors and one-handed, so tap targets stay large
   and the scanner verdict has to be readable at arm's length. */

:root {
  --bg: #0b1220;
  --panel: #141d2e;
  --panel-2: #1b2740;
  --line: #27334a;
  --ink: #e9eef7;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-ink: #06263a;
  --chrome: #141d2e;   /* top bar; re-tinted per theme and by the staff area */
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- chrome ---------- */

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1rem;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: .55rem; min-width: 0;
  font-weight: 700; color: var(--ink); line-height: 1.2;
  font-size: clamp(.95rem, .82rem + .6vw, 1.05rem);
}
.brand-mark { width: 1.9rem; height: 1.9rem; border-radius: 50%; flex: none; }

/* ---------- menu (replaces a bare row of topbar links) ---------- */

.menu { margin-left: auto; position: relative; }
.menu-btn {
  display: flex; align-items: center; gap: .55rem;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: .5rem .8rem; border-radius: 10px; cursor: pointer; font: inherit; font-size: .9rem;
}
.menu-btn:hover { border-color: var(--accent); }
.menu-btn[aria-expanded="true"] { border-color: var(--accent); }
.menu-icon { display: inline-flex; flex-direction: column; gap: .2rem; width: 1.1rem; }
.menu-icon span { display: block; height: 2px; border-radius: 2px; background: currentColor; }

.menu-panel {
  position: absolute; top: calc(100% + .5rem); right: 0; z-index: 40;
  min-width: 12rem; padding: .4rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: .1rem;
}
/* A class selector outranks the UA stylesheet's [hidden] rule, so the display
   above would otherwise pin the panel open and the toggle could never shut it. */
.menu-panel[hidden] { display: none; }
.menu-panel a, .menu-item-btn {
  display: block; width: 100%; text-align: left;
  padding: .55rem .7rem; border-radius: 8px; color: var(--ink);
  font-size: .93rem; white-space: nowrap; background: none; border: 0; font: inherit; cursor: pointer;
}
.menu-panel a:hover, .menu-item-btn:hover { background: var(--panel-2); text-decoration: none; }
.menu-panel form { margin: 0; }
.menu-divider { height: 1px; background: var(--line); margin: .35rem .2rem; }
.menu-panel .lang-switch { margin: .3rem .2rem 0; }

.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 0; }
.lang-btn {
  flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-size: .82rem;
  font-weight: 650; padding: .45rem .55rem; cursor: pointer;
}
.lang-btn:hover:not(.active) { background: var(--panel-2); color: var(--ink); }
.lang-btn.active { background: var(--accent); color: var(--accent-ink); cursor: default; }

/* The staff area carries a distinct accent so a glance at the bar tells you
   which side of the system you are on -- the counter and the public shop must
   never be mistaken for each other mid-shift. */
body.staff { --accent: #fbbf24; --accent-ink: #3b2503; }
body.staff .topbar { background: #1d1708; border-bottom-color: #43350f; }
body.staff .brand { color: var(--accent); }

.wrap { max-width: 940px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem 1rem 2.5rem; }

h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 .6rem; }
.sub { color: var(--muted); margin: 0 0 1.25rem; }

/* ---------- panels ---------- */

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; margin-bottom: .85rem;
}
.card h3 { margin: 0 0 .3rem; font-size: 1.05rem; }
.meta { color: var(--muted); font-size: .9rem; }
.grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.stack > * + * { margin-top: .75rem; }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 2rem 1rem; text-align: center; color: var(--muted);
}

/* ---------- staff home: station menu ----------
   The counter and the gate are picked on a phone, often in a hurry and with
   one hand, so each station is a single large target rather than a text link.
   Only the stations a role may actually open are rendered -- offering a tile
   that answers 403 is worse than not offering it. */

.staff-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .75rem; margin-bottom: 1.25rem;
}
.staff-head .sub { margin: 0; }
.badge-role {
  background: rgba(251,191,36,.16); color: var(--accent); white-space: nowrap;
}

.callout {
  display: flex; align-items: center; gap: .85rem;
  padding: .9rem 1rem; margin-bottom: 1.25rem;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--accent); border-radius: var(--radius);
}
.callout:hover { text-decoration: none; background: var(--panel-2); }
.callout-dot {
  width: .6rem; height: .6rem; border-radius: 50%; flex: none;
  background: var(--accent); box-shadow: 0 0 0 4px rgba(251,191,36,.18);
}
.callout-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.callout-go { margin-left: auto; color: var(--accent); font-size: 1.2rem; }

.tiles { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.tile {
  display: flex; align-items: flex-start; gap: .9rem;
  padding: 1.1rem; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tile:hover, .tile:focus-visible {
  text-decoration: none; border-color: var(--accent); background: var(--panel-2);
}
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-icon {
  display: grid; place-items: center; flex: none;
  width: 2.75rem; height: 2.75rem; border-radius: 10px;
  background: var(--panel-2); color: var(--accent);
}
.tile-icon svg { width: 1.5rem; height: 1.5rem; }
.tile-body { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.tile-body strong { font-size: 1.05rem; }

/* ---------- forms ---------- */

label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: .25rem; }
input, select, button {
  font: inherit; border-radius: 9px;
}
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; padding: .7rem .75rem;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: .85rem; }
.errors { color: #fca5a5; font-size: .87rem; margin: .3rem 0 0; padding-left: 1.1rem; }

.btn {
  display: inline-block; padding: .75rem 1.1rem; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 650;
  border-radius: 9px; text-align: center;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: .45rem .75rem; font-size: .9rem; }
.btn-ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--bad); color: #fff; }

/* ---------- messages ---------- */

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg { padding: .7rem .9rem; border-radius: 9px; margin-bottom: .5rem; border-left: 4px solid var(--muted); background: var(--panel); }
.msg-success { border-color: var(--ok); }
.msg-error { border-color: var(--bad); }
.msg-warning { border-color: var(--warn); }

/* ---------- tables ---------- */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- badges ---------- */

.badge {
  display: inline-block; padding: .18rem .5rem; border-radius: 999px;
  font-size: .76rem; font-weight: 650; letter-spacing: .02em;
  background: var(--panel-2); color: var(--muted);
}
.badge-VALID { background: rgba(34,197,94,.16); color: #4ade80; }
.badge-USED { background: rgba(148,163,184,.16); color: var(--muted); }
.badge-CANCELLED, .badge-REFUNDED { background: rgba(239,68,68,.16); color: #f87171; }
.badge-PENDING { background: rgba(245,158,11,.16); color: #fbbf24; }

/* ---------- tier picker (counter + checkout) ---------- */

.tier {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 0; border-bottom: 1px solid var(--line);
}
.tier:last-child { border-bottom: 0; }
.tier-name { font-weight: 600; }
.tier-info { flex: 1 1 12rem; min-width: 0; }
.tier input[type=number] { width: 5.5rem; }
.soldout { color: var(--muted); font-size: .87rem; }

.total {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 1.25rem; font-weight: 700; padding: .9rem 0 .3rem;
  border-top: 2px solid var(--line); margin-top: .5rem;
}

/* ---------- ticket / QR ---------- */

.qr-wrap { background: #fff; padding: 1rem; border-radius: var(--radius); display: inline-block; }
.qr-wrap img { display: block; width: min(72vw, 300px); height: auto; image-rendering: pixelated; }
.ticket-code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.1rem; letter-spacing: .04em; }

/* ---------- gate scanner ---------- */

#reader { width: 100%; max-width: 460px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; position: relative; }
#reader video { width: 100%; display: block; }
.verdict {
  border-radius: var(--radius); padding: 1.5rem 1rem; text-align: center;
  font-size: 1.6rem; font-weight: 800; letter-spacing: .02em; margin-bottom: .85rem;
}
.verdict small { display: block; font-size: .95rem; font-weight: 500; margin-top: .4rem; opacity: .9; letter-spacing: 0; }
.verdict-idle { background: var(--panel); color: var(--muted); font-size: 1.05rem; font-weight: 600; }
.verdict-ok { background: var(--ok); color: #052e13; }
.verdict-bad { background: var(--bad); color: #fff; }
.verdict-warn { background: var(--warn); color: #3b2503; }

/* ---------- light theme (public side only) ----------
   The counter and the gate stay dark whatever the device asks for: those
   screens are worked outdoors, one-handed, where a bright panel is harder to
   read, not easier. Everything a customer sees follows the visitor's choice --
   an explicit pick from the menu, or their system setting on "auto". */

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) body:not(.staff) {
    --bg: #f7f4ee;
    --panel: #ffffff;
    --panel-2: #eeeae1;
    --line: #dcd6c9;
    --chrome: #ffffff;
    --ink: #1a2233;
    --muted: #5c6675;
    --accent: #0b6d94;
    --accent-ink: #ffffff;
    --ok: #15803d;
    --warn: #a16207;
    --bad: #b91c1c;
  }
}
:root[data-theme="light"] body:not(.staff) {
  --bg: #f7f4ee;
  --panel: #ffffff;
  --panel-2: #eeeae1;
  --line: #dcd6c9;
  --chrome: #ffffff;
  --ink: #1a2233;
  --muted: #5c6675;
  --accent: #0b6d94;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --warn: #a16207;
  --bad: #b91c1c;
}

/* The theme control shares the language switcher's segmented look. It has no
   place in the staff area, whose darkness is a deliberate choice. */
.theme-switch { margin: .3rem .2rem 0; }
.theme-switch .lang-btn { letter-spacing: .01em; }
body.staff .theme-switch { display: none; }

/* ---------- order summary: quantity x amount = subtotal, tax included ---------- */

.summary { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.summary th, .summary td { padding: .35rem 0; text-align: left; font-weight: 400; }
.summary .num { text-align: right; padding-left: .6rem; white-space: nowrap; }
.summary thead th {
  font-size: .72rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line);
}
.summary tbody tr + tr td { border-top: 1px dashed var(--line); }
.summary tfoot tr:first-child th, .summary tfoot tr:first-child td { border-top: 1px solid var(--line); padding-top: .55rem; }
.summary tfoot th { color: var(--muted); }
.summary .summary-total th, .summary .summary-total td {
  color: var(--ink); font-weight: 700; font-size: 1.15rem; padding-top: .45rem;
}

/* ---------- POS receipt slip (80 mm thermal roll) ----------
   80 mm paper prints about 72 mm wide, so the slip is laid out in millimetres
   and in pure black: a thermal head has no grey, and no gold. On screen it is
   shown as the paper it will become. */

.pos-actions { margin: 0 0 1rem; }
.pos {
  width: 80mm; max-width: 100%; margin: 0 auto 1.25rem; padding: 5mm 4mm 6mm;
  background: #fff; color: #000; border-radius: 3px;
  box-shadow: 0 14px 40px -18px rgba(0,0,0,.8);
  font: 12px/1.35 "Helvetica Neue", Arial, sans-serif;
  --line: #000; --muted: #000; --ink: #000;
}
.pos p { margin: 0; }
.pos-head { text-align: center; }
.pos-mark { display: block; width: 90%; margin: 0 auto 2mm; }
.pos-name { font-weight: 700; font-size: 11px; }
.pos-small { font-size: 10px; }
.pos-head .pos-small, .pos-ticket .pos-small { text-align: center; }
.pos-cut { border: 0; border-top: 1px dashed #000; margin: 3mm 0; }
.pos-label { font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 1.5mm !important; }
.pos-facts { display: grid; grid-template-columns: auto 1fr; gap: .5mm 3mm; margin: 0; font-size: 11px; }
.pos-facts dt { font-weight: 400; }
.pos-facts dd { margin: 0; text-align: right; font-weight: 600; word-break: break-word; }
.pos-event { font-size: 15px; font-weight: 700; text-align: center; margin-bottom: 1mm !important; }
.pos > .pos-small { text-align: center; margin-bottom: 3mm !important; }
.pos .summary { font-size: 11px; }
.pos .summary thead th { font-size: 9px; font-weight: 700; }
.pos .summary .summary-total th, .pos .summary .summary-total td { font-size: 15px; }
.pos-cash { margin-top: 2.5mm; padding-top: 2mm; border-top: 1px solid #000; }
.pos-ticket { text-align: center; break-inside: avoid; page-break-inside: avoid; }
.pos-qr { display: block; width: 50mm; height: 50mm; margin: 1mm auto; image-rendering: pixelated; }
.pos-code { font: 700 15px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; }
.pos-links { margin-top: 1.5mm !important; font-size: 11px; }
.pos-links a { color: #000; text-decoration: underline; }
.pos-foot { text-align: center; font-size: 10px; }

/* ---------- paying by bank ----------
   The method picker is a list of tappable rows rather than a <select>: the
   methods now behave differently from one another (one redirects to a provider,
   two ask for a receipt), so each needs a line saying what happens next, and a
   dropdown has nowhere to put it. */

.methods { display: grid; gap: .5rem; margin: 1rem 0 0; }
.method {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2); cursor: pointer;
}
.method:has(input:checked) { border-color: var(--accent); background: var(--panel); }
.method input { margin: .25rem 0 0; flex: none; width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.method-body { min-width: 0; }
.method-name { font-weight: 600; }
.method-note { color: var(--muted); font-size: .87rem; }

/* Where to send the money. Monospaced digits so an account number can be read
   off a phone and typed into a banking app without losing your place. */
.bank { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 0; }
.bank dt { color: var(--muted); }
.bank dd { margin: 0; font-weight: 600; word-break: break-word; }
.bank .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .03em; }

.proofs { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .6rem; }
.proof { display: block; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel-2); }
.proof img { display: block; width: 8rem; height: 8rem; object-fit: cover; }
.proof-file { display: block; padding: .6rem .7rem; font-size: .87rem; max-width: 12rem; }
.proof-when { display: block; padding: .3rem .5rem; font-size: .75rem; color: var(--muted); }

.badge-AWAITING { background: rgba(56,189,248,.16); color: #7dd3fc; }
.badge-COMPLETED { background: rgba(34,197,94,.16); color: #4ade80; }
.badge-FAILED { background: rgba(239,68,68,.16); color: #f87171; }

/* A count of people waiting on you, on the staff tile. */
.tile-count {
  display: inline-block; margin-left: .4rem; padding: .1rem .45rem; border-radius: 999px;
  background: var(--warn); color: #3b2503; font-size: .75rem; font-weight: 700;
}

@media print {
  .topbar, .foot, .noprint { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .qr-wrap { border-color: #999; background: #fff; }
}

@media print {
  /* Receipt printers take their paper size from the driver; zero margins keep
     the browser from shrinking the 80 mm slip to fit a page border. */
  @page { margin: 0; }
  body.staff main.wrap { max-width: none; margin: 0; padding: 0; }
  body.staff .messages { display: none; }
  .pos { width: 80mm; margin: 0; padding: 3mm 4mm 8mm; box-shadow: none; border-radius: 0; }
}
