/* ==========================================================================
   LaundryPro - app.css
   Structure:
     1. Tokens
     2. Base / typography
     3. Layout shell (sidebar, topbar, mobile bottom-bar)
     4. Components: cards, KPI, tables, badges, buttons, forms, flash
     5. Charts & data-viz helpers
     6. Screens: POS, order detail, receipt, auth
     7. Utilities
     8. Responsive (tablet -> phone)
     9. Print
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --ink: #101828;
    --ink-2: #475467;
    --ink-3: #98a2b3;
    --line: #e4e7ec;
    --line-soft: #f2f4f7;

    --brand: #0f766e;
    --brand-2: #14b8a6;
    --brand-soft: #e6fffb;
    --side: #0b1220;
    --side-2: #131c2e;
    --side-ink: #cbd5e1;

    /* data-viz palette */
    --c1: #0ea5e9;
    --c2: #14b8a6;
    --c3: #22c55e;
    --c4: #f59e0b;
    --c5: #8b5cf6;
    --c6: #ef4444;
    --c7: #ec4899;
    --c8: #06b6d4;

    --ok: #067647;
    --ok-soft: #d1fadf;
    --warn: #b54708;
    --warn-soft: #fef0c7;
    --bad: #b42318;
    --bad-soft: #fee4e2;
    --info: #175cd3;
    --info-soft: #dbeafe;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 12px 28px -18px rgba(16, 24, 40, .25);
    --shadow-lg: 0 18px 44px -24px rgba(16, 24, 40, .45);
    --topbar-h: 62px;
    --tap: 44px;               /* minimum touch target */
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    overscroll-behavior-y: contain;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 10px; line-height: 1.25; }
h1 { font-size: 20px; letter-spacing: -.2px; }
h2 { font-size: 16.5px; }
h3 { font-size: 15px; }
small { color: var(--ink-3); }
hr, .divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

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

.sidebar {
    width: 244px;
    flex: 0 0 244px;
    background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
    color: var(--side-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 60;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark {
    width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
    box-shadow: 0 6px 16px -6px rgba(20,184,166,.9);
}
.brand-name { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: #7c8aa5; text-transform: uppercase; letter-spacing: .9px; }

.nav { padding: 10px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.1px; color: #64748b; padding: 12px 10px 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px; min-height: var(--tap);
    padding: 8px 10px; border-radius: var(--radius-sm); color: var(--side-ink); font-weight: 500;
}
.nav a:hover, .nav a:focus-visible { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(20,184,166,.16); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav .pill { margin-left: auto; background: var(--brand-2); color: #04231f; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11.5px; color: #64748b; }

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

.topbar {
    background: #fff; border-bottom: 1px solid var(--line);
    min-height: var(--topbar-h); padding: 10px 20px;
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 40;
}
.topbar h1 { margin: 0 12px 0 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar form.inline-form { margin: 0 0 0 4px; }
.topbar .who { text-align: right; line-height: 1.15; margin: 0 2px 0 10px; }
.topbar .who b { display: block; font-size: 13px; }
.topbar .who span { font-size: 11px; color: var(--ink-3); }
.avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; }

.content { padding: 18px 20px 40px; max-width: 1320px; width: 100%; }

/* mobile bottom navigation (hidden on desktop) */
.mobile-bar { display: none; }

/* 4. Components ------------------------------------------------------------ */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.card.tight { padding: 0; overflow: hidden; }
.card.tight .card-head { padding: 14px 16px; margin: 0; border-bottom: 1px solid var(--line); }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 1.6fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 1.6fr; }

/* KPI cards */
.kpi {
    position: relative; overflow: hidden; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.kpi::after {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
    background: linear-gradient(180deg, var(--brand-2), var(--brand));
}
.kpi.k-1::after { background: linear-gradient(180deg, #38bdf8, #0ea5e9); }
.kpi.k-2::after { background: linear-gradient(180deg, #34d399, #22c55e); }
.kpi.k-3::after { background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.kpi.k-4::after { background: linear-gradient(180deg, #a78bfa, #8b5cf6); }
.kpi.k-5::after { background: linear-gradient(180deg, #fb7185, #ef4444); }
.kpi .k-label { font-size: 11.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .5px; }
.kpi .k-value { font-size: 22px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; word-break: break-word; }
.kpi .k-foot { position: relative; z-index: 1; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); padding-right: 60px; }
.kpi .k-icon {
    position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; border-radius: 8px;
    display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 13px;
}
/* sparkline sits bottom-right; a mask fades its tail so it never collides with the footer text */
.kpi .spark { position: absolute; right: 0; bottom: 0; width: 104px; height: 34px; opacity: .9; pointer-events: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 40%);
    mask-image: linear-gradient(90deg, transparent 0, #000 40%); }
.trend { font-weight: 700; font-size: 11.5px; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--bad); }

/* Tables */
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3);
    background: #fafbfc; font-weight: 700; white-space: nowrap;
}
tbody tr:hover { background: #fbfcfe; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { background: #fafbfc; border-top: 2px solid var(--line); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--line-soft); color: var(--ink-2); }
.badge-express { background: #fff1e6; color: #b54708; border: 1px dashed #f0b27a; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 38px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink); font: 600 13px/1 inherit; cursor: pointer;
    text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #0c5f59; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--bad-soft); border-color: #fda29b; color: var(--bad); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Forms */
label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
/* Text-ish inputs, including ones written without a type attribute */
input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=hidden]):not([type=file]),
select, textarea {
    width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line);
    border-radius: var(--radius-sm); font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20,184,166,.18);
}
.field { margin-bottom: 12px; }
.field-row, .field-row-3 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.field-row-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 32px; }
.checkline input { width: auto; min-height: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 132px; flex: 1 1 132px; }

/* Flash messages */
.flash {
    display: flex; align-items: center; gap: 10px; padding: 11px 14px; margin-bottom: 14px;
    border-radius: 10px; font-weight: 600; border: 1px solid transparent;
}
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: #a6f4c5; }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: #fda29b; }
.flash-x { margin-left: auto; background: none; border: 0; color: inherit; font-size: 18px; cursor: pointer; }

/* Tabs & pills */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tag { font-size: 11px; background: var(--line-soft); color: var(--ink-2); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }

/* 5. Charts & data-viz ----------------------------------------------------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-card { min-height: 120px; }
.chart-card .chart-title { font-weight: 700; font-size: 13.5px; }
.chart-card .chart-sub { font-size: 11.5px; color: var(--ink-3); }

.donut { width: 100%; height: auto; display: block; margin: 0 auto; }
.legend { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.legend-label { flex: 1; min-width: 0; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-val { display: inline-flex; align-items: baseline; gap: 5px; justify-content: flex-end;
    font-weight: 700; font-variant-numeric: tabular-nums; }
.legend-val small { color: var(--ink-3); font-weight: 600; }

.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin-bottom: 4px; }
.hbar-top span { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 9px; border-radius: 20px; background: var(--line-soft); overflow: hidden; }
.hbar-track > span { display: block; height: 100%; border-radius: 20px; }

.stackbar { display: flex; height: 16px; border-radius: 20px; overflow: hidden; background: var(--line-soft); }
.stackbar > span { display: block; height: 100%; }
.stackbar > span + span { box-shadow: -2px 0 0 #fff; }

.spark { display: block; }
.gauge { width: 100%; height: auto; display: block; margin: 0 auto; }

.heatmap { display: flex; flex-direction: column; gap: 6px; }
.heat-row { display: grid; grid-template-columns: 116px repeat(var(--cols), minmax(0, 1fr)); gap: 6px; align-items: center; }
.heat-head span { font-size: 10.5px; color: var(--ink-3); text-align: center; }
.heat-label { font-size: 12px; color: var(--ink-2); }
.heat-cell {
    display: grid; place-items: center; min-height: 34px; border-radius: 7px;
    font-size: 11px; font-weight: 700; color: #0b3b36;
}
.chart-grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* 6. Screens --------------------------------------------------------------- */
/* POS */
.pos-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; align-items: start; }
.pos-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pos-tab {
    min-height: 34px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line);
    background: #fff; font: 600 12.5px/1 inherit; cursor: pointer; color: var(--ink-2);
}
.pos-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.svc {
    border: 1px solid var(--line); border-radius: 11px; padding: 10px; background: #fff;
    cursor: pointer; text-align: left; font: inherit; min-height: 78px; transition: .15s ease;
}
.svc:hover { border-color: var(--brand-2); box-shadow: 0 8px 18px -12px rgba(15,118,110,.6); transform: translateY(-1px); }
.svc .n { font-weight: 700; font-size: 12.5px; line-height: 1.3; display: block; min-height: 32px; }
.svc .p { color: var(--brand); font-weight: 800; font-size: 13px; margin-top: 6px; display: block; }
.svc .u { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.svc[hidden] { display: none; }

.cart { position: sticky; top: calc(var(--topbar-h) + 12px); }
.cart-line { display: flex; gap: 8px; align-items: flex-start; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.cart-line .t { flex: 1; min-width: 0; }
.cart-line .t b { display: block; font-size: 12.5px; }
.cart-line .t small { font-size: 11px; }
.cart-line input { width: 62px; min-height: 34px; padding: 4px 6px; font-size: 12px; text-align: center; }
.cart-line .lt { font-weight: 700; font-size: 12.5px; min-width: 60px; text-align: right; }
.cart-total { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13px; }
.cart-total.grand { font-weight: 800; font-size: 16px; padding-top: 10px; margin-top: 6px; border-top: 2px solid var(--ink); }
.cart-bar { display: none; }

/* Order detail / receipt */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 12px 20px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.timeline li::after { content: ""; position: absolute; left: 4px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }

.receipt {
    width: 302px; max-width: 100%; margin: 0 auto; padding: 16px; background: #fff;
    font: 12px/1.4 "Courier New", monospace; color: #111; border: 1px dashed #cbd5e1;
}
.receipt h4 { text-align: center; margin: 0 0 2px; font-size: 14px; letter-spacing: 1px; }
.receipt .c { text-align: center; }
.receipt .row { display: flex; justify-content: space-between; gap: 8px; }
.receipt .dash { border-top: 1px dashed #94a3b8; margin: 7px 0; }
.receipt table { width: 100%; }
.receipt td { padding: 2px 0; border: 0; font-size: 12px; }
.receipt .tot { font-weight: bold; font-size: 13px; }

/* Auth */
.auth-wrap {
    min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px;
    background: radial-gradient(1100px 500px at 12% -10%, #0f766e 0%, #0b1220 46%, #070c15 100%);
}
.auth-card { width: 100%; max-width: 396px; background: #fff; border-radius: 18px; padding: 26px; box-shadow: var(--shadow-lg); }
.auth-card .brand-name { color: var(--ink); }
.auth-head { text-align: center; margin-bottom: 16px; }
.auth-head .brand-mark { margin: 0 auto 10px; }
.demo-keys { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: #f8fafc; font-size: 12px; color: var(--ink-2); }

/* 7. Utilities ------------------------------------------------------------- */
.empty { text-align: center; padding: 30px 14px; color: var(--ink-3); }
.empty .big { font-size: 28px; margin-bottom: 6px; }
.muted { color: var(--ink-3); }
.right { text-align: right; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-split { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.show-xs { display: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 7b. Scripts & direction
   Bengali and Arabic glyphs are taller than Latin ones; without extra leading
   the sidebar and table rows look cramped. Japanese/Chinese need a slightly
   looser line so kanji do not touch.  */
.lang-bn { --font: var(--font-bn); }
.lang-ar { --font: var(--font-ar); }
.lang-hi { --font: var(--font-hi); }
.lang-ja, .lang-zh { --font: var(--font-cjk); }
/* receipt stays monospaced, but the Latin-only stack leaves CJK/Arabic/Bengali
to the browser default - keep the script font as a fallback so the 80 mm slip
still prints readable names */
.receipt { font-family: "Courier New", ui-monospace, "LP Bengali", "Noto Sans Bengali", var(--font), monospace; }

.lang-bn body, body.lang-bn, body.lang-ar, body.lang-hi { line-height: 1.62; }
body.lang-ja, body.lang-zh { line-height: 1.55; }
body.lang-bn .k-value, body.lang-bn .kpi .k-value { font-size: 0.94em; }   /* Bengali digits run wide */
body.lang-ar .k-value, body.lang-ar .kpi .k-value { font-size: 0.96em; }

/* Arabic/Persian numerals stay Western here on purpose: shop staff read Latin
   digits on receipts, and mixing systems breaks cash reconciliation. */

/* ---- RTL: mirror the shell, never the content ---- */
[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--line); }
[dir="rtl"] .nav a .pill { margin-left: 0; margin-right: auto; }
[dir="rtl"] .nav a .ico { margin-right: 0; }
[dir="rtl"] .topbar h1 { margin: 0 0 0 12px; }
[dir="rtl"] .table-wrap th, [dir="rtl"] .table-wrap td { text-align: right; }
[dir="rtl"] .num, [dir="rtl"] .table-wrap td.num, [dir="rtl"] th.num { text-align: left; }
[dir="rtl"] .card-head .spacer { order: -1; }
[dir="rtl"] .chart-legend .lg-val { margin-left: 0; margin-right: auto; }
[dir="rtl"] .kpi .k-icon { right: auto; left: 14px; }
[dir="rtl"] .kpi .spark { right: auto; left: 0; transform: scaleX(-1); }
[dir="rtl"] .kpi .k-foot { padding-right: 0; padding-left: 60px; }
[dir="rtl"] .heat-head, [dir="rtl"] .heat-row { direction: rtl; }
[dir="rtl"] .mobile-bar { direction: rtl; }
[dir="rtl"] .cart-bar { direction: rtl; }
[dir="rtl"] .brand-mark { margin-right: 0; }
[dir="rtl"] .flash { border-left: 0; border-right: 4px solid var(--brand); }
[dir="rtl"] .field input, [dir="rtl"] .field select, [dir="rtl"] .field textarea { text-align: right; }
[dir="rtl"] input[type=date], [dir="rtl"] input[type=number], [dir="rtl"] .mono { direction: ltr; text-align: right; }
[dir="rtl"] .tabs { flex-direction: row-reverse; justify-content: flex-end; }

/* ---- language switcher ---- */
.lang-switch { display: inline-flex; align-items: center; gap: 6px; }
.lang-switch select {
    min-height: 34px; padding: 5px 8px; font-size: 12.5px; width: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.lang-switch .globe { display: inline-flex; color: var(--ink-3); }

/* 8. Responsive ------------------------------------------------------------ */
@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    .grid-3, .grid-2, .grid-2-1, .grid-1-2, .pos-grid, .chart-grid-2 { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; left: -260px; width: 260px; flex-basis: 260px;
        transition: left .22s ease; box-shadow: none;
    }
    body.nav-open .sidebar { left: 0; box-shadow: 0 0 0 100vmax rgba(2,6,23,.5); }
    body.nav-open { overflow: hidden; }
    .cart { position: static; }
}

@media (max-width: 720px) {
    .content { padding: 12px 12px 92px; }         /* room for the bottom bar */

    /* Charts are SVG with a 720-unit viewBox - scale the type up so it stays
       legible at ~350px wide instead of shrinking to 5px. */
    .chart .ax { font-size: 19px; }
    .chart .ax-y { display: none; }
    .donut .donut-big, .gauge .gauge-big { font-size: 22px; }
    .donut .donut-sub { font-size: 14px; }
    .heat-head span { font-size: 9.5px; }
    .kpi .k-foot { padding-right: 60px; }
    .topbar { padding: 8px 12px; gap: 8px; }
    .topbar h1 { font-size: 16px; flex: 1 1 auto; min-width: 0; }
    .topbar .who, .topbar .avatar { display: none; }
    /* the bottom bar already has "New" - no need to duplicate the CTA up here */
    .topbar .btn-primary { display: none; }
    .topbar .btn-ghost { min-height: 34px; padding: 6px 8px; font-size: 12px; white-space: nowrap; }

    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .field-row, .field-row-3, .chart-grid-2, .chart-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .kpi { padding: 12px; }
    .kpi .k-label { font-size: 10.5px; letter-spacing: .3px; }
    .kpi .k-value { font-size: 17px; }
    .kpi .k-foot { font-size: 10.5px; padding-right: 0; }
    .kpi .k-icon { width: 24px; height: 24px; font-size: 10px; border-radius: 6px; }
    .kpi .spark { display: none; }
    .card { padding: 13px; border-radius: 12px; }
    .card.tight .card-head { padding: 12px 13px; }

    /* tables become stacked cards */
    .table-wrap table thead { display: none; }
    .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
    .table-wrap tr {
        border: 1px solid var(--line); border-radius: 11px; margin: 0 0 10px; padding: 6px 4px; background: #fff;
    }
    .table-wrap td {
        display: flex; justify-content: space-between; gap: 12px; align-items: center;
        padding: 6px 12px; border: 0; text-align: right;
    }
    .table-wrap td::before {
        content: attr(data-label); font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
        color: var(--ink-3); font-weight: 700; text-align: left; flex: 0 0 40%;
    }
    .table-wrap td[data-label=""]::before, .table-wrap td:not([data-label])::before { content: ""; }
    .table-wrap td.num, .table-wrap th.num { text-align: right; }
    .table-wrap tfoot { display: block; }
    .table-wrap tfoot tr { border: 0; background: transparent; }

    .tabs { gap: 2px; padding-bottom: 4px; scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs a { padding: 8px 10px; font-size: 12.5px; }
    .tabs::after {
        content: ""; position: sticky; right: 0; flex: 0 0 22px; margin-left: auto;
        background: linear-gradient(90deg, rgba(244,246,251,0), var(--bg));
    }

    /* inline status forms stack instead of squeezing the select */
    .table-wrap td form { flex-wrap: wrap; justify-content: flex-end; }
    .table-wrap td form select { flex: 1 1 auto; min-width: 120px; }
    .table-wrap td .btn { flex: 0 0 auto; }
    .hide-xs { display: none; }
    .show-xs { display: inline; }
    .lang-switch select { max-width: 92px; text-overflow: ellipsis; }
    [dir="rtl"] .kpi .spark { display: none; }
    [dir="rtl"] .kpi .k-foot { padding-left: 0; }

    /* POS: floating "view basket" bar */
    .cart-bar {
        display: flex; position: fixed; left: 12px; right: 12px; bottom: 74px; z-index: 45;
        align-items: center; justify-content: space-between; gap: 10px;
        background: var(--brand); color: #fff; padding: 10px 14px; border-radius: 12px;
        box-shadow: var(--shadow-lg); font-weight: 700; min-height: 48px;
    }
    .cart-bar .n { font-size: 12.5px; opacity: .9; font-weight: 600; }
    .pos-tab, .btn, .svc { min-height: var(--tap); }
    .svc .n { min-height: 0; }

    /* mobile bottom navigation */
    .mobile-bar {
        display: grid; grid-template-columns: repeat(5, 1fr);
        position: fixed; inset: auto 0 0 0; z-index: 50;
        background: #fff; border-top: 1px solid var(--line);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        box-shadow: 0 -8px 24px -18px rgba(16,24,40,.5);
    }
    .mobile-bar a {
        display: flex; flex-direction: column; align-items: center; gap: 2px;
        font-size: 10.5px; color: var(--ink-2); padding: 4px 2px; border-radius: 10px; min-height: 44px;
    }
    .mobile-bar a.active { color: var(--brand); background: var(--brand-soft); }
    .mobile-bar .mi { font-size: 16px; line-height: 1; }

    .receipt { border: 0; width: 100%; }
    .heat-row { grid-template-columns: 92px repeat(var(--cols), minmax(0, 1fr)); }
    .heat-label { font-size: 11px; }
    .heat-cell { min-height: 30px; font-size: 10px; }
}

@media (max-width: 420px) {
    .kpi .k-value { font-size: 16px; }
    .mobile-bar a { font-size: 9.5px; }
    .svc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 9. Print ----------------------------------------------------------------- */
@media print {
    .sidebar, .topbar, .no-print, .flash, .mobile-bar, .cart-bar, .tabs, .lang-switch { display: none !important; }
    body { background: #fff; }
    .shell { display: block; }
    .content { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 12px; }
    .grid, .grid-4, .grid-3, .grid-2, .grid-2-1, .grid-1-2, .chart-grid-2, .chart-grid-3 { display: block; }
    .chart, .donut, .gauge { break-inside: avoid; }
    a { color: #000; }
}
