/* аиКиоск brand: orange #F47B20 + blue #1BA3E0. Phone-first app, wide layout for the admin panel. */
:root {
  --brand-orange: #F47B20; --brand-blue: #1BA3E0; --on-brand: #FFFFFF;
  --bg: #ECEEF1; --surface: #FFFFFF; --surface-2: #F4F6F8; --ink: #14202B; --muted: #5B6773; --line: #D9DEE4;
  --accent: #0A84C1; --accent-ink: #FFFFFF; --accent-soft: #E1F2FB;
  --charge: #F47B20; --good: #12945D; --good-soft: #DDF3E8; --bad: #CF3F36; --bad-soft: #FBE3E1;
  --shadow: 0 18px 40px -24px rgba(20, 32, 43, .45);
  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0C1117; --surface: #161D26; --surface-2: #1C2530; --ink: #E8EEF3; --muted: #97A4B1; --line: #2A3542;
    --accent: #3DB5EE; --accent-ink: #0B0F18; --accent-soft: #12324A;
    --charge: #FF8A33; --good: #3CC488; --good-soft: #173528; --bad: #F06A60; --bad-soft: #3A1E1D;
    --shadow: 0 18px 40px -24px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--f-body); -webkit-font-smoothing: antialiased }
button, input, select { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance }
h2 { font-size: 16px }
h3 { font-size: 14px; margin-bottom: 6px }
.num { font-variant-numeric: tabular-nums }
.muted { color: var(--muted) }
.small { font-size: 13px }
.block { display: block }
.center { text-align: center }
.stack { display: flex; flex-direction: column; gap: 12px }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px }
.row.wrap { flex-wrap: wrap }
.inline { display: inline-flex; align-items: center; gap: 6px }
.boot { text-align: center; color: var(--muted); padding: 40vh 16px 0 }
.boot-error { max-width: 420px; margin: 30vh auto 0; padding: 0 16px; text-align: center }

/* shell */
#app { min-height: 100dvh }
.screen-app { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) }
.app-head { display: flex; justify-content: space-between; align-items: center }
.logo { display: block; width: auto }
.hello { margin: 0; padding: 0 2px }
.hello small { display: block; color: var(--muted) }
.hello b { font-size: 19px }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px }

/* building blocks */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px }
.label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .05em; text-transform: uppercase }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px }
.btn { width: 100%; border: 0; border-radius: 16px; padding: 15px; font-weight: 700; font-size: 16px; background: var(--accent); color: var(--accent-ink); transition: filter .15s, transform .1s }
.btn:hover:not(:disabled) { filter: brightness(1.06) }
.btn:active:not(:disabled) { transform: scale(.99) }
.btn:disabled { opacity: .45; cursor: not-allowed }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; padding: 9px }
.btn.dark { background: var(--ink); color: var(--bg) }
.btn.small { width: auto; padding: 11px 18px; font-size: 14px; border-radius: 12px }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600 }
.chip-btn:hover { border-color: var(--accent) }
.chip-btn.armed { border-color: var(--bad); color: var(--bad) }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 5px 10px; font-size: 12px; font-weight: 600; white-space: nowrap }
.mini:hover { border-color: var(--accent) }
.mini.armed { border-color: var(--bad); color: var(--bad); background: var(--bad-soft) }
.err { margin: 0; background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600 }
.err[hidden] { display: none }
.note { margin: 0; background: var(--accent-soft); color: var(--accent); border-radius: 12px; padding: 10px 12px; font-weight: 600; text-align: center }
input, select { border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; width: 100% }
input:focus, select:focus { border-color: var(--accent); outline: none }
.big-input { font-size: 22px; font-weight: 700; padding: 13px 14px }
.code-input { letter-spacing: .4em; text-align: center; font-family: var(--f-display) }

.lvl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px 4px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; width: fit-content }
.lvl.charge { background: var(--brand-orange); color: var(--on-brand) }
.cells { display: inline-flex; gap: 2px; padding: 2px; border: 1.5px solid currentColor; border-radius: 4px; position: relative }
.cells::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 5px; background: currentColor; border-radius: 0 1px 1px 0 }
.cells i { width: 4px; height: 7px; border-radius: 1px; background: currentColor; opacity: .3 }
.cells i.on { opacity: 1 }

.demo-badge { position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 25;
  background: var(--brand-orange); color: var(--on-brand); font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; pointer-events: none }
.note[hidden] { display: none }

/* login */
.auth { max-width: 420px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left)) }
.auth-brand { display: flex; justify-content: center; margin-bottom: 28px }
.auth-card { background: var(--surface); border-radius: 26px; padding: 24px 20px; box-shadow: var(--shadow) }
.auth-title { font-family: var(--f-display); font-size: 22px }
.auth p { margin: 0 }
textarea { width: 100%; border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font: inherit; color: inherit; resize: vertical }
textarea:focus { border-color: var(--accent); outline: none }
.tg-preview { white-space: pre-wrap; background: var(--accent-soft); border-radius: 14px 14px 14px 4px; padding: 10px 14px; max-width: 420px; font-size: 14px }
.table td.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.narrow-wide { max-width: 760px }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px }
.btn-telegram { display: block; text-align: center; text-decoration: none; background: #229ED9; color: #FFFFFF }
.welcome-burst { font-family: var(--f-display); font-size: 56px; font-weight: 700; color: var(--brand-orange); margin-top: 8px }

/* client */
.balance { background: var(--brand-blue); color: var(--on-brand) }
.balance .label { color: inherit; opacity: .85 }
.balance-num { font-family: var(--f-display); font-size: 44px; font-weight: 700; line-height: 1.05; margin-top: 8px; letter-spacing: -.02em }
.balance-num span { font-size: 17px; font-weight: 600; opacity: .85; margin-left: 8px; letter-spacing: 0 }
.pending { margin-top: 6px; font-size: 13px; font-weight: 500 }
.pending b { background: var(--brand-orange); border-radius: 6px; padding: 0 5px }
.meter { margin-top: 16px }
.meter-track { height: 10px; border-radius: 6px; background: color-mix(in srgb, var(--on-brand) 30%, transparent); overflow: hidden }
.meter-track.light { background: var(--surface-2); height: 8px; margin-top: 6px }
.meter-fill { height: 100%; background: var(--brand-orange); border-radius: 6px; transition: width .6s ease }
.meter-cap { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 500; margin-top: 7px }
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center }
.qr-box { background: #FFFFFF; padding: 14px; border-radius: 18px; width: 248px; max-width: 100%; aspect-ratio: 1; display: grid; place-items: center }
.qr-img { width: 100%; height: auto; display: block }
.qr-timer { width: 248px; max-width: 100%; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden }
.qr-timer i { display: block; height: 100%; background: var(--accent); transition: width 1s linear }
.qr-meta { font-size: 13px; color: var(--muted) }
.qr-meta code { font: 600 14px/1 ui-monospace, Consolas, monospace; color: var(--ink); letter-spacing: .08em }
.hist h2 { margin-bottom: 4px }
.hist-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line) }
.hist-item:first-of-type { border-top: 0 }
.hist-item small { display: block; color: var(--muted); font-size: 12px }
.delta { font-weight: 700; white-space: nowrap; text-align: right }
.delta.plus { color: var(--good) }
.delta.minus { color: var(--bad) }
.delta small { display: block; font-weight: 500 }
.tag-wait { color: var(--charge) !important }
.rules summary { font-weight: 700; cursor: pointer }
.rules ul { margin: 10px 0 0; padding-left: 18px; color: var(--muted); display: grid; gap: 4px }

#toast { position: fixed; left: 0; right: 0; top: max(12px, env(safe-area-inset-top)); z-index: 30; display: flex; justify-content: center; pointer-events: none; padding: 0 12px }
.toast { width: min(440px, 100%); background: var(--ink); color: var(--bg); border-radius: 18px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; box-shadow: var(--shadow); animation: drop .3s ease; pointer-events: auto }
.toast b { display: block }
.toast-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--brand-orange); color: var(--on-brand); display: grid; place-items: center; font-weight: 800; flex: none }
.toast-error .toast-icon { background: var(--bad) }
.toast-ok .toast-icon { background: var(--good) }
@keyframes drop { from { transform: translateY(-120%); opacity: 0 } }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 22, .5); display: flex; align-items: flex-end; justify-content: center }
.sheet { width: min(460px, 100%); background: var(--surface); border-radius: 26px 26px 0 0; padding: 22px 18px max(26px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; animation: rise .3s ease }
.sheet h2 { font-family: var(--f-display); font-size: 21px }
.sheet p { margin: 0 }
@keyframes rise { from { transform: translateY(100%) } }

/* cashier */
.cashier { display: flex; flex-direction: column; gap: 14px }
.cashier p { margin: 0 }
.scan-frame { aspect-ratio: 1; width: 220px; max-width: 100%; margin: 4px auto; position: relative; border-radius: 22px; background: var(--surface-2); overflow: hidden }
.scan-frame.live { width: 100%; background: #000 }
.scan-frame::before { content: ""; position: absolute; inset: 16px; z-index: 2; --c: linear-gradient(var(--accent) 0 0);
  background: var(--c) top left/36px 4px, var(--c) top left/4px 36px, var(--c) top right/36px 4px, var(--c) top right/4px 36px,
    var(--c) bottom left/36px 4px, var(--c) bottom left/4px 36px, var(--c) bottom right/36px 4px, var(--c) bottom right/4px 36px;
  background-repeat: no-repeat }
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover }
.scan-line { position: absolute; z-index: 3; left: 22px; right: 22px; height: 2px; background: var(--brand-orange); box-shadow: 0 0 12px var(--brand-orange); animation: scan 1.4s ease-in-out infinite alternate }
@keyframes scan { from { top: 22px } to { top: calc(100% - 24px) } }
.manual { display: flex; gap: 8px }
.code-field { text-transform: uppercase; letter-spacing: .08em; font-weight: 600 }
.who { display: flex; gap: 12px; align-items: center }
.who-main { display: flex; flex-direction: column; gap: 3px; min-width: 0 }
.who-main small { color: var(--muted) }
.who-bal { margin-left: auto; text-align: right }
.who-bal small { display: block; color: var(--muted) }
.who-bal b { font-family: var(--f-display); font-size: 18px }
.sum-input { font: 700 28px var(--f-display); padding: 12px 14px }
.quick { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap }
.quick button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 600 }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer }
.switch input { appearance: none; -webkit-appearance: none; margin: 0; padding: 0; width: 46px; height: 28px; border: 0; border-radius: 14px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); transition: transform .2s }
.switch input:checked { background: var(--accent) }
.switch input:checked::after { transform: translateX(18px) }
.switch input:disabled { opacity: .4; cursor: not-allowed }
.switch small { display: block; color: var(--muted); font-size: 12px }
.sum-rows { display: flex; flex-direction: column; gap: 8px; font-size: 14px }
.sum-rows .total { font-size: 17px; font-weight: 700; padding-top: 8px; border-top: 1px dashed var(--line) }
.earn { color: var(--good); font-weight: 700 }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); margin: 16px auto 4px; animation: spin 1s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }
.ok-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--good-soft); color: var(--good); display: grid; place-items: center; font-size: 30px; font-weight: 800; margin: 6px auto 0 }
.ok-mark.bad { background: var(--bad-soft); color: var(--bad) }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px }
.stat { background: var(--surface); border-radius: 16px; padding: 10px 12px; min-width: 0 }
.stat b { display: block; font-size: 15px }
.stat small { color: var(--muted); font-size: 11px; font-weight: 600 }
.ops h2 { margin-bottom: 4px }
.op { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px }
.op:first-of-type { border-top: 0 }
.op small { display: block; color: var(--muted); font-size: 12px }
.refunded { font-size: 12px; color: var(--bad); font-weight: 600 }

/* admin */
.admin { max-width: 1180px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)) }
.admin p { margin: 0 }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 0 14px }
.admin-brand { display: flex; align-items: center; gap: 12px }
.admin-tag { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-orange) }
.admin-user { display: flex; align-items: center; gap: 10px }
.admin-nav { display: flex; gap: 4px; overflow-x: auto; padding: 4px; background: var(--surface); border-radius: 14px; margin-bottom: 18px; scrollbar-width: none }
.admin-nav button { border: 0; background: transparent; padding: 9px 14px; border-radius: 10px; font-weight: 600; white-space: nowrap; color: var(--muted) }
.admin-nav button:hover { color: var(--ink) }
.admin-nav button.active { background: var(--brand-blue); color: var(--on-brand) }
.admin-title { font-family: var(--f-display); font-size: 24px }
.narrow { max-width: 520px }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px }
.tiles.small { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) }
.tile { background: var(--surface); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line) }
.tile small { color: var(--muted); font-weight: 600; font-size: 12px }
.tile b { font-family: var(--f-display); font-size: 22px }
.tile span { font-size: 12px }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; align-items: start }
.admin-grid > * { min-width: 0 }
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; height: 180px; align-items: end; margin-top: 14px }
.bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px }
.bar-fill { width: 100%; min-height: 2px; background: var(--brand-blue); border-radius: 6px 6px 2px 2px }
.bar:last-child .bar-fill { background: var(--brand-orange) }
.bar small { font-size: 11px; color: var(--muted) }
.level-row { padding: 8px 0 }
.table-wrap { overflow-x: auto }
.table { width: 100%; border-collapse: collapse; font-size: 14px }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top }
.table.clickable tbody tr { cursor: pointer }
.table.clickable tbody tr:hover, .table.clickable tbody tr:focus { background: var(--surface-2); outline: none }
.table tr.dim td { opacity: .5 }
.adjust { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end }
.adjust .field { display: flex; flex-direction: column; min-width: 160px }
.adjust .grow { flex: 1 }
.adjust .err { flex-basis: 100% }
.client-card h2 { font-family: var(--f-display); font-size: 20px }
.level-edit { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center }
.level-edit input[type="number"] { width: 96px }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px }
.settings-grid .field small { display: block; margin-top: 4px }

@media (max-width: 560px) {
  .level-edit { grid-template-columns: 1fr 1fr }
  .admin-title { font-size: 20px }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important } }
