/* ═══════════════════════════════════════════════════
   B60-POS - B60 OS (indigo, solid white cards on a
   lavender canvas). This :root is the single permanent
   theme; dark mode is dropped per the design brief.
   Every legacy variable name is preserved so the pages
   that consume them re-skin automatically - the values
   now point at the --ds-* tokens in design-system.css,
   which is the one source of truth for the palette.
   ═══════════════════════════════════════════════════ */

:root {
    color-scheme: light;

    /* -- Backgrounds (B60 OS canvas + solid surfaces) -- */
    --bg-void: var(--ds-canvas);
    --bg-panel: var(--ds-surface);
    --bg-surface: var(--ds-surface);
    --bg-elevated: var(--ds-surface-alt);
    --bg-input: var(--ds-surface);

    /* -- Gold names retired; values fold into indigo primary -- */
    --gold: var(--ds-primary);
    --gold-dark: var(--ds-primary-press);
    --gold-tint: var(--ds-primary-tint);
    --gold-rgb: 79, 70, 229;

    /* -- Green - status/success -- */
    --green: var(--ds-success);
    --green-light: #34D399;
    --green-tint: var(--ds-success-tint);
    --green-rgb: 16, 185, 129;

    /* -- Text hierarchy -- */
    --text-primary: var(--ds-text-primary);
    --text-secondary: var(--ds-text-secondary);
    --text-hint: var(--ds-text-tertiary);

    /* -- Borders -- */
    --border-default: var(--ds-border);
    --border-strong: var(--ds-border-strong);

    /* -- Semantic -- */
    --red: var(--ds-danger);
    --red-tint: var(--ds-danger-tint);
    --red-rgb: 239, 68, 68;
    --blue: var(--ds-info);
    --blue-tint: var(--ds-info-tint);
    --blue-rgb: 59, 130, 246;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;

    /* -- Interactive accent: indigo primary -- */
    --accent: var(--ds-primary);
    --accent-hover: var(--ds-primary-hover);
    --accent-secondary: var(--ds-primary);
    --accent-glow: var(--ds-primary-tint);
    --accent-tint: var(--ds-primary-tint);
    --text-on-accent: #FFFFFF;
    --success: var(--ds-success);
    --warning: var(--ds-warning);
    --danger: var(--ds-danger);
    --danger-dark: var(--ds-primary-press);
    --info: var(--ds-info);

    /* -- Glass names kept; solid surfaces, blur disabled -- */
    --glass-base: var(--ds-surface);
    --glass-elevated: var(--ds-surface);
    --glass-chrome: var(--ds-surface);
    --glass-pressed: var(--ds-surface);
    --glass-rim: 1px solid var(--ds-border);
    /* Transparent no-op rather than `none`: both are used as one entry in a
       comma-separated box-shadow list, and `none` is only valid on its own,
       which would invalidate the whole declaration. */
    --glass-rim-inset: inset 0 0 0 rgba(0, 0, 0, 0);
    --rim-light: inset 0 0 0 rgba(0, 0, 0, 0);
    --blur-card: 0px;
    --blur-panel: 0px;
    --blur-overlay: 0px;

    /* -- Finance palette (readable on light) -- */
    --profit-green: var(--ds-success);
    --profit-green-tint: var(--ds-success-tint);
    --ar-rose: var(--ds-danger);
    --ar-rose-tint: var(--ds-danger-tint);
    --alert-amber: var(--ds-warning);
    --alert-amber-tint: var(--ds-warning-tint);
    --report-blue: var(--ds-info);
    --report-blue-tint: var(--ds-info-tint);
    --view-accent: var(--ds-primary);
    --view-accent-dark: var(--ds-primary-press);
    --bg-primary: var(--bg-void);
    --bg-secondary: var(--bg-panel);
    --bg-tertiary: var(--bg-elevated);
    --bg-hover: var(--bg-elevated);
    --text-muted: var(--text-hint);
    --border: var(--border-default);
    --border-light: var(--border-strong);

    /* -- Typography - self-hosted Geist (offline-first; no CDN) -- */
    --font-heading: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --font-body: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', ui-monospace, 'Consolas', monospace;

    /* -- Type scale -- */
    --text-xs: 11px;
    --text-sm: 12px;
    --text-md: 13px;
    --text-base: 14px;
    --text-lg: 16px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 1.5rem;

    /* -- Font weights -- */
    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;

    /* -- Spacing (base 4px) -- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;

    /* -- Radii (B60 OS) -- */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 999px;

    /* -- Shadows (B60 OS card/pop family) -- */
    --shadow-sm: var(--ds-shadow-card);
    --shadow-md: var(--ds-shadow-pop);
    --shadow-lg: var(--ds-shadow-modal);
    --shadow-soft: var(--ds-shadow-card);

    /* -- Layout (sidebar: 72px rail / 232px expanded) -- */
    --sidebar-width: 72px;
    --sidebar-width-expanded: 232px;
    --sidebar-collapsed: 72px;
    --topbar-height: 56px;
    --ds-shell-gutter-inline: clamp(12px, 2vw, 24px);
    --ds-shell-gutter-block: clamp(8px, 1.5vh, 24px);

    /* -- Breakpoints -- */
    --bp-sm: 600px;
    --bp-md: 768px;
    --bp-lg: 900px;

    /* -- Transitions -- */
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.2s ease-out;

    /* -- Z-index -- */
    --z-sidebar: 100;
    --z-overlay: 200;
    --z-modal: 300;
    --z-toast: 400;
    --z-popover: 500;
    --z-tooltip: 600;

    /* -- Touch targets -- */
    --touch-target: 44px;
}

/* ═══════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ═══════════════════════════════════════════════════ */

[data-theme="light"] {
    color-scheme: light;

    /* Mirror B60 OS :root so this inert block cannot revert the palette */
    --gold-rgb: 79, 70, 229;
    --green-rgb: 16, 185, 129;
    --blue-rgb: 59, 130, 246;
    --red-rgb: 239, 68, 68;

    --bg-void: var(--ds-canvas);
    --bg-panel: var(--ds-surface);
    --bg-surface: var(--ds-surface);
    --bg-elevated: var(--ds-surface-alt);
    --bg-input: var(--ds-surface);

    --gold: var(--ds-primary);
    --gold-dark: var(--ds-primary-press);
    --gold-tint: var(--ds-primary-tint);

    --green: var(--ds-success);
    --green-light: #34D399;
    --green-tint: var(--ds-success-tint);

    --text-primary: var(--ds-text-primary);
    --text-secondary: var(--ds-text-secondary);
    --text-hint: var(--ds-text-tertiary);

    --border-default: var(--ds-border);
    --border-strong: var(--ds-border-strong);

    --red: var(--ds-danger);
    --red-tint: var(--ds-danger-tint);
    --blue: var(--ds-info);
    --blue-tint: var(--ds-info-tint);

    --profit-green-tint: var(--ds-success-tint);
    --ar-rose-tint: var(--ds-danger-tint);
    --alert-amber-tint: var(--ds-warning-tint);
    --report-blue-tint: var(--ds-info-tint);

    --profit-green: var(--ds-success);
    --ar-rose: var(--ds-danger);
    --alert-amber: var(--ds-warning);
    --report-blue: var(--ds-info);

    --shadow-sm: var(--ds-shadow-card);
    --shadow-md: var(--ds-shadow-pop);
    --shadow-lg: var(--ds-shadow-modal);

    --op-bg-panel: var(--ds-surface);
    --op-bg-row: var(--ds-surface-alt);
    --op-bg-row-hover: var(--ds-surface-alt);
    --op-bg-header: var(--ds-surface-alt);
    --op-accent: var(--ds-primary);
    --op-accent-dim: var(--ds-primary-press);
    --op-btn-debt-bg: var(--ds-danger-tint);
    --op-btn-debt-text: var(--ds-danger);
    --op-btn-print-bg: var(--ds-surface-alt);
    --op-btn-print-text: var(--ds-text-primary);
    --op-border-panel: var(--ds-border);
    --op-border-row: var(--ds-border);

    --bg-primary: var(--bg-void);
    --bg-secondary: var(--bg-panel);
    --bg-tertiary: var(--bg-surface);
    --bg-hover: var(--bg-elevated);
    --border: var(--border-default);
    --border-light: var(--border-strong);
}

/* POS order panel — light mode overrides */
[data-theme="light"] .pos-order-header .order-title        { color: #0A0806; }
[data-theme="light"] .pos-order-header .order-subtitle     { color: #2E2318; }
[data-theme="light"] .pos-order-header .header-actions .btn {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.12);
    color: #4A3C2E;
}
[data-theme="light"] .pos-order-header .header-actions .btn:hover {
    background: rgba(0,0,0,0.10);
    color: #1A1208;
}
[data-theme="light"] .pos-empty-cart                       { color: #5A4838; }
[data-theme="light"] .pos-empty-cart svg                   { color: #8A7060; }
[data-theme="light"] .pos-empty-cart .empty-title          { color: #0A0806; }
[data-theme="light"] .pos-empty-cart .empty-hint           { color: #7A6858; }
[data-theme="light"] .pos-order-item                       { background: #F4EEE2; border-color: rgba(0,0,0,0.07); }
[data-theme="light"] .pos-order-item:hover                 { background: #EBE3D4; }
[data-theme="light"] .pos-order-item.selected              { background: #F0E6D0; border-color: #9A7020; }
[data-theme="light"] .pos-order-item .item-name            { color: #0A0806; }
[data-theme="light"] .pos-order-item .item-unit-price      { color: #5A4838; }
[data-theme="light"] .pos-order-item .item-emoji,
[data-theme="light"] .pos-order-item .item-image           { background: rgba(0,0,0,0.06); }
[data-theme="light"] .pos-order-item .item-remove          { color: rgba(0,0,0,0.35); }
[data-theme="light"] .pos-order-item .item-remove:hover    { background: rgba(200,50,50,0.10); color: #c03020; }
[data-theme="light"] .pos-order-item .qty-btn              { background: rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.15); color: #0A0806; }
[data-theme="light"] .pos-order-item .qty-value            { color: #0A0806; }
[data-theme="light"] .pos-summary-row                      { color: #5A4838; }
[data-theme="light"] .pos-summary-row.total-row            { color: #2E2318; border-top-color: rgba(0,0,0,0.10); }
[data-theme="light"] .pos-summary-row.total-row .total-item-count { color: #7A6858; }
[data-theme="light"] .pos-order-tab .tab-icon              { background: rgba(0,0,0,0.07); }
[data-theme="light"] .pos-order-tab::before                { background: none; }
[data-theme="light"] .pos-order-tab.active                 { box-shadow: 0 0 0 1px rgba(154,112,32,0.35), 0 2px 8px rgba(0,0,0,0.10); }
[data-theme="light"] .pos-order-tab.active::after          { box-shadow: none; }
[data-theme="light"] .pos-action-btn.print-btn             { border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .pos-order-panel                 { background: #EEE9E1; }
[data-theme="light"] .pos-order-panel > #orderPanel   { background: #FDFAF4; border-color: rgba(154,112,32,0.35); box-shadow: 0 4px 24px rgba(0,0,0,0.12), 0 1px 6px rgba(0,0,0,0.08); }
[data-theme="light"] .pos-order-header                { background: #F8F3EB; }
[data-theme="light"] .pos-order-items                 { background: #FDFAF4; }
[data-theme="light"] .pos-view-banner                 { background: #F0E8D8; color: #3A2A10; }
[data-theme="light"] .pos-view-banner-badge           { background: rgba(154,112,32,0.15); color: #7A5010; }
[data-theme="light"] .pos-order-footer                { background: #FDFAF4; }
[data-theme="light"] .pos-order-tab {
    background: linear-gradient(180deg, var(--bg-surface), var(--bg-panel));
    color: var(--text-secondary);
}
[data-theme="light"] .pos-product-card {
    background: var(--bg-surface);
    border-color: var(--border-default);
}
[data-theme="light"] .pos-product-card:hover {
    background: var(--bg-elevated);
    border-color: rgba(154,112,32,0.5);
}

/* General component overrides */
[data-theme="light"] .modal           { background: var(--bg-surface); }
[data-theme="light"] .modal-header    { background: var(--bg-elevated); border-color: var(--border-default); }
[data-theme="light"] .modal-footer    { background: var(--bg-elevated); border-color: var(--border-default); }
[data-theme="light"] .input:focus,
[data-theme="light"] input:focus      { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(154,112,32,0.18); }
[data-theme="light"] .toast           { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-strong); }

/* Kill dark-mode glow effects that bleed into light */
[data-theme="light"] .stat-value                    { text-shadow: none; color: var(--text-primary); }
[data-theme="light"] .table td .text-success,
[data-theme="light"] .table td.text-success         { text-shadow: none; }
[data-theme="light"] .table td .text-danger,
[data-theme="light"] .table td.text-danger          { text-shadow: none; }
[data-theme="light"] .empty-state svg               { filter: none; }

/* Badges — light readable colors */
[data-theme="light"] .badge.ok,
[data-theme="light"] .badge.success,
[data-theme="light"] .badge.green,
[data-theme="light"] .status-ok {
    color: #1A5E30;
    background: rgba(26,107,58,0.14);
    box-shadow: inset 0 0 0 1px rgba(26,107,58,0.3);
}
[data-theme="light"] .badge.out,
[data-theme="light"] .badge.danger,
[data-theme="light"] .badge.red,
[data-theme="light"] .badge.error,
[data-theme="light"] .status-out {
    color: #9A2818;
    background: rgba(200,56,40,0.12);
    box-shadow: inset 0 0 0 1px rgba(200,56,40,0.28);
}
[data-theme="light"] .badge.warning,
[data-theme="light"] .badge.low,
[data-theme="light"] .status-low {
    color: #7A4800;
    background: rgba(200,120,0,0.12);
    box-shadow: inset 0 0 0 1px rgba(200,120,0,0.28);
}
[data-theme="light"] .badge.info,
[data-theme="light"] .badge.blue {
    color: #1A3E88;
    background: rgba(42,94,176,0.12);
    box-shadow: inset 0 0 0 1px rgba(42,94,176,0.28);
}

/* Icon-only danger buttons */
[data-theme="light"] .btn.btn-sm.btn-danger:has(> svg:only-child)       { color: #9A2818 !important; }
[data-theme="light"] .btn.btn-sm.btn-danger:has(> svg:only-child):hover { color: #7A1A10 !important; }

/* Stat icon session (was light-blue) */
[data-theme="light"] .stat-icon.session       { color: #1A3E88 !important; background: rgba(42,94,176,0.14); }
[data-theme="light"] .stat-icon               { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }

/* Primary/success gradient buttons — text contrast on light gold/green bg */
[data-theme="light"] .btn.btn-primary         { color: #fff; box-shadow: 0 4px 14px rgba(154,112,32,0.25); }
[data-theme="light"] .btn.btn-success         { color: #fff; box-shadow: 0 4px 14px rgba(26,107,58,0.22); }

/* Shimmer on loading skeletons */
[data-theme="light"] .skeleton,
[data-theme="light"] [class*="skeleton"]      { background: linear-gradient(90deg, var(--bg-surface) 0%, var(--bg-elevated) 50%, var(--bg-surface) 100%); }

/* Modal overlay — less black on light bg */
[data-theme="light"] .modal-overlay          { background: rgba(0,0,0,0.35); }

/* Tables view (self-contained dark panel — keep dark, fix visible stat values) */
[data-theme="light"] .tv-hc-stat-val[style*="color:#34d399"],
[data-theme="light"] .tv-hc-stat-val         { color: #f0ece6; }
[data-theme="light"] .tv-stat-num            { color: rgba(255,255,255,0.85) !important; }

/* Scrollbars */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border-strong); }
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg-surface); }

/* Theme toggle button state */
#themeToggleBtn .icon-sun  { display: none; }
#themeToggleBtn .icon-moon { display: block; }
[data-theme="light"] #themeToggleBtn .icon-sun  { display: block; }
[data-theme="light"] #themeToggleBtn .icon-moon { display: none; }

/* ═══════════════════════════════════════════════════
   GLOBAL RESET & BASE
   ═══════════════════════════════════════════════════ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.5;
    color: var(--text-primary);
    /* Living Daylight ambient wash over the pearl canvas -- warm upper-left,
       cool lower-right (One Sun). The --ds-daylight-* vars are swapped by
       js/daylight.js on <body>; they resolve from css/design-system.css. */
    background:
        radial-gradient(ellipse 900px 600px at 12% 8%, var(--ds-daylight-glow-a, transparent), transparent 60%),
        radial-gradient(ellipse 900px 700px at 88% 96%, var(--ds-daylight-glow-b, transparent), transparent 60%),
        var(--bg-void);
    background-attachment: fixed;
    overflow: hidden;
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 500;
    line-height: 1.2;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

/* -- Focus ring - blue (interactive, not monetary) per Law 4 -- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* ── Skip link ── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-tooltip);
    padding: 10px 24px;
    background: var(--gold);
    color: var(--bg-void);
    font-weight: 500;
    font-size: var(--text-base);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 8px;
}

/* ═══════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════ */

.sidebar {
    position: absolute;
    width: var(--sidebar-width);
    /* Deep glass chrome -- one of the three blur-budget surfaces */
    background: var(--glass-chrome);
    backdrop-filter: blur(var(--blur-panel)) saturate(1.2);
    -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(1.2);
    border-right: var(--glass-rim);
    box-shadow: var(--glass-rim-inset);
    display: flex;
    flex-direction: column;
    transition: width 0.22s ease;
    flex-shrink: 0;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    z-index: var(--z-sidebar);
}

/* ── Expanded state (hover or pinned) ── */
.sidebar:not(.collapsed) {
    width: var(--sidebar-width-expanded);
}

.sidebar:not(.collapsed) .logo-text {
    display: block;
}

.sidebar:not(.collapsed) .nav-item span {
    display: block;
}

.sidebar:not(.collapsed) .nav-item {
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 14px;
}

.sidebar:not(.collapsed) .sidebar-header {
    justify-content: space-between;
    padding: 12px 14px;
}

.sidebar:not(.collapsed) .session-status {
    font-size: var(--text-xs);
    width: auto;
    height: auto;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-secondary);
}

.sidebar:not(.collapsed) .session-indicator {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.sidebar:not(.collapsed) .session-indicator button {
    display: flex;
}

/* ── Collapsed state: hide labels ── */
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .session-indicator .session-status,
.sidebar.collapsed .session-indicator button {
    display: none;
}

/* ── Header ── */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-default);
    gap: 8px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.logo-text {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Fallback brand mark when the business has no uploaded logo (mockup vibe:
   a gold "60" monogram). Hidden once a real logo_url is bound. */
.logo-mark {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: -0.02em;
    box-shadow: var(--shadow-sm);
}

/* ── Toggle button (hamburger) ── */
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--radius-md);
    color: var(--text-hint);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

/* ── Nav ── */
.sidebar-nav {
    flex: 1;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 10px 0;
    border-radius: var(--radius-md);
    color: var(--text-hint);
    transition: var(--transition-fast);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}

/* Active nav: frosted-white lift + the signature gold notch (kept exactly
   as the approved mockup vibe). The notch is the one decorative gold in the
   chrome -- a premium brand accent, distinct from Law 4's money-gold. */
.nav-item.active {
    background: var(--glass-pressed);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm), var(--rim-light);
    border-left: none;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 3px;
    background: var(--gold);
}

.sidebar:not(.collapsed) .nav-item.active::before {
    left: 6px;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item span {
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
}

/* ── Section dividers ── */
.nav-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section+.nav-section {
    border-top: 1px solid var(--border-default);
    margin-top: 6px;
    padding-top: 6px;
}

.nav-section-label {
    font-size: 11px;
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    color: var(--text-hint);
    letter-spacing: 0.05em;
    padding: 4px 14px;
    display: none;
}

.sidebar:not(.collapsed) .nav-section-label {
    display: block;
}

/* ── Footer ── */
.sidebar-footer {
    padding: 8px 6px;
    border-top: 1px solid var(--border-default);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
}

.user-badge svg {
    flex-shrink: 0;
}

.user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .user-name {
    display: none;
}

.session-indicator {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.session-status {
    font-size: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-hint);
    display: block;
    user-select: none;
    pointer-events: none;
    /* decorative dot — text hidden for visual purposes. Parent should have aria-label */
}

.session-status.online {
    background: var(--green-light);
}

.session-status::before {
    display: none;
}

.session-indicator button {
    display: none;
}

/* ── Hover tooltip (collapsed only) ── */
.sidebar.collapsed .nav-item[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 68px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    z-index: var(--z-tooltip);
    border: 1px solid var(--border-default);
}

/* ═══════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    /* Transparent so the body's Living Daylight canvas wash shows through */
    background: transparent;
    margin-inline-start: var(--sidebar-width);
    transition: margin-inline-start 0.22s ease;
}

/* A4: push mode (>=1024px) -- a pinned/expanded sidebar shifts content over
   instead of covering it. :has lets the content react to the sibling
   sidebar's state without a JS class on the content element. */
@media (min-width: 1024px) {
    #app:has(.sidebar:not(.collapsed)) .main-content {
        margin-inline-start: var(--sidebar-width-expanded);
    }
}

/* A4: 768–1024px is overlay mode — only .open (scrim-backed) may expand.
   A sidebar still expanded from push mode after a resize down (pinned,
   no .open) would cover content with no scrim; render it as the rail. */
@media (min-width: 768.02px) and (max-width: 1023.98px) {
    .sidebar:not(.collapsed):not(.open) {
        width: var(--sidebar-width);
    }
    .sidebar:not(.collapsed):not(.open) .logo-text,
    .sidebar:not(.collapsed):not(.open) .nav-item span,
    .sidebar:not(.collapsed):not(.open) .nav-section-label,
    .sidebar:not(.collapsed):not(.open) .user-name,
    .sidebar:not(.collapsed):not(.open) .session-indicator .session-status,
    .sidebar:not(.collapsed):not(.open) .session-indicator button {
        display: none;
    }
    .sidebar:not(.collapsed):not(.open) .nav-item {
        justify-content: center;
        gap: 0;
        padding: 10px 0;
    }
    .sidebar:not(.collapsed):not(.open) .sidebar-header {
        justify-content: center;
        padding: 14px 0;
    }
    .sidebar:not(.collapsed):not(.open) .nav-item.active::before {
        left: 4px;
    }
}

/* A4: scrim behind the sidebar in overlay mode (<1024px) */
.sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}
.sidebar-scrim.visible {
    opacity: 1;
    visibility: visible;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    /* Frosted floating header -- glass chrome, One Sun rim */
    background: var(--glass-chrome);
    backdrop-filter: blur(var(--blur-panel)) saturate(1.2);
    -webkit-backdrop-filter: blur(var(--blur-panel)) saturate(1.2);
    border-bottom: var(--glass-rim);
    box-shadow: var(--glass-rim-inset);
    flex-shrink: 0;
    height: var(--topbar-height);
}

.page-title h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.datetime {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-secondary);
}

.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.page-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    background: transparent;
}

.page-content[data-page="pos"] {
    padding: 0;
    overflow: hidden;
}

/* ── POS: show page title in topbar (matches target design) ── */
body[data-page="pos"] .page-subtitle {
    display: block;
}

/* ═══════════════════════════════════════════════════
   MISC HELPERS
   ═══════════════════════════════════════════════════ */

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--text-secondary);
}

.text-success {
    color: var(--green-light);
}

.text-danger {
    color: var(--red);
}

.text-warning {
    color: var(--warning);
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mb-24 { margin-bottom: 24px; }
.mt-24 { margin-top: 24px; }

/* ═══════════════════════════════════════════════════
   MOBILE BOTTOM NAV — hidden on desktop
   ═══════════════════════════════════════════════════ */

.mobile-bottom-nav {
    display: none;
}

/* Orders page responsive gating -- desktop defaults MUST precede the
   max-width media query below so the narrow-width override wins at <=768px
   (equal-specificity rules resolve by source order). Table at desktop,
   card list at narrow, never both. */
.orders-mobile-list { display: none; }
.orders-desktop-table { display: table; }

@media (max-width: 768px) {

    /* Hide desktop sidebar entirely */
    .sidebar { display: none !important; }

    /* Main content fills full width, no inline offset */
    .main-content {
        margin-inline-start: 0;
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* Compact top bar */
    .top-bar {
        padding: 0 14px;
        height: 48px;
    }
    .top-bar .page-title h1 { font-size: 16px; }
    .top-bar .page-subtitle  { display: none; }
    .top-bar .datetime        { display: none; }

    /* Page content full bleed */
    .page-content {
        padding: 12px 14px;
    }

    /* Grid layouts → single column */
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }

    /* KPI stat cards — stack 2-per-row on phone */
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    .stat-card { padding: 14px 12px !important; }
    .stat-value { font-size: 18px !important; }
    .stat-label { font-size: 11px !important; }

    /* Cards */
    .card { padding: 14px; }

    /* Tables — horizontal scroll */
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Modals — full width on mobile */
    .modal {
        width: calc(100vw - 24px) !important;
        max-width: 100% !important;
        margin: 12px;
        max-height: calc(100vh - 80px);
    }

    /* Forms */
    .form-group { margin-bottom: 12px; }
    .input, select.input, textarea.input { font-size: 16px; } /* prevents iOS zoom on focus */

    /* Buttons */
    .btn { min-height: 44px; }
    .btn-block { width: 100%; }

    /* Invoice mobile page — full screen feel */
    .invoice-mobile-page { padding: 0; }

    /* Orders page — tighter rows */
    .order-row { padding: 10px 12px; }

    /* Session banner — stack on mobile */
    .session-banner {
        flex-direction: column;
        gap: 10px;
        padding: 12px 14px;
    }
    .session-info { flex-wrap: wrap; gap: 12px; }
    .session-cash { border-left: none; border-top: 1px solid var(--border); padding-left: 0; padding-top: 10px; }

    /* Bottom nav — show on mobile */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--bg-panel);
        border-top: 1px solid var(--border-default);
        z-index: 9000;
        align-items: stretch;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
    }
    .mbn-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.02em;
        transition: color 0.15s ease;
        padding: 6px 0;
        position: relative;
    }
    .mbn-item svg { transition: transform 0.15s ease; }
    .mbn-item.active {
        color: var(--gold);
    }
    .mbn-item.active svg { transform: translateY(-2px); }
    .mbn-item.active::after {
        content: '';
        position: absolute;
        top: 0; left: 20%; right: 20%;
        height: 2px;
        background: var(--gold);
        border-radius: 0 0 3px 3px;
    }

    /* Light mode bottom nav */
    [data-theme="light"] .mobile-bottom-nav {
        background: var(--bg-panel);
        box-shadow: 0 -2px 12px rgba(0,0,0,0.12);
    }

    /* ── Orders page mobile ── */
    .orders-desktop-table { display: none !important; }
    .orders-mobile-list   { display: block; }

    /* Filter bar — stack on mobile */
    .orders-page .card:first-child > div {
        flex-direction: column;
        align-items: stretch;
    }
    .orders-page .card:first-child select,
    .orders-page .card:first-child input[type="date"] {
        width: 100% !important;
        min-width: unset !important;
    }

    /* Order card */
    .order-mobile-card {
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-default);
        cursor: pointer;
        transition: background 0.12s;
    }
    .order-mobile-card:last-child { border-bottom: none; }
    .order-mobile-card:active { background: var(--bg-elevated); }

    .omc-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 5px;
    }
    .omc-id {
        font-family: var(--font-mono);
        font-weight: 700;
        font-size: 14px;
        color: var(--text-primary);
    }
    .omc-total {
        font-weight: 700;
        font-size: 16px;
        color: var(--gold);
    }
    .omc-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        font-size: 11px;
        color: var(--text-secondary);
        margin-bottom: 4px;
    }
    .omc-meta span + span::before {
        content: '·';
        margin-right: 6px;
        opacity: 0.5;
    }
    .omc-items {
        font-size: 12px;
        color: var(--text-secondary);
        margin-bottom: 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .omc-footer {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .omc-actions { margin-left: auto; display: flex; gap: 6px; }
}

/* Invoice scanner grid — 2-col desktop, 1-col mobile */
.invoice-scanner-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}
/* Mobile cards hidden on desktop */
.inv-mobile-items { display: none; }

@media (max-width: 768px) {
    .invoice-scanner-grid { grid-template-columns: 1fr; gap: 16px; }
    .invoice-scanner-grid .inv-empty-review { display: none; }
    /* Swap table → cards on mobile */
    .inv-desktop-table { display: none !important; }
    .inv-mobile-items  { display: block; }
    /* Header fields → single column on mobile */
    .inv-header-grid   { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ═══════════════════════════════════════════════════
   TOUCH TARGETS (coarse pointer devices)
   ═══════════════════════════════════════════════════ */

@media (pointer: coarse) {
    .icon-btn { width: var(--touch-target); height: var(--touch-target); min-width: var(--touch-target); min-height: var(--touch-target); }
    .sidebar-toggle { width: var(--touch-target); height: var(--touch-target); min-width: var(--touch-target); min-height: var(--touch-target); }
    .nav-item { min-height: var(--touch-target); }
    .modal-close { width: var(--touch-target); height: var(--touch-target); }
}

/* ═══════════════════════════════════════════════════
   RTL SUPPORT
   ═══════════════════════════════════════════════════ */

body[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: 0;
    margin-inline-start: var(--sidebar-width);
}

@media (min-width: 1024px) {
    body[dir="rtl"] #app:has(.sidebar:not(.collapsed)) .main-content {
        margin-inline-start: var(--sidebar-width-expanded);
    }
}

body[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--border-default);
}

body[dir="rtl"] .nav-item.active {
    border-left: none;
    border-right: 2px solid var(--accent);
}

#receiptContainer {
    display: none;
}

@media print {
    .sidebar,
    .sidebar-overlay,
    .top-bar-actions,
    .pos-action-buttons,
    .pos-shortcuts-bar,
    .toast-container,
    .modal-overlay,
    .bg-texture {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .page-content {
        overflow: visible !important;
    }

    body {
        overflow: visible !important;
        background: white;
        color: black;
    }

    #app {
        display: block;
    }
}