:root {
    --primary: #6d28d9;
    --primary-dark: #5b21b6;
    --primary-light: #ede9fe;
    --accent: #f59e0b;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
    --shadow: 0 4px 16px rgba(17, 24, 39, 0.08);
    --shadow-lg: 0 12px 32px rgba(17, 24, 39, 0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- Layout shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: linear-gradient(180deg, #1e1b2e 0%, #2d1b4e 100%);
    color: #e5e7eb;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    display: flex; flex-direction: column;
    z-index: 50;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .logo {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--primary); display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 18px; color: #fff; flex-shrink: 0;
    overflow: hidden;
}
.sidebar-brand .logo img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-brand .name { font-weight: 700; font-size: 15px; color: #fff; }
.sidebar-brand .sub { font-size: 11px; color: #9ca3af; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sidebar-nav .section { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #6d7280; padding: 14px 10px 6px; }

.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: #d1d5db; font-weight: 500; margin-bottom: 2px;
    transition: all .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(109,40,217,0.4); }
.sidebar-nav a .ico { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-nav a .ico svg { display: block; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-foot .user { display: flex; align-items: center; gap: 10px; }
.sidebar-foot .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #111; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-foot .u-name { font-size: 13px; color: #fff; font-weight: 600; }
.sidebar-foot .u-role { font-size: 11px; color: #9ca3af; }

.main {
    flex: 1; margin-left: 250px; padding: 24px 28px;
    min-width: 0;
}

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.topbar h1 { font-size: 22px; font-weight: 700; margin: 0; }

/* ---------- Cards & stats ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 20px;
}
.grid { display: grid; gap: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }

.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-card .value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; }
.stat-card .delta { font-size: 12px; margin-top: 6px; }
.stat-card .icon {
    position: absolute; top: 16px; right: 16px; width: 42px; height: 42px;
    border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.icon.purple { background: var(--primary-light); }
.icon.green { background: #d1fae5; }
.icon.orange { background: #fef3c7; }
.icon.red { background: #fee2e2; }
.icon.blue { background: #dbeafe; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
    cursor: pointer; transition: all .15s; line-height: 1;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 14px; background: #fff; color: var(--text);
    transition: border .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,40,217,0.12); }
.form-select { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; background: #fff; }
.form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,40,217,0.12); }
textarea.form-control { resize: vertical; }

/* ---------- Table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left; padding: 12px 16px; font-size: 12px; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-muted); background: #fafafa; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafafa; }

/* ---------- Badge ---------- */
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600; line-height: 1;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-purple { background: var(--primary-light); color: var(--primary-dark); }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #065f46; border: 1px solid #bbf7d0; }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2d1b4e 0%, #6d28d9 55%, #9333ea 100%);
    padding: 20px;
}
.auth-card {
    width: 100%; max-width: 420px; background: #fff; border-radius: 20px;
    box-shadow: var(--shadow-lg); padding: 40px; text-align: center;
}
.auth-logo {
    width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 16px;
    background: var(--primary); color: #fff; font-size: 28px; font-weight: 800;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.auth-logo img { width: 100%; height: 100%; object-fit: cover; }
.auth-card h2 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.auth-card form { text-align: left; }

/* ---------- Landing ---------- */
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 20px 40px; position: relative; z-index: 10; }
.landing-nav .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; color: #fff; }
.landing-hero { text-align: center; padding: 60px 20px 80px; color: #fff; }
.landing-hero h1 { font-size: 48px; font-weight: 800; margin: 0 0 16px; letter-spacing: -1px; }
.landing-hero p { font-size: 18px; color: #e9d5ff; max-width: 640px; margin: 0 auto 32px; }
.landing-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; padding: 0 40px 60px; max-width: 1100px; margin: 0 auto; }
.feature-card { background: #fff; border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.feature-card .f-ico { width: 44px; height: 44px; border-radius: 12px; font-size: 22px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.feature-card h3 { margin: 0 0 8px; font-size: 16px; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: 14px; }

.landing-cta { background: #fff; border-radius: 20px; padding: 40px; text-align: center; max-width: 900px; margin: 0 auto 60px; box-shadow: var(--shadow-lg); }
.landing-cta h2 { margin: 0 0 12px; font-size: 26px; }

/* ---------- POS / cashier ---------- */
.pos-wrap { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .pos-wrap { grid-template-columns: 1fr; } .sidebar { width: 70px; } .sidebar .brand .name, .sidebar .brand .sub, .sidebar-nav a span.txt, .sidebar-nav .section, .sidebar-foot .u-name, .sidebar-foot .u-role { display: none; } .sidebar-brand { justify-content: center; } .sidebar-nav a { justify-content: center; } .main { margin-left: 70px; } }

.pos-products { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.pos-search { position: relative; margin-bottom: 16px; }
.pos-search input { width: 100%; padding: 16px 20px; font-size: 18px; border: 2px solid var(--border); border-radius: 12px; }
.pos-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(109,40,217,0.1); }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pos-item {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 14px; cursor: pointer; transition: all .12s; text-align: center;
}
.pos-item:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.pos-item .p-name { font-weight: 600; font-size: 13px; margin-bottom: 4px; min-height: 32px; }
.pos-item .p-price { color: var(--primary); font-weight: 700; font-size: 14px; }
.pos-item .p-stock { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.pos-cart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; position: sticky; top: 24px; }
.pos-cart h3 { margin: 0 0 16px; font-size: 18px; }
.cart-items { max-height: 360px; overflow-y: auto; margin-bottom: 16px; }
.cart-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f3f4f6; }
.cart-row .c-name { flex: 1; min-width: 0; }
.cart-row .c-name .n { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-row .c-name .p { font-size: 11px; color: var(--text-muted); }
.cart-qty { width: 54px; text-align: center; padding: 6px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.cart-row .c-sub { font-weight: 700; min-width: 80px; text-align: right; font-size: 13px; }
.cart-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; padding: 4px; }

.pos-summary { border-top: 2px solid var(--border); padding-top: 14px; }
.sum-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.sum-row.total { font-size: 22px; font-weight: 800; color: var(--primary); padding: 12px 0; }
.sum-row .big { font-weight: 800; }

/* ---------- Search dropdown ---------- */
.search-results {
    position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; z-index: 100;
}
.search-results button { display: block; width: 100%; text-align: left; padding: 12px 16px; background: none; border: none; border-bottom: 1px solid #f3f4f6; cursor: pointer; }
.search-results button:hover { background: var(--primary-light); }

/* ---------- Chart ---------- */
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.chart-box h3 { margin: 0 0 16px; font-size: 15px; }

/* ---------- Receipt ---------- */
.receipt { font-family: 'Courier New', monospace; font-size: 13px; max-width: 80mm; margin: 0 auto; color: #000; }
.receipt .center { text-align: center; }
.receipt h2 { font-size: 16px; margin: 0; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: 8px 0; }
.receipt .row { display: flex; justify-content: space-between; }
.receipt .total { font-weight: bold; font-size: 16px; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
}

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.w-full { width: 100%; }

/* ---------- Themes (phase 10) ---------- */
html[data-theme="emerald"] { --primary:#059669; --primary-dark:#047857; --primary-light:#d1fae5; --sidebar-1:#06231b; --sidebar-2:#064e3b; --glow:5,150,105; }
html[data-theme="ocean"]   { --primary:#0284c7; --primary-dark:#0369a1; --primary-light:#e0f2fe; --sidebar-1:#0b1a2b; --sidebar-2:#0c4a6e; --glow:2,132,199; }
html[data-theme="sunset"]  { --primary:#ea580c; --primary-dark:#c2410c; --primary-light:#ffedd5; --sidebar-1:#2b1508; --sidebar-2:#7c2d12; --glow:234,88,12; }
html[data-theme="rose"]    { --primary:#e11d48; --primary-dark:#be123c; --primary-light:#ffe4e6; --sidebar-1:#2b0b16; --sidebar-2:#881337; --glow:225,29,72; }
html[data-theme="mono"]    { --primary:#111827; --primary-dark:#000000; --primary-light:#e5e7eb; --sidebar-1:#0b0f17; --sidebar-2:#374151; --glow:17,24,39; }
html[data-theme="violet"],:root { --sidebar-1:#1e1b2e; --sidebar-2:#2d1b4e; --glow:109,40,217; }

.sidebar { background: linear-gradient(180deg, var(--sidebar-1) 0%, var(--sidebar-2) 100%); }
.sidebar-nav a.active { box-shadow: 0 4px 14px rgba(var(--glow), .45); }

/* ---------- Dark mode ---------- */
html[data-mode="dark"] {
    --bg:#0b0b12; --surface:#15151f; --border:#26263a;
    --text:#e7e7ef; --text-muted:#9ca3af;
    --shadow-sm:0 1px 2px rgba(0,0,0,.5);
    --shadow:0 6px 20px rgba(0,0,0,.5);
    --shadow-lg:0 16px 40px rgba(0,0,0,.6);
}
html[data-mode="dark"] .form-control,
html[data-mode="dark"] .form-select,
html[data-mode="dark"] .pos-item,
html[data-mode="dark"] .search-results,
html[data-mode="dark"] .auth-card,
html[data-mode="dark"] .feature-card,
html[data-mode="dark"] .landing-cta { background: var(--surface); color: var(--text); }
html[data-mode="dark"] .form-label { color: #cbd5e1; }
html[data-mode="dark"] .table th { background:#1c1c29; }
html[data-mode="dark"] .table td { border-bottom-color:#22222f; }
html[data-mode="dark"] .table tbody tr:hover { background:#1c1c29; }
html[data-mode="dark"] .cart-row { border-bottom-color:#22222f; }
html[data-mode="dark"] .icon.green,html[data-mode="dark"] .badge-success { background:#064e3b54; color:#6ee7b7; }
html[data-mode="dark"] .icon.orange,html[data-mode="dark"] .badge-warning { background:#78350f54; color:#fcd34d; }
html[data-mode="dark"] .icon.red,html[data-mode="dark"] .badge-danger { background:#7f1d1d54; color:#fca5a5; }
html[data-mode="dark"] .icon.blue,html[data-mode="dark"] .badge-info { background:#1e3a8a54; color:#93c5fd; }
html[data-mode="dark"] .badge-gray { background:#26263a; color:#cbd5e1; }

/* ---------- Responsive shell ---------- */
.mobile-bar { display: none; }
.backdrop { display: none; }

@media (max-width: 900px) {
    .mobile-bar {
        display: flex; align-items: center; gap: 12px;
        position: sticky; top: 0; z-index: 40;
        padding: 12px 16px; background: var(--surface);
        border-bottom: 1px solid var(--border);
    }
    .mobile-bar .mb-title { font-weight: 700; flex: 1; font-size: 15px; }
    .mobile-bar button, .mobile-bar a.mb-btn {
        background: none; border: 1px solid var(--border); border-radius: 10px;
        padding: 8px 10px; cursor: pointer; color: var(--text); display: inline-flex;
        align-items: center; gap: 6px; font-size: 13px; font-weight: 600; text-decoration: none;
    }
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; width: 264px; }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0,0,0,.6); }
    .sidebar .txt, .sidebar .section, .sidebar-foot .u-name, .sidebar-foot .u-role,
    .sidebar-brand .name, .sidebar-brand .sub { display: block; }
    .sidebar-brand, .sidebar-nav a { justify-content: flex-start; }
    .sidebar-nav a { padding: 12px 14px; }
    .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 35; }
    .main { margin-left: 0 !important; padding: 16px; }
    .topbar { flex-wrap: wrap; gap: 10px; }
    .topbar h1 { font-size: 19px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .value { font-size: 19px; }
    .stat-card .icon { width: 34px; height: 34px; top: 12px; right: 12px; }
    .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    .table-wrap { overflow-x: auto; }
    table.table { min-width: 560px; }
    .pos-cart { position: static; }
    .landing-nav { padding: 16px 20px; }
    .landing-hero { padding: 40px 20px 56px; }
    .landing-hero h1 { font-size: 31px; }
    .landing-hero p { font-size: 16px; }
    .landing-features { padding: 0 20px 40px; }
    .landing-cta { margin: 0 20px 40px; padding: 28px 20px; }
    .auth-card { padding: 28px 22px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .btn-lg { width: 100%; }
}

/* ---------- Dashboard v2 (phase 12) ---------- */
.hero-card {
    position: relative; overflow: hidden; border-radius: 20px; color: #fff;
    padding: 24px 26px; margin-bottom: 20px;
    background: radial-gradient(900px 380px at 88% -10%, rgba(255,255,255,.22), transparent 60%),
                linear-gradient(120deg, var(--sidebar-1) 0%, var(--sidebar-2) 55%, var(--primary) 100%);
    box-shadow: 0 14px 34px rgba(var(--glow), .28);
}
.hero-card h2 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.6px; }
.hero-card p { margin: 0; color: rgba(255,255,255,.82); font-size: 14px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.hero-actions .btn { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.32); color: #fff; backdrop-filter: blur(4px); }
.hero-actions .btn:hover { background: rgba(255,255,255,.28); }
.hero-actions .btn.solid { background: #fff; color: var(--primary-dark); border-color: #fff; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.quick-btn {
    display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 14px 16px; font-weight: 600; font-size: 14px; transition: all .14s;
}
.quick-btn:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); color: var(--text); }
.quick-btn .qi { width: 38px; height: 38px; border-radius: 11px; background: var(--primary-light); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.trend { display: flex; align-items: flex-end; gap: 10px; height: 168px; padding-top: 12px; }
.trend .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend .bar { width: 100%; max-width: 46px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); min-height: 4px; }
.trend .bar.today { background: linear-gradient(180deg, var(--accent), #d97706); }
.trend .lbl { font-size: 10px; color: var(--text-muted); }
.trend .val { font-size: 10px; font-weight: 700; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .lr-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; }
.list-row .lr-sub { font-size: 11px; color: var(--text-muted); }
.list-row .lr-val { font-weight: 800; font-size: 13px; }
.progress { height: 7px; border-radius: 6px; background: var(--primary-light); overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 6px; }

@media (max-width: 900px) {
    .hero-card { padding: 20px; }
    .hero-card h2 { font-size: 19px; }
    .trend { height: 140px; gap: 6px; }
}

/* ---------- Legacy grid shim (halaman lama masih pakai kelas bootstrap) ---------- */
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > [class*="col-"] { min-width: 0; }
.col-md-3 { flex: 1 1 210px; }
.col-md-4 { flex: 1 1 300px; }
.col-md-6 { flex: 1 1 380px; }
.col-md-8 { flex: 1 1 480px; }
.col-md-12 { flex: 1 1 100%; }
.p-3 { padding: 20px; }
.btn-outline-secondary { background: transparent; }
.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
@media (max-width: 640px) {
    .col-md-3, .col-md-4, .col-md-6, .col-md-8 { flex: 1 1 100%; }
}

/* ---------- Pemindai kamera (barcode / QR) ---------- */
.pscan { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,.72); padding: 16px; }
.pscan.open { display: flex; }
.pscan-box { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.45); }
.pscan-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pscan-head strong { font-size: 15px; }
.pscan-x { background: none; border: 0; color: var(--text-muted); font-size: 26px; line-height: 1; cursor: pointer; padding: 0 6px; }
.pscan-box video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; border-radius: 12px; display: block; }
.pscan-hint { font-size: 12.5px; color: var(--text-muted); margin: 10px 0; min-height: 32px; }
.pscan-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.pscan-manual input { width: 100%; }

/* ---------- Responsif menyeluruh ---------- */
@media (max-width: 1024px) {
    .grid { grid-template-columns: 1fr !important; }
    .pos-wrap { grid-template-columns: 1fr !important; }
    .topbar { flex-wrap: wrap; gap: 10px; }
}

@media (max-width: 820px) {
    .main { padding: 16px 14px 90px; }
    .topbar h1 { font-size: 20px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; gap: 12px; }
    .stat-card .value { font-size: 20px; }
    .hero-card { padding: 18px !important; }
    .hero-card h2 { font-size: 21px !important; }
    .quick-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; }
    .chart-box { padding: 14px; overflow-x: auto; }
    .table th, .table td { padding: 9px 10px; font-size: 13px; }
    .btn { min-height: 42px; }
    .btn-sm { min-height: 36px; }
    .form-control, .form-select { min-height: 42px; font-size: 15px; } /* cegah zoom otomatis iOS */
    .pscan-actions .btn { flex: 1; }
}

@media (max-width: 560px) {
    .main { padding: 12px 10px 96px; }
    .card { padding: 14px; border-radius: 14px; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; }
    .stat-card { padding: 12px; }
    .stat-card .value { font-size: 17px; }
    .stat-card .icon { display: none; }
    .topbar { align-items: stretch; }
    .topbar > .btn, .topbar > a.btn { flex: 1 1 100%; justify-content: center; }
    .hero-card .hero-actions { display: flex; flex-direction: column; gap: 8px; }
    .hero-card .hero-actions .btn { width: 100%; justify-content: center; }
    .table th, .table td { padding: 8px 8px; font-size: 12.5px; }
    .table-wrap { -webkit-overflow-scrolling: touch; }
    .badge { font-size: 10.5px; }
    .settings-section .form-group, .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    .flex[style*="gap"] { flex-wrap: wrap; }
    .modal-card, .card[style*="max-width"] { max-width: 100% !important; }
    .pscan { padding: 0; align-items: stretch; }
    .pscan-box { max-width: 100%; border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; }
    .pscan-box video { aspect-ratio: 3 / 4; flex: 1; min-height: 260px; }
    .pscan-manual { margin-top: auto; }
}

/* layar sentuh: target jempol minimal */
@media (hover: none) {
    .sidebar-nav a { padding-top: 12px; padding-bottom: 12px; }
    .pos-item { min-height: 64px; }
    .qty-btn { min-width: 40px; min-height: 40px; }
}

html { -webkit-text-size-adjust: 100%; }
