/* Modern Khmer POS System - Core Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Kantumruy+Pro:wght@300;400;500;600;700&display=swap');

:root,
[data-theme="light"] {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-glow: rgba(2, 132, 199, 0.25);
    
    --success: #10b981;
    --success-hover: #059669;
    --success-light: #d1fae5;
    
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-light: #fef3c7;
    
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: #fee2e2;

    --dark: #0f172a;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #0284c7;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    
    --bg-main: #f8fafc;
    --surface: #ffffff;
    --surface-card: #ffffff;
    --surface-border: #e2e8f0;
    --surface-card-subtle: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --color-primary: var(--primary);
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --table-header-bg: #f8fafc;
    --table-row-hover: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
    --modal-bg: #ffffff;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --font-khmer: 'Kantumruy Pro', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-latin: 'Inter', 'Kantumruy Pro', sans-serif;
}

[data-theme="dark"] {
    --primary: #38bdf8;
    --primary-hover: #0284c7;
    --primary-light: rgba(56, 189, 248, 0.15);
    --primary-glow: rgba(56, 189, 248, 0.35);
    
    --success: #34d399;
    --success-hover: #10b981;
    --success-light: rgba(52, 211, 153, 0.15);
    
    --warning: #fbbf24;
    --warning-hover: #f59e0b;
    --warning-light: rgba(251, 191, 36, 0.15);
    
    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-light: rgba(248, 113, 113, 0.15);

    --dark: #ffffff;
    --sidebar-bg: #090c20;
    --sidebar-hover: #181d45;
    --sidebar-active: #6366f1;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    
    /* Cyber Space Midnight Theme */
    --bg-main: #0B0E23;
    --surface: #15193B;
    --surface-card: #15193B;
    --surface-border: rgba(255, 255, 255, 0.09);
    --surface-card-subtle: #1c214c;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --color-primary: var(--primary);
    --input-bg: #101432;
    --input-border: rgba(255, 255, 255, 0.12);
    --table-header-bg: #101435;
    --table-row-hover: #1b204c;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --modal-bg: #15193B;
    
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 35px rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-khmer);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    display: flex;
    min-height: 100vh;
}

/* Layout */
.app-wrapper {
    display: flex;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar */
.app-sidebar {
    width: 270px;
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    transition: all 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-brand {
    padding: 14px 16px 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
@media (max-width: 992px) {
    .sidebar-brand {
        padding: 12px 14px 10px 14px;
    }
}

.brand-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 1;
    min-width: 0;
}

.brand-logo-card {
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    transition: transform 0.2s ease;
}

.brand-link:hover .brand-logo-card {
    transform: translateY(-1px);
}

.brand-logo-img {
    max-height: 46px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    border-radius: 10px;
}

.brand-logo-light {
    display: block !important;
    filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.22));
}

.brand-logo-dark {
    display: none !important;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.45));
}

[data-theme="dark"] .brand-logo-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 2px 0 !important;
}

[data-theme="dark"] .brand-logo-light {
    display: none !important;
}

[data-theme="dark"] .brand-logo-dark {
    display: block !important;
}

.brand-logo {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.brand-text h1 {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 1.35;
    word-break: break-word;
}

.brand-text span {
    font-size: 11px;
    color: #94a3b8;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
}

.menu-category {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    padding: 16px 12px 6px 12px;
    letter-spacing: 0.8px;
}

.menu-item {
    margin-bottom: 4px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.menu-link svg {
    width: 19px;
    height: 19px;
    stroke-width: 2;
    flex-shrink: 0;
}

.menu-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.menu-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.menu-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.4);
}

.user-snippet {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.user-info {
    line-height: 1.2;
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: #f8fafc;
}

.user-info .role-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    display: inline-block;
    margin-top: 3px;
}

.role-badge.admin {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.role-badge.sales {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-logout {
    color: #94a3b8;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.btn-logout:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Main Content Area */
.app-main {
    margin-left: 270px;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-main);
    overflow-x: hidden;
}

.app-topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
}
.mobile-sidebar-toggle:hover {
    border-color: #0284c7;
    background: #f0f9ff;
    color: #0284c7;
}
.mobile-sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    margin-left: auto;
    transition: background 0.2s ease;
}
.sidebar-close-btn:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Modern Topbar Branch Picker */
.topbar-branch-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 9999px;
    height: 38px;
    padding: 0 10px 0 6px;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.topbar-branch-picker:hover {
    border-color: #0284c7;
    background: #f8fafc;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.12);
}

.topbar-branch-picker:focus-within {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.branch-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e0f2fe;
    color: #0284c7;
    flex-shrink: 0;
}

.topbar-branch-picker select {
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-family: 'Kantumruy Pro', var(--font-kh), sans-serif !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    cursor: pointer !important;
    padding: 0 20px 0 0 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    height: 36px !important;
    line-height: 36px !important;
    box-shadow: none !important;
}

.topbar-branch-picker select option {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface);
    padding: 8px 12px;
}

.branch-chevron {
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #64748b;
    display: flex;
    align-items: center;
}

.topbar-branch-locked {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    color: #15803d;
    height: 38px;
    padding: 0 14px 0 6px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 700;
}

.clock-display {
    font-family: var(--font-latin);
    font-size: 12.5px;
    font-weight: 600;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    height: 38px;
    padding: 0 16px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.topbar-pos-btn {
    height: 38px;
    padding: 0 18px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.25);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pm-btn-icon.transfer-btn {
    background: #f0f9ff;
    color: #0284c7;
    border-color: #bae6fd;
}
.pm-btn-icon.transfer-btn:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
    transform: translateY(-1px);
}

.topbar-pos-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.content-body {
    padding: 28px;
    flex: 1;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Cards & Containers */
.card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--surface-border);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Dashboard Centered Hero Banner */
/* Modern Enterprise Dashboard Hero Banner (Horizontal Balanced Layout) */
/* Modern Enterprise Dashboard Hero Banner */
.dashboard-hero-banner {
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 18px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    position: relative;
    overflow: hidden;
}

.dashboard-hero-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3.5px;
    background: linear-gradient(90deg, #0284c7 0%, #38bdf8 35%, #6366f1 70%, #0284c7 100%);
}

.dashboard-hero-logo {
    background: #ffffff;
    padding: 10px 24px;
    border-radius: 16px;
    border: 1.5px solid #bae6fd;
    box-shadow: 0 4px 18px rgba(2, 132, 199, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.dashboard-hero-logo:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.16);
    border-color: #38bdf8;
}

.dashboard-hero-logo img {
    height: 80px;
    max-width: 320px;
    width: auto;
    object-fit: contain;
    display: block;
}

/* Responsive Modern Hero Container */
.modern-hero-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 20px;
    gap: 14px;
}

.hero-titles-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.hero-store-title {
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 8px 0;
    letter-spacing: -0.3px;
    line-height: 1.35;
}

.hero-pills-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    flex-wrap: wrap;
}

.hero-pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 12.5px;
    color: #475569;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.hero-pill-link:hover {
    background: #e0f2fe;
    color: #0284c7;
    border-color: #bae6fd;
}

.hero-pill-exchange {
    cursor: pointer;
    font-family: inherit;
    outline: none;
    border-color: #cbd5e1;
    background: #f8fafc;
}

.hero-pill-exchange:hover {
    background: #f0f9ff;
    border-color: #0284c7;
}

.hero-exchange-edit-btn {
    background: #0284c7;
    color: #ffffff;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hero-quick-actions {
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.hero-action-btn {
    font-weight: 700;
    font-size: 13px;
    padding: 9px 20px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

.hero-action-btn:hover {
    transform: translateY(-2px);
}

.hero-action-btn:active {
    transform: translateY(0);
}

.btn-hero-pos {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
    border: none;
}
.btn-hero-pos:hover {
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
}

.btn-hero-stock {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
    border: none;
}
.btn-hero-stock:hover {
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}

.btn-hero-expense {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(244, 63, 94, 0.28);
    border: none;
}
.btn-hero-expense:hover {
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(244, 63, 94, 0.38);
}

/* Low Stock Alert Center */
.low-stock-alert-card {
    width: 100%;
    margin: 0 0 24px 0;
    border-radius: 18px;
    border: 2px solid #facc15;
    background: #ffffff;
    box-shadow: 0 4px 20px -2px rgba(245, 158, 11, 0.12);
    overflow: hidden;
    padding: 0;
}

[data-theme="dark"] .low-stock-alert-card {
    background: var(--surface);
    border-color: rgba(245, 158, 11, 0.45);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.low-stock-card-header {
    background: #fffbeb;
    padding: 12px 18px;
    border-bottom: 1px solid #fef08a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

[data-theme="dark"] .low-stock-card-header {
    background: rgba(245, 158, 11, 0.12);
    border-bottom-color: rgba(245, 158, 11, 0.25);
}

.low-stock-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.low-stock-header-title .warning-icon {
    font-size: 18px;
    line-height: 1;
}

.low-stock-header-title .title-text {
    font-weight: 800;
    color: #854d0e;
    font-size: 14.5px;
    font-family: 'Kantumruy Pro', sans-serif;
}

[data-theme="dark"] .low-stock-header-title .title-text {
    color: #fbbf24;
}

.branch-pill-tag {
    background: #e0f2fe;
    color: #0284c7;
    border: 1px solid #bae6fd;
    font-size: 11.5px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

[data-theme="dark"] .branch-pill-tag {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
}

.branch-pill-tag.branch-all {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.count-pill-tag {
    background: #ef4444;
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 20px;
    line-height: 1.2;
}

.low-stock-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-lowstock-viewall {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-weight: 700;
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
}

.btn-lowstock-viewall:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
}

[data-theme="dark"] .btn-lowstock-viewall {
    background: var(--surface-card);
    border-color: var(--surface-border);
    color: var(--text-secondary);
}

.btn-lowstock-add {
    background: #0284c7;
    border: none;
    color: #ffffff;
    font-weight: 700;
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
    transition: all 0.15s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
}

.btn-lowstock-add:hover {
    filter: brightness(1.08);
}

.low-stock-desktop-table {
    display: block;
}

.low-stock-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.low-stock-table thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 12.5px;
    font-weight: 700;
    border-bottom: 1px solid #e2e8f0;
    font-family: 'Kantumruy Pro', sans-serif;
}

[data-theme="dark"] .low-stock-table thead th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border-bottom-color: var(--surface-border);
}

.low-stock-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.low-stock-table tbody tr:hover {
    background: #fafafa;
}

[data-theme="dark"] .low-stock-table tbody tr {
    border-bottom-color: var(--surface-border);
}

[data-theme="dark"] .low-stock-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.stock-item-name {
    font-weight: 800;
    color: #0f172a;
    font-size: 14px;
    font-family: 'Kantumruy Pro', sans-serif;
}

[data-theme="dark"] .stock-item-name {
    color: #f8fafc;
}

.stock-item-sub {
    font-size: 11.5px;
    color: #64748b;
    margin-top: 2px;
}

.stock-branch-badge {
    background: #e0f2fe;
    color: #0284c7;
    border: 1px solid #bae6fd;
    font-weight: 700;
    font-size: 11.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 8px;
}

[data-theme="dark"] .stock-branch-badge {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
}

.stock-qty-val {
    font-size: 16px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
}

.stock-qty-val.qty-low {
    color: #d97706;
}

.stock-qty-val.qty-out {
    color: #ef4444;
}

.badge-stock-low {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
    border-radius: 14px;
    padding: 3px 12px;
    font-size: 11.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.3;
}

[data-theme="dark"] .badge-stock-low {
    background: rgba(245, 158, 11, 0.15);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.3);
}

.badge-stock-out {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-radius: 14px;
    padding: 3px 12px;
    font-size: 11.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.3;
}

[data-theme="dark"] .badge-stock-out {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.stock-action-cell {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.btn-stock-in-pill {
    background: #0284c7;
    color: #ffffff;
    font-weight: 700;
    font-size: 11.5px;
    padding: 5px 12px;
    border-radius: 8px;
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(2, 132, 199, 0.25);
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    line-height: 1.2;
}

.btn-stock-in-pill:hover {
    filter: brightness(1.08);
}

.btn-stock-transfer-pill {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    font-weight: 700;
    font-size: 11.5px;
    padding: 4px 10px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    line-height: 1.2;
}

.btn-stock-transfer-pill:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
}

[data-theme="dark"] .btn-stock-transfer-pill {
    background: var(--surface-card);
    border-color: var(--surface-border);
    color: var(--text-secondary);
}

.low-stock-mobile-cards {
    display: none;
}

/* Healthy Stock Card */
.low-stock-healthy-card {
    max-width: 820px;
    margin: 20px auto 30px auto;
    border-left: 4px solid #10b981;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.06);
    border-radius: 12px;
    padding: 0;
}

.healthy-card-inner {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.healthy-info-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.healthy-icon-box {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #dcfce7;
    color: #16a34a;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.healthy-title {
    font-weight: 700;
    font-size: 13.5px;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.healthy-badge {
    background: #dcfce7;
    color: #15803d;
    font-size: 10.5px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.healthy-desc {
    font-size: 12px;
    color: #64748b;
}

.healthy-actions {
    display: flex;
    gap: 8px;
}

/* Dashboard Responsive Grids */
.dashboard-grid-chart {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 992px) {
    .dashboard-grid-chart,
    .dashboard-grid-2col {
        grid-template-columns: 1fr;
    }
}

/* Modern Executive KPI Cards */
.stat-card-modern {
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 18px;
    padding: 22px 20px;
    box-shadow: 0 6px 18px -3px rgba(15, 23, 42, 0.04), 0 2px 6px -2px rgba(15, 23, 42, 0.02);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease, border-color 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-card-modern:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 28px -4px rgba(15, 23, 42, 0.09), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
    border-color: #cbd5e1;
}

.stat-card-modern .top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-card-modern .icon-box {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.stat-card-modern .trend-badge {
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stat-card-modern .stat-title {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 6px;
}

.stat-card-modern .stat-main-val {
    font-size: 26px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.15;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.stat-card-modern .stat-sub-val {
    font-size: 12.5px;
    color: #94a3b8;
    font-weight: 500;
}

/* Quick Action Tiles in Dashboard */
.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (max-width: 480px) {
    .quick-action-grid {
        grid-template-columns: 1fr;
    }
}

.quick-action-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    text-decoration: none;
    color: #1e293b;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-action-tile:hover {
    background: #ffffff;
    border-color: #0284c7;
    color: #0284c7;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px -2px rgba(2, 132, 199, 0.12);
}

.quick-action-tile .tile-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 17px;
}

/* Modern Leaderboard */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    transition: background 0.15s ease, transform 0.15s ease;
}

.leaderboard-item:hover {
    background: #f1f5f9;
    transform: translateX(2px);
}

.leaderboard-rank {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.leaderboard-rank.rank-1 { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.leaderboard-rank.rank-2 { background: #e2e8f0; color: #475569; border: 1px solid #cbd5e1; }
.leaderboard-rank.rank-3 { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.leaderboard-rank.rank-other { background: #f1f5f9; color: #64748b; }

/* Universal KPI Stat Cards Grid */
.kpi-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-stat-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.kpi-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.kpi-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary);
    border-radius: 4px 0 0 4px;
}

.kpi-stat-card.kpi-primary::before { background: #0284c7; }
.kpi-stat-card.kpi-success::before { background: #10b981; }
.kpi-stat-card.kpi-warning::before { background: #f59e0b; }
.kpi-stat-card.kpi-danger::before  { background: #ef4444; }
.kpi-stat-card.kpi-purple::before  { background: #8b5cf6; }
.kpi-stat-card.kpi-indigo::before  { background: #6366f1; }

.kpi-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.kpi-stat-info {
    flex: 1;
    min-width: 0;
}

.kpi-stat-lbl {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-stat-val {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-latin);
    line-height: 1.2;
}

.kpi-stat-sub {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Stat Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: #e0f2fe;
    color: #0284c7;
}

.stat-icon.green {
    background: #d1fae5;
    color: #10b981;
}

.stat-icon.purple {
    background: #f3e8ff;
    color: #9333ea;
}

.stat-icon.amber {
    background: #fef3c7;
    color: #d97706;
}

.stat-icon.red {
    background: #fee2e2;
    color: #ef4444;
}

.stat-info .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-info .stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-latin);
    line-height: 1.2;
    margin-top: 4px;
}

.stat-info .stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

.table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 2px solid var(--surface-border);
    white-space: nowrap;
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tr:hover td {
    background-color: #f1f5f9;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.badge-success {
    background: var(--success-light);
    color: #065f46;
}

.badge-warning {
    background: var(--warning-light);
    color: #92400e;
}

.badge-danger {
    background: var(--danger-light);
    color: #991b1b;
}

.badge-primary {
    background: var(--primary-light);
    color: #075985;
}

.badge-secondary {
    background: #f1f5f9;
    color: #475569;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1.4;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-outline {
    background: #fff;
    border-color: var(--surface-border);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Forms */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* Flash Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #075985;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: transform 0.25s ease;
}

.modal-backdrop.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 16.5px;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
}

.btn-close:hover {
    color: var(--text-primary);
}

/* Responsive 2-Column Form & Table Grid System */
.form-table-grid,
.stock-in-grid,
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    align-items: start;
}

.stock-in-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.stock-in-action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}

.form-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

/* Responsive */
/* ======================================================
   Responsive Design (iOS & Android Mobile Optimization)
   ====================================================== */

@media (max-width: 992px) {
    .form-table-grid,
    .stock-in-grid,
    .two-col-grid,
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns:1fr 2fr"] {
        grid-template-columns: 1fr !important;
        gap: 18px !important;
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 280px;
        max-width: 84vw;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .app-sidebar.open {
        transform: translateX(0);
    }
    .mobile-sidebar-toggle {
        display: inline-flex;
    }
    .sidebar-close-btn {
        display: flex;
    }
    .app-main {
        margin-left: 0;
        width: 100%;
    }
    body.sidebar-mobile-open {
        overflow: hidden;
    }
}

@media (max-width: 768px) {
    /* Topbar adjustments */
    .app-topbar {
        height: 56px;
        padding: 0 12px;
        padding-top: env(safe-area-inset-top, 0px);
    }
    .topbar-left {
        gap: 8px;
        min-width: 0;
        flex: 1;
        overflow: hidden;
    }
    .page-title {
        font-size: 14px;
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-weight: 700;
    }
    .clock-display {
        display: none !important;
    }
    .topbar-right {
        gap: 6px;
        flex-shrink: 0;
    }
    .theme-label {
        display: none !important;
    }
    .theme-toggle-btn {
        width: 34px !important;
        height: 32px !important;
        min-height: 32px !important;
        padding: 0 4px !important;
        border-radius: 8px !important;
        justify-content: center !important;
    }
    .topbar-branch-picker {
        height: 32px;
        padding: 0 6px 0 4px;
        gap: 4px;
        max-width: 120px;
    }
    .branch-icon-badge {
        width: 22px;
        height: 22px;
    }
    .branch-icon-badge svg {
        width: 12px;
        height: 12px;
    }
    .topbar-branch-picker select {
        font-size: 11px !important;
        height: 30px !important;
        line-height: 30px !important;
        max-width: 82px;
        padding-right: 14px !important;
    }
    .branch-chevron {
        right: 6px;
    }
    .branch-chevron svg {
        width: 10px;
        height: 10px;
    }
    .topbar-branch-locked {
        height: 32px;
        font-size: 11.5px;
        padding: 0 10px 0 4px;
    }
    .topbar-pos-btn {
        height: 32px;
        padding: 0 10px;
        font-size: 11.5px;
        gap: 4px;
    }
    .topbar-pos-btn svg {
        width: 14px;
        height: 14px;
    }

    /* Content body */
    .content-body {
        padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px)) 12px;
    }

    .card {
        padding: 16px 14px;
        border-radius: 14px;
        margin-bottom: 16px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px;
        border-radius: 14px;
    }
    .modal-header {
        padding: 14px 16px;
    }
    .modal-body {
        padding: 16px;
    }
    .modal-footer {
        padding: 12px 16px;
    }

    /* Table horizontal touch scroll */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    /* Sales History / General Tabs 2x2 Grid on Mobile */
    .tab-text-mobile {
        display: inline !important;
    }
    .tab-text-desktop {
        display: none !important;
    }
    .tab-nav {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        background: var(--surface-card-subtle, #f1f5f9) !important;
        padding: 6px !important;
        border-radius: 12px !important;
        border-bottom: none !important;
        margin-bottom: 16px !important;
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
    }
    .tab-btn {
        margin-bottom: 0 !important;
        border-radius: 9px !important;
        border-bottom: none !important;
        padding: 9px 6px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 5px !important;
        background: transparent;
        color: var(--text-secondary, #64748b) !important;
        min-height: 42px;
        white-space: nowrap;
        border: 1px solid transparent !important;
        box-sizing: border-box;
    }
    .tab-btn svg {
        width: 15px !important;
        height: 15px !important;
        flex-shrink: 0;
    }
    .tab-btn .tab-count {
        font-size: 10.5px !important;
        padding: 1px 6px !important;
    }
    .tab-btn.active {
        background: var(--surface, #ffffff) !important;
        color: var(--primary, #002ca8) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09) !important;
        border-color: rgba(0, 0, 0, 0.06) !important;
    }
    [data-theme="dark"] .tab-nav {
        background: rgba(255, 255, 255, 0.05) !important;
        border: 1px solid var(--surface-border) !important;
    }
    [data-theme="dark"] .tab-btn.active {
        background: var(--surface, #15193b) !important;
        color: #38bdf8 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
        border-color: rgba(255, 255, 255, 0.12) !important;
    }

    /* PM Nav Tabs on Mobile (Income, Expenses, etc) */
    .tab-label-desktop {
        display: none !important;
    }
    .tab-label-mobile {
        display: inline !important;
    }
    .pm-nav-tabs {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
        padding: 5px !important;
        margin-bottom: 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
        overflow: hidden !important;
    }
    .pm-nav-tab {
        padding: 9px 6px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        justify-content: center !important;
        text-align: center !important;
        gap: 5px !important;
        min-height: 42px !important;
        white-space: nowrap !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 9px !important;
    }
    .pm-nav-tab svg {
        width: 15px !important;
        height: 15px !important;
        flex-shrink: 0 !important;
    }
    .pm-nav-tab .tab-badge {
        padding: 1px 6px !important;
        font-size: 10.5px !important;
    }
}

@media (max-width: 640px) {
    /* Hero Banner Mobile */
    .modern-hero-container {
        padding: 16px 12px;
        border-radius: 14px;
        margin-bottom: 16px;
    }
    .modern-hero-container .dashboard-hero-logo {
        padding: 8px 16px;
        border-radius: 12px;
    }
    .modern-hero-container .dashboard-hero-logo img {
        height: 60px;
        max-width: 260px;
    }
    .hero-store-title {
        font-size: 18px;
        line-height: 1.35;
    }
    .hero-pills-bar {
        gap: 6px;
    }
    .hero-pill-badge {
        font-size: 11.5px;
        padding: 4px 10px;
    }
    .hero-quick-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        width: 100%;
    }
    .hero-action-btn {
        width: 100%;
        min-height: 44px;
        font-size: 13.5px;
        padding: 10px 14px;
        border-radius: 10px;
    }

    /* Low Stock Urgency Alert: Hide Desktop Table, Show Mobile Cards */
    .low-stock-desktop-table {
        display: none !important;
    }
    .low-stock-mobile-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 12px;
        background: #f8fafc;
    }
    .low-stock-card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 14px;
    }
    .low-stock-header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    .btn-lowstock-viewall, .btn-lowstock-add {
        text-align: center;
        justify-content: center;
        padding: 8px 10px;
        font-size: 12px;
        min-height: 38px;
    }

    /* Mobile Stock Cards Styling */
    .m-stock-card {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 12px 14px;
        box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
        display: flex;
        flex-direction: column;
        gap: 8px;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    .m-stock-card:active {
        background: #f8fafc;
        transform: scale(0.99);
    }
    .m-stock-card-top {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 8px;
    }
    .m-stock-product-name {
        font-size: 14.5px;
        font-weight: 700;
        color: #0f172a;
        line-height: 1.35;
    }
    .m-stock-product-sub {
        font-size: 11.5px;
        color: #64748b;
        margin-top: 2px;
    }
    .m-stock-badge-wrap .m-badge {
        font-size: 11px;
        padding: 3px 8px;
        white-space: nowrap;
    }
    .m-stock-card-meta {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-top: 6px;
        border-top: 1px dashed #e2e8f0;
        gap: 8px;
    }
    .m-stock-branch-pill {
        background: #e0f2fe;
        color: #0369a1;
        border: 1px solid #bae6fd;
        font-weight: 700;
        font-size: 11.5px;
        padding: 2px 8px;
        border-radius: 6px;
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }
    .m-stock-qty-display {
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .m-qty-lbl {
        font-size: 11.5px;
        color: #64748b;
        font-weight: 600;
    }
    .m-qty-num {
        font-size: 16px;
        font-weight: 800;
    }
    .m-qty-num.text-danger {
        color: #ef4444;
    }
    .m-qty-num.text-warning {
        color: #d97706;
    }
    .m-stock-card-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 2px;
    }
    .m-stock-action-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: 12px;
        font-weight: 700;
        padding: 8px 10px;
        border-radius: 8px;
        min-height: 38px;
        text-decoration: none;
    }
    .btn-stock-in {
        background: #0284c7;
        color: #ffffff;
        border: 1px solid #0284c7;
    }
    .btn-stock-in:hover {
        background: #0369a1;
        color: #ffffff;
    }
    .btn-stock-transfer {
        background: #f0f9ff;
        color: #0284c7;
        border: 1px solid #bae6fd;
    }
    .btn-stock-transfer:hover {
        background: #e0f2fe;
        color: #0369a1;
    }

    /* Healthy state mobile */
    .healthy-card-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .healthy-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .healthy-actions .btn {
        text-align: center;
        justify-content: center;
        min-height: 38px;
    }
}

@media (max-width: 640px) {
    .stock-in-field-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    .stock-in-action-btns {
        width: 100%;
        display: flex;
        gap: 6px;
    }
    .stock-in-action-btns .btn {
        flex: 1;
        justify-content: center;
        padding: 7px 8px;
        font-size: 11.5px;
        white-space: nowrap;
    }
    .form-row-2col,
    .modal-body div[style*="grid-template-columns: 1fr 1fr"],
    .modal-body div[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        margin-bottom: 10px !important;
    }
}

@media (max-width: 420px) {
    .page-title {
        font-size: 13.5px !important;
        max-width: 155px !important;
    }
    .topbar-branch-picker {
        max-width: 105px !important;
    }
    .topbar-branch-picker select {
        max-width: 70px !important;
    }
    .topbar-pos-btn span {
        display: none;
    }
    .topbar-pos-btn {
        padding: 0 8px;
    }
}

/* ======================================================
   Global Live Camera QR Code Scanner & Laser Animation
   ====================================================== */

.qr-scanner-modal-content {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    border: 1px solid #e2e8f0;
    background: #ffffff;
}

.qr-scanner-viewport-wrap {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #090d16;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.85);
}

.qr-scanner-viewport-wrap video {
    border-radius: 10px;
    object-fit: cover;
    max-height: 340px;
    width: 100% !important;
}

.qr-scan-laser {
    position: absolute;
    left: 8%;
    right: 8%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #22c55e, #86efac, #22c55e, transparent);
    box-shadow: 0 0 14px #22c55e, 0 0 6px #86efac;
    border-radius: 2px;
    z-index: 12;
    pointer-events: none;
    animation: scanLaserAnim 2.2s infinite ease-in-out;
}

@keyframes scanLaserAnim {
    0% { top: 12%; opacity: 0.25; }
    50% { top: 86%; opacity: 1; }
    100% { top: 12%; opacity: 0.25; }
}

.qr-scanner-viewport-wrap::before,
.qr-scanner-viewport-wrap::after {
    content: '';
    position: absolute;
    width: 36px;
    height: 36px;
    border-color: #22c55e;
    border-style: solid;
    pointer-events: none;
    z-index: 11;
}

.qr-scanner-viewport-wrap::before {
    top: 16px;
    left: 16px;
    border-width: 3.5px 0 0 3.5px;
    border-top-left-radius: 8px;
}

.qr-scanner-viewport-wrap::after {
    bottom: 16px;
    right: 16px;
    border-width: 0 3.5px 3.5px 0;
    border-bottom-right-radius: 8px;
}

/* ======================================================
   Product Image Uploader & Camera Snap Component
   ====================================================== */
.product-img-upload-container {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface-card-subtle);
    border: 1.5px dashed var(--surface-border);
    border-radius: 12px;
    padding: 12px 16px;
    transition: border-color 0.2s, background-color 0.2s;
}

.product-img-upload-container:hover {
    border-color: var(--primary);
    background: var(--surface-card-subtle);
}

.product-img-preview-box {
    width: 86px;
    height: 86px;
    border-radius: 10px;
    background: var(--surface);
    border: 1.5px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease;
}

.product-img-preview-box:hover {
    transform: scale(1.02);
    border-color: var(--primary);
}

.product-img-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-img-preview-placeholder,
.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10.5px;
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    padding: 4px;
}

.btn-remove-img {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: #ffffff;
    border: none;
    font-size: 14px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: transform 0.15s, background-color 0.15s;
    z-index: 5;
}

.btn-remove-img:hover {
    transform: scale(1.15);
    background: #dc2626;
}

.product-img-preview-box.has-img .btn-remove-img {
    display: flex;
}

.product-img-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.btn-camera-snap {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #ffffff !important;
    border: none;
    font-weight: 700;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);
}

.btn-camera-snap:hover {
    background: #0369a1;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    transform: translateY(-1px);
}

.btn-choose-file {
    font-weight: 600;
    font-size: 12px;
    border-radius: 8px;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-choose-file:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--surface-card-subtle);
}

.upload-tip-text {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.35;
}

/* Product Table Thumbnail */
.pm-prod-avatar.has-image {
    padding: 0;
    overflow: hidden;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pm-prod-avatar.has-image:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border-color: #0284c7;
}

.pm-prod-avatar.has-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 480px) {
    .product-img-upload-container {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }
    .product-img-actions {
        width: 100%;
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Modern Executive KPI Dashboard Styles
   ========================================================================== */
.kpi-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-stat-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.kpi-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    border-color: #cbd5e1;
}

.kpi-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background 0.2s ease;
}

.kpi-stat-card.kpi-primary::before { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.kpi-stat-card.kpi-success::before { background: linear-gradient(90deg, #059669, #34d399); }
.kpi-stat-card.kpi-warning::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.kpi-stat-card.kpi-danger::before { background: linear-gradient(90deg, #dc2626, #f87171); }
.kpi-stat-card.kpi-purple::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.kpi-stat-card.kpi-indigo::before { background: linear-gradient(90deg, #4f46e5, #818cf8); }

.kpi-stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.kpi-stat-card:hover .kpi-stat-icon {
    transform: scale(1.06);
}

.kpi-stat-icon svg {
    width: 26px;
    height: 26px;
}

.kpi-primary .kpi-stat-icon {
    background: rgba(2, 132, 199, 0.1);
    color: #0284c7;
}

.kpi-success .kpi-stat-icon {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.kpi-warning .kpi-stat-icon {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.kpi-danger .kpi-stat-icon {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.kpi-purple .kpi-stat-icon {
    background: rgba(139, 92, 246, 0.12);
    color: #7c3aed;
}

.kpi-indigo .kpi-stat-icon {
    background: rgba(79, 70, 229, 0.12);
    color: #4f46e5;
}

.kpi-stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.kpi-stat-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-stat-value {
    font-size: 22px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    line-height: 1.2;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.kpi-stat-sub {
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   Recent Transactions Table Styles
   ========================================================================== */
.recent-transactions-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.02);
    margin-top: 24px;
    margin-bottom: 24px;
    overflow: hidden;
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #fafafa;
}

.recent-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.recent-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-modern {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table-modern thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 12.5px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1.5px solid #e2e8f0;
    white-space: nowrap;
}

.table-modern tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
}

.table-modern tbody tr:hover {
    background: #f8fafc;
}

.table-modern tbody td {
    padding: 12px 16px;
    color: #334155;
    vertical-align: middle;
}

.invoice-pill-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: 'Inter', monospace;
    font-weight: 700;
    color: #0284c7;
    background: #f0f9ff;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #bae6fd;
    text-decoration: none;
    transition: all 0.15s ease;
}

.invoice-pill-link:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

.badge-status-paid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11.5px;
    font-weight: 700;
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.badge-status-partial {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11.5px;
    font-weight: 700;
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.badge-status-unpaid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11.5px;
    font-weight: 700;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.recent-actions-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-action-icon:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0284c7;
}

/* ==========================================================================
   Theme Toggle Switcher Button
   ========================================================================== */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--surface);
    border: 1.5px solid var(--surface-border);
    border-radius: 9999px;
    height: 38px;
    padding: 0 13px 0 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}
.theme-toggle-btn:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--primary-glow);
}
.theme-toggle-btn .theme-icon {
    font-size: 17px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.theme-toggle-btn:hover .theme-icon {
    transform: rotate(20deg) scale(1.15);
}
.theme-toggle-btn .sun-icon {
    display: none;
}
.theme-toggle-btn .moon-icon {
    display: inline-flex;
}

html[data-theme="dark"] .theme-toggle-btn .sun-icon,
[data-theme="dark"] .theme-toggle-btn .sun-icon {
    display: inline-flex !important;
}

html[data-theme="dark"] .theme-toggle-btn .moon-icon,
[data-theme="dark"] .theme-toggle-btn .moon-icon {
    display: none !important;
}

.theme-toggle-btn .theme-label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ==========================================================================
   Dark Mode Comprehensive Overrides (Cyber Midnight Palette)
   ========================================================================== */
[data-theme="dark"] body {
    background-color: var(--bg-main);
    color: var(--text-primary);
}
[data-theme="dark"] .app-main {
    background: var(--bg-main);
}
[data-theme="dark"] .app-topbar {
    background: rgba(21, 25, 59, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
}
[data-theme="dark"] .sidebar,
[data-theme="dark"] .app-sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .card {
    background: var(--surface);
    border-color: var(--surface-border);
    box-shadow: var(--card-shadow);
    color: var(--text-primary);
}
[data-theme="dark"] .form-control,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: #f8fafc;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus {
    border-color: var(--primary);
    background: #14183a;
    box-shadow: 0 0 0 3px var(--primary-glow);
}
[data-theme="dark"] .table th,
[data-theme="dark"] .table-modern thead th {
    background: #101435;
    color: #94a3b8;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .table td,
[data-theme="dark"] .table-modern tbody td {
    border-bottom-color: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
}
[data-theme="dark"] .table tr:hover td,
[data-theme="dark"] .table-modern tbody tr:hover {
    background: #181e46;
}
[data-theme="dark"] .recent-transactions-card {
    background: var(--surface);
    border-color: var(--surface-border);
}
[data-theme="dark"] .recent-header {
    background: #101435;
    border-bottom-color: var(--surface-border);
}
[data-theme="dark"] .recent-header-title {
    color: #f8fafc;
}
[data-theme="dark"] .kpi-stat-card {
    background: var(--surface);
    border-color: var(--surface-border);
    box-shadow: var(--card-shadow);
}
[data-theme="dark"] .kpi-stat-value {
    color: #ffffff;
}
[data-theme="dark"] .kpi-stat-label {
    color: #94a3b8;
}
[data-theme="dark"] .btn-outline {
    border-color: rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.03);
}
[data-theme="dark"] .btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
[data-theme="dark"] .btn-action-icon {
    background: #1a1f48;
    border-color: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}
[data-theme="dark"] .btn-action-icon:hover {
    background: #252c66;
    color: #38bdf8;
    border-color: #38bdf8;
}
[data-theme="dark"] .topbar-branch-picker {
    background: #15193B;
    border-color: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
}
[data-theme="dark"] .topbar-branch-picker select {
    color: #f8fafc;
    background: transparent;
}
[data-theme="dark"] .topbar-branch-picker select option {
    background: #15193B;
    color: #f8fafc;
}
[data-theme="dark"] .clock-display {
    background: #15193B;
    border-color: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}
[data-theme="dark"] .modal-content {
    background: var(--modal-bg);
    border: 1px solid var(--surface-border);
    color: #f8fafc;
}
[data-theme="dark"] .modal-header {
    border-bottom-color: var(--surface-border);
}
[data-theme="dark"] .modal-footer {
    border-top-color: var(--surface-border);
}
[data-theme="dark"] .btn-close {
    color: #94a3b8;
}
[data-theme="dark"] .low-stock-alert-card {
    background: #1f1b2e;
    border-color: rgba(245, 158, 11, 0.3);
}
[data-theme="dark"] .low-stock-card-header {
    background: rgba(245, 158, 11, 0.08);
}
[data-theme="dark"] .low-stock-healthy-card {
    background: #12232e;
    border-color: rgba(16, 185, 129, 0.3);
}
[data-theme="dark"] .dashboard-hero-banner {
    background: linear-gradient(135deg, #101438 0%, #171c4c 100%);
    border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .hero-pill-badge {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}
[data-theme="dark"] .hero-store-title {
    color: #ffffff;
}
[data-theme="dark"] .m-stock-card {
    background: #15193B;
    border-color: var(--surface-border);
}
[data-theme="dark"] .m-stock-product-name {
    color: #ffffff;
}

/* ==========================================================================
   Visual Dashboard Trend Analytics (Charts & Indicators)
   ========================================================================== */
.dashboard-visual-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 24px;
}
@media (max-width: 1024px) {
    .dashboard-visual-grid {
        grid-template-columns: 1fr;
    }
}

.visual-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    padding: 20px 22px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.visual-card:hover {
    box-shadow: var(--shadow-lg);
}

.visual-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.visual-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 9px;
}
.visual-card-badge {
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
}

/* Weekly Sales Trends 7-Day Bar Chart */
.weekly-bars-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    height: 180px;
    padding: 10px 4px 4px 4px;
    border-bottom: 2px solid var(--surface-border);
    position: relative;
}
.weekly-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 8px;
}
.weekly-bar-fill-wrap {
    width: 100%;
    max-width: 38px;
    height: 130px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    position: relative;
}
.weekly-bar-fill {
    width: 100%;
    border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, #ec4899 0%, #8b5cf6 100%);
    box-shadow: 0 4px 14px rgba(236, 72, 153, 0.35);
    transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s;
    min-height: 4px;
    position: relative;
}
.weekly-bar-fill.active-today {
    background: linear-gradient(180deg, #38bdf8 0%, #3b82f6 100%);
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.45);
}
.weekly-bar-fill:hover {
    transform: scaleX(1.1) scaleY(1.03);
}
.weekly-bar-tooltip {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
.weekly-bar-fill-wrap:hover .weekly-bar-tooltip {
    opacity: 1;
}
.weekly-bar-day {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 6px;
}
.weekly-bar-val {
    font-size: 11px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: var(--text-muted);
}

/* Revenue vs Expense Comparison Meter */
.rev-exp-summary-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--surface-border);
}
.rev-exp-item {
    display: flex;
    flex-direction: column;
}
.rev-exp-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
}
.rev-exp-val {
    font-size: 17px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
}
.rev-exp-val.rev-color { color: #10b981; }
.rev-exp-val.exp-color { color: #f43f5e; }

/* Top 5 Products Breakdown */
.top-sellers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.top-seller-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}
.top-seller-rank {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-card-subtle);
    border: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-primary);
    flex-shrink: 0;
}
.top-seller-rank.rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; border: none; }
.top-seller-rank.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); color: #fff; border: none; }
.top-seller-rank.rank-3 { background: linear-gradient(135deg, #b45309, #78350f); color: #fff; border: none; }

.top-seller-info {
    flex: 1;
    min-width: 0;
}
.top-seller-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-seller-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    display: flex;
    justify-content: space-between;
}
.top-seller-progress-track {
    width: 100%;
    height: 6px;
    background: var(--surface-card-subtle);
    border-radius: 999px;
    margin-top: 5px;
    overflow: hidden;
}
.top-seller-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #ec4899, #8b5cf6);
    transition: width 0.5s ease;
}
.top-seller-amount {
    font-size: 13px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    color: var(--primary);
    white-space: nowrap;
}

/* Stock Health Conversion Donut Card */
.stock-health-card-body {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 0;
}
.stock-health-circle-wrap {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
}
.stock-health-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}
.stock-health-circle-bg {
    fill: none;
    stroke: var(--surface-card-subtle);
    stroke-width: 8;
}
.stock-health-circle-fill {
    fill: none;
    stroke: #10b981;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease;
}
.stock-health-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}
.stock-health-pct {
    font-size: 18px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    line-height: 1;
}
.stock-health-desc {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ==========================================================================
   Multi-Device Cross-Platform (iOS, Android, PC Portrait & Landscape)
   ========================================================================== */
/* iPad & Tablet Landscape / Portrait */
@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-visual-grid {
        grid-template-columns: 1fr;
    }
    .kpi-metrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile Landscape (iOS / Android rotated horizontally) */
@media (max-height: 540px) and (orientation: landscape) {
    .app-topbar {
        height: 48px !important;
    }
    .content-body {
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)) 12px;
    }
    .dashboard-hero-banner {
        padding: 12px 14px;
        margin-bottom: 12px;
    }
    .hero-store-title {
        font-size: 16px;
    }
    .kpi-metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 10px;
    }
    .kpi-stat-card {
        padding: 12px 14px;
    }
    .weekly-bars-container {
        height: 130px;
    }
}

/* Touch Targets for iOS & Android */
@media (pointer: coarse) {
    .btn, 
    .menu-link, 
    .topbar-branch-picker, 
    .theme-toggle-btn, 
    .form-control {
        min-height: 44px;
    }
    .btn-sm {
        min-height: 38px;
    }
}

/* iOS & Android Form Input Optimization: Prevent automatic zoom on focus in Safari/Chrome */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="email"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important; /* iOS standard to prevent intrusive viewport zooming */
    }
}

/* Prevent horizontal page bounce on iOS & Android */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

* {
    -webkit-tap-highlight-color: transparent;
}

/* Modal mobile landscape adaptation: prevent keyboard or screen clipping */
@media (max-height: 560px) {
    .modal-content {
        max-height: 94vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .modal-header {
        padding: 10px 14px !important;
    }
    .modal-body {
        padding: 12px 14px !important;
    }
    .modal-footer {
        padding: 10px 14px !important;
    }
}

/* ==========================================================================
   Modern Executive Hero Card (Matching User Specification)
   ========================================================================== */

/* ── Hero Card (Top Card) ── */
.dash-hero-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 34px 24px 32px 24px;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    margin-bottom: 22px;
    text-align: center;
    transition: all 0.2s ease;
}

[data-theme="dark"] .dash-hero-card {
    background: var(--surface);
    border-color: var(--surface-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.dash-hero-brand-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #bae6fd;
    border-radius: 18px;
    padding: 14px 42px 16px 42px;
    background: #ffffff;
    box-shadow: 0 3px 14px rgba(186, 230, 253, 0.35);
    margin: 0 auto 16px auto;
}

[data-theme="dark"] .dash-hero-brand-box {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.dash-hero-store-name {
    font-size: 28px;
    font-weight: 800;
    color: #1d4ed8;
    line-height: 1.2;
    letter-spacing: -0.3px;
    font-family: 'Kantumruy Pro', sans-serif;
}

[data-theme="dark"] .dash-hero-store-name {
    color: #38bdf8;
}

.dash-hero-brand-sub {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.dash-hero-slogan {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    font-family: 'Kantumruy Pro', sans-serif;
}

[data-theme="dark"] .dash-hero-slogan {
    color: #e2e8f0;
}

.dash-hero-tag {
    background: #1d4ed8;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 6px;
    text-transform: lowercase;
    letter-spacing: 0.3px;
    font-family: 'Inter', sans-serif;
}

.dash-hero-title {
    font-size: 21px;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 10px 0;
    line-height: 1.35;
    font-family: 'Kantumruy Pro', sans-serif;
}

[data-theme="dark"] .dash-hero-title {
    color: #f8fafc;
}

.dash-hero-meta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    margin-bottom: 12px;
}

.dash-hero-pill-subtitle {
    background: #e0f2fe;
    color: #0284c7;
    border: 1px solid #bae6fd;
    border-radius: 20px;
    padding: 3px 12px;
    font-weight: 700;
    font-size: 12px;
}

[data-theme="dark"] .dash-hero-pill-subtitle {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.3);
}

.dash-hero-dot {
    color: #94a3b8;
    font-weight: 700;
}

.dash-hero-contact-link {
    color: #334155;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.15s;
}

.dash-hero-contact-link:hover {
    color: #0284c7;
}

[data-theme="dark"] .dash-hero-contact-link {
    color: #cbd5e1;
}

.dash-hero-exchange-wrapper {
    margin: 6px 0 20px 0;
}

.dash-hero-exchange-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 30px;
    padding: 4px 6px 4px 14px;
    box-shadow: 0 1px 4px rgba(16, 185, 129, 0.08);
}

[data-theme="dark"] .dash-hero-exchange-pill {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.28);
}

.dash-hero-exchange-pill .rate-icon {
    font-size: 14px;
}

.dash-hero-exchange-pill .rate-label {
    color: #166534;
    font-size: 13px;
    font-weight: 700;
}

[data-theme="dark"] .dash-hero-exchange-pill .rate-label {
    color: #86efac;
}

.dash-hero-exchange-pill .rate-val {
    color: #0284c7;
    font-weight: 800;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
}

[data-theme="dark"] .dash-hero-exchange-pill .rate-val {
    color: #38bdf8;
}

.dash-hero-exchange-pill .btn-rate-edit {
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 3px 11px;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
    transition: transform 0.15s, opacity 0.15s;
    font-family: inherit;
}

.dash-hero-exchange-pill .btn-rate-edit:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.dash-hero-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dash-hero-btn-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.dash-hero-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    font-size: 14.5px;
    font-weight: 700;
    text-decoration: none;
    padding: 10px 24px;
    color: #ffffff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Kantumruy Pro', sans-serif;
    line-height: 1.3;
}

.dash-hero-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.08);
}

.dash-hero-btn.btn-pos {
    background: #0284c7;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.dash-hero-btn.btn-stock-in {
    background: #059669;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.dash-hero-btn.btn-expense {
    background: #e11d48;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
}

@media (max-width: 640px) {
    .dash-hero-card {
        padding: 22px 16px 24px 16px;
    }
    .dash-hero-brand-box {
        padding: 12px 20px;
        width: 100%;
        max-width: 320px;
    }
    .dash-hero-store-name {
        font-size: 22px;
    }
    .dash-hero-title {
        font-size: 17px;
    }
    .dash-hero-btn-row {
        width: 100%;
        flex-direction: column;
        gap: 9px;
    }
    .dash-hero-btn {
        width: 100%;
    }
}



/* ── Transaction Ledger Badges & Pill Buttons ── */
.invoice-pill-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-card-subtle);
    border: 1px solid var(--surface-border);
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s;
}
.invoice-pill-link:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.badge-status-paid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 9999px;
    white-space: nowrap;
}
.badge-status-partial {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 9999px;
    white-space: nowrap;
}
.badge-status-unpaid {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
    font-size: 11.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 9999px;
    white-space: nowrap;
}

.btn-action-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-card-subtle);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}
.btn-action-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* ── Reports Hub & Analytics Theme Adaptations ── */
[data-theme="dark"] .reports-nav-tabs {
    background: var(--surface);
    border-color: var(--surface-border);
}
[data-theme="dark"] .reports-nav-tab {
    color: var(--text-secondary);
}
[data-theme="dark"] .reports-nav-tab:hover {
    color: var(--primary);
    background: var(--surface-card-subtle);
}
[data-theme="dark"] .sales-report-hero h2,
[data-theme="dark"] .stock-hero-title h2,
[data-theme="dark"] .pnl-hero-title h2,
[data-theme="dark"] .report-header-title {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .period-btn,
[data-theme="dark"] .period-tab-btn,
[data-theme="dark"] .stock-status-btn {
    background: var(--surface-card-subtle) !important;
    border-color: var(--surface-border) !important;
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .period-btn:hover,
[data-theme="dark"] .period-tab-btn:hover,
[data-theme="dark"] .stock-status-btn:hover {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--primary) !important;
}
[data-theme="dark"] .period-btn.active,
[data-theme="dark"] .period-tab-btn.active,
[data-theme="dark"] .stock-status-btn.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
}
[data-theme="dark"] .filter-card,
[data-theme="dark"] .filter-box-card,
[data-theme="dark"] .chart-box,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .waterfall-card,
[data-theme="dark"] .pnl-statement-sheet,
[data-theme="dark"] .detail-box-card,
[data-theme="dark"] .pm-nav-tabs,
[data-theme="dark"] .pm-kpi-card,
[data-theme="dark"] .pm-toolbar-card,
[data-theme="dark"] .pm-module-banner,
[data-theme="dark"] .pm-btn-icon,
[data-theme="dark"] .stock-kpi-card,
[data-theme="dark"] .stock-health-card,
[data-theme="dark"] .insight-card,
[data-theme="dark"] .kpi-stat-card,
[data-theme="dark"] .expense-kpi-card,
[data-theme="dark"] .income-kpi-card,
[data-theme="dark"] .user-stat-card,
[data-theme="dark"] .role-perm-card,
[data-theme="dark"] .u-perm-card,
[data-theme="dark"] .perm-group-card,
[data-theme="dark"] .preset-bar,
[data-theme="dark"] .preset-btn,
[data-theme="dark"] .users-table-toolbar,
[data-theme="dark"] .users-filter-btn,
[data-theme="dark"] .settings-card,
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-body,
[data-theme="dark"] .card-footer,
[data-theme="dark"] .panel,
[data-theme="dark"] .box,
[data-theme="dark"] .card {
    background: var(--surface) !important;
    border-color: var(--surface-border) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .table thead tr,
[data-theme="dark"] .table tfoot tr,
[data-theme="dark"] .pm-table th,
[data-theme="dark"] .table th,
[data-theme="dark"] .table-modern thead th {
    background: var(--table-header-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--surface-border) !important;
}
[data-theme="dark"] .table td,
[data-theme="dark"] .table-modern td,
[data-theme="dark"] .pm-table td,
[data-theme="dark"] .statement-table td {
    color: var(--text-primary);
    border-color: var(--surface-border) !important;
}
[data-theme="dark"] .card-title,
[data-theme="dark"] .card-title span,
[data-theme="dark"] .card-header span,
[data-theme="dark"] .form-label,
[data-theme="dark"] label {
    color: var(--text-primary);
}
[data-theme="dark"] select option {
    background: #15193B;
    color: #f8fafc;
}
[data-theme="dark"] .pm-table tbody tr:hover td,
[data-theme="dark"] .table tr:hover td {
    background-color: var(--table-row-hover) !important;
}
[data-theme="dark"] .pm-badge-barcode {
    background: var(--surface-card-subtle) !important;
    color: var(--text-secondary) !important;
    border-color: var(--surface-border) !important;
}
[data-theme="dark"] .statement-header {
    border-bottom-color: var(--surface-border) !important;
}
[data-theme="dark"] .waterfall-bar-track {
    background: var(--surface-border) !important;
}
[data-theme="dark"] .view-tab-badge {
    background: var(--surface-card-subtle) !important;
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .view-tab-btn {
    color: var(--text-muted) !important;
}
[data-theme="dark"] .view-tab-btn:hover {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .view-tab-btn.active {
    color: var(--primary) !important;
    border-bottom-color: var(--primary) !important;
}
[data-theme="dark"] .view-tab-btn.active .view-tab-badge {
    background: rgba(56, 189, 248, 0.15) !important;
    color: var(--primary) !important;
}

/* Dark mode overrides for sales history debt rows and banners */
[data-theme="dark"] .debt-row-highlight {
    background: rgba(239, 68, 68, 0.15) !important;
}
[data-theme="dark"] .debt-row-highlight td {
    background: transparent !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .debt-row-highlight:hover td {
    background: rgba(239, 68, 68, 0.22) !important;
}
[data-theme="dark"] .debt-summary-banner {
    background: rgba(239, 68, 68, 0.12) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}
[data-theme="dark"] .debt-badge {
    background: rgba(239, 68, 68, 0.18) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #f87171 !important;
}
[data-theme="dark"] .cust-summary-banner {
    background: rgba(2, 132, 199, 0.12) !important;
    border-color: rgba(2, 132, 199, 0.3) !important;
}

/* Dark mode image upload & product avatars */
[data-theme="dark"] .pm-prod-avatar.has-image {
    background: var(--surface) !important;
    border-color: var(--surface-border) !important;
}

/* Dark mode modals */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    background: var(--surface) !important;
    border-color: var(--surface-border) !important;
    color: var(--text-primary) !important;
}
[data-theme="dark"] .modal-title {
    color: var(--text-primary) !important;
}

/* Brand logo card in sidebar - keep clean background so brand logo is always clearly visible */
[data-theme="dark"] .brand-logo-card {
    background: #ffffff !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
}
[data-theme="dark"] .brand-logo-img {
    filter: none !important;
}

/* Dark mode sales return banner */
[data-theme="dark"] .return-summary-banner {
    background: rgba(245, 158, 11, 0.12) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
}
[data-theme="dark"] .return-summary-banner .return-info h4 {
    color: #fbbf24 !important;
}
[data-theme="dark"] .return-summary-banner .return-info .return-total {
    color: #f59e0b !important;
}
[data-theme="dark"] .return-summary-banner .return-info small {
    color: #fcd34d !important;
}
[data-theme="dark"] .btn-return-action {
    background: rgba(245, 158, 11, 0.18) !important;
    border-color: rgba(245, 158, 11, 0.35) !important;
    color: #fbbf24 !important;
}

/* Dark mode topbar branch picker */
[data-theme="dark"] .topbar-branch-picker {
    background: var(--surface) !important;
    border-color: var(--surface-border) !important;
}
[data-theme="dark"] .topbar-branch-picker select {
    color: var(--text-primary) !important;
}
[data-theme="dark"] .branch-icon-badge {
    background: rgba(2, 132, 199, 0.2) !important;
    color: #38bdf8 !important;
}

