/* =========================================================
   TillBox POS  (public/css/pos.css)
   Simple, soft and friendly. One accent (pistachio),
   dark ink buttons, rounded shapes, lots of space.
   ========================================================= */

:root {
    --bg: #f5f6fa;
    --card: #ffffff;
    --ink: #1b1f2a;
    --muted: #7a8094;
    --line: #e7e9f0;
    --accent: #f89151;        /* pistachio: active states and highlights */
    --accent-soft: #eefbdc;
    --lilac: #e9e4ff;
    --peach: #ffe6d6;
    --danger: #e5484d;

    --r: 22px;
    --r-sm: 14px;
    --shadow: 0 1px 2px rgba(27, 31, 42, .04), 0 10px 30px -14px rgba(27, 31, 42, .14);
    --font: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --bs-body-font-family: var(--font);
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-link-color: var(--ink);
}

[data-theme="dark"] {
    --bg: #101219;
    --card: #181b25;
    --ink: #eef0f6;
    --muted: #8e94a8;
    --line: #272b38;
    --accent-soft: #24301a;
    --lilac: #2a2547;
    --peach: #3a2a22;
    --shadow: 0 10px 30px -14px rgba(0, 0, 0, .6);
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
    --bs-link-color: var(--ink);
}

* { -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
}

/* Thin bar at the very top */
.nav-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 4100; pointer-events: none; opacity: 0; transition: opacity .3s; }
.nav-progress.on { opacity: 1; }
.nav-progress > span { display: block; width: 0; height: 100%; background: var(--accent, #f06c1a); box-shadow: 0 0 10px var(--accent, #f06c1a); border-radius: 0 3px 3px 0; transition: width .3s cubic-bezier(.22, 1, .36, 1); }

/* Overlay */
.boot {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: grid;
    place-items: center;
    color: var(--ink, #20232b);
    background: color-mix(in srgb, var(--bg, #f3f4f6) 72%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .3s ease, visibility 0s linear .3s;
}
html.loader-on .boot { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .25s ease, visibility 0s; }
html.loader-splash .boot { background: var(--bg, #f3f4f6); -webkit-backdrop-filter: none; backdrop-filter: none; transition-duration: .5s; }

.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px; text-align: center; }

/* Logo with two orbiting rings */
.boot-logo { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.boot-mark {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    font: 800 32px/1 'Onest', system-ui, sans-serif;
    color: var(--on-accent, #fff);
    background: var(--accent, #f06c1a);
    border-radius: 20px;
    box-shadow: 0 16px 32px -10px rgba(240, 108, 26, .75);
    animation: bootBob 1.6s ease-in-out infinite;
}
.boot-ring { position: absolute; inset: 0; border: 3px solid transparent; border-top-color: var(--accent, #f06c1a); border-right-color: rgba(240, 108, 26, .35); border-radius: 50%; animation: bootSpin 1.1s linear infinite; }
.boot-ring.r2 { inset: -12px; border-top-color: transparent; border-right-color: transparent; border-bottom-color: rgba(240, 108, 26, .55); border-left-color: rgba(240, 108, 26, .2); animation-duration: 1.8s; animation-direction: reverse; }

/* Splash-only parts */
.boot-brand, .boot-scan, .boot-msg { display: none; }
html.loader-splash .boot-brand { display: block; }
html.loader-splash .boot-scan { display: flex; }
html.loader-splash .boot-msg { display: block; }

.boot-brand { font: 700 22px/1.1 'Onest', system-ui, sans-serif; letter-spacing: -.03em; }
.boot-brand small { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; letter-spacing: .08em; color: var(--muted, #6f7684); }
.boot-msg { min-height: 20px; font-size: 14px; color: var(--muted, #6f7684); }

/* Barcode with a sweeping laser */
.boot-scan { position: relative; align-items: center; justify-content: center; gap: 4px; min-width: 150px; height: 44px; }
.boot-scan i { display: block; width: 3px; height: 100%; background: currentColor; border-radius: 1px; opacity: .85; }
.boot-scan i:nth-child(2n) { width: 2px; }
.boot-scan i:nth-child(3n) { width: 5px; }
.boot-scan i:nth-child(5n) { width: 4px; }
.boot-scan i:nth-child(4n) { height: 76%; }
.boot-scan i:nth-child(7n) { height: 60%; }
.boot-scan::after {
    content: "";
    position: absolute;
    top: -7px;
    bottom: -7px;
    left: 0;
    width: 3px;
    background: var(--accent, #f06c1a);
    border-radius: 3px;
    box-shadow: 0 0 14px 3px rgba(240, 108, 26, .7);
    animation: bootLaser 1.3s ease-in-out infinite alternate;
}

@keyframes bootSpin  { to { transform: rotate(360deg); } }
@keyframes bootBob   { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-5px) rotate(3deg); } }
@keyframes bootLaser { to { left: calc(100% - 3px); } }

/* The old page slides away a little while the next one loads */
html.is-leaving .stage { opacity: 0; transform: translateY(-10px); transition: opacity .25s ease, transform .25s ease; }

/* Reduced motion: keep a slow spin so people can still see something is happening */
@media (prefers-reduced-motion: reduce) {
    .boot-ring { animation: bootSpin 2.4s linear infinite !important; }
    .boot-ring.r2 { animation-duration: 3.6s !important; }
    .boot-mark, .boot-scan::after { animation: none !important; }
    html.is-leaving .stage { transition: none; }
}

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -.02em; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Top bar ---------- */
.top {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 14px 32px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -.03em;
}
.logo-dot {
    width: 22px;
    height: 22px;
    background: var(--ink);
    border-radius: 50% 50% 50% 6px;     /* a speech-bubble / price-tag shape */
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 5px;
    background: var(--card);
    border-radius: 999px;
    box-shadow: var(--shadow);
}
.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    font-weight: 500;
    color: var(--muted);
    border-radius: 999px;
    transition: background .15s, color .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--accent); color: #1b1f2a; font-weight: 600; }

.top-tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.search { position: relative; }
.search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input {
    width: 190px;
    height: 44px;
    padding: 0 16px 0 40px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: width .2s, border-color .15s;
}
.search input:focus { outline: none; width: 260px; border-color: var(--ink); }

.round-btn, .avatar {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 18px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
    transition: transform .12s;
}
.round-btn:hover, .avatar:hover { transform: scale(1.06); }
.avatar { font-weight: 700; font-size: 16px; background: var(--ink); color: var(--bg); border-color: var(--ink); }

.pos-menu {
    min-width: 220px;
    padding: 8px;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    margin-top: 10px !important;
}
.pos-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--ink);
    border-radius: 12px;
}
.pos-menu .dropdown-item:hover { background: var(--accent-soft); }
.pos-menu .dropdown-divider { border-color: var(--line); }
.menu-who { display: flex; flex-direction: column; line-height: 1.25; padding: 8px 12px 10px; }
.menu-who small { color: var(--muted); }

/* ---------- Page ---------- */
.stage { max-width: 1240px; margin: 0 auto; padding: 18px 32px 60px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 26px;
}
.page-head h1 { margin: 0; font-size: clamp(30px, 4vw, 42px); line-height: 1.1; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.flash {
    display: flex;
    gap: 10px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-weight: 500;
    border-radius: var(--r-sm);
}
.flash-success { background: var(--accent-soft); }
.flash-error { background: var(--peach); }

/* ---------- Components ---------- */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.b-3 { grid-column: span 3; }
.b-4 { grid-column: span 4; }
.b-6 { grid-column: span 6; }
.b-8 { grid-column: span 8; }
.b-12 { grid-column: span 12; }

.panel {
    padding: 24px;
    background: var(--card);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}
.panel-title { margin: 0 0 16px; font-size: 18px; }
.panel.tint-accent { background: var(--accent-soft); box-shadow: none; }
.panel.tint-lilac { background: var(--lilac); box-shadow: none; }
.panel.tint-peach { background: var(--peach); box-shadow: none; }

.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { margin-top: 4px; font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }

.btn-pos {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 22px;
    font: inherit;
    font-weight: 600;
    color: var(--bg);
    background: var(--ink);
    border: 1px solid var(--ink);
    border-radius: 999px;
    cursor: pointer;
    transition: transform .12s, opacity .15s;
}
.btn-pos:hover { color: var(--bg); opacity: .88; }
.btn-pos:active { transform: scale(.97); }
.btn-pos.accent { background: var(--accent); border-color: var(--accent); color: #1b1f2a; }
.btn-pos.accent:hover { color: #1b1f2a; }
.btn-pos.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-pos.ghost:hover { color: var(--ink); border-color: var(--ink); opacity: 1; }
.btn-pos.block { width: 100%; }

.badge-pos {
    display: inline-block;
    padding: 2px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    background: var(--accent-soft);
    border-radius: 999px;
}
.badge-pos.lilac { background: var(--lilac); }
.badge-pos.peach { background: var(--peach); }

.pos-table { width: 100%; border-collapse: collapse; }
.pos-table th { padding: 8px 12px; text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); }
.pos-table td { padding: 14px 12px; border-top: 1px solid var(--line); }
.pos-table .num { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.form-control, .form-select {
    min-height: 48px;
    color: var(--ink);
    background-color: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}
.form-control:focus, .form-select:focus {
    color: var(--ink);
    background-color: var(--card);
    border-color: var(--ink);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
/* ---------- Quick shortcuts: 2 rows of buttons ---------- */
.shortcuts-scroll { margin: 0; padding: 4px 0 0; }
.shortcuts { display: grid; gap: 12px; }
.shortcut-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }

.shortcut {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 106px;
    padding: 14px 8px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    color: var(--ink);
    background: var(--bg);
    border: 0;
    border-radius: 20px;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .25s var(--ease, ease), box-shadow .25s var(--ease, ease), background-color .2s;
}
.shortcut:hover { color: var(--ink); transform: translateY(-4px); box-shadow: 0 16px 28px -16px rgba(32, 35, 43, .4); }
.shortcut:active { transform: scale(.95); }

.sc-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    font-size: 22px;
    border-radius: 15px;
    background: var(--card);
    transition: transform .35s var(--ease-bounce, ease);
}
.shortcut:hover .sc-icon { transform: scale(1.12) rotate(-6deg); }
.shortcut.t0 .sc-icon { background: var(--accent-soft); color: var(--accent); }
.shortcut.t1 .sc-icon { background: var(--lilac); }
.shortcut.t2 .sc-icon { background: var(--peach); color: var(--accent); }

.shortcut.primary { color: var(--on-accent); background: var(--accent); box-shadow: var(--glow-sm); }
.shortcut.primary:hover { color: var(--on-accent); box-shadow: var(--glow); }
.shortcut.primary .sc-icon { color: var(--on-accent); background: rgba(255, 255, 255, .22); }

.sc-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--on-accent);
    background: var(--accent);
    border-radius: 999px;
}

@media (hover: none) { .shortcut:hover { transform: none; box-shadow: none; } .shortcut.primary:hover { box-shadow: var(--glow-sm); } }

/* Phones: both rows scroll sideways together, so there are always exactly 2 lines */
@media (max-width: 767.98px) {
    .shortcuts-scroll { margin: 0 -20px; padding: 4px 20px 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .shortcuts-scroll::-webkit-scrollbar { display: none; }
    .shortcuts { min-width: 580px; }
    .shortcut-row { grid-template-columns: repeat(5, minmax(104px, 1fr)); }
}

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 78px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.pos-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 230px;
    max-width: 340px;
    padding: 14px 18px;
    font-weight: 500;
    color: #fff;
    background: var(--ink);
    border-radius: 16px;
    box-shadow: 0 16px 34px -12px rgba(0, 0, 0, .4);
    animation: toastIn .25s ease;
}
[data-theme="dark"] .pos-toast { color: var(--bg); }
.pos-toast i { color: var(--accent); }
.pos-toast.error i { color: #ff8a8e; }
.pos-toast.warning i { color: #ffd166; }
.pos-toast.leaving { opacity: 0; transform: translateY(-8px); transition: all .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ---------- Mobile bottom tabs ---------- */
.bottom-tabs { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1099.98px) {
    .tab span { display: none; }
    .tab { padding: 0 16px; }
    .search input, .search input:focus { width: 150px; }
}

@media (max-width: 991.98px) {
    .b-3 { grid-column: span 6; }
    .b-4, .b-6, .b-8 { grid-column: span 12; }
}

@media (max-width: 767.98px) {
    .top { grid-template-columns: 1fr auto; padding: 12px 16px; }
    .tabs { display: none; }
    .search { display: none; }

    .stage { padding: 6px 16px 110px; }
    .panel { padding: 20px; border-radius: 20px; }
    .stat-value { font-size: 28px; }

    .bottom-tabs {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        z-index: 1030;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding: 6px;
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: 26px;
        box-shadow: 0 18px 40px -16px rgba(27, 31, 42, .35);
    }
    .bottom-tabs a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 8px 0 6px;
        font-size: 11.5px;
        font-weight: 500;
        color: var(--muted);
        border-radius: 20px;
    }
    .bottom-tabs a i { font-size: 20px; }
    .bottom-tabs a.is-active { background: var(--accent); color: #1b1f2a; font-weight: 600; }

    .toast-stack { left: 16px; right: 16px; top: auto; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
    .pos-toast { max-width: none; }
}

@media (max-width: 480px) {
    .b-3 { grid-column: span 12; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
    .top, .bottom-tabs, .toast-stack { display: none !important; }
    body { background: #fff; }
    .panel { box-shadow: none; }
}

/* ---------- Charts ---------- */
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.chart-head .panel-title { margin: 0; }
.chart-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-sub { color: var(--muted); font-size: 13px; }
.chart-box { position: relative; height: 290px; }
.chart-box.short { height: 250px; }


.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.tool-search { position: relative; flex: 1 1 240px; min-width: 0; }
.tool-search > i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.tool-search .form-control { padding-left: 44px; font-size: 16px; border-radius: 999px; }
.toolbar .form-select { flex: 1 1 140px; width: auto; max-width: 200px; font-size: 16px; border-radius: 999px; padding-left: 18px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; }

.cell-product { display: flex; align-items: center; gap: 12px; min-width: 210px; }
.cell-icon { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); border-radius: 14px; }
.cell-product b { display: block; font-weight: 600; line-height: 1.25; }
.cell-product small { color: var(--muted); }

.badge-pos.ok { background: var(--ok-soft); }
.badge-pos.warn { background: var(--peach); }
.badge-pos.out { background: var(--danger-soft); }

/* Actions column: always the last column, stays visible when the table scrolls sideways */
.pos-table th.actions, .pos-table td.actions { position: sticky; right: 0; text-align: right; white-space: nowrap; background: var(--card); box-shadow: -10px 0 10px -10px rgba(32, 35, 43, .22); }
.pos-table tbody tr:hover td.actions { background: var(--accent-soft); }
.row-actions { display: inline-flex; gap: 6px; }
.act-btn {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    font-size: 17px;
    color: var(--ink);
    background: var(--bg);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: transform .2s var(--ease, ease), background-color .2s, color .2s;
}
.act-btn:hover { color: var(--on-accent); background: var(--accent); transform: translateY(-2px); }
.act-btn.danger:hover { color: #fff; background: var(--danger); }
.act-btn:active { transform: scale(.92); }

.table-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.pagination { margin: 0; gap: 6px; flex-wrap: wrap; }
.pagination .page-link { min-width: 40px; height: 40px; display: grid; place-items: center; padding: 0 12px; color: var(--ink); background: var(--bg); border: 0; border-radius: 12px !important; }
.pagination .page-item.active .page-link { color: var(--on-accent); background: var(--accent); }
.pagination .page-item.disabled .page-link { opacity: .45; background: var(--bg); }

.btn-pos.danger { --spin: #fff; color: #fff; background: var(--danger); border-color: var(--danger); }
.btn-pos.danger:hover { color: #fff; }

/* Confirm dialog */
.pos-modal .modal-content { color: var(--ink); background: var(--card); border: 0; border-radius: 26px; box-shadow: 0 30px 70px -20px rgba(0, 0, 0, .5); }
.pos-modal.fade .modal-dialog { transform: scale(.88) translateY(24px); transition: transform .4s var(--ease-bounce, ease); }
.pos-modal.show .modal-dialog { transform: none; }
.pos-modal .modal-body { padding: 32px 26px 26px; }
.pos-modal h3 { margin: 14px 0 6px; font-size: 22px; }
.modal-icon { width: 64px; height: 64px; margin: 0 auto; display: grid; place-items: center; font-size: 28px; color: var(--danger); background: var(--danger-soft); border-radius: 50%; }
.modal-backdrop { --bs-backdrop-bg: #14161b; --bs-backdrop-opacity: .55; }

@media (max-width: 767.98px) {
    .toolbar .form-select { max-width: none; }
    .toolbar .count { width: 100%; margin-left: 0; }
}