/* Handy-Pager app pages (customer + counter). Dark, warm, one accent. */
:root {
    --bg: #14110f;
    --bg-elev: #1f1b17;
    --bg-card: #262019;
    --text: #f5efe6;
    --muted: #b3a99b;
    --line: #36302a;
    --amber: #ffb020;
    --amber-dim: #5a3d0c;
    --green: #2ecc71;
    --green-dim: #0f3d24;
    --grey: #4a4540;
    --red: #e74c3c;
    --ok-text: #6fe3a0;
    --warn-text: #ffcf6b;
    /* data-viz roles: series colour for "today", grey for the previous period, never a status colour */
    --series-1: #3987e5;
    --series-prev: #6f6861;
    --radius: 16px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .4s ease;
}
body.flash { background: var(--green); }

a { color: var(--amber); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 8px; }
.icon { width: 1.1em; height: 1.1em; flex: 0 0 auto; vertical-align: -.15em; }

.page {
    max-width: 560px;
    margin: 0 auto;
    padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.page--center { min-height: 100vh; min-height: 100dvh; justify-content: center; text-align: center; }
.page--order { min-height: 100vh; min-height: 100dvh; align-items: center; text-align: center; justify-content: center; }

.eyebrow { margin: 0; color: var(--amber); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; font-size: .8rem; }
.headline { margin: 0; font-size: 2rem; line-height: 1.15; font-weight: 700; text-wrap: balance; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .9rem; }
.strong { font-weight: 600; margin: 0; }
.center { text-align: center; }
.break { word-break: break-all; }
.error { color: #ff8a7a; margin: 0; }
.ok { color: var(--ok-text); font-weight: 600; margin: 0; display: flex; gap: 8px; align-items: flex-start; text-align: left; }
.label { font-size: .9rem; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* Buttons: 44px minimum, icon + label */
.btn {
    font: inherit;
    font-weight: 600;
    border: 0;
    border-radius: 999px;
    min-height: 44px;
    padding: 10px 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text);
    background: var(--bg-card);
    touch-action: manipulation;
    user-select: none;
    transition: transform .08s ease, opacity .2s ease, background-color .2s ease;
}
a.btn, .btn { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--busy { opacity: .7; }
.btn--primary { background: var(--amber); color: #1a1205; }
.btn--primary:hover { background: #ffc24d; }
.btn--secondary { background: var(--bg-card); border: 1px solid var(--line); }
.btn--secondary:hover { border-color: var(--muted); }
.btn--ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn--ghost:hover { color: var(--text); }
.btn--danger { background: var(--red); color: #fff; }
.btn--success { background: var(--green); color: #052e16; }
.btn--xl { font-size: 1.25rem; min-height: 64px; padding: 16px 28px; width: 100%; }
.btn--sm { font-size: .95rem; padding: 8px 16px; }

.input {
    font: inherit;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    color: var(--text);
}
.input--pin { font-size: 2rem; letter-spacing: .6em; text-align: center; font-variant-numeric: tabular-nums; }

/* Status chips: icon + label, never colour alone */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--line);
}
.chip--lg { font-size: 1.05rem; }
.chip--sm { font-size: .8rem; padding: 4px 10px; gap: 6px; }
.chip__icon { width: 1.15em; height: 1.15em; display: none; }
.chip[data-status="preparing"] { color: var(--amber); border-color: var(--amber-dim); }
.chip[data-status="preparing"] .chip__icon--preparing { display: block; }
.chip[data-status="ready"] { color: var(--green); border-color: var(--green-dim); }
.chip[data-status="ready"] .chip__icon--ready { display: block; }
.chip[data-status="collected"], .chip[data-status="cancelled"] { color: var(--muted); }
.chip[data-status="collected"] .chip__icon--done, .chip[data-status="cancelled"] .chip__icon--done { display: block; }

/* Customer ring of LEDs */
.ring {
    --size: min(78vw, 320px);
    position: relative;
    width: var(--size);
    height: var(--size);
    display: grid;
    place-items: center;
    border-radius: 50%;
}
.led {
    --r: calc(var(--size) / 2 - 10px);
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    border-radius: 50%;
    background: var(--grey);
    transform: rotate(calc(var(--i) * 30deg)) translateY(calc(var(--r) * -1));
    transition: background-color .3s ease, box-shadow .3s ease;
}
.number {
    font-size: calc(var(--size) * .42);
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}
body.status-preparing .led { animation: chase 1.2s linear infinite; animation-delay: calc(var(--i) * -100ms); }
@keyframes chase {
    0%, 100% { background: var(--amber-dim); box-shadow: none; }
    8% { background: var(--amber); box-shadow: 0 0 14px var(--amber); }
    40% { background: var(--amber-dim); box-shadow: none; }
}
body.status-ready .led { background: var(--green); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 4px var(--green); opacity: .7; transform: rotate(calc(var(--i) * 30deg)) translateY(calc(var(--r) * -1)) scale(.9); }
    50% { box-shadow: 0 0 22px var(--green); opacity: 1; transform: rotate(calc(var(--i) * 30deg)) translateY(calc(var(--r) * -1)) scale(1.15); }
}
body.status-ready .number { color: var(--green); }
body.status-collected .led, body.status-cancelled .led { background: var(--grey); animation: none; }
body.status-collected .number, body.status-cancelled .number { color: var(--muted); }

.banner {
    width: 100%;
    padding: 18px;
    border-radius: var(--radius);
    background: var(--green);
    color: #052e16;
    font-size: 1.4rem;
    font-weight: 800;
    animation: bannerIn .4s ease;
}
@keyframes bannerIn { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

.card { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.push { width: 100%; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.push__title { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.push__bell { width: 22px; height: 22px; color: var(--amber); }
.push .btn { width: 100%; }
.push__active { align-items: stretch; }
.install-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.install-steps li { display: flex; gap: 12px; align-items: flex-start; counter-increment: step; }
.install-steps li::before { content: counter(step); flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--amber); color: #1a1205; font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.install-steps .icon { width: 22px; height: 22px; color: var(--amber); margin-top: 2px; }
.order-head, .order-foot { display: flex; flex-direction: column; gap: 4px; }

/* Counter console */
.page--console { gap: 16px; max-width: 640px; }
.console-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.counts { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.mode { font-size: .75rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.mode::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.notice { margin: 0; padding: 12px 16px; border-radius: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--bg-elev); animation: bannerIn .3s ease; }
.notice[data-kind="ok"] { color: var(--ok-text); border-color: var(--green-dim); }
.notice[data-kind="warn"] { color: var(--warn-text); border-color: var(--amber-dim); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpi { margin: 0; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kpi__label { margin: 0; font-size: .78rem; color: var(--muted); }
.kpi__value { margin: 0; font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi__delta { margin: 0; font-size: .78rem; color: var(--muted); min-height: 1.2em; }
.kpi__delta[data-dir="1"] { color: var(--ok-text); }
.kpi__delta[data-dir="-1"] { color: var(--warn-text); }
.spark { width: 100%; height: 44px; margin-top: 6px; overflow: visible; touch-action: none; }
.spark__prev { stroke: var(--series-prev); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark__now { stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark__dot { fill: var(--series-1); stroke: var(--bg-card); stroke-width: 2; vector-effect: non-scaling-stroke; }
.kpi__legend { margin: 4px 0 0; font-size: .72rem; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi__key { display: inline-block; width: 14px; height: 2px; border-radius: 2px; }
.kpi__key--now { background: var(--series-1); }
.kpi__key--prev { background: var(--series-prev); }
.kpi-table summary { cursor: pointer; }
.kpi-table table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; font-size: .9rem; }
.kpi-table th, .kpi-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.kpi-table td { text-align: right; }
.kpi-table thead th:not(:first-child) { text-align: right; }

.qr-card { display: flex; gap: 14px; align-items: center; }
.qr-card__code { width: 112px; height: 112px; flex: 0 0 auto; background: #fff; border-radius: 10px; padding: 6px; }
.qr-card__code svg { display: block; width: 100%; height: 100%; }
.qr-card__text { display: flex; flex-direction: column; gap: 8px; min-width: 0; align-items: flex-start; }

.orders { display: flex; flex-direction: column; gap: 10px; }
.order-row {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "number meta" "number actions";
    gap: 8px 14px;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
}
.order-row--new { animation: rowIn .35s ease; }
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.order-row[data-status="ready"] { border-color: var(--green-dim); }
.order-row__number {
    grid-area: number;
    font: inherit;
    font-size: 2.6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    min-width: 2.2ch;
    text-align: center;
    line-height: 1;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    border-radius: 12px;
}
.order-row[data-status="ready"] .order-row__number { color: var(--green); }
.order-row[data-status="preparing"] .order-row__number { color: var(--amber); }
.order-row__meta { grid-area: meta; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.order-row__elapsed { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.order-row__push { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--muted); }
.order-row__push[data-devices]:not([data-devices="0"]) { color: var(--ok-text); }
.order-row__actions { grid-area: actions; display: flex; gap: 8px; flex-wrap: wrap; }
.order-row__actions .btn { flex: 1 1 auto; }

.reset { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.reset__confirm { display: flex; flex-direction: column; gap: 8px; align-items: stretch; width: 100%; padding: 12px; border: 1px solid var(--red); border-radius: var(--radius); text-align: center; }

/* Overlays */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    cursor: pointer;
}
.overlay--white { background: #fff; color: #222; }
.overlay__qr { width: min(88vw, 88vh, 640px); height: min(88vw, 88vh, 640px); }
.overlay__qr svg, .overlay__qr img { width: 100%; height: 100%; display: block; }
.overlay__qr--small { width: min(60vw, 42vh, 360px); height: min(60vw, 42vh, 360px); }
.overlay__caption { margin: 0; font-size: 1rem; opacity: .7; text-align: center; }
.overlay__label { margin: 0; color: #666; font-size: 1.2rem; }
.overlay__number { margin: 0; font-size: min(28vw, 22vh); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.overlay__number--dark { color: #1a1205; }

.join { width: 100%; }
.join summary { cursor: pointer; list-style: none; text-decoration: underline; text-underline-offset: 3px; }
.join summary::-webkit-details-marker { display: none; }
.join__form { display: flex; gap: 10px; margin-top: 12px; }
.input--number { flex: 1 1 auto; font-size: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; }
.join .error { margin-top: 8px; }

/* Error pages */
.oops { min-height: 100dvh; display: grid; place-items: center; text-align: center; padding: 24px; }

@media (min-width: 600px) {
    .headline { font-size: 2.4rem; }
    .order-row__actions .btn { flex: 0 1 auto; }
}
@media (max-width: 420px) {
    .kpis { grid-template-columns: 1fr 1fr; }
    .kpi:first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
    .led, .banner, .order-row--new, .notice { animation: none !important; }
    body { transition: none; }
}

/* One-tap pager flow */
.start { display: flex; flex-direction: column; gap: 20px; width: 100%; text-align: center; }
.pager { display: flex; flex-direction: column; gap: 20px; align-items: center; width: 100%; }
.status-card { width: 100%; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.status-card__line { margin: 0; display: flex; gap: 10px; align-items: flex-start; }
.status-card__line .icon { margin-top: .2em; width: 20px; height: 20px; }
.ios-hint summary { cursor: pointer; }
.ios-hint .install-steps { margin-top: 10px; }
