/* Lotterie POS — light touch-friendly design */

.pos-body {
    margin: 0;
    background: #f0f5fb;
    color: #0f172a;
    font-family: "Outfit", system-ui, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.pos-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* —— Top nav —— */
.pos-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #ffffff;
    border-bottom: 2px solid #dbeafe;
    position: sticky;
    top: 0;
    z-index: 60;
}

.pos-nav-brand {
    color: #1d4ed8;
    font-weight: 800;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 1rem;
    max-width: min(42vw, 220px);
}

.pos-nav-brand .pos-brand-logo {
    height: 28px;
    width: auto;
    max-width: 48px;
    object-fit: contain;
    flex-shrink: 0;
}

.pos-nav-brand .pos-brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pos-nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    flex: 1;
}

.pos-nav-link {
    color: #64748b;
    text-decoration: none;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 44px;
}

.pos-nav-link.active,
.pos-nav-link:hover {
    color: #1d4ed8;
    background: #eff6ff;
}

.pos-nav-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    font-size: 0.85rem;
    color: #475569;
}

.pos-online { color: #16a34a; }
.pos-online.offline { color: #dc2626; }

.pos-nav-logout {
    background: transparent;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    min-height: 44px;
    cursor: pointer;
}

.pos-nav-logout:hover {
    background: #fef2f2;
}

/* —— Toolbar —— */
.pos-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.55rem 0.65rem;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.pos-toolbar .tool-btn {
    min-height: 48px;
    min-width: 72px;
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    font-weight: 600;
    font-size: 0.82rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    cursor: pointer;
}

.pos-toolbar .tool-btn i { font-size: 1.15rem; color: #1d4ed8; }
.pos-toolbar .tool-btn:active { background: #eff6ff; }
.pos-toolbar .tool-btn.danger { border-color: #fecaca; color: #dc2626; }
.pos-toolbar .tool-btn.danger i { color: #dc2626; }
.pos-toolbar .tool-btn.gold i { color: #ea580c; }

.pos-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: #64748b;
}

/* —— Layout & panels —— */
.pos-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 0.65rem;
    padding: 0.65rem;
    min-height: 0;
}

.pos-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.75rem;
    min-height: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.pos-panel h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin: 0 0 0.65rem;
    font-weight: 700;
}

/* —— Draw & game buttons —— */
.draw-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.draw-btn {
    min-height: 56px;
    padding: 0.5rem 0.85rem;
    border-radius: 10px;
    border: 2px solid #bfdbfe;
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.95rem;
    flex: 1 1 120px;
    cursor: pointer;
}

.draw-btn.active {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(29, 78, 216, 0.25);
}

.draw-btn.closed { opacity: 0.45; }

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.game-btn {
    min-height: 72px;
    border-radius: 12px;
    border: 2px solid #bfdbfe;
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    cursor: pointer;
}

.game-btn small { color: #64748b; font-weight: 500; font-size: 0.72rem; }

.game-btn.active {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #ffffff;
}

.game-btn.active small { color: rgba(255, 255, 255, 0.8); }

.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.option-btn {
    min-height: 88px;
    border-radius: 12px;
    border: 2px solid #93c5fd;
    background: #eff6ff;
    color: #0f172a;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.75rem 0.9rem;
    cursor: pointer;
    text-align: left;
}

.option-btn small {
    color: #475569;
    font-weight: 500;
    font-size: 0.78rem;
    line-height: 1.25;
}

.option-btn.active {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #ffffff;
}

.option-btn.active small { color: rgba(255, 255, 255, 0.85); }

.selected-option-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #eff6ff;
    border: 2px solid #93c5fd;
    border-radius: 12px;
    padding: 0.65rem 0.9rem;
    margin-bottom: 0.75rem;
}

.selected-option-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    color: #0f172a;
    font-weight: 600;
}

.selected-option-text strong { color: #1d4ed8; }

/* —— Number entry —— */
.number-display {
    background: #f8fafc;
    border: 2px solid #bfdbfe;
    border-radius: 12px;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 800;
    letter-spacing: 0.18em;
    color: #1d4ed8;
    margin-bottom: 0.65rem;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
}

.numpad button {
    min-height: 56px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 1.45rem;
    font-weight: 700;
    cursor: pointer;
}

.numpad button:active { background: #eff6ff; }
.numpad button.fn { font-size: 0.95rem; background: #f1f5f9; color: #475569; }
.numpad button.clear { color: #dc2626; border-color: #fecaca; }
.numpad button.ok { background: #1d4ed8; border-color: #1d4ed8; color: #ffffff; }

.amount-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.45rem;
    margin-top: 0.65rem;
}

.amount-row input {
    min-height: 56px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #0f172a;
    font-size: 1.35rem;
    font-weight: 700;
    text-align: center;
    width: 100%;
}

.quick-amounts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}

.quick-amounts button {
    min-height: 44px;
    min-width: 56px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-weight: 600;
    cursor: pointer;
}

.quick-amounts button:active { background: #eff6ff; color: #1d4ed8; }

/* —— Bet list —— */
.bet-list {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.bet-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    background: #f8fafc;
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e2e8f0;
}

.bet-item .nums { font-weight: 800; font-size: 1.15rem; color: #1d4ed8; letter-spacing: 0.08em; }
.bet-item .game { color: #64748b; font-size: 0.8rem; }
.bet-item .amt { font-weight: 700; color: #16a34a; }

.bet-item .remove {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid #fecaca;
    background: #ffffff;
    color: #dc2626;
    font-size: 1.2rem;
    cursor: pointer;
}

/* —— Total & sell —— */
.pos-total {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
}

.pos-total .label { color: #64748b; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.pos-total .value { font-size: 1.8rem; font-weight: 800; color: #1d4ed8; }

.sell-btn {
    width: 100%;
    min-height: 72px;
    border: none;
    border-radius: 12px;
    background: #16a34a;
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 4px 16px rgba(22, 163, 74, 0.3);
    cursor: pointer;
}

.sell-btn:active { background: #15803d; }
.sell-btn:disabled { opacity: 0.45; box-shadow: none; cursor: not-allowed; }

.cancel-btn,
.btn-cancel {
    min-height: 48px;
    border: 2px solid #dc2626;
    background: transparent;
    color: #dc2626;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

/* —— Toast & modals —— */
.pos-toast {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    border: 1px solid #bfdbfe;
    color: #0f172a;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    z-index: 200;
    display: none;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.pos-toast.show { display: block; }
.pos-toast.error { border-color: #fecaca; color: #dc2626; }

.modal-content.pos-modal {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.pos-modal .form-control {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
    min-height: 48px;
}

/* —— POS dashboard pages —— */
.pos-page { padding: 0.75rem; max-width: 1400px; margin: 0 auto; }
.pos-page-header h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.25rem; color: #0f172a; }

.pos-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.65rem;
    margin-top: 0.75rem;
}

.dash-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.85rem;
    min-height: 90px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.dash-label { font-size: 0.75rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.04em; }
.dash-value { font-size: 1.35rem; font-weight: 800; margin-top: 0.25rem; color: #0f172a; }
.dash-value.gold { color: #1d4ed8; }
.dash-value.warn { color: #ea580c; }
.dash-sub { font-size: 0.78rem; color: #64748b; margin-top: 0.15rem; }

.pos-dashboard-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.75rem; }

.draw-chip {
    display: inline-block;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.82rem;
    margin: 0.2rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}

.draw-chip.closing { background: #fff7ed; border-color: #fed7aa; color: #ea580c; }

.payout-preview {
    margin-top: 0.75rem;
    padding: 0.65rem;
    border-radius: 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.preview-label { font-size: 0.75rem; color: #64748b; }
.preview-value { font-size: 1.25rem; font-weight: 800; color: #1d4ed8; }

.recent-numbers { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.recent-num-btn {
    min-height: 44px;
    min-width: 56px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
}

.recent-num-btn:active { background: #eff6ff; color: #1d4ed8; }

.ticket-preview-panel {
    margin-top: 0.75rem;
    padding: 0.65rem;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    max-width: 320px;
}

.ticket-preview-panel .ticket-preview-identity img {
    max-height: 36px;
    max-width: 90%;
    object-fit: contain;
}

.qr-reader { max-width: 360px; min-height: 240px; border-radius: 10px; overflow: hidden; }
.notif-item { padding: 0.5rem 0; border-bottom: 1px solid #e2e8f0; }
.notif-item.unread { border-left: 3px solid #1d4ed8; padding-left: 0.5rem; }

/* —— Optional dark theme override —— */
body.pos-theme-dark.pos-body {
    background: #0f172a;
    color: #e2e8f0;
}

body.pos-theme-dark .pos-nav { background: #1e293b; border-color: #334155; }
body.pos-theme-dark .pos-nav-brand { color: #93c5fd; }
body.pos-theme-dark .pos-nav-link { color: #94a3b8; }
body.pos-theme-dark .pos-nav-link.active { background: #1e3a5f; color: #93c5fd; }
body.pos-theme-dark .pos-panel,
body.pos-theme-dark .dash-card { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.pos-theme-dark .pos-toolbar { background: #1e293b; border-color: #334155; }
body.pos-theme-dark .pos-toolbar .tool-btn { background: #0f172a; color: #e2e8f0; border-color: #334155; }
body.pos-theme-dark .game-btn,
body.pos-theme-dark .draw-btn { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.pos-theme-dark .game-btn.active,
body.pos-theme-dark .draw-btn.active { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
body.pos-theme-dark .numpad button { background: #0f172a; border-color: #334155; color: #e2e8f0; }
body.pos-theme-dark .number-display { background: #0f172a; border-color: #334155; color: #93c5fd; }

/* —— Thermal receipt (58mm / 80mm) —— */
.receipt-body {
    margin: 0;
    padding: 0;
    background: #fff;
    color: #000;
    font-family: "Courier New", Courier, monospace;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.receipt-toolbar {
    padding: 12px;
    text-align: center;
}

.receipt-toolbar button {
    margin: 0 4px;
    padding: 6px 14px;
    font-size: 14px;
    cursor: pointer;
}

.receipt {
    margin: 0 auto;
    padding: 6px 8px;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    background: #fff;
    color: #000;
}

.receipt.w-80 { width: 80mm; max-width: 80mm; }
.receipt.w-58 { width: 58mm; max-width: 58mm; }

.receipt h1,
.receipt .ticket-identity-name {
    font-size: 16px;
    margin: 0 0 4px;
    text-align: center;
    font-weight: 800;
    letter-spacing: 0.02em;
    word-wrap: break-word;
}

.receipt.w-58 .ticket-identity-name { font-size: 13px; }

.receipt .ticket-identity { margin-bottom: 4px; text-align: center; }
.receipt .ticket-identity-logo { margin-bottom: 4px; text-align: center; }
.receipt .receipt-logo {
    display: inline-block;
    vertical-align: middle;
    max-width: 90%;
    height: auto;
    object-fit: contain;
}

.receipt .center { text-align: center; }
.receipt .right { text-align: right; }
.receipt .small { font-size: 10px; }
.receipt.w-58 .small { font-size: 9px; }
.receipt .line { border-top: 1px dashed #000; margin: 6px 0; }

.receipt .ticket-number {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    word-break: break-all;
    margin: 2px 0 4px;
}
.receipt.w-58 .ticket-number { font-size: 11px; }

.receipt table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
    table-layout: fixed;
}
.receipt.w-58 table { font-size: 10px; }
.receipt td {
    padding: 2px 0;
    vertical-align: top;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.receipt .nums {
    letter-spacing: 1px;
    font-weight: 700;
    white-space: nowrap;
}
.receipt .total-amt { font-size: 15px; font-weight: 700; }
.receipt.w-58 .total-amt { font-size: 13px; }
.receipt .pot-win { font-weight: 500; }

.receipt .qr-wrap {
    text-align: center;
    margin: 8px 0 4px;
    page-break-inside: avoid;
}
.receipt .qr {
    display: inline-block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.receipt.w-58 .qr { width: 96px; height: 96px; max-width: 100%; }
.receipt.w-80 .qr { width: 120px; height: 120px; max-width: 100%; }
.receipt.w-58 .receipt-logo { max-height: 42px; max-width: 85%; }
.receipt.w-80 .receipt-logo { max-height: 56px; max-width: 90%; }

.receipt .ticket-items td:nth-child(1) { width: 46%; }
.receipt .ticket-items td:nth-child(2) { width: 22%; }
.receipt .ticket-items td:nth-child(3) { width: 32%; }

@media print {
    @page {
        margin: 0 !important;
        size: auto;
    }

    html, body.receipt-body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        width: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .no-print,
    .receipt-toolbar,
    .pos-nav,
    .pos-sidebar,
    .pos-toolbar,
    .pos-bottom-nav,
    .pos-sell-dock-spacer,
    .navbar,
    .admin-sidebar,
    .sidebar,
    nav,
    header.pos-nav,
    button:not(.keep-print) {
        display: none !important;
    }

    .receipt-body {
        background: #fff !important;
        color: #000 !important;
    }

    .receipt {
        margin: 0 !important;
        padding: 2mm 2.5mm !important;
        box-shadow: none !important;
        page-break-after: avoid;
        page-break-inside: avoid;
        float: none !important;
    }

    .receipt.w-80 {
        width: 72mm !important;
        max-width: 72mm !important;
    }

    .receipt.w-58 {
        width: 48mm !important;
        max-width: 48mm !important;
    }

    .receipt .qr-wrap,
    .receipt .ticket-number,
    .receipt .ticket-identity,
    .receipt table {
        page-break-inside: avoid;
    }

    .receipt * {
        color: #000 !important;
        background: transparent !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
}

/* —— Touch / focus (no hover-only actions) —— */
.pos-nav-link:focus-visible,
.tool-btn:focus-visible,
.draw-btn:focus-visible,
.game-btn:focus-visible,
.option-btn:focus-visible,
.numpad button:focus-visible,
.sell-btn:focus-visible,
.quick-amounts button:focus-visible,
.recent-num-btn:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

.pos-nav-link:active,
.tool-btn:active {
    transform: scale(0.98);
}

/* Sticky sell dock — always reachable on POS */
.pos-sell-dock {
    position: sticky;
    bottom: 0;
    z-index: 40;
    margin: 0 -0.75rem -0.75rem;
    padding: 0.65rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, #ffffff 35%);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.06);
}

.pos-sell-dock .pos-total { margin-bottom: 0.5rem; }
.pos-sell-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

/* Modals fit viewport */
#posModal .modal-dialog,
#favoritesModal .modal-dialog {
    margin: 0.5rem auto;
    max-width: min(520px, calc(100vw - 1rem));
    max-height: calc(100dvh - 1rem);
}

#posModal .modal-content,
#favoritesModal .modal-content {
    max-height: calc(100dvh - 1rem);
    display: flex;
    flex-direction: column;
}

#posModal .modal-body,
#favoritesModal .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

#posModal .modal-footer,
#favoritesModal .modal-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
}

#posModal .modal-footer .btn,
#favoritesModal .modal-footer .btn,
.pos-modal-action {
    min-height: 48px;
    min-width: 110px;
    font-weight: 700;
}

.pos-modal .btn-close {
    width: 2rem;
    height: 2rem;
    opacity: 0.75;
}

/* Responsive tables → stacked cards on small screens */
.pos-table-cards {
    width: 100%;
    border-collapse: collapse;
}

@media (max-width: 700px) {
    .pos-table-cards thead { display: none; }
    .pos-table-cards,
    .pos-table-cards tbody,
    .pos-table-cards tr,
    .pos-table-cards td {
        display: block;
        width: 100%;
    }
    .pos-table-cards tr {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 0.65rem 0.75rem;
        margin-bottom: 0.55rem;
    }
    .pos-table-cards td {
        padding: 0.2rem 0;
        border: 0;
        text-align: left !important;
    }
    .pos-table-cards td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #64748b;
        font-weight: 700;
    }
}

/* Keyboard open: keep focused field visible */
body.pos-keyboard-open {
    padding-bottom: var(--pos-keyboard-pad, 0px);
}

body.pos-keyboard-open .pos-sell-dock {
    bottom: var(--pos-keyboard-pad, 0px);
}

body.pos-keyboard-open .pos-toast {
    bottom: calc(1rem + var(--pos-keyboard-pad, 0px));
}

.pos-scroll-anchor {
    scroll-margin-bottom: calc(120px + var(--pos-keyboard-pad, 0px) + env(safe-area-inset-bottom, 0px));
}

/* —— Breakpoints: tablets / POS terminals —— */
@media (max-width: 1366px) {
    .pos-layout {
        grid-template-columns: 1.05fr 0.95fr;
        gap: 0.55rem;
        padding: 0.55rem;
    }
    .game-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}

@media (max-width: 1100px) {
    .pos-nav {
        flex-wrap: nowrap;
        gap: 0.35rem;
        padding: 0.4rem 0.5rem;
        overflow: visible;
    }
    .pos-nav-links {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .pos-nav-links::-webkit-scrollbar { display: none; }
    .pos-nav-link {
        flex: 0 0 auto;
        white-space: nowrap;
    }
    .pos-nav-user { display: none; }
    .pos-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .pos-toolbar::-webkit-scrollbar { display: none; }
    .pos-toolbar .tool-btn { flex: 0 0 auto; }
    .pos-meta {
        margin-left: 0;
        flex: 0 0 auto;
        white-space: nowrap;
    }
}

@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
        padding: 0.5rem;
        gap: 0.5rem;
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    }
    .pos-panel { padding: 0.65rem; }
    .bet-list { max-height: min(280px, 38vh); }
    .pos-dashboard-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .option-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .selected-option-bar { flex-wrap: wrap; }
    .amount-row {
        grid-template-columns: 1fr;
    }
    .amount-row #btnAddBet { min-height: 56px; width: 100%; }
    .ticket-preview-panel { max-width: 100%; }
    .qr-reader { max-width: 100%; min-height: 200px; }
}

/* Phones / 5–7" POS + portrait tablets */
@media (max-width: 768px) {
    .pos-body { font-size: 15px; }
    .pos-nav-brand { max-width: min(36vw, 140px); font-size: 0.9rem; }
    .pos-nav-link span { display: none; }
    .pos-nav-link {
        min-width: 48px;
        min-height: 48px;
        justify-content: center;
        padding: 0.5rem;
    }
    .pos-nav-link i { font-size: 1.25rem; }
    .pos-page { padding: 0.55rem; }
    .pos-page-header h1 { font-size: 1.25rem; }
    .numpad button { min-height: 52px; font-size: 1.35rem; }
    .number-display {
        min-height: 64px;
        font-size: clamp(1.5rem, 8vw, 2.2rem);
    }
    .draw-btn { min-height: 52px; flex: 1 1 46%; }
    .game-btn { min-height: 64px; }
    .sell-btn { min-height: 64px; font-size: 1.2rem; }
    .pos-total .value { font-size: 1.5rem; }
    .bet-item {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "info remove"
            "amt remove";
    }
    .bet-item > div:first-child { grid-area: info; }
    .bet-item .amt { grid-area: amt; }
    .bet-item .remove { grid-area: remove; align-self: center; }
}

/* Very small POS (≈5–6") */
@media (max-width: 420px) {
    .pos-toolbar .tool-btn {
        min-width: 64px;
        min-height: 44px;
        font-size: 0.72rem;
        padding: 0.35rem 0.45rem;
    }
    .pos-toolbar .tool-btn i { font-size: 1rem; }
    .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .option-grid { grid-template-columns: 1fr; }
    .dash-card { min-height: 78px; padding: 0.7rem; }
    .dash-value { font-size: 1.15rem; }
}

/* Short landscape POS terminals */
@media (max-height: 520px) and (orientation: landscape) {
    .pos-nav { padding: 0.25rem 0.4rem; }
    .pos-nav-link { min-height: 40px; padding: 0.3rem 0.45rem; }
    .pos-toolbar { padding: 0.35rem; }
    .pos-toolbar .tool-btn { min-height: 40px; min-width: 60px; }
    .pos-layout { padding: 0.35rem; gap: 0.35rem; }
    .number-display { min-height: 48px; margin-bottom: 0.35rem; }
    .numpad { gap: 0.25rem; }
    .numpad button { min-height: 40px; font-size: 1.1rem; }
    .game-btn { min-height: 52px; }
    .draw-btn { min-height: 44px; }
    .sell-btn { min-height: 52px; font-size: 1.05rem; }
    .bet-list { max-height: 140px; }
    .pos-sell-dock { padding: 0.4rem 0.55rem; }
}

/* Large desktop POS (1080p+) keep comfortable spacing */
@media (min-width: 1600px) {
    .pos-layout {
        grid-template-columns: 1.2fr 0.8fr;
        max-width: 1600px;
        margin: 0 auto;
        width: 100%;
    }
    .numpad button { min-height: 64px; }
    .sell-btn { min-height: 80px; }
}

/* POS login (auth shell) — username/password, touch-friendly */
.pos-signin {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}
.pos-signin-title {
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    font-weight: 800;
    margin: 0 0 0.35rem;
    text-align: center;
}
.pos-signin-hint {
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    line-height: 1.4;
}
.pos-signin-form .form-label {
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.pos-signin-input,
.auth-card .form-control-lg,
.auth-card .btn-lg,
.pos-signin-btn {
    min-height: 52px;
    font-size: 1.05rem;
}
.pos-signin-btn {
    font-weight: 700;
    letter-spacing: 0.02em;
}
.pos-signin .form-check {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.pos-signin .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0;
}
.auth-card .alert {
    position: relative;
    z-index: 1;
    margin-bottom: 1rem;
}
@media (max-width: 576px) {
    .pos-signin-input,
    .pos-signin-btn,
    .auth-card .form-control-lg,
    .auth-card .btn-lg {
        min-height: 56px;
        font-size: 1.1rem;
    }
}

body.pos-theme-dark .pos-sell-dock {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.92) 0%, #1e293b 35%);
    border-top-color: #334155;
}
