/* Hoftor. One dark brand theme on purpose: the colours carry the scan result
   (green / red / amber fill the whole screen), so there is no light variant. */
:root {
    --brown: #2a2119;
    --brown-2: #3b2f24;
    --gold: #d9a441;
    --muted: #cdbfad;
    --green: #15803d;
    --red: #b91c1c;
    --amber: #b45309;
    --bg: var(--brown);
    --glow: rgba(217, 164, 65, .30);
    color-scheme: dark;
}

* { box-sizing: border-box; }
/* The hidden attribute must win over every display rule (.btn is inline-flex etc.). */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #fff;
    background-color: var(--bg);
    background-image: radial-gradient(130% 70% at 50% -12%, var(--glow), transparent 70%);
    background-repeat: no-repeat;
    transition: background-color .18s ease;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}
body[data-mode="out"] { --glow: rgba(120, 160, 200, .30); }
body[data-mode="topup"] { --glow: rgba(130, 190, 120, .30); }
body[data-state="ok"] { --bg: var(--green); --glow: rgba(255, 255, 255, .16); }
body[data-state="bad"],
body[data-state="confirm"] { --bg: var(--red); --glow: rgba(255, 255, 255, .14); }
body[data-state="error"] { --bg: var(--amber); --glow: rgba(255, 255, 255, .14); }

button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
svg { flex: none; }

/* ---------- scanner screen ---------- */

.app {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 10px);
    -webkit-user-select: none;
    user-select: none;
}

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 66px;
    border-radius: 18px;
    border: 2px solid rgba(255, 255, 255, .38);
    background: transparent;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: .02em;
    cursor: pointer;
}
.mode svg { width: 24px; height: 24px; }
.mode[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--brown); }
/* With Hofkasse: Eingang Ausgang / Aufladen Ausgaben, two rows, a bit lower. */
.modes.four { gap: 10px; }
.modes.four .mode { height: 54px; font-size: 1.2rem; }
body:is([data-state="ok"], [data-state="bad"], [data-state="confirm"], [data-state="error"]) .mode[aria-pressed="true"] {
    background: #fff; border-color: #fff; color: #1b1b1b;
}
body[data-state="locked"] .modes { visibility: hidden; }

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 12px 0;
    text-align: center;
    min-height: 0;
}

.center {
    --size: min(74vw, 46vh, 420px);
    position: relative;
    width: var(--size);
    height: var(--size);
    transition: width .2s ease, height .2s ease;
}
body:is([data-state="ok"], [data-state="bad"], [data-state="error"]) .center { --size: min(44vw, 25vh, 250px); }
body[data-state="confirm"] .center { --size: min(34vw, 17vh, 190px); }
body[data-state="scanning"] .center { --size: min(88vw, 54vh, 480px); }

.logo {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
}
.logo-mark {
    display: block;
    width: 100%;
    height: 100%;
    background: #fff;
    -webkit-mask: url(logo.svg) center / contain no-repeat;
    mask: url(logo.svg) center / contain no-repeat;
    transition: transform .12s ease;
}
.logo:active .logo-mark { transform: scale(.96); }
body[data-state="sending"] .logo-mark { animation: pulse .9s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.95); } }

.scanner {
    position: absolute;
    inset: 0;
    display: none;
    border-radius: 28px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .28);
}
.scanner video { display: block; width: 100%; height: 100%; object-fit: cover; }
.frame {
    position: absolute;
    inset: 16%;
    border: 4px solid rgba(255, 255, 255, .92);
    border-radius: 20px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .28);
}
body[data-state="scanning"] .logo { display: none; }
body[data-state="scanning"] .scanner { display: block; }

/* Close button on the scanner's top-right corner, half outside so it never covers the code. */
.scan-close {
    position: absolute;
    top: -18px;
    right: -18px;
    z-index: 2;
    display: none;
    place-items: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 3px solid var(--brown);
    border-radius: 50%;
    background: #fff;
    color: var(--brown);
    box-shadow: 0 3px 12px rgba(0, 0, 0, .45);
    cursor: pointer;
}
.scan-close svg { width: 30px; height: 30px; stroke-width: 3; }
body[data-state="scanning"] .scan-close { display: grid; }

.hint { margin: 0; color: var(--muted); font-size: 1.1rem; max-width: 22em; }
body[data-state="locked"] .hint { color: #fff; font-size: 1.25rem; font-weight: 700; }

.result { display: none; width: 100%; max-width: 34rem; }
body:is([data-state="ok"], [data-state="bad"], [data-state="confirm"], [data-state="error"]) .result { display: block; }
body:is([data-state="ok"], [data-state="bad"], [data-state="confirm"], [data-state="error"]) .hint { display: none; }
.result h1 {
    margin: 0 0 .22em;
    font-size: clamp(2.3rem, 11vw, 4.6rem);
    line-height: 1.02;
    font-weight: 900;
    text-transform: uppercase;
    /* Words are never split; app.js shrinks a word that does not fit (fitTitle). */
    overflow-wrap: normal;
}
.res-main { margin: 0 0 .25em; font-size: clamp(1.45rem, 6.6vw, 2.5rem); font-weight: 700; line-height: 1.2; }
.res-sub { margin: 0; font-size: clamp(1.15rem, 5vw, 1.8rem); line-height: 1.25; opacity: .93; }
.res-sub:empty, .res-main:empty, .res-code:empty, .res-inside:empty { display: none; }
.res-code {
    margin: 1em 0 0;
    font: 600 1rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    opacity: .8;
    overflow-wrap: anywhere;
}
.res-inside { margin: .35em 0 0; font-size: 1.05rem; opacity: .85; }
body[data-state="confirm"] .res-inside { display: none; }

.res-actions { display: none; flex-direction: column; gap: 12px; margin-top: 20px; }
body:is([data-state="confirm"], [data-state="error"]) .res-actions { display: flex; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 64px;
    padding: 10px 22px;
    border-radius: 18px;
    border: 2px solid transparent;
    font-size: 1.25rem;
    font-weight: 800;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.btn svg { width: 24px; height: 24px; }
.btn-white { background: #fff; color: var(--red); }
body[data-state="error"] .btn-white { color: var(--amber); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .75); }
.btn-line { background: transparent; border-color: rgba(255, 255, 255, .3); color: #fff; font-size: 1.1rem; min-height: 56px; }

/* ---------- till (Aufladen / Ausgaben, see kasse.js) ---------- */

.till { display: none; }
body:is([data-mode="topup"], [data-mode="sale"])[data-state="idle"] .till { display: flex; }
body:is([data-mode="topup"], [data-mode="sale"])[data-state="idle"] :is(.center, .hint) { display: none; }
body:is([data-mode="topup"], [data-mode="sale"])[data-state="idle"] .stage { justify-content: flex-start; padding-bottom: 0; }
.till { flex-direction: column; gap: 10px; align-self: stretch; text-align: left; }
.till-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 10px; padding-top: 6px; }
.till-grid[data-kind="topup"] { grid-template-columns: 1fr 1fr; }
.till-empty { grid-column: 1 / -1; color: var(--muted); text-align: center; }
.pick-wrap { position: relative; }
.pick {
    width: 100%;
    min-height: 106px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: 16px;
    border: 2px solid transparent;
    background: var(--brown-2);
    text-align: center;
    cursor: pointer;
}
.pick-wrap.on .pick { border-color: var(--gold); background: #4a3a28; }
.pick:active { transform: scale(.97); }
.pick-ico svg { width: 42px; height: 42px; }
.pick-name { font-weight: 700; font-size: 1rem; line-height: 1.15; }
.pick-price { color: var(--muted); font-size: .95rem; }
.pick-card { display: grid; place-content: center; width: 100%; aspect-ratio: 1.62; border-radius: 10px; background: var(--paper); color: #1d1d1b; }
.pick-card small { font-size: .85rem; font-weight: 700; }
.pick-card b { font-size: 1.7rem; font-weight: 900; }
.wk-50 { --paper: #a5cda1; }
.wk-20 { --paper: #f1d78e; }
.wk-x { --paper: #aecbe6; }
.pick-count {
    position: absolute; top: -8px; right: -4px;
    display: grid; place-items: center;
    min-width: 34px; height: 34px; padding: 0 8px;
    border-radius: 17px;
    background: var(--gold); color: var(--brown);
    font-size: 1.15rem; font-weight: 900;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
    pointer-events: none;
}
.pick-minus {
    position: absolute; top: -8px; left: -4px;
    display: grid; place-items: center;
    width: 38px; height: 38px; padding: 0;
    border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7);
    background: var(--brown); cursor: pointer;
}
.pick-minus svg { width: 20px; height: 20px; }
.till-bar {
    position: sticky;
    bottom: calc(env(safe-area-inset-bottom) + 6px);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
    padding: 12px;
    border-radius: 20px;
    background: var(--brown-2);
    box-shadow: 0 -6px 22px rgba(0, 0, 0, .4);
}
.till-label { color: var(--muted); }
.till-total { display: block; white-space: nowrap; font-size: clamp(1.6rem, 8vw, 2.9rem); font-weight: 900; line-height: 1.05; letter-spacing: -.01em; }
.till-clear { margin-top: 8px; padding: 8px 14px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, .3); background: none; font-weight: 700; cursor: pointer; }
.till-qr {
    position: relative;
    display: grid; place-items: center;
    width: min(42vw, 22vh, 180px);
    aspect-ratio: 1;
    padding: 0; border: 0; border-radius: 14px;
    background: #fff; overflow: hidden; cursor: pointer;
}
.till-qr-code { position: absolute; inset: 0; transition: filter .15s ease, opacity .15s ease; }
.till-qr-code svg { display: block; width: 100%; height: 100%; }
.till-qr-note { position: relative; padding: 6px; color: var(--brown); font-weight: 800; text-align: center; }
.till-qr[data-state="empty"] { background: rgba(255, 255, 255, .07); }
.till-qr[data-state="empty"] .till-qr-note { color: var(--muted); font-weight: 600; }
.till-qr[data-state="pending"] .till-qr-code { filter: blur(6px); opacity: .3; }
.till-qr:is([data-state="error"], [data-state="expired"]) .till-qr-code { opacity: .1; }
.till-qr[data-state="open"] .till-qr-note { display: none; }
.till-status { grid-column: 1 / -1; margin: 0; color: var(--muted); font-weight: 600; text-align: center; }
.till-status:empty { display: none; }
.till-status[data-kind="seen"] { color: var(--gold); }
.till-status[data-kind="bad"] { padding: 8px 12px; border-radius: 12px; background: var(--amber); color: #fff; }
.qr-big {
    position: fixed; inset: 0; z-index: 30;
    display: grid; place-content: center; justify-items: center; gap: 12px;
    padding: 20px;
    background: #fff; color: var(--brown);
    cursor: pointer;
}
.qr-big-code { width: min(88vw, 68vh); }
.qr-big-code svg { display: block; width: 100%; height: auto; }
.qr-big-total { margin: 0; font-size: 2.8rem; font-weight: 900; }
.qr-big-hint { margin: 0; color: #6b5b4b; }

.foot { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.device-label { margin-right: auto; color: var(--muted); font-size: .95rem; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
    display: inline-flex; align-items: center; gap: 8px;
    height: 44px; padding: 0 16px;
    border-radius: 22px; border: 2px solid rgba(255, 255, 255, .35);
    background: transparent; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.pill svg { width: 20px; height: 20px; }
.gear {
    display: grid; place-items: center;
    width: 52px; height: 52px;
    padding: 0; border: 0; border-radius: 50%;
    background: none; color: var(--muted); cursor: pointer;
}
.gear svg { width: 32px; height: 32px; }
body:not([data-state="idle"]):not([data-state="locked"]) .foot { visibility: hidden; }

/* ---------- settings sheet ---------- */

/* Anchored below the iPhone status bar: the app draws under it (black-translucent),
   so a centred sheet slid its title and close button behind the clock. */
.sheet {
    width: min(100vw - 24px, 460px);
    margin: calc(env(safe-area-inset-top) + 12px) auto auto;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    padding: 0 20px calc(env(safe-area-inset-bottom) + 20px);
    border: 0;
    border-radius: 22px;
    background: var(--brown-2);
    color: #fff;
    overflow-y: auto;
}
.sheet::backdrop { background: rgba(0, 0, 0, .6); }
.sheet-head {
    position: sticky; top: 0; z-index: 1;
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 0 10px;
    background: var(--brown-2);
}
.sheet h2 { margin: 0; font-size: 1.5rem; }
.sheet h3 { margin: 0 0 12px; font-size: 1.15rem; color: var(--gold); }
.icon-btn {
    display: grid; place-items: center;
    width: 46px; height: 46px; padding: 0;
    border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }
.block { padding: 16px 0 18px; border-bottom: 1px solid rgba(255, 255, 255, .12); margin-bottom: 18px; }
.block .btn, .sheet > .btn { width: 100%; }
.sheet > .btn + .btn { margin-top: 10px; }
.qr { width: min(100%, 300px); margin: 0 auto 12px; border-radius: 14px; overflow: hidden; background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.qr p { margin: 0; padding: 40px 16px; color: #333; text-align: center; font-weight: 700; }
.muted { color: var(--muted); font-size: 1rem; line-height: 1.45; }
.ios-hint svg { width: 18px; height: 18px; vertical-align: -3px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { color: var(--muted); font-size: .95rem; }
.field input {
    height: 52px; padding: 0 14px;
    border-radius: 12px; border: 2px solid rgba(255, 255, 255, .25);
    background: rgba(0, 0, 0, .25); color: #fff;
    font: inherit; font-size: 1.15rem; /* iOS zooms into anything below 16px */
}
.readonly {
    margin: 0; padding: 13px 14px;
    border-radius: 12px; background: rgba(0, 0, 0, .25);
    font-size: 1.15rem; font-weight: 700;
}
/* Browser only (iPhone/Android, not installed): install before the name, because the
   iPhone home-screen app does not see what was typed in Safari. */
.install-first {
    margin: 16px 0 6px;
    padding: 16px 16px 14px;
    border: 3px solid var(--gold);
    border-radius: 18px;
    background: rgba(217, 164, 65, .12);
}
.install-title { margin: 0 0 10px; color: var(--gold); font-size: 1.7rem; font-weight: 900; line-height: 1.1; }
.install-steps { margin: 0; padding-left: 1.4em; font-size: 1.2rem; line-height: 1.45; }
.install-steps li { margin-bottom: 8px; }
.install-steps svg { width: 22px; height: 22px; vertical-align: -4px; }
.install-steps .btn { width: 100%; margin-top: 8px; }
.install-note { margin: 4px 0 0; font-size: 1.1rem; font-weight: 800; }
.name-step { display: grid; gap: 4px; padding: 6px 0 4px; }
.name-step .muted { margin: 0 0 10px; }
.name-step .btn { width: 100%; margin-top: 6px; }
.initial { width: 5em; text-transform: uppercase; text-align: center; }
.form-error { margin: 0 0 8px; color: #ffb4a8; font-weight: 700; }
.name-preview { margin: 4px 0 12px; font-size: 2.2rem; font-weight: 900; text-align: center; }
.btn-gold { background: var(--gold); color: var(--brown); }
.check { display: flex; align-items: center; gap: 12px; font-size: 1.1rem; min-height: 44px; }
.check input { width: 24px; height: 24px; accent-color: var(--gold); }
.meta { margin: 14px 0 0; color: var(--muted); font-size: .85rem; text-align: center; opacity: .75; }

/* ---------- Protokoll ---------- */

body.report { background-image: none; -webkit-user-select: text; user-select: text; }
.report-head {
    position: sticky; top: 0; z-index: 2;
    display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
    background: var(--brown);
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.report-head h1 { margin: 0; font-size: 1.45rem; }
.report-head a { color: #fff; }
.report-tools { display: flex; gap: 10px; }
.report-main { max-width: 960px; margin: 0 auto; padding: 14px 16px calc(env(safe-area-inset-bottom) + 30px); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 18px; }
.tile { padding: 14px; border-radius: 16px; background: var(--brown-2); }
.tile b { display: block; font-size: 2rem; line-height: 1.1; }
.tile span { color: var(--muted); font-size: .95rem; }
.tile.alert { background: var(--red); }
.tile.alert span { color: #fff; }
.tile.main { background: var(--gold); color: var(--brown); }
.tile.main span { color: var(--brown); }
.card { margin-bottom: 18px; padding: 16px; border-radius: 18px; background: var(--brown-2); }
.card h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 1.25rem; }
.card.alert { box-shadow: inset 4px 0 0 var(--red); }
.badge { min-width: 30px; padding: 2px 10px; border-radius: 14px; background: rgba(255, 255, 255, .14); font-size: 1rem; text-align: center; }
.card.alert .badge { background: var(--red); }
.rows { display: grid; gap: 8px; }
.row { padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, .2); line-height: 1.45; }
.row .top { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.row .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); }
.tag { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: .85rem; font-weight: 700; background: rgba(255, 255, 255, .14); }
.tag.red { background: var(--red); }
.tag.green { background: var(--green); }
.tag.amber { background: var(--amber); }
.empty { color: var(--muted); margin: 4px 0; }
.search {
    width: 100%; height: 50px; margin-bottom: 12px; padding: 0 14px;
    border-radius: 12px; border: 2px solid rgba(255, 255, 255, .2);
    background: rgba(0, 0, 0, .25); color: #fff; font: inherit; font-size: 1.05rem;
}
.exports { display: grid; gap: 10px; }
.stamp { color: var(--muted); margin: 0 0 4px; }
