:root {
    --bg: #0f1727;
    --panel: #19253b;
    --text: #f5f7fb;
    --muted: #9aa7bd;
    --accent: #ea5178;
    --ok: #26a65b;
    --warn: #ffbf2f;
    --bad: #e03131;
    --kid: #3b82f6;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    min-height: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; font-size: 18px; }
.error { color: #ff8787; font-weight: 600; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
    background: var(--panel);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }
.net { font-size: 14px; }
.net.online { color: var(--ok); }
.net.offline { color: var(--bad); }

main {
    padding: 16px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 24px);
    max-width: 560px;
    margin: 0 auto;
}

h1 { font-size: 22px; margin: 8px 0 12px; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row .btn { flex: 1; }

.btn {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 16px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    background: var(--panel);
    cursor: pointer;
}
.btn.primary { background: var(--accent); }
.btn.ghost { background: transparent; border: 2px solid var(--panel); }
.btn.big { font-size: 20px; padding: 20px; background: rgba(0, 0, 0, 0.35); }
.btn.gate { text-align: left; }
.btn:active { transform: scale(0.99); }

.link {
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 15px;
    padding: 6px 0;
    cursor: pointer;
}
.link.back { display: block; margin-bottom: 4px; }

form label { display: block; margin: 14px 0 6px; font-size: 14px; color: var(--muted); }
form input, form select {
    width: 100%;
    border: 2px solid var(--panel);
    border-radius: 12px;
    background: #0b1220;
    color: var(--text);
    font-size: 22px;
    padding: 14px;
    letter-spacing: 0.08em;
}
#device-name { font-size: 16px; letter-spacing: 0; }
form .btn { margin-top: 16px; }

.scan-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.counter { font-size: 26px; font-weight: 800; }

#qr-reader {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    min-height: 280px;
}
#qr-reader video { border-radius: 16px; }
#qr-reader__dashboard { display: none !important; }

.overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 20px);
    color: #fff;
    text-align: center;
}
.overlay.valid { background: var(--ok); }
.overlay.kid { background: var(--kid); }
.overlay.already_used { background: var(--warn); color: #1b1b1b; }
.overlay.invalid { background: var(--bad); }
.overlay.offline { background: #495057; }

.overlay-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.ov-icon { font-size: 96px; line-height: 1; }
.ov-title { font-size: 26px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.ov-type { font-size: 44px; font-weight: 900; line-height: 1.1; word-break: break-word; }
.ov-detail { font-size: 17px; opacity: 0.92; white-space: pre-line; }
.overlay.already_used .btn.big { background: rgba(0, 0, 0, 0.15); color: #1b1b1b; }
