/* TicketMate POS — touch-first styles */
:root {
  --bg: #f3f1f8; --panel: #fff; --ink: #1d1530; --muted: #6b6480; --line: #e3dfec;
  --brand: #5b21b6; --brand-2: #7c3aed; --brand-soft: #f3efff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --tile: #2e1065; --radius: 14px; --tap: 52px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
button, a, input, select, label, .tile, .key { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; }
button:disabled { cursor: not-allowed; }
input, select { font: inherit; font-size: 17px; min-height: var(--tap); padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus { outline: 3px solid rgba(124, 58, 237, .35); border-color: var(--brand-2); }
button:focus-visible { outline: 3px solid rgba(124, 58, 237, .5); outline-offset: 2px; }
label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); font-weight: 600; }
label input, label select { display: block; width: 100%; margin-top: 6px; }
h2, h3, h4 { margin: 0; }
h3 { font-size: 20px; }
h4 { margin: 18px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); width: 100%; grid-column: 1 / -1; }
.empty.small { padding: 24px 12px; font-size: 15px; }
.bad { color: var(--bad); }
.n { text-align: right; white-space: nowrap; }
.neg { color: var(--bad); } .pos { color: var(--warn); }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn { min-height: var(--tap); border: 0; border-radius: 12px; padding: 10px 18px; background: #ece8f5; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .06s, filter .1s; }
.btn:active:not(:disabled), .tile:active:not(:disabled), .key:active, .method:active, .chip:active, .opt-btn:active, .tb-btn:active, .presets button:active, .quick-cash button:active, .qty button:active, .cal-day:active { transform: scale(.96); filter: brightness(.95); }
.btn:disabled { opacity: .45; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ghost { background: #fff; border: 1.5px solid var(--line); }
.btn-ghost.danger { color: var(--bad); border-color: #f5c2c2; }
.btn-xl { min-height: 60px; font-size: 18px; padding: 12px 22px; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn-row.grow > * { flex: 1 1 0; }
.grow-form { display: flex; margin: 0; } .grow-form .btn { flex: 1; }
.btn-pay { width: 100%; min-height: 72px; border: 0; border-radius: var(--radius); font-size: 24px; font-weight: 800; background: var(--ok); color: #fff; letter-spacing: .3px; }
.btn-pay:disabled { background: #a3a3b3; }
.btn-pay:active:not(:disabled) { transform: scale(.98); }
.icon-btn { width: var(--tap); height: var(--tap); flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; font-size: 22px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--tile); color: #fff; flex-wrap: wrap; position: relative; z-index: 20; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .3px; white-space: nowrap; }
.brand span { color: #c4b5fd; }
.ev-btn { min-height: var(--tap); max-width: 340px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; padding: 6px 14px; border: 1.5px solid rgba(255,255,255,.3); border-radius: 12px; background: rgba(255,255,255,.08); color: #fff; }
.ev-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; opacity: .7; }
.ev-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 310px; }
.spacer { flex: 1; }
.chip { min-height: var(--tap); border: 0; border-radius: 12px; padding: 6px 14px; font-weight: 800; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; line-height: 1.15; }
.chip small { font-weight: 600; font-size: 12px; opacity: .85; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.tb-btn { min-height: var(--tap); min-width: var(--tap); border: 1.5px solid rgba(255,255,255,.3); background: transparent; color: #fff; border-radius: 12px; padding: 4px 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.tb-btn .ico { font-size: 18px; line-height: 1; }

/* ---------- date picker ---------- */
.datepick { position: relative; display: flex; align-items: stretch; background: #fff; color: var(--ink); border-radius: 12px; overflow: visible; }
.dp-arrow { width: var(--tap); min-height: var(--tap); border: 0; background: transparent; font-size: 30px; line-height: 1; color: var(--brand); }
.dp-arrow:first-child { border-radius: 12px 0 0 12px; border-right: 1px solid var(--line); }
.dp-arrow:last-of-type { border-radius: 0 12px 12px 0; border-left: 1px solid var(--line); }
.dp-arrow:disabled { color: #cfcadd; }
.dp-main { min-height: var(--tap); min-width: 230px; border: 0; background: transparent; padding: 4px 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.dp-main.single { cursor: default; border-radius: 12px; }
.dp-label { font-weight: 800; font-size: 16px; white-space: nowrap; }
.dp-sub { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.dp-sub u { color: var(--brand); text-decoration: none; font-weight: 700; }
.dp-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #ccc; }
.dp-dot.ok { background: var(--ok); } .dp-dot.low { background: #f59e0b; } .dp-dot.out { background: var(--bad); }

.cal-pop { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: min(460px, 94vw); background: #fff; color: var(--ink); border-radius: 18px; box-shadow: 0 20px 60px rgba(20, 10, 40, .35); padding: 14px; z-index: 40; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 800; font-size: 18px; }
.cal-nav { width: var(--tap); height: var(--tap); border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 28px; line-height: 1; color: var(--brand); }
.cal-nav:disabled { color: #d6d2e2; border-color: #f0eef5; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day { min-height: 58px; border: 0; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: transparent; color: #c7c2d4; font-weight: 700; position: relative; padding: 2px; }
.cal-day .n { font-size: 17px; }
.cal-day .left { font-size: 10.5px; font-weight: 700; line-height: 1.1; }
.cal-day.ev { background: var(--brand-soft); color: var(--ink); }
.cal-day.ev.ok .left { color: var(--ok); }
.cal-day.ev.low { background: var(--warn-soft); } .cal-day.ev.low .left { color: var(--warn); }
.cal-day.ev.out { background: var(--bad-soft); } .cal-day.ev.out .left { color: var(--bad); }
.cal-day.ev.past { background: #f4f3f7; color: #b9b4c7; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--brand-2); }
.cal-day.sel { background: var(--brand) !important; color: #fff !important; }
.cal-day.sel .left { color: #e9d5ff !important; }
.cal-foot { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cal-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-quick button { min-height: 46px; padding: 6px 14px; border: 1.5px solid var(--brand); color: var(--brand); background: #fff; border-radius: 999px; font-weight: 700; }
.cal-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.cal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.cal-legend i.ok { background: var(--brand-soft); border: 1px solid #d8ccff; } .cal-legend i.low { background: var(--warn-soft); border: 1px solid #f7d58b; } .cal-legend i.out { background: var(--bad-soft); border: 1px solid #f5b5b5; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 1fr minmax(360px, 34%); gap: 12px; padding: 12px; height: calc(100vh - 72px); height: calc(100dvh - 72px); }
.catalogue, .cart { background: var(--panel); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.06); min-height: 0; }
.catalogue { display: flex; flex-direction: column; padding: 12px; }
.cat-tools { display: flex; gap: 8px; align-items: center; }
.search-wrap { position: relative; flex: 1; }
.search-wrap input { width: 100%; padding-right: 52px; }
.search-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border: 0; background: transparent; font-size: 26px; color: var(--muted); }
.sync { margin: 6px 2px 8px; }
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; overflow-y: auto; align-content: start; padding: 2px 2px 12px; -webkit-overflow-scrolling: touch; }

.tile { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 132px; padding: 14px; border: 0; border-radius: var(--radius); background: var(--tile); color: #fff; text-align: left; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .06s; }
.tile .t-title { font-weight: 700; font-size: 16px; line-height: 1.25; padding-right: 36px; }
.tile .t-price { font-size: 24px; font-weight: 800; margin-top: 8px; }
.tile .t-left { font-size: 13px; opacity: .85; font-weight: 600; }
.tile .t-badge { position: absolute; top: 10px; right: 10px; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 999px; background: #fff; color: var(--tile); font-weight: 800; display: flex; align-items: center; justify-content: center; }
.tile.low { background: #92400e; }
.tile.soldout { background: #d4d4dc; color: #6b7280; }
.tile.soldout .t-badge { background: var(--tile); color: #fff; }

/* ---------- cart ---------- */
.cart { display: flex; flex-direction: column; padding: 12px; gap: 10px; }
.cart-head { display: flex; justify-content: space-between; align-items: center; }
.cart-head h2 { font-size: 19px; }
.cart-lines { flex: 1; overflow-y: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 120px; -webkit-overflow-scrolling: touch; }
.line { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "info total" "qty rm"; gap: 8px 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.line.last { background: var(--brand-soft); border-radius: 10px; }
.l-info { grid-area: info; min-width: 0; }
.l-title { font-weight: 700; font-size: 16px; }
.l-total { grid-area: total; text-align: right; font-weight: 800; font-size: 18px; }
.qty { grid-area: qty; display: flex; align-items: center; }
.qty button { width: var(--tap); height: var(--tap); border: 1.5px solid var(--line); background: #f8f7fb; font-size: 24px; font-weight: 700; line-height: 1; }
.qty button:first-child { border-radius: 12px 0 0 12px; }
.qty button:last-child { border-radius: 0 12px 12px 0; }
.qty .q { width: 64px; border-left: 0; border-right: 0; background: #fff; font-size: 20px; }
.rm { grid-area: rm; justify-self: end; width: var(--tap); height: var(--tap); border: 1.5px solid #f5c2c2; border-radius: 12px; background: #fff; color: var(--bad); font-size: 26px; line-height: 1; }
.cart-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt-btn { min-height: 60px; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 6px 12px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; text-align: left; }
.opt-btn .opt-k { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.opt-btn .opt-v { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.opt-btn.set { border-color: var(--brand-2); background: var(--brand-soft); }
.totals .row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-size: 16px; }
.totals .grand { font-size: 30px; font-weight: 800; border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; }

/* ---------- modals / sheets ---------- */
.modal { position: fixed; inset: 0; background: rgba(20, 10, 40, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
.modal-card { background: #fff; border-radius: 20px; padding: 20px; width: 460px; max-width: 100%; max-height: 94vh; max-height: 94dvh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); -webkit-overflow-scrolling: touch; }
.modal-card.wide { width: 760px; }
.modal-card.xwide { width: 1040px; }
.modal-card.center { text-align: center; }
.modal-card.pad-card { width: 420px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.x { width: var(--tap); height: var(--tap); flex: none; border: 0; border-radius: 12px; background: #f3f1f8; font-size: 30px; line-height: 1; color: var(--muted); }
#askModal .modal-card, #userModal .modal-card { width: 440px; }
#askText { font-size: 22px; line-height: 1.35; margin: 8px 0 4px; }

/* event cards */
.event-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.event-card { position: relative; min-height: 92px; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.event-card.on { border-color: var(--brand); background: var(--brand-soft); }
.ec-title { font-weight: 800; font-size: 17px; padding-right: 80px; }
.ec-meta { color: var(--muted); font-size: 14px; }
.ec-badge { position: absolute; top: 12px; right: 12px; background: var(--ok-soft); color: var(--ok); font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; }

/* keypad */
.amount-box { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; background: #f6f4fb; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 16px; margin: 10px 0; }
.amount-box strong { font-size: 36px; font-variant-numeric: tabular-nums; margin-left: auto; }
.amount-box.with-sur { padding-top: 6px; padding-bottom: 6px; }
.amount-box.with-sur strong { font-size: 24px; }
.sur-break { border: 1.5px solid #fcd34d; background: #fffbeb; border-radius: 14px; padding: 8px 16px; margin: -2px 0 10px; }
.sur-break .row { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 0; font-size: 16px; font-variant-numeric: tabular-nums; }
.sur-break { margin-top: 10px; }
.sur-break .row.amt b { font-size: 26px; }
.sur-break .row.sur { color: #b45309; }
.sur-break .row.tot { border-top: 1.5px dashed #f59e0b; margin-top: 4px; padding-top: 6px; font-size: 18px; }
.sur-break .row.tot b { font-size: 32px; color: var(--tile); }
.due-sub { font-size: 14px; font-weight: 600; color: #b45309; }
.pay-sum .row.tot { border-top: 1.5px solid var(--line); margin-top: 2px; padding-top: 6px; font-weight: 800; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { min-height: 64px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.key-fn { background: #f3f1f8; font-size: 24px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.presets button { min-height: 50px; min-width: 64px; padding: 6px 14px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-weight: 700; }
.presets button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
#padHint { min-height: 18px; margin: 6px 2px; }

/* payment */
.modal-head h3 strong { color: var(--brand); font-size: 26px; margin-left: 4px; }
.pay-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px; }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.method { min-height: 60px; padding: 8px; border: 2px solid var(--line); border-radius: 14px; background: #fff; font-weight: 800; font-size: 16px; }
.method.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.method { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; position: relative; line-height: 1.15; }
.method img { max-width: 100%; height: 34px; object-fit: contain; pointer-events: none; }
.method .sur-tag { position: absolute; top: 4px; right: 6px; font-size: 11px; font-weight: 800; color: #b45309; background: #fef3c7; border-radius: 6px; padding: 1px 5px; }
.pay-hint { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: #fffbeb; color: #78350f; font-size: 15px; }
.cash-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 10px; }
.cash-notes .note { position: relative; min-height: 58px; border: 1.5px solid #bbf7d0; border-radius: 12px; background: #f0fdf4; color: #14532d; font-size: 18px; font-weight: 800; overflow: hidden; padding: 0; display: flex; align-items: center; justify-content: center; }
.cash-notes .note.has-img { aspect-ratio: 2 / 1; min-height: 0; background: #fff; }
.cash-notes .note img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.cash-notes .note.has-img b { position: absolute; right: 4px; bottom: 3px; background: rgba(20, 83, 45, .85); color: #fff; font-size: 13px; border-radius: 6px; padding: 1px 6px; }
.cash-notes .note:active { transform: scale(.95); }
.cash-notes .note.pop { animation: notePop .25s ease; }
@keyframes notePop { 50% { box-shadow: 0 0 0 4px #86efac; } }
.ref-wrap input { width: 100%; font-size: 19px; }
.pay-pad-row { display: grid; grid-template-columns: 1fr 150px; gap: 10px; margin-top: 10px; }
.pay-pad-row .quick-cash[hidden] + * { }
.quick-cash { display: flex; flex-direction: column; gap: 8px; }
.quick-cash button { flex: 1; min-height: 56px; border: 1.5px solid #bbf7d0; border-radius: 14px; background: #f0fdf4; font-weight: 800; font-size: 18px; color: #14532d; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.quick-cash button small { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
#btnAddPay { width: 100%; margin-top: 10px; }
.pay-right { display: flex; flex-direction: column; gap: 10px; }
.pay-list { flex: 1; min-height: 140px; border: 1.5px solid var(--line); border-radius: 14px; padding: 6px 10px; }
.pad-empty { padding: 14px 4px; line-height: 1.6; }
.tender { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 17px; }
.tender span { flex: 1; }
.tender .rm { width: 46px; height: 46px; font-size: 24px; }
.pay-sum .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 18px; }
.pay-sum .row.change { font-size: 26px; color: var(--ok); }
.alert { background: var(--bad-soft); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: 15px; font-weight: 600; }

/* done */
.done-tick { width: 76px; height: 76px; margin: 4px auto 10px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: 44px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.big-change { font-size: 20px; margin: 18px 0 6px; color: var(--muted); }
.big-change strong { display: block; font-size: 64px; color: var(--ok); line-height: 1.1; }

/* tables / kpis */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th.n, .tbl td.n { text-align: right; }
.tbl.big td { font-size: 20px; padding: 14px 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 8px; }
.kpis div { background: var(--brand-soft); border-radius: 12px; padding: 10px 12px; }
.kpis span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.kpis b { font-size: 20px; }

/* sales list */
#salesSearch { width: 100%; margin-bottom: 10px; }
.sales-list { display: flex; flex-direction: column; gap: 8px; max-height: 66vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sale-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.sale-row.voided { background: #faf9fc; }
.sale-row.voided .sr-total { text-decoration: line-through; color: var(--muted); }
.sr-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sr-total { font-weight: 800; font-size: 19px; }
.sr-actions { display: flex; gap: 8px; }
.tag { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 6px; }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.void-box { grid-column: 1 / -1; border-top: 1px dashed var(--line); padding-top: 8px; }
.void-go { display: flex; gap: 8px; }
.void-go input { flex: 1; }

/* report */
.report-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.report-tools label { margin: 0; flex: 1 1 160px; }
.report-body { max-height: 56vh; overflow-y: auto; }

/* toast */
.toast { position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 14px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 92vw; font-size: 17px; font-weight: 600; text-align: center; }
.toast.bad { background: var(--bad); }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #2e1065, #5b21b6); padding: 16px; }
.login-card { background: #fff; border-radius: 20px; padding: 28px; width: 400px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card .btn { width: 100%; min-height: 60px; font-size: 18px; margin-top: 8px; }
.login-alt { display: flex; align-items: center; justify-content: center; min-height: 48px; margin-top: 6px; font-weight: 700; color: var(--brand); text-decoration: none; border-radius: 12px; }
.login-alt:active { background: var(--brand-soft, #ede9fe); }
.alert.ok { background: #dcfce7; color: #166534; }
.login-logo { display: block; max-width: 180px; max-height: 90px; margin: 0 auto 14px; object-fit: contain; }
.login-body.has-bg .login-card { box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.login-brand { font-size: 26px; font-weight: 800; color: var(--tile); }
.login-brand span { color: var(--brand-2); }

/* ---------- smaller screens (portrait tablets / phones) ---------- */
@media (max-width: 1100px) {
  .tb-btn span:not(.ico) { display: none; }
  .ev-btn { max-width: 240px; } .ev-title { max-width: 210px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .ticket-grid { max-height: none; overflow: visible; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cart { position: sticky; bottom: 0; }
  .pay-grid { grid-template-columns: 1fr; }
  .brand { display: none; }
  .datepick { order: 10; width: 100%; }
  .dp-main { flex: 1; min-width: 0; }
  .ev-btn { flex: 1; max-width: none; } .ev-title { max-width: 60vw; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card, .modal-card.wide, .modal-card.xwide, .modal-card.pad-card { width: 100%; border-radius: 20px 20px 0 0; max-height: 96dvh; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .cal-pop { position: fixed; top: auto; bottom: 0; left: 0; transform: none; width: 100%; border-radius: 20px 20px 0 0; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .sale-row { grid-template-columns: 1fr auto; }
  .sr-actions { grid-column: 1 / -1; } .sr-actions .btn { flex: 1; }
}

/* ---------- on-screen keyboard ---------- */
.osk-wrap { position: relative; display: block; margin-top: 6px; }
.osk-wrap input { width: 100%; margin-top: 0 !important; padding-right: 62px; }
.osk-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 52px; height: 44px; border: 0; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 24px; line-height: 1; }
.osk-btn:active { transform: translateY(-50%) scale(.94); }
input.osk-active { border-color: var(--brand-2); outline: 3px solid rgba(124, 58, 237, .35); }
.osk { position: fixed; left: 0; right: 0; bottom: 0; z-index: 300; background: #e9e6f1; border-top: 1px solid #cfc9de; padding: 8px 8px max(10px, env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(20, 10, 40, .25); user-select: none; -webkit-user-select: none; }
.osk-bar { display: flex; align-items: center; gap: 8px; max-width: 1100px; margin: 0 auto 6px; }
.osk-field { flex: 1; font-weight: 700; color: var(--muted); font-size: 14px; padding-left: 4px; }
.osk-row { display: flex; gap: 6px; justify-content: center; max-width: 1100px; margin: 0 auto 6px; }
.osk-k { flex: 1 1 0; min-width: 0; height: 58px; border: 0; border-radius: 10px; background: #fff; color: var(--ink); font-size: 22px; font-weight: 600; box-shadow: 0 1px 0 #b8b2c8; touch-action: manipulation; }
.osk-k:active { background: var(--brand-soft); transform: scale(.95); }
.osk-fn { background: #d6d1e3; font-size: 17px; font-weight: 700; }
.osk-k.wide { flex: 1.5 1 0; }
.osk-k.space { flex: 4 1 0; font-size: 16px; color: var(--muted); }
.osk-k.on { background: var(--brand-2); color: #fff; }
.osk-k.lock { background: var(--brand); box-shadow: inset 0 -3px 0 #fff; }
.osk-go { flex: 2 1 0; background: var(--brand); color: #fff; font-size: 18px; font-weight: 800; }
.osk-bar .osk-k { flex: none; height: 44px; padding: 0 16px; font-size: 15px; }
body.osk-open.login-body { align-items: flex-start; padding-top: 24px; padding-bottom: 340px; }
@media (pointer: coarse) { .login-body { align-items: flex-start; padding-top: 24px; padding-bottom: 340px; } }
.recent { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 2px; }
.recent button { min-height: 44px; padding: 6px 14px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-weight: 700; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent button:active { background: var(--brand-soft); }
@media (max-width: 600px) { .osk { padding-left: 3px; padding-right: 3px; } .osk-row { gap: 4px; } .osk-k { height: 50px; font-size: 19px; border-radius: 8px; } .osk-fn { font-size: 14px; } }

/* ---------- ticket delivery (print / email) ---------- */
.deliver { border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.deliver-k { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.seg-t { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 6px; }
.seg-t button { min-height: 50px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 800; font-size: 15px; }
.seg-t button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
#deliverEmailWrap .osk-wrap { margin-top: 0; }
#deliverEmail { width: 100%; font-size: 18px; }
.mail-status { margin: 4px 0 2px; padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.mail-status.busy { background: #f3efff; color: var(--brand); }
.mail-status.ok { background: var(--ok-soft); color: var(--ok); }
.mail-status.bad { background: var(--bad-soft); color: var(--bad); }
.sr-actions { flex-wrap: wrap; }
/* keep dialogs usable above the on-screen keyboard */
body.osk-open .modal { align-items: flex-start; padding-bottom: 380px; overflow-y: auto; }
body.osk-open .modal-card { max-height: none; }

/* user menu: three actions */
#userModal .modal-card { width: 560px; max-width: calc(100vw - 32px); }
#userModal .btn-row { flex-wrap: wrap; }
#userModal .btn-row > * { flex: 1 1 150px; white-space: nowrap; }
#userModal .btn-row .grow-form .btn { width: 100%; }
