/* ==========================================================================
   Shop POS — Design System
   Apple-inspired: soft neutrals, one confident accent, generous radius,
   restrained motion, SF-style type stack. No emoji anywhere — SVG only.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --accent: #0a84ff;
    --accent-dark: #0066d6;
    --accent-soft: #e8f2ff;
    --accent-press: #0071e3;

    --success: #34c759;
    --success-soft: #e6f9ea;
    --danger: #ff3b30;
    --danger-soft: #ffefed;
    --warning: #ff9f0a;
    --warning-soft: #fff4e5;

    --dept-auto: #0a84ff;
    --dept-auto-soft: #e8f2ff;
    --dept-hardware: #ff9f0a;
    --dept-hardware-soft: #fff4e5;
    --dept-groceries: #34c759;
    --dept-groceries-soft: #e6f9ea;

    --bg: #f2f2f7;
    --bg-elevated: #fbfbfd;
    --surface: #ffffff;
    --surface-2: #f7f7f9;
    --border: rgba(60, 60, 67, 0.12);
    --border-soft: rgba(60, 60, 67, 0.07);

    --ink: #1c1c1e;
    --ink-2: #48484a;
    --ink-3: #8a8a8e;
    --ink-4: #c7c7cc;

    --sidebar-bg: #1c1c1e;
    --sidebar-ink: #d1d1d6;
    --sidebar-ink-dim: #8a8a8e;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 8px rgba(0, 0, 0, 0.04);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.08);

    --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --topbar-h: 56px;
    --tabbar-h: 58px;
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.011em;
}
h1, h2, h3, .font-bold, .font-semibold { letter-spacing: -0.02em; }
a { text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }
::-webkit-scrollbar-track { background: transparent; }

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-1);
    transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}

button, .btn, a.btn, input[type="submit"] {
    font-family: inherit;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: transform .15s var(--ease), background-color .2s var(--ease), opacity .2s var(--ease), box-shadow .2s var(--ease);
}
button:active, .btn:active, a.btn:active { transform: scale(0.97); }
button:disabled { cursor: not-allowed; }

.bg-blue-700, .bg-blue-800, .bg-blue-600 { background: var(--accent) !important; border: none; }
.hover\:bg-blue-800:hover, .hover\:bg-blue-700:hover { background: var(--accent-dark) !important; }
.text-blue-700, .text-blue-600 { color: var(--accent) !important; }
.focus\:ring-blue-600:focus { --tw-ring-color: var(--accent) !important; }
.border-blue-700 { border-color: var(--accent) !important; }

.bg-gray-800, .bg-gray-900 { background: var(--ink) !important; }
.hover\:bg-gray-900:hover, .hover\:bg-gray-800:hover { background: #000 !important; }

.bg-green-600 { background: var(--success) !important; }
.hover\:bg-green-700:hover { background: #29a745 !important; }
.text-green-600, .text-green-700 { color: #1e9e46 !important; }
.bg-green-100 { background: var(--success-soft) !important; }

.bg-red-600 { background: var(--danger) !important; }
.hover\:bg-red-700:hover { background: #e0291e !important; }
.text-red-600, .text-red-700 { color: var(--danger) !important; }
.bg-red-100 { background: var(--danger-soft) !important; }

button, a.btn, .rounded-lg, input, select, textarea { border-radius: var(--radius-sm) !important; }
.rounded-xl { border-radius: var(--radius) !important; }
.rounded-full { border-radius: 999px !important; }

button.bg-blue-700, a.bg-blue-700, button[class*="bg-blue-700"] {
    box-shadow: 0 1px 2px rgba(10, 132, 255, 0.25), 0 4px 12px rgba(10, 132, 255, 0.18);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
    border: 1px solid transparent; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(10,132,255,.25), 0 4px 12px rgba(10,132,255,.18); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: #ececef; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-icon { padding: 10px; }
.btn-block { width: 100%; }

input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input[type="date"], input[type="search"], input[type="tel"], select, textarea {
    background: var(--surface-2);
    border: 1px solid var(--border) !important;
    color: var(--ink);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
input:focus, select:focus, textarea:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--accent-soft) !important;
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }

[class*="rounded-full"][class*="text-xs"], .badge { font-weight: 600; letter-spacing: -0.005em; }
.bg-blue-100 { background: var(--accent-soft) !important; }
.text-blue-800 { color: var(--accent-dark) !important; }
.bg-gray-100 { background: var(--surface-2) !important; color: var(--ink-2); }
.bg-amber-100, .bg-yellow-100 { background: var(--warning-soft) !important; }
.text-amber-700, .text-amber-600, .text-yellow-700 { color: #b3720a !important; }
.bg-amber-50 { background: var(--warning-soft) !important; }
.text-amber-800 { color: #b3720a !important; }
.badge-in { background: var(--success-soft); color: #1e9e46; }
.badge-out { background: var(--danger-soft); color: var(--danger); }
.badge-adjustment { background: var(--warning-soft); color: #b3720a; }
.badge-dept-auto { background: var(--dept-auto-soft); color: var(--dept-auto); }
.badge-dept-hardware { background: var(--dept-hardware-soft); color: #b3720a; }
.badge-dept-groceries { background: var(--dept-groceries-soft); color: #1e9e46; }
.low-stock-row { background: linear-gradient(90deg, var(--warning-soft), transparent 40%); }

table { border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
thead th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); font-weight: 700; }
tbody tr { border-color: var(--border-soft) !important; transition: background .15s var(--ease); }
tbody tr:hover { background: var(--surface-2); }

@media (max-width: 760px) {
    .card table, .card table thead, .card table tbody, .card table th, .card table td, .card table tr { display: block; }
    .card table thead { display: none; }
    .card table tbody tr {
        background: var(--surface);
        border: 1px solid var(--border-soft) !important;
        border-radius: var(--radius);
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: var(--shadow-1);
    }
    .card table tbody tr:last-child { margin-bottom: 0; }
    .card table td {
        display: flex; justify-content: space-between; align-items: center;
        padding: 6px 0 !important; text-align: right; border: none !important;
        font-size: 13.5px;
    }
    .card table td:empty { display: none; }
    .card table td[data-label]::before {
        content: attr(data-label);
        font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
        color: var(--ink-3); text-align: left; margin-right: 10px;
    }
}

.sidebar { background: var(--sidebar-bg) !important; }
.sidebar nav a {
    color: var(--sidebar-ink);
    display: flex; align-items: center; gap: 11px;
    font-weight: 500; font-size: 13.5px;
    transition: background .18s var(--ease), color .18s var(--ease);
}
.sidebar nav a svg { flex-shrink: 0; width: 18px; height: 18px; opacity: .85; }
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: var(--accent) !important; color: #fff !important; box-shadow: 0 2px 10px rgba(10,132,255,.35); }
.sidebar nav a.active svg { opacity: 1; }
.sidebar .nav-label { color: var(--sidebar-ink-dim); font-weight: 700; letter-spacing: .06em; }

.topbar {
    display: none;
    position: sticky; top: 0; z-index: 40;
    align-items: center; justify-content: space-between;
    height: var(--topbar-h);
    padding: 0 16px;
    background: rgba(251, 251, 253, 0.86);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-soft);
}
.topbar .topbar-title { font-weight: 700; font-size: 17px; color: var(--ink); }
.topbar .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent); color: #fff; font-weight: 700; font-size: 12.5px;
    display: flex; align-items: center; justify-content: center;
}

.tabbar {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(251, 251, 253, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border-soft);
}
.tabbar-inner { display: flex; height: var(--tabbar-h); }
.tabbar a, .tabbar button.tabbar-more {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: var(--ink-3); font-size: 10.5px; font-weight: 600;
    transition: color .15s var(--ease); background: none; border: none; padding: 0;
}
.tabbar a svg, .tabbar button.tabbar-more svg { width: 23px; height: 23px; stroke-width: 1.9; }
.tabbar a.active, .tabbar button.tabbar-more.active { color: var(--accent); }
.tabbar a:active, .tabbar button.tabbar-more:active { transform: scale(0.92); }

.more-sheet-backdrop { display: none; position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.35); }
.more-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
    background: var(--bg-elevated);
    border-radius: 22px 22px 0 0;
    padding: 10px 14px calc(20px + env(safe-area-inset-bottom, 0));
    transform: translateY(100%);
    transition: transform .32s var(--ease-spring);
    max-height: 70vh; overflow-y: auto;
}
.more-sheet.open, .more-sheet-backdrop.open { display: block; }
.more-sheet.open { transform: translateY(0); }
.more-sheet .sheet-handle { width: 36px; height: 4px; border-radius: 4px; background: var(--ink-4); margin: 6px auto 14px; }
.more-sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 4px; }
.more-sheet-grid a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 4px; border-radius: 16px; color: var(--ink-2); font-size: 11.5px; font-weight: 600; text-align: center; }
.more-sheet-grid a:active { background: var(--surface-2); }
.more-sheet-grid .icon-wrap { width: 46px; height: 46px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.more-sheet-grid .icon-wrap svg { width: 22px; height: 22px; }

@media (max-width: 900px) {
    aside.sidebar { display: none !important; }
    .topbar { display: flex; }
    .tabbar { display: block; }
    main.flex-1 { padding-bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom, 0)); }
    body.no-chrome-page .topbar, body.no-chrome-page .tabbar { display: none; }
}

.stat-card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border-soft); box-shadow: var(--shadow-1); padding: 18px; position: relative; overflow: hidden; }
.stat-card .stat-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 10px; }
.stat-card .stat-icon svg { width: 18px; height: 18px; }
.stat-card .stat-label { font-size: 12px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 24px; font-weight: 800; color: var(--ink); margin-top: 3px; letter-spacing: -0.02em; }
.stat-card .stat-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty-state svg { width: 42px; height: 42px; color: var(--ink-4); margin-bottom: 10px; }
.empty-state p { font-size: 13.5px; }

#toastStack {
    position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%);
    z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
    width: 100%; max-width: 380px; padding: 0 14px; pointer-events: none;
}
@media (min-width: 901px) { #toastStack { top: 18px; } }
.toast {
    pointer-events: auto;
    display: flex; align-items: center; gap: 10px;
    background: rgba(28,28,30,0.92); color: #fff; font-size: 13.5px; font-weight: 500;
    padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-3);
    backdrop-filter: blur(10px);
    animation: toast-in .35s var(--ease-spring);
    width: 100%;
}
.toast.success svg { color: var(--success); }
.toast.error svg { color: #ff6961; }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.hide { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(.95); } }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0; padding: 8px 15px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
    background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border);
    transition: all .18s var(--ease); cursor: pointer; white-space: nowrap;
}
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: var(--shadow-1); }

.seg { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { flex: 1; padding: 9px 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: transparent; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button svg { width: 15px; height: 15px; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.product-tile {
    background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius);
    padding: 12px; cursor: pointer; text-align: left;
    transition: transform .15s var(--ease-spring), box-shadow .15s var(--ease), border-color .15s var(--ease);
    position: relative; overflow: hidden;
}
.product-tile:hover { box-shadow: var(--shadow-2); border-color: transparent; }
.product-tile:active { transform: scale(0.96); }
.product-tile.out-of-stock { opacity: .42; cursor: not-allowed; }
.product-tile .dept-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.product-tile .p-name { font-weight: 600; font-size: 13.5px; color: var(--ink); line-height: 1.25; }
.product-tile .p-sku { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.product-tile .p-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.product-tile .p-price { color: var(--accent); font-weight: 700; font-size: 13.5px; }
.product-tile .p-qty { font-size: 10.5px; color: var(--ink-3); }
.product-tile .low-flag { position: absolute; top: 8px; right: 8px; color: var(--warning); }
.product-tile .low-flag svg { width: 14px; height: 14px; }

.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper button { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; border: 1px solid var(--border); }
.qty-stepper button:active { background: var(--ink); color: #fff; }
.qty-stepper span { width: 22px; text-align: center; font-weight: 700; font-size: 13.5px; }

.cart-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.cart-line:last-child { border-bottom: none; }

.cart-fab {
    display: none;
    position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0));
    z-index: 45; width: 58px; height: 58px; border-radius: 50%;
    background: var(--accent); color: #fff; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(10,132,255,.4);
}
.cart-fab svg { width: 24px; height: 24px; }
.cart-fab .fab-badge {
    position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; padding: 0 5px; border: 2px solid var(--bg);
}
@media (max-width: 900px) { .cart-fab.show { display: flex; } }

.sheet-backdrop { display: none; position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.4); }
.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 71;
    background: var(--bg-elevated); border-radius: 22px 22px 0 0;
    max-height: 88vh; display: flex; flex-direction: column;
    transform: translateY(100%); transition: transform .34s var(--ease-spring);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet-backdrop.open, .sheet.open { display: flex; }
.sheet.open { transform: translateY(0); }
.sheet .sheet-handle { width: 36px; height: 4px; border-radius: 4px; background: var(--ink-4); margin: 8px auto; flex-shrink: 0; }
.sheet-body { overflow-y: auto; padding: 0 18px 18px; }

@media (min-width: 901px) {
    .sheet.desktop-modal { border-radius: var(--radius-lg); top: 50%; left: 50%; bottom: auto; right: auto;
        transform: translate(-50%, -46%) scale(.96); width: 100%; max-width: 420px; opacity: 0; transition: transform .28s var(--ease-spring), opacity .2s var(--ease); }
    .sheet.desktop-modal.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); }
.icon-btn:hover { background: #ececef; }
.icon-btn svg { width: 17px; height: 17px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, #eceef1 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media print {
    .no-print { display: none !important; }
    .tabbar, .topbar, .cart-fab { display: none !important; }
    body { background: #fff; }
}
