:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --border: #deddd7;
  --text: #16161a;
  --text-2: #55544f;
  --muted: #67665f;
  --accent: #2a64c5;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --good: #1d7a3a;
  --good-bg: #e3f3e7;
  --warn: #8a5a00;
  --warn-bg: #fdf1d8;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --info-bg: #e5eefb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hero-from: #1d3f8f;
  --hero-to: #5b3cc4;
  --hero-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121212;
    --surface: #1b1b1a;
    --surface-2: #242423;
    --border: #353532;
    --text: #f2f2ef;
    --text-2: #c3c2b7;
    --muted: #96958d;
    --accent: #5b91ea;
    --accent-ink: #0b0b0b;
    --series-1: #3987e5;
    --good: #6fd08c;
    --good-bg: #1a3322;
    --warn: #f0c060;
    --warn-bg: #3a2e12;
    --bad: #ff8a80;
    --bad-bg: #3d1c1a;
    --info-bg: #1b2a40;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212; --surface: #1b1b1a; --surface-2: #242423; --border: #353532;
  --text: #f2f2ef; --text-2: #c3c2b7; --muted: #96958d; --accent: #5b91ea; --accent-ink: #0b0b0b;
  --series-1: #3987e5; --good: #6fd08c; --good-bg: #1a3322; --warn: #f0c060; --warn-bg: #3a2e12;
  --bad: #ff8a80; --bad-bg: #3d1c1a; --info-bg: #1b2a40;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--text-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a:hover, .nav a.active { background: var(--surface-2); color: var(--text); }
main { padding: 24px 0 48px; }
.site-footer { color: var(--muted); font-size: .85rem; padding: 24px 0; border-top: 1px solid var(--border); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.brand .version { font-weight: 400; font-size: .8em; color: var(--muted); margin-left: 4px; }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-small { padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }

form p, form > div { margin: 0 0 14px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; vertical-align: middle; margin-right: 6px; accent-color: var(--accent); }
.helptext, .help { display: block; color: var(--muted); font-size: .85rem; font-weight: 400; }
.errorlist { list-style: none; padding: 0; margin: 4px 0; color: var(--bad); font-size: .9rem; }
div:has(> input[type=checkbox]) label, form ul label { display: inline; font-weight: 500; }
form ul { list-style: none; padding: 0; margin: 4px 0; }
form ul li { margin: 4px 0; }
.qty { width: 80px !important; }

.messages { list-style: none; padding: 0; margin: 0 0 20px; }
.messages li { padding: 12px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--info-bg); }
.messages .success { background: var(--good-bg); color: var(--good); }
.messages .error { background: var(--bad-bg); color: var(--bad); }
.messages .warning { background: var(--warn-bg); color: var(--warn); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge-paid, .badge-active, .badge-sent, .badge-ok, .badge-delivered, .badge-converted { background: var(--good-bg); color: var(--good); }
.badge-awaiting_payment, .badge-pending, .badge-scheduled, .badge-sending, .badge-waiting, .badge-offered { background: var(--warn-bg); color: var(--warn); }
.badge-dispute-won { background: var(--good-bg); color: var(--good); }
.badge-dispute-open, .badge-dispute-lost,
.badge-cancelled, .badge-expired, .badge-failed, .badge-bounced, .badge-complained, .badge-removed { background: var(--bad-bg); color: var(--bad); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .label { color: var(--text-2); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: .82rem; }

.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.meter > span { display: block; height: 100%; background: var(--series-1); border-radius: 4px; }

/* Sales-per-day bar chart (single series; hover tooltip; table view below) */
.barchart { display: flex; align-items: flex-end; gap: 2px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--border); }
.barchart .col { flex: 1; height: 100%; display: flex; align-items: flex-end; position: relative; cursor: default; }
.barchart .bar { width: 100%; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 0; }
.barchart .col:hover .bar { filter: brightness(1.15); }
.barchart .col .tip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 6px 8px; border-radius: 6px; font-size: .8rem; white-space: nowrap;
  z-index: 5; pointer-events: none; }
.barchart .col:hover .tip { display: block; }
.barchart .col:first-child .tip { left: 0; transform: none; }
.barchart .col:last-child .tip { left: auto; right: 0; transform: none; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 4px; }

.ticket { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.ticket .qr { width: 160px; height: 160px; background: #fff; border-radius: 8px; padding: 4px; }
@media (max-width: 560px) { .ticket { grid-template-columns: 1fr; } .ticket .qr { margin: 0 auto; } }

.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.strike { text-decoration: line-through; color: var(--muted); font-weight: 400; margin-right: 6px; }

/* Check-in scanner */
.scan-result { border-radius: var(--radius); padding: 18px; text-align: center; font-size: 1.2rem; font-weight: 700; margin: 12px 0; }
.scan-result.ok { background: var(--good-bg); color: var(--good); }
.scan-result.bad { background: var(--bad-bg); color: var(--bad); }
.scan-result.warn { background: var(--warn-bg); color: var(--warn); }
.scan-result .who { display: block; font-size: 1rem; font-weight: 500; color: var(--text); margin-top: 4px; }
#reader { width: 100%; max-width: 480px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; }
#reader video { width: 100%; display: block; }

.receipt { background: #fff; color: #111; }
/* Phones: let amounts drop the currency onto its own line instead of forcing a sideways scroll */
@media (max-width: 560px) { .receipt td.num { white-space: normal; } .receipt th, .receipt td { padding: 8px 6px; } }
@media print {
  .no-print, .site-header, .site-footer, .messages { display: none !important; }
  body { background: #fff; color: #111; }
  .card { box-shadow: none; border: none; padding: 0; }
}

/* Offline check-in status */
.offline-status { font-size: .85rem; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); }
.offline-status.is-offline { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
