:root {
    color-scheme: light;
    --ink: #172027;
    --muted: #677078;
    --line: #dfe4df;
    --surface: #fff;
    --canvas: #f4f6f3;
    --dark: #101923;
    --accent: #ec6b34;
    --accent-dark: #c94f1f;
    --success: #217a52;
    --danger: #b63434;
    --shadow: 0 18px 60px rgba(22, 32, 39, .13);
    --radius: 18px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(236, 107, 52, .28); outline-offset: 2px; }
[hidden] { display: none !important; }

.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #fff 0, transparent 32%), var(--canvas); }
.login-card { width: min(100%, 410px); padding: 34px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); }
.login-logo { display: block; width: min(210px, 72%); height: auto; margin: 0 0 24px; object-fit: contain; }
.eyebrow { margin: 0 0 5px; color: var(--accent-dark); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 1.35rem; letter-spacing: -.025em; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 18px; margin-top: 28px; }
label > span, legend { display: block; margin-bottom: 7px; color: #444f56; font-size: .8rem; font-weight: 750; }
input, select { width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid #cfd6d0; border-radius: 12px; background: #fff; color: var(--ink); font-size: 1rem; }
input:focus, select:focus { border-color: var(--accent); }
.primary-button, .secondary-button { min-height: 52px; padding: 0 19px; border-radius: 13px; border: 0; font-weight: 800; cursor: pointer; }
.primary-button { background: var(--dark); color: #fff; box-shadow: 0 8px 18px rgba(16, 25, 35, .16); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .42; cursor: default; box-shadow: none; }
.secondary-button { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.form-error { margin: -5px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff0f0; color: var(--danger); font-size: .84rem; }

.app-view { min-height: 100dvh; }
.app-header { position: fixed; z-index: 20; inset: 0 0 auto 0; height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); border-bottom: 1px solid rgba(255,255,255,.08); background: var(--dark); color: #fff; }
.brand-compact, .header-actions { display: flex; align-items: center; gap: 10px; }
.menu-logo { display: block; width: 112px; height: auto; max-height: 42px; object-fit: contain; }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c6ced5; font-size: .8rem; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: inherit; font-size: 1.7rem; cursor: pointer; }
.icon-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:active { background: rgba(255,255,255,.1); }
.workspace { min-height: 100dvh; padding-top: 64px; }
.pos-view { display: grid; grid-template-columns: minmax(0, 1fr) 390px; min-height: calc(100dvh - 64px); }
.catalog-pane { min-width: 0; padding: 24px; padding-bottom: 96px; }
.search-wrap { position: sticky; z-index: 5; top: 76px; display: flex; align-items: center; max-width: 720px; margin: 0 auto 15px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(22,32,39,.07); }
.search-wrap svg { flex: 0 0 auto; width: 21px; margin-left: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search-wrap input { min-width: 0; border: 0; background: transparent; }
.search-wrap input:focus { outline: 0; }
.search-wrap button { width: 48px; height: 48px; border: 0; background: transparent; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.category-list { display: flex; gap: 8px; max-width: 920px; margin: 0 auto 18px; overflow-x: auto; padding: 2px 1px 7px; scrollbar-width: none; scroll-snap-type: x proximity; }
.category-list::-webkit-scrollbar { display: none; }
.category-chip { flex: 0 0 auto; min-height: 42px; padding: 0 15px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: #4f595f; font-size: .82rem; font-weight: 750; cursor: pointer; scroll-snap-align: start; }
.category-chip i { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; }
.category-chip.active { border-color: var(--dark); background: var(--dark); color: #fff; }
.catalog-status { max-width: 920px; margin: 12vh auto 0; color: var(--muted); text-align: center; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 12px; max-width: 920px; margin: 0 auto; }
.product-card { position: relative; min-height: 150px; padding: 16px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; cursor: pointer; box-shadow: 0 3px 10px rgba(22,32,39,.035); }
.product-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--category-color, var(--accent)); }
.product-card:active { transform: scale(.985); background: #fcfcfa; }
.product-card .sku { display: block; margin-bottom: 15px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .06em; }
.product-card strong { display: block; min-height: 42px; font-size: .96rem; line-height: 1.3; }
.product-meta { position: absolute; inset: auto 14px 13px 16px; display: flex; align-items: end; justify-content: space-between; gap: 8px; }
.product-price { color: var(--ink); font-size: 1.08rem; font-weight: 850; }
.stock { color: var(--muted); font-size: .67rem; }
.stock.low { color: var(--danger); font-weight: 750; }
.empty-message { grid-column: 1 / -1; padding: 70px 20px; color: var(--muted); text-align: center; }

.cart-pane { position: sticky; top: 64px; height: calc(100dvh - 64px); display: flex; flex-direction: column; border-left: 1px solid var(--line); background: #fff; }
.cart-heading { display: flex; align-items: center; justify-content: space-between; padding: 24px 22px 16px; }
.text-button { min-height: 42px; padding: 0 8px; border: 0; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 800; cursor: pointer; }
.text-button.danger { color: var(--danger); }
.cart-lines { flex: 1; overflow: auto; padding: 0 14px; overscroll-behavior: contain; }
.cart-empty { display: grid; place-items: center; height: 100%; min-height: 170px; padding: 25px; color: var(--muted); text-align: center; font-size: .88rem; }
.cart-line { padding: 14px 8px; border-bottom: 1px solid #edf0ed; }
.cart-line-main { display: flex; justify-content: space-between; gap: 12px; }
.cart-line-name { min-width: 0; font-size: .88rem; font-weight: 750; }
.cart-line-price { flex: 0 0 auto; font-size: .9rem; font-weight: 850; }
.quantity-control { display: flex; align-items: center; gap: 3px; margin-top: 9px; }
.quantity-control button { width: 42px; height: 38px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: 1.15rem; cursor: pointer; }
.quantity-control button:first-child { border-radius: 10px 0 0 10px; }
.quantity-control button:last-child { border-radius: 0 10px 10px 0; }
.quantity-control span { display: grid; place-items: center; width: 42px; height: 38px; border-block: 1px solid var(--line); font-weight: 800; }
.cart-summary { padding: 16px 22px 7px; border-top: 1px solid var(--line); }
.cart-summary > div { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: .82rem; }
.cart-summary .cart-total { align-items: baseline; color: var(--ink); font-size: 1rem; }
.cart-total strong { font-size: 1.7rem; letter-spacing: -.04em; }
.checkout-button { margin: 7px 22px max(20px, env(safe-area-inset-bottom)); }
.cart-handle { display: none; }

.bottom-nav { position: fixed; z-index: 30; inset: auto 0 0; display: none; height: calc(68px + env(safe-area-inset-bottom)); padding: 5px max(7px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(7px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.nav-button { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; border: 0; background: transparent; color: #7a8287; font-size: .65rem; font-weight: 750; cursor: pointer; }
.nav-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-button.active { color: var(--accent-dark); }
.scan-circle { display: grid; place-items: center; width: 48px; height: 42px; border-radius: 15px; background: var(--dark); color: #fff; }
.badge { position: absolute; z-index: 1; top: 2px; left: calc(50% + 7px); display: grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border: 2px solid #fff; border-radius: 99px; background: var(--accent); color: #fff; font-size: .62rem; }
.backdrop { position: fixed; z-index: 39; inset: 0; background: rgba(8,13,18,.48); }

.history-view { max-width: 900px; min-height: calc(100dvh - 64px); margin: auto; padding: 30px 24px 100px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading input { width: auto; min-height: 44px; }
.history-list { display: grid; gap: 10px; }
.sale-row { display: grid; grid-template-columns: 1fr auto; gap: 7px 18px; padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: #fff; cursor: pointer; }
.sale-row strong { font-size: .93rem; }
.sale-row .sale-total { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 1.08rem; }
.sale-row small { color: var(--muted); }

.admin-view { max-width: 1040px; min-height: calc(100dvh - 64px); margin: auto; padding: 30px 24px 105px; }
.admin-heading { margin-bottom: 23px; }
.admin-heading .muted { margin-bottom: 0; }
.admin-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 18px; align-items: start; }
.admin-card { padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: 0 5px 18px rgba(22,32,39,.04); }
.admin-card-heading { display: flex; gap: 13px; align-items: start; }
.admin-card-heading h2 { margin: 1px 0 4px; }
.admin-card-heading p { margin: 0; color: var(--muted); font-size: .8rem; }
.step-number { flex: 0 0 auto; display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: #fff0e9; color: var(--accent-dark); font-size: .8rem; font-weight: 900; }
.compact-stack { gap: 14px; margin-top: 22px; }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.color-order-row { grid-template-columns: 90px 1fr; }
input[type="color"] { padding: 5px; cursor: pointer; }
.toggle-field { display: flex; align-items: center; gap: 11px; min-height: 58px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.toggle-field > input { flex: 0 0 auto; width: 22px; min-height: 22px; accent-color: var(--accent); }
.toggle-field > span { margin: 0; }
.toggle-field strong, .toggle-field small { display: block; }
.toggle-field small { margin-top: 2px; color: var(--muted); font-weight: 400; }
.admin-category-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.admin-category-item { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; background: var(--canvas); color: #485158; font-size: .74rem; font-weight: 750; }
.admin-category-item i { width: 8px; height: 8px; border-radius: 50%; }
.admin-summary { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

.app-dialog { width: min(94vw, 480px); max-height: 90dvh; padding: 22px; overflow: auto; border: 0; border-radius: 22px; color: var(--ink); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgba(8,13,18,.6); backdrop-filter: blur(3px); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dialog-header .icon-button { margin: -8px -7px 0 0; color: var(--muted); }
.scanner-frame { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 16px; background: #080b0d; }
.scanner-frame video { width: 100%; height: 100%; object-fit: cover; }
.scanner-guide { position: absolute; inset: 25% 8%; border: 2px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.28); }
.scanner-dialog .muted { margin: 13px 0; font-size: .82rem; }
.manual-code { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.manual-code .secondary-button { min-height: 50px; }
.payment-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; border: 0; }
.payment-options legend { grid-column: 1 / -1; }
.payment-options label { position: relative; }
.payment-options input { position: absolute; opacity: 0; pointer-events: none; }
.payment-options span { display: grid; place-items: center; min-height: 51px; margin: 0; padding: 7px; border: 1px solid var(--line); border-radius: 11px; text-align: center; }
.payment-options input:checked + span { border-color: var(--dark); background: var(--dark); color: #fff; }
.change-row, .receipt-row { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--line); }
.change-row strong { font-size: 1.3rem; }
.receipt-dialog > form:last-child { margin-top: 18px; }
.receipt-dialog > form:last-child button { width: 100%; }
.receipt-lines { margin: 12px 0; border-block: 1px solid var(--line); }
.receipt-line { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; padding: 11px 0; }
.receipt-line small { color: var(--muted); }
.receipt-line strong { grid-row: 1 / 3; grid-column: 2; align-self: center; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); width: max-content; max-width: min(90vw, 430px); padding: 12px 17px; transform: translateX(-50%); border-radius: 12px; background: var(--dark); color: #fff; box-shadow: var(--shadow); font-size: .84rem; text-align: center; }

@media (min-width: 821px) {
    .workspace { padding-left: 78px; }
    .bottom-nav {
        display: flex;
        inset: 64px auto 0 0;
        width: 78px;
        height: auto;
        padding: 13px 7px;
        flex-direction: column;
        gap: 5px;
        border-top: 0;
        border-right: 1px solid var(--line);
        background: #fff;
        backdrop-filter: none;
    }
    .nav-button { flex: 0 0 67px; width: 100%; border-radius: 13px; }
    .nav-button:hover { background: var(--canvas); color: var(--ink); }
    .nav-button.active { background: #fff0e9; color: var(--accent-dark); }
    .scan-circle { width: 44px; height: 38px; }
    .cart-nav-button { display: none; }
    .toast { bottom: 26px; }
}

@media (max-width: 820px) {
    .app-header { height: 56px; }
    .menu-logo { width: 92px; max-height: 34px; }
    .workspace { padding-top: 56px; }
    .pos-view { display: block; min-height: calc(100dvh - 56px); }
    .catalog-pane { padding: 14px 12px 94px; }
    .search-wrap { top: 66px; margin-bottom: 11px; border-radius: 14px; }
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .product-card { min-height: 136px; padding: 14px 12px; border-radius: 15px; }
    .product-card strong { font-size: .88rem; }
    .product-meta { inset: auto 11px 11px 12px; display: block; }
    .stock { display: block; margin-top: 2px; }
    .cart-pane { position: fixed; z-index: 40; inset: auto 0 0; height: min(82dvh, 700px); border: 0; border-radius: 24px 24px 0 0; transform: translateY(105%); transition: transform .22s ease; box-shadow: var(--shadow); }
    .cart-pane.open { transform: translateY(0); }
    .cart-handle { display: block; width: 44px; height: 5px; margin: 8px auto 0; border-radius: 5px; background: #d8ddda; }
    .bottom-nav { display: flex; }
    .history-view { min-height: calc(100dvh - 56px); padding: 20px 13px 92px; }
    .admin-view { min-height: calc(100dvh - 56px); padding: 20px 13px 92px; }
    .admin-grid { grid-template-columns: 1fr; }
    .admin-card { padding: 19px 16px; border-radius: 17px; }
    .section-heading { align-items: start; }
    .section-heading input { width: 145px; }
}

@media (max-width: 390px) {
    .product-grid { gap: 7px; }
    .product-card { min-height: 128px; }
    .payment-options { grid-template-columns: 1fr; }
    .payment-options span { min-height: 44px; }
    .form-pair { grid-template-columns: 1fr; }
    .color-order-row { grid-template-columns: 86px 1fr; }
}

@media (max-width: 820px) and (orientation: landscape) {
    .pos-view { display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
    .catalog-pane { padding-bottom: 80px; }
    .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cart-pane { position: sticky; z-index: 1; inset: auto; top: 56px; height: calc(100dvh - 56px); border-left: 1px solid var(--line); border-radius: 0; transform: none; box-shadow: none; }
    .cart-handle, .cart-nav-button, #cartBackdrop { display: none !important; }
    .bottom-nav { right: auto; width: calc(100% - 330px); }
}

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