/* ==========================================================================
   Jisan Enterprise — Design System
   Light/dark, responsive, animated. No external dependencies.
   ========================================================================== */

:root {
    --brand: #0e9f6e;
    --brand-600: #057a55;
    --brand-700: #046c4e;
    --brand-soft: rgba(14, 159, 110, 0.12);
    --accent: #6366f1;
    --danger: #e02424;
    --danger-soft: rgba(224, 36, 36, 0.12);
    --warn: #c27803;
    --warn-soft: rgba(194, 120, 3, 0.14);
    --info: #1c64f2;
    --success: #0e9f6e;

    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e5e9f0;
    --text: #1b2430;
    --muted: #6b7482;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .18);
    --shadow-lg: 0 24px 60px -20px rgba(16, 24, 40, .35);
    --radius: 14px;
    --radius-sm: 9px;
    --sidebar-w: 258px;
    --font: "Segoe UI", system-ui, -apple-system, "Hind Siliguri", "Noto Sans Bengali", Roboto, Arial, sans-serif;
    --speed: .22s;
}

[data-theme="dark"] {
    --bg: #0e131b;
    --surface: #161d29;
    --surface-2: #1c2533;
    --border: #27303f;
    --text: #e7ecf3;
    --muted: #93a0b4;
    --brand-soft: rgba(14, 159, 110, 0.18);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 30px -14px rgba(0,0,0,.6);
    --shadow-lg: 0 30px 70px -20px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background var(--speed), color var(--speed);
}
a { color: var(--brand-600); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 700; line-height: 1.25; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 14px; }
small { font-size: .82em; }

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: transform var(--speed) ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 18px; border-bottom: 1px solid var(--border);
}
.brand-badge {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-700));
    color: #fff; font-weight: 800; letter-spacing: .5px;
    box-shadow: 0 6px 16px -6px var(--brand);
}
.brand-text strong { display: block; font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 11px; }

.sidebar-nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px; margin-bottom: 3px;
    color: var(--text); font-weight: 600; font-size: 14.5px;
    transition: background var(--speed), color var(--speed), transform .12s;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-700); }
.nav-link.active .nav-ic { transform: scale(1.08); }
.nav-ic { width: 26px; text-align: center; font-size: 18px; transition: transform .15s; }
.nav-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 8px; }
.sidebar-foot .nav-link small { font-weight: 500; }
.sidebar-scrim {
    position: fixed; inset: 0; background: rgba(6,12,20,.5);
    opacity: 0; pointer-events: none; transition: opacity var(--speed); z-index: 35;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    padding: 12px 20px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(140%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.page-title { font-size: 19px; margin: 0; flex: 1; }
.topbar-tools { display: flex; align-items: center; gap: 8px; }
.icon-btn {
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text); width: 40px; height: 40px; border-radius: 11px;
    font-size: 17px; cursor: pointer; display: grid; place-items: center;
    transition: background var(--speed), transform .12s, border-color var(--speed);
}
.icon-btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0) scale(.96); }
.menu-toggle { display: none; }

.lang-switch {
    display: inline-flex; border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; font-size: 12.5px; font-weight: 700;
}
.lang-switch a { padding: 9px 10px; color: var(--muted); }
.lang-switch a.on { background: var(--brand); color: #fff; }

.profile-menu { position: relative; }
.profile-trigger {
    width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border);
    overflow: hidden; cursor: pointer; padding: 0; background: var(--brand-soft);
}
.profile-trigger img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback { display: grid; place-items: center; height: 100%; font-weight: 800; color: var(--brand-700); }
.dropdown {
    position: absolute; right: 0; top: 50px; min-width: 220px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
    opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
    transition: all var(--speed); z-index: 50;
}
.dropdown.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); font-weight: 600; }
.dropdown a:hover { background: var(--surface-2); }
.dropdown a.danger { color: var(--danger); }

/* ---------- Content & cards ---------- */
.content { padding: 22px; max-width: 1320px; width: 100%; margin: 0 auto; flex: 1; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; margin-bottom: 18px;
    animation: rise .35s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { font-size: 17px; margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    position: relative; overflow: hidden; animation: rise .4s ease both;
}
.stat::after {
    content: ""; position: absolute; right: -20px; top: -20px;
    width: 90px; height: 90px; border-radius: 50%; background: var(--brand-soft);
}
.stat .stat-ic { font-size: 22px; }
.stat .stat-val { font-size: 26px; font-weight: 800; margin-top: 8px; }
.stat .stat-lbl { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat.green::after { background: rgba(14,159,110,.14); }
.stat.blue::after { background: rgba(28,100,242,.14); }
.stat.amber::after { background: rgba(194,120,3,.14); }
.stat.red::after { background: rgba(224,36,36,.14); }
.stat.violet::after { background: rgba(99,102,241,.14); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 11px; border: 1px solid transparent;
    background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 14px;
    cursor: pointer; transition: transform .12s, background var(--speed), box-shadow var(--speed), filter var(--speed);
    text-decoration: none; line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff; box-shadow: 0 8px 18px -8px var(--brand); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-soft { background: var(--brand-soft); color: var(--brand-700); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { padding: 14px 22px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; color: var(--text); }
input, select, textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 14.5px; transition: border-color var(--speed), box-shadow var(--speed);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 84px; }
.stack > * + * { margin-top: 14px; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filter-bar .field { margin: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 560px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
table.data th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); position: sticky; top: 0; }
table.data tbody tr { transition: background var(--speed); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.thumb { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.green { background: var(--brand-soft); color: var(--brand-700); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: rgba(28,100,242,.12); color: var(--info); }
.badge.gray { background: var(--surface-2); color: var(--muted); }
.chip-role { text-transform: capitalize; }

/* ---------- Alerts / toasts ---------- */
.alert { padding: 12px 16px; border-radius: 11px; margin-bottom: 14px; font-weight: 600; font-size: 14px; border: 1px solid transparent; animation: rise .3s ease both; }
.alert-success { background: var(--brand-soft); color: var(--brand-700); border-color: rgba(14,159,110,.3); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(224,36,36,.3); }
.alert-info { background: rgba(28,100,242,.1); color: var(--info); }
.alert-warning { background: var(--warn-soft); color: var(--warn); }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand); box-shadow: var(--shadow-lg); padding: 13px 16px; border-radius: 11px; font-weight: 600; min-width: 220px; animation: toastIn .3s ease both; }
.toast.danger { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 44px 20px; }
.empty-icon { font-size: 46px; margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(8,14,22,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.open { display: flex; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; animation: pop .24s cubic-bezier(.2,.8,.3,1.2) both; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Calculator ---------- */
.calc-box { max-width: 340px; }
.calc { padding: 16px; }
.calc-expr { text-align: right; font-size: 18px; height: 46px; border: 1px solid var(--border); margin-bottom: 4px; background: var(--surface-2); }
.calc-result { text-align: right; font-size: 26px; font-weight: 800; padding: 4px 6px; min-height: 34px; color: var(--brand-700); }
.calc-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 10px; }
.ck { padding: 13px 0; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; font-size: 15px; cursor: pointer; transition: transform .1s, background var(--speed); }
.ck:hover { background: var(--surface-2); }
.ck:active { transform: scale(.94); }
.ck.fn { color: var(--accent); font-size: 13px; }
.ck.warn { color: var(--danger); }
.ck.eq { background: linear-gradient(135deg, var(--brand), var(--brand-600)); color: #fff; }

/* ---------- Auth ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; background:
    radial-gradient(1200px 500px at 10% -10%, var(--brand-soft), transparent),
    radial-gradient(900px 500px at 110% 10%, rgba(99,102,241,.12), transparent), var(--bg); padding: 18px; }
.auth-card { width: 100%; max-width: 400px; }
.setup-steps { display: flex; gap: 8px; margin-bottom: 16px; }
.setup-step { flex: 1; text-align: center; padding: 8px 6px; border-radius: 9px; font-size: 12.5px; font-weight: 700;
    background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.setup-step.on { background: var(--brand-soft); color: var(--brand-700); border-color: var(--brand); }
.setup-step.done { background: var(--brand); color: #fff; border-color: var(--brand); }
.brand-lockup { margin-bottom: 20px; }
.brand-lockup .brand-badge { width: 56px; height: 56px; font-size: 20px; margin: 0 auto 12px; }
.brand-lockup h1 { font-size: 22px; margin: 0; }

/* ==========================================================================
   POS
   ========================================================================== */
.pos-layout { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; align-items: start; }
.pos-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pos-panel-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pos-search { position: relative; }
.pos-search input { padding-left: 38px; }
.pos-search::before { content: "🔎"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); }
.pos-results { max-height: 300px; overflow-y: auto; }
.pos-result { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--speed); }
.pos-result:hover, .pos-result.hl { background: var(--brand-soft); }
.pos-result .grow { flex: 1; min-width: 0; }
.pos-result .grow strong { display: block; font-size: 14px; }
.pos-result .grow small { color: var(--muted); }

.pos-mode-badge { font-size: 13px; font-weight: 800; padding: 6px 12px; border-radius: 999px; }
.pos-mode-badge.sell { background: var(--brand-soft); color: var(--brand-700); }
.pos-mode-badge.buy { background: rgba(28,100,242,.12); color: var(--info); }

.cart-items { max-height: 46vh; overflow-y: auto; }
.cart-row { display: grid; grid-template-columns: 26px 1fr 96px; gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); animation: rise .2s ease both; }
.cart-row .cart-serial { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.cart-row .cart-name { font-weight: 600; font-size: 14px; }
.cart-row .cart-inputs { display: flex; gap: 6px; margin-top: 6px; }
.cart-row .cart-inputs input { padding: 7px 8px; font-size: 13px; text-align: right; }
.cart-row .cart-amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cart-row .cart-del { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 15px; }
.qty-in { max-width: 62px; } .rate-in { max-width: 82px; }

.pos-totals { padding: 14px 16px; border-top: 1px solid var(--border); }
.tot-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14.5px; }
.tot-row.grand { font-size: 20px; font-weight: 800; border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 12px; }
.tot-row.due span:last-child { color: var(--danger); font-weight: 800; }

.pos-party-info { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-top: 10px; }
.pos-party-info .pi-row { display: flex; justify-content: space-between; }

.pay-methods { display: flex; flex-wrap: wrap; gap: 6px; }
.pay-methods label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px; margin: 0; cursor: pointer; font-size: 13px; font-weight: 600; }
.pay-methods label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-700); }
.pay-methods input { width: auto; margin: 0; }

/* Sell/Buy chooser */
.chooser { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 20px; }
.chooser button { border: 2px solid var(--border); border-radius: 16px; padding: 26px 16px; background: var(--surface); cursor: pointer; transition: transform .15s, border-color var(--speed), background var(--speed); text-align: center; }
.chooser button:hover { transform: translateY(-3px); }
.chooser .c-sell:hover { border-color: var(--brand); background: var(--brand-soft); }
.chooser .c-buy:hover { border-color: var(--info); background: rgba(28,100,242,.1); }
.chooser .c-ic { font-size: 38px; }
.chooser h3 { margin: 10px 0 4px; }
.chooser small { color: var(--muted); }

/* ---------- POS product grid ---------- */
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 14px 16px; max-height: 44vh; overflow-y: auto; }
.pos-card { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 11px 12px; cursor: pointer; transition: transform .12s, border-color var(--speed), background var(--speed); font-family: inherit; }
.pos-card:hover { transform: translateY(-2px); border-color: var(--brand); background: var(--brand-soft); }
.pos-card:active { transform: scale(.97); }
.pos-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.pos-card-name { font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.pos-card small { display: block; margin-top: 4px; }

/* ---------- POS search / party dropdowns ---------- */
.pos-picker { position: relative; }
.pos-dropdown {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; padding: 5px;
}
.pos-dd-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 8px;
    cursor: pointer; transition: background var(--speed);
}
.pos-dd-item:hover { background: var(--brand-soft); }
.pos-dd-item .grow { flex: 1; min-width: 0; }
.pos-dd-item .grow strong { display: block; font-size: 14px; }
.pos-dd-item .grow small { color: var(--muted); font-size: 12px; }
.pos-dd-item.add-new { color: var(--brand-700); font-weight: 700; }

/* ---------- Invoice designer ---------- */
.design-list { list-style: none; margin: 0; padding: 0; }
.design-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface); cursor: grab; transition: box-shadow var(--speed), border-color var(--speed); }
.design-item:hover { border-color: var(--brand); }
.design-item.dragging { opacity: .5; box-shadow: var(--shadow-lg); }
.design-item .grow { flex: 1; font-weight: 600; }
.drag-handle { color: var(--muted); cursor: grab; font-size: 18px; letter-spacing: -3px; }
.a4-preview { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: #fff; color: #222; min-height: 200px; }
.a4-preview .pv-head { border-bottom: 3px solid var(--brand); padding-bottom: 8px; margin-bottom: 10px; }
.a4-preview .pv-block { border: 1px dashed #cfd6df; border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 13px; color: #333; }
.a4-preview .pv-foot { margin-top: 10px; font-size: 12px; color: #777; }

/* ---------- Category tree ---------- */
.cat-main { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.cat-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; }
.cat-row + .cat-row { border-top: 1px solid var(--border); }
.cat-sub { background: var(--surface-2); font-size: 14px; }

/* ---------- Due toggle switch ---------- */
.due-toggle { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 4px; font-weight: 700; font-size: 14px; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background var(--speed); }
.switch .slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform var(--speed); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Invoice (A4) ---------- */
.invoice-toolbar { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.a4 {
    width: 210mm; min-height: 297mm; margin: 0 auto; background: #fff; color: #1b2430;
    padding: 18mm 16mm; box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.a4 * { position: relative; z-index: 1; }
.a4-watermark {
    position: absolute; inset: 0; z-index: 0; display: grid; place-items: center;
    font-size: 90px; font-weight: 800; color: rgba(14,159,110,.07);
    transform: rotate(-28deg); letter-spacing: 8px; pointer-events: none; text-align: center;
}
.a4-head { display: flex; justify-content: space-between; border-bottom: 3px solid var(--brand); padding-bottom: 14px; margin-bottom: 20px; }
.a4-company h2 { font-size: 24px; color: var(--brand-700); margin: 0; }
.a4-meta { text-align: right; font-size: 13px; }
.a4-meta .a4-title { font-size: 20px; font-weight: 800; text-transform: uppercase; }
.a4 table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.a4 table th { background: #f1f5f4; text-align: left; padding: 9px 10px; font-size: 12px; text-transform: uppercase; border-bottom: 2px solid var(--brand); }
.a4 table td { padding: 9px 10px; border-bottom: 1px solid #e5e9f0; font-size: 13px; }
.a4 .a4-totals { width: 300px; margin-left: auto; }
.a4 .a4-totals td { border: none; padding: 5px 10px; }
.a4 .a4-grand { font-size: 17px; font-weight: 800; border-top: 2px solid var(--brand) !important; }
.a4-foot { display: flex; justify-content: space-between; margin-top: 60px; font-size: 12px; }
.a4-sign { border-top: 1px solid #333; padding-top: 6px; width: 180px; text-align: center; }
.a4-billto { margin-bottom: 14px; }
.a4-note { margin-top: 6px; }

/* Paper sizes */
.a4.paper-A5 { width: 148mm; min-height: 210mm; padding: 12mm; }
.a4.paper-A5 .a4-company h2 { font-size: 20px; }
.a4.paper-mm80 { width: 80mm; min-height: auto; padding: 5mm 4mm; }
.a4.paper-mm58 { width: 58mm; min-height: auto; padding: 4mm 3mm; }
.a4.paper-mm80 .a4-head, .a4.paper-mm58 .a4-head { flex-direction: column; gap: 4px; text-align: center; align-items: center; padding-bottom: 8px; }
.a4.paper-mm80 .a4-meta, .a4.paper-mm58 .a4-meta { text-align: center; }
.a4.paper-mm80 .a4-company h2 { font-size: 16px; }
.a4.paper-mm58 .a4-company h2 { font-size: 14px; }
.a4.paper-mm80 .a4-title, .a4.paper-mm58 .a4-title { font-size: 14px; }
.a4.paper-mm80 table th, .a4.paper-mm58 table th { font-size: 9px; padding: 4px 3px; }
.a4.paper-mm80 table td, .a4.paper-mm58 table td { font-size: 10px; padding: 4px 3px; }
.a4.paper-mm80 .a4-totals, .a4.paper-mm58 .a4-totals { width: 100%; }
.a4.paper-mm80 .a4-foot, .a4.paper-mm58 .a4-foot { flex-direction: column; gap: 12px; margin-top: 16px; text-align: center; }
.a4.paper-mm80 .a4-sign, .a4.paper-mm58 .a4-sign { display: none; }
.a4.paper-mm80 .a4-watermark, .a4.paper-mm58 .a4-watermark { font-size: 42px; }

/* ---------- Premium invoice look ---------- */
.a4-brand { display: flex; align-items: center; gap: 12px; }
.a4-monogram {
    width: 46px; height: 46px; border-radius: 12px; flex: none;
    display: grid; place-items: center; font-weight: 800; font-size: 18px; letter-spacing: .5px;
    background: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px var(--brand);
}
.a4 .a4-company h2 { font-size: 25px; letter-spacing: .3px; margin: 0; line-height: 1.1; }
.a4 .a4-cinfo { font-size: 12.5px; color: #566; margin-top: 3px; }
.a4 .a4-head { align-items: flex-start; padding-bottom: 16px; margin-bottom: 22px; }
.a4 .a4-meta .a4-title {
    display: inline-block; background: var(--brand); color: #fff; padding: 4px 14px;
    border-radius: 999px; font-size: 14px; letter-spacing: 1.5px; margin-bottom: 6px;
}
.a4 .a4-billto { background: #f7faf9; border-left: 3px solid var(--brand); border-radius: 0 8px 8px 0; padding: 10px 14px; font-size: 13px; }
.a4 table th { background: var(--brand); color: #fff; border-bottom: none; padding: 10px; font-size: 11.5px; letter-spacing: .4px; }
.a4 table thead tr th:first-child { border-radius: 8px 0 0 0; }
.a4 table thead tr th:last-child { border-radius: 0 8px 0 0; }
.a4 table:not(.a4-totals) tbody tr:nth-child(even) td { background: #f8faf9; }
.a4 table td { padding: 9px 10px; }
.a4 .a4-totals { margin-top: 8px; }
.a4 .a4-totals td { padding: 6px 12px; background: transparent; }
.a4 .a4-grand td { background: var(--brand) !important; color: #fff; font-size: 16px; font-weight: 800; border: none !important; }
.a4 .a4-grand td:first-child { border-radius: 8px 0 0 8px; }
.a4 .a4-grand td:last-child { border-radius: 0 8px 8px 0; }
.a4-watermark { font-weight: 900; letter-spacing: 10px; }
/* Filled-accent header reads white on receipts too */
.a4.paper-mm80 table th, .a4.paper-mm58 table th { color: #fff; }
.a4.paper-mm80 .a4-billto, .a4.paper-mm58 .a4-billto { text-align: center; font-size: 11px; }
.a4.paper-mm80 table td, .a4.paper-mm58 table td { border-bottom: 1px dashed #ddd; }
.a4.paper-mm80 .a4-grand, .a4.paper-mm58 .a4-grand { font-size: 14px; }
.a4.paper-mm80 .a4-foot, .a4.paper-mm58 .a4-foot { font-size: 11px; }
/* Thermal cut line + feed space (receipt sizes only) */
.receipt-cut { display: none; }
.a4.paper-mm80 .receipt-cut, .a4.paper-mm58 .receipt-cut {
    display: block; text-align: center; letter-spacing: 1px; color: #777;
    margin-top: 12px; padding-bottom: 18mm; overflow: hidden; white-space: nowrap;
}

/* ---------- Barcode labels ---------- */
.bc-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.bc-label { border: 1px dashed var(--border); border-radius: 8px; padding: 8px 6px; text-align: center; background: #fff; color: #111; break-inside: avoid; }
.bc-shop { font-size: 10px; font-weight: 700; color: #333; }
.bc-name { font-size: 12px; font-weight: 700; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-svg svg { max-width: 100%; height: auto; }
.bc-code { font-size: 11px; letter-spacing: 2px; font-family: monospace; margin-top: 2px; }
@media print {
  .bc-sheet { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .bc-label { border-color: #ccc; }
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.flex { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.text-danger { color: var(--danger); }
.text-success { color: var(--brand-700); }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .pos-layout { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .app-shell.nav-open .sidebar { transform: translateX(0); }
    .app-shell.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
    .menu-toggle { display: grid; }
    .content { padding: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .lang-switch a { padding: 9px 8px; }
    .page-title { font-size: 16px; }
}
@media (max-width: 640px) {
    .topbar { padding: 10px 12px; gap: 8px; }
    .topbar-tools { gap: 6px; }
    #installBtn .btn-lbl { display: none; }
    .pos-grid { max-height: 38vh; }
}
@media (max-width: 480px) {
    .topbar-tools .icon-btn#cacheBtn { display: none; }
    .icon-btn { width: 38px; height: 38px; font-size: 16px; }
    .page-head h1 { font-size: 19px; }
    .stat .stat-val { font-size: 22px; }
    .content { padding: 12px; }
    .card { padding: 15px; }
    .btn { padding: 9px 13px; }
    .modal-box { max-width: 100%; }
    .pos-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .invoice-toolbar, .no-print { display: none !important; }
    body, .content { background: #fff; padding: 0; margin: 0; }
    .a4 { box-shadow: none; margin: 0; width: auto; min-height: auto; padding: 10mm; }
    @page { size: A4; margin: 0; }
}
