/* ============================================================
   DIGITEX SERVICE CRM PRO — PHASE 3 DESIGN SYSTEM
   Brand Tokens | Premium Dark Navy Sidebar | Responsive
   ============================================================ */

/* --- Design Tokens / CSS Variables --- */
:root {
    /* Brand Palette */
    --brand-navy: #001F5B;
    --brand-navy-dark: #00153F;
    --brand-navy-light: #002B73;
    --brand-blue: #007BDF;
    --brand-blue-bright: #009FF7;
    --brand-blue-hover: #005FB8;
    --brand-orange: #F87800;
    --brand-orange-hover: #E06C00;

    /* Primary (dynamic — overwritten by JS from settings) */
    --primary: #007BDF;
    --primary-dark: #005FB8;
    --primary-light: #009FF7;
    --primary-bg: rgba(0, 123, 223, 0.08);
    --primary-ring: rgba(0, 123, 223, 0.25);

    /* Semantic Status */
    --success: #059669;
    --success-bg: rgba(5, 150, 105, 0.08);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --info: #0284c7;
    --info-bg: rgba(2, 132, 199, 0.08);
    --purple: #7c3aed;
    --purple-bg: rgba(124, 58, 237, 0.08);
    --orange: #F87800;
    --orange-bg: rgba(248, 120, 0, 0.08);
    --emerald: #10b981;
    --emerald-bg: rgba(16, 185, 129, 0.08);

    /* Surfaces */
    --bg: #F5F8FC;
    --surface: #FFFFFF;
    --surface-hover: #F8FAFD;
    --surface-active: #EFF4FB;

    /* Text */
    --text: #0B1B33;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Borders */
    --border: #DCE5F0;
    --border-light: #EEF2F7;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 27, 60, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 27, 60, 0.06), 0 1px 2px rgba(0, 27, 60, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 27, 60, 0.07), 0 2px 4px -2px rgba(0, 27, 60, 0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0, 27, 60, 0.08), 0 4px 6px -4px rgba(0, 27, 60, 0.04);
    --shadow-xl: 0 20px 40px -5px rgba(0, 27, 60, 0.12);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --header-height: 64px;

    /* Sidebar (dark navy) */
    --sidebar-bg: linear-gradient(180deg, #0B4EA2 0%, #061A3A 100%);
    --sidebar-surface: rgba(255, 255, 255, 0.04);
    --sidebar-surface-hover: rgba(255, 255, 255, 0.08);
    --sidebar-surface-active: rgba(0, 123, 223, 0.2);
    --sidebar-text: rgba(255, 255, 255, 0.65);
    --sidebar-text-hover: rgba(255, 255, 255, 0.95);
    --sidebar-text-active: #FFFFFF;
    --sidebar-accent: #F87800;
    --sidebar-border: rgba(255, 255, 255, 0.08);

    /* Focus ring */
    --focus-ring: 0 0 0 3px var(--primary-ring);

    /* Transition */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --bg: #071326;
    --surface: #0D1E37;
    --surface-hover: #112240;
    --surface-active: #162A4A;

    --text: #F4F8FF;
    --text-secondary: #94A3C0;
    --text-muted: #5A6F8C;

    --border: #1D3557;
    --border-light: #152742;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.45);

    --primary-bg: rgba(0, 159, 247, 0.12);
    --primary-ring: rgba(0, 159, 247, 0.3);
    --success-bg: rgba(5, 150, 105, 0.12);
    --warning-bg: rgba(217, 119, 6, 0.12);
    --danger-bg: rgba(220, 38, 38, 0.12);
    --info-bg: rgba(2, 132, 199, 0.12);
    --purple-bg: rgba(124, 58, 237, 0.12);
    --orange-bg: rgba(248, 120, 0, 0.12);
    --emerald-bg: rgba(16, 185, 129, 0.12);

    --sidebar-bg: linear-gradient(180deg, #040D20 0%, #071830 100%);
}

/* --- Base / Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
    outline: none;
}

a { text-decoration: none; color: var(--primary); transition: color var(--transition-fast); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
ul { list-style: none; }

/* --- Skip Link (Accessibility) --- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 99999;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: top var(--transition-fast);
}
.skip-link:focus {
    top: 16px;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }

/* ============================================================
   SIDEBAR — Premium Dark Navy
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow), width var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 20px 16px 16px; }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-user .user-info,
.sidebar.collapsed .sidebar-nav .nav-section-title,
.sidebar.collapsed .sidebar-nav .nav-item span { display: none; }
.sidebar.collapsed .sidebar-nav .nav-item { justify-content: center; padding: 10px; position: relative; }
.sidebar.collapsed .sidebar-nav .nav-item i { margin-right: 0; font-size: 18px; }

.sidebar.collapsed .sidebar-nav .nav-item:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface);
    color: var(--text);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    margin-left: 8px;
}

.sidebar.collapsed ~ .top-header { left: var(--sidebar-collapsed-width); }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-width); }

/* Sidebar Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand-icon {
    width: 180px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.brand-logo {
    width: 100%;
    object-fit: contain;
    padding: 4px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--sidebar-surface-hover);
    color: var(--sidebar-text-hover);
}

/* Sidebar User */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-bright));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

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

.user-name {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--sidebar-text-active);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 12px;
    color: var(--sidebar-text);
    text-transform: capitalize;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 12px;
}

.nav-section { margin-bottom: 8px; }

.nav-section-title {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255, 255, 255, 0.35);
    padding: 10px 12px 6px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: var(--sidebar-text);
    transition: color var(--transition-fast);
}

.nav-item:hover {
    background: var(--sidebar-surface-hover);
    color: var(--sidebar-text-hover);
}

.nav-item:hover i { color: var(--sidebar-text-hover); }

.nav-item.active {
    background: var(--sidebar-surface-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

.nav-item.active i { color: var(--brand-blue-bright); }

/* Orange accent dot for active */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--brand-orange);
    border-radius: 0 2px 2px 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--sidebar-border);
}

.logout-form { margin: 0; }

.logout-btn {
    width: 100%;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    color: var(--sidebar-text);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #F87171;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.open { display: block; }

/* ============================================================
   HEADER — Clean Light Surface
   ============================================================ */
.top-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 100;
    transition: left var(--transition-slow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.hamburger:hover { background: var(--surface-hover); }

.header-search {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.header-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.header-search input::placeholder { color: var(--text-muted); }

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    background: var(--surface);
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
}

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

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.theme-toggle:hover { background: var(--surface-hover); color: var(--text); }
.theme-toggle .fa-sun { display: none; }
[data-theme="dark"] .theme-toggle .fa-moon { display: none; }
[data-theme="dark"] .theme-toggle .fa-sun { display: inline; }

/* Notification & User Dropdowns */
.notification-dropdown, .user-dropdown { position: relative; }

.notif-btn, .user-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition-fast);
    position: relative;
}

.notif-btn:hover, .user-btn:hover { background: var(--surface-hover); color: var(--text); }

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--surface);
}

.user-btn {
    width: auto;
    gap: 8px;
    padding: 0 12px 0 8px;
}

.user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-bright));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    overflow: hidden;
}

.user-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }

/* Dropdown Menus */
.notif-menu, .user-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 9999;
    min-width: 320px;
    max-width: 95vw;
}

.user-menu { min-width: 220px; }
.notif-menu.active, .user-menu.active { display: block; }

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

.notif-header h4 { font-size: 14px; font-weight: 600; }

.notif-mark-read {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.notif-list { max-height: 300px; overflow-y: auto; }

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 18px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
}

.notif-item:hover { background: var(--surface-hover); }

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.notif-content { flex: 1; min-width: 0; }

.notif-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }

.notif-message {
    font-size: 12px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }
.notif-empty { text-align: center; padding: 30px 18px; color: var(--text-muted); }
.notif-empty i { font-size: 32px; margin-bottom: 8px; color: var(--success); display: block; }
.notif-item-read { opacity: 0.6; }
.notif-footer { padding: 12px 18px; border-top: 1px solid var(--border); text-align: center; }

.notif-view-all { display: block; color: var(--primary); font-size: 13px; font-weight: 500; text-decoration: none; padding: 4px; }
.notif-view-all:hover { text-decoration: underline; }

.notif-filter-btn.active {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}

/* User Menu */
.user-menu-header { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.user-menu-name { font-weight: 600; font-size: 14px; color: var(--text); }
.user-menu-email { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.user-menu-body { padding: 8px; }

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text);
    transition: all var(--transition-fast);
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.user-menu-item i { width: 18px; color: var(--text-muted); }
.user-menu-item:hover { background: var(--surface-hover); }
.user-menu-item.text-danger { color: var(--danger); }
.user-menu-item.text-danger i { color: var(--danger); }
.user-menu-body hr { border: none; border-top: 1px solid var(--border); margin: 6px 0; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: 28px 32px 40px;
    transition: margin-left var(--transition-slow);
}

.page-container { max-width: 1400px; margin: 0 auto; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.page-subtitle { font-size: 14px; color: var(--text-muted); font-weight: 400; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover { box-shadow: var(--shadow-sm); }

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

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 24px; }
.card-body.p-0 { padding: 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    white-space: nowrap;
    line-height: 1.4;
    min-height: 40px;
}

.btn:active { transform: scale(0.98); }

.btn:focus-visible {
    box-shadow: var(--focus-ring);
    outline: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    color: var(--primary);
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0, 123, 223, 0.3);
}

.btn-secondary {
    background: var(--brand-navy);
    color: white;
    border-color: var(--brand-navy);
}

.btn-secondary:hover {
    background: var(--brand-navy-dark);
    border-color: var(--brand-navy-dark);
}

.btn-warning {
    background: var(--brand-orange);
    color: white;
    border-color: var(--brand-orange);
}

.btn-warning:hover {
    background: var(--brand-orange-hover);
    border-color: var(--brand-orange-hover);
    box-shadow: 0 4px 12px rgba(248, 120, 0, 0.3);
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #b91c1c;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    padding: 8px 12px;
}

.btn-text:hover { background: var(--primary-bg); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); min-height: 32px; }
.btn-lg { padding: 14px 28px; font-size: 16px; min-height: 48px; }
.btn-block { width: 100%; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--surface);
    min-height: auto;
}

.btn-icon:hover { background: var(--surface-hover); color: var(--primary); border-color: var(--primary); }
.btn-icon-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* Loading spinner */
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
}

@keyframes btnSpin { to { transform: rotate(360deg); } }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
    margin-top: 28px;
}

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

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

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

.stat-icon-blue { background: var(--primary-bg); color: var(--primary); }
.stat-icon-purple { background: var(--purple-bg); color: var(--purple); }
.stat-icon-orange { background: var(--orange-bg); color: var(--orange); }
.stat-icon-green { background: var(--success-bg); color: var(--success); }
.stat-icon-red { background: var(--danger-bg); color: var(--danger); }
.stat-icon-emerald { background: var(--emerald-bg); color: var(--emerald); }

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

.stat-value { display: block; font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-label { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-trend { font-size: 12px; font-weight: 600; }
.stat-trend-up { color: var(--success); }
.stat-trend-down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.table th:first-child { padding-left: 24px; }
.table th:last-child { padding-right: 24px; }

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

.table td:first-child { padding-left: 24px; }
.table td:last-child { padding-right: 24px; }

.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }

.table .link { font-weight: 500; color: var(--primary); }
.table .link:hover { text-decoration: underline; }

.action-btns { display: flex; gap: 6px; }

/* Priority Row Colors */
.priority-urgent td { border-left: 3px solid var(--danger); }
.priority-high td { border-left: 3px solid var(--warning); }
.priority-medium td { border-left: 3px solid var(--primary); }
.priority-low td { border-left: 3px solid var(--success); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: capitalize;
}

.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-secondary { background: var(--surface-active); color: var(--text-secondary); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }

/* ============================================================
   FORMS
   ============================================================ */
.form { max-width: 100%; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-grid .full-width { grid-column: 1 / -1; }

.form-group { margin-bottom: 0; }

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

/* Required indicator */
.form-label.required::after {
    content: ' *';
    color: var(--danger);
    font-weight: 400;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
    margin: 7px 0;
}

.form-input::placeholder { color: var(--text-muted); }

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-input:disabled, .form-input[readonly] {
    background: var(--surface-active);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Validation states */
.form-input.is-valid { border-color: var(--success); }
.form-input.is-valid:focus { box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); }
.form-input.is-invalid { border-color: var(--danger); }
.form-input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15); }

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 4px;
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-input { min-height: 100px; resize: vertical; }

.form-input-sm { width: auto; padding: 6px 10px; font-size: 13px; min-height: auto; }

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-section { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; margin-bottom: 0; }

.form-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.form-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.form-section-header h3 { font-size: 15px; font-weight: 600; }

/* Input Groups */
.input-group { position: relative; }

.input-icon {
    position: absolute;
    left: 19px;
    top: 37%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    z-index: 1;
    pointer-events: none;
}

.input-group .form-input { padding-left: 44px; }

.password-toggle {
    position: absolute;
    right: 12px;
    top: 39%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
}

/* Checkbox */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    border-radius: 4px;
    cursor: pointer;
}

/* Radio */
.radio-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}

.radio-inline input[type="radio"] {
    accent-color: var(--primary);
    cursor: pointer;
}

/* Filters Bar */
.filters-bar { padding: 16px 20px; margin-bottom: 20px; }

.filters-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box { position: relative; flex: 1; min-width: 200px; }

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 9px 14px 9px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.filter-select { min-width: 160px; }

/* Search Results */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text);
    font-size: 14px;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-light);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface-hover); }

.search-result-item i {
    width: 32px;
    height: 32px;
    background: var(--primary-bg);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 14px;
    flex-shrink: 0;
}

.search-result-item strong { display: block; font-weight: 600; }
.search-result-empty { text-align: center; padding: 20px; color: var(--text-muted); font-size: 13px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info { font-size: 13px; color: var(--text-muted); }

.pagination { display: flex; gap: 4px; }

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    background: var(--surface);
    transition: all var(--transition-fast);
}

.page-btn:hover { background: var(--surface-hover); border-color: var(--border); }

.page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================================
   CHARTS
   ============================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card .card-body { padding: 0 20px 20px; }
.chart-card canvas { height: 280px !important; }

/* ============================================================
   AUTH / LOGIN
   ============================================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}

.auth-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 1000px;
    width: 100%;
    min-height: 600px;
    border-radius: var(--radius-2xl);
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.auth-left {
    background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-navy-light) 100%);
    padding: 48px;
    display: flex;
    flex-direction: column;
    color: white;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.auth-brand { margin-bottom: 40px; }

.auth-brand-icon {
    width: 110px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.auth-logo { width: 100%; height: 100%; object-fit: contain; padding: 6px; }

.auth-brand h1 { font-size: 28px; font-weight: 700; color: white; margin-bottom: 4px; }
.auth-brand p { font-size: 14px; opacity: 0.8; }

.auth-features { display: flex; flex-direction: column; gap: 12px; }
.auth-feature { display: flex; align-items: center; gap: 12px; font-size: 14px; opacity: 0.85; }
.auth-feature i { color: #34d399; font-size: 16px; }

.auth-right { display: flex; align-items: center; justify-content: center; padding: 48px; }
.auth-form-container { width: 100%; max-width: 380px; }
.auth-form-header { margin-bottom: 28px; }
.auth-form-header h2 { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.auth-form-header p { color: var(--text-muted); font-size: 14px; }
.auth-form .form-group { margin-bottom: 20px; }

.form-options { display: flex; align-items: center; justify-content: space-between; }
.forgot-link { font-size: 13px; color: var(--primary); font-weight: 500; }
.auth-footer-text { text-align: center; margin-top: 24px; }
.auth-footer-text a { font-size: 14px; color: var(--text-muted); }
.auth-footer-text a:hover { color: var(--primary); }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-container {
    position: fixed;
    top: 80px;
    right: 28px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

.flash-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.flash-success { border-left: 3px solid var(--success); }
.flash-success i { color: var(--success); }
.flash-error { border-left: 3px solid var(--danger); }
.flash-error i { color: var(--danger); }
.flash-warning { border-left: 3px solid var(--warning); }
.flash-warning i { color: var(--warning); }
.flash-info { border-left: 3px solid var(--info); }
.flash-info i { color: var(--info); }

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
}

/* ============================================================
   DETAIL / INFO GRIDS
   ============================================================ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item.full-width { grid-column: 1 / -1; }

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.info-value { font-size: 14px; color: var(--text); font-weight: 500; }

.customer-info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline { position: relative; padding-left: 24px; }

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--surface);
}

.timeline-content { padding-left: 12px; }
.timeline-status { font-weight: 600; font-size: 14px; color: var(--text); }
.timeline-desc { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.timeline-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; display: block; }

/* ============================================================
   ERROR PAGES
   ============================================================ */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--bg);
}

.error-content { text-align: center; max-width: 500px; }
.error-code { font-size: 120px; font-weight: 800; color: var(--primary); line-height: 1; margin: 0 0 10px; }
.error-content h2 { font-size: 28px; color: var(--text); margin: 0 0 10px; }
.error-content p { color: var(--text-secondary); margin: 0 0 30px; font-size: 16px; }

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-grid { display: grid; gap: 20px; }

/* ============================================================
   PAGE ACTIONS — Pill-style toolbar
   ============================================================ */
.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.page-actions .btn {
    padding: 7px 16px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    gap: 7px;
    border: none;
    box-shadow: var(--shadow-xs);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    min-height: auto;
}

.page-actions .btn i,
.page-actions .btn .fas,
.page-actions .btn .fab { font-size: 14px; }

.page-actions .btn:hover {
	/* color: #ffffff;	 */
    border: 1px solid var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.page-actions .btn.btn-secondary:hover {
    background: var(--brand-navy);
    color: white;
}

.page-actions .btn:active { transform: translateY(0) scale(0.97); }

.page-actions .btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Ripple effect */
.page-actions .btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.2);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
}
.page-actions .btn:active::after { opacity: 1; transition: 0s; }

/* Icon-colored action buttons */
.page-actions .btn:has(i.fa-eye):not(.btn-success):not(.btn-danger) {
    background: var(--primary-bg);
    color: var(--primary);
}
.page-actions .btn:has(i.fa-eye):not(.btn-success):not(.btn-danger):hover {
    background: var(--primary);
    color: white;
}
.page-actions .btn:has(i.fa-eye):not(.btn-success):not(.btn-danger):hover i.fa-eye { color: white; }

.page-actions .btn:has(i.fa-edit):not(.btn-success):not(.btn-danger):not(.btn-primary) {
    background: var(--purple-bg);
    color: var(--purple);
}
.page-actions .btn:has(i.fa-edit):not(.btn-success):not(.btn-danger):not(.btn-primary):hover {
    background: var(--purple);
    color: white;
}

.page-actions .btn:has(i.fa-file-pdf):not(.btn-success):not(.btn-danger) {
    background: var(--danger-bg);
    color: var(--danger);
}
.page-actions .btn:has(i.fa-file-pdf):not(.btn-success):not(.btn-danger):hover {
    background: var(--danger);
    color: white;
}

.page-actions .btn:has(i.fa-print):not(.btn-success):not(.btn-danger):not(.btn-primary) {
    background: var(--surface-active);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.page-actions .btn:has(i.fa-print):not(.btn-success):not(.btn-danger):not(.btn-primary):hover {
    background: var(--text-secondary);
    color: white;
    border-color: var(--text-secondary);
}

.page-actions .btn:has(.fa-whatsapp) {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.25);
}
.page-actions .btn:has(.fa-whatsapp):hover {
    background: linear-gradient(135deg, #20bd5a, #0e7a6e);
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.4);
}

.page-actions .btn:has(.fa-dollar-sign) {
    background: var(--emerald);
    color: white;
}
.page-actions .btn:has(.fa-dollar-sign):hover {
    background: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.page-actions .btn:has(.fa-trash) {
    background: var(--danger-bg);
    color: var(--danger);
}
.page-actions .btn:has(.fa-trash):hover {
    background: var(--danger);
    color: white;
}

.page-actions .btn:has(.fa-file-invoice) {
    background: var(--primary);
    color: white;
}
.page-actions .btn:has(.fa-file-invoice):hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(0, 123, 223, 0.3);
}

.page-actions .btn:has(.fa-check) {
    background: var(--success);
    color: white;
}
.page-actions .btn:has(.fa-check):hover {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

/* ============================================================
   DROPDOWN (for table action menus)
   ============================================================ */
.dropdown { position: relative; display: inline-block; }

table td:has(.dropdown), .table td:has(.dropdown) {
    overflow: visible;
    position: relative;
}

.dropdown-toggle.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: auto;
}

.dropdown-toggle.btn-icon:hover,
.dropdown-toggle.btn-icon:focus-visible {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--primary);
}

.dropdown-toggle.btn-icon:active,
.dropdown-toggle.btn-icon.show {
    background: var(--primary-bg);
    color: var(--primary);
    border-color: var(--primary);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 99999;
    padding: 6px;
    margin: 4px 0 0;
    animation: dropdownFadeIn 0.15s ease;
    list-style: none;
    text-align: left;
    font-size: inherit;
}

.dropdown-menu.show { display: block; }

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
    text-decoration: none;
}

.dropdown-item i,
.dropdown-item .fas,
.dropdown-item .fab {
    width: 18px;
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.dropdown-item:hover, .dropdown-item:focus {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.dropdown-item:hover i, .dropdown-item:focus i { color: var(--text); }

.dropdown-item.text-danger { color: var(--danger); }
.dropdown-item.text-danger i { color: var(--danger); }
.dropdown-item.text-danger:hover { background: var(--danger-bg); color: var(--danger); }

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
    border: none;
}

/* Floating dropdown */
.dropdown-menu.dropdown-fixed {
    position: fixed !important;
    margin: 0 !important;
    animation: dropdownFadeIn 0.15s ease;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-container {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 960px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title { font-size: 18px; font-weight: 600; color: var(--text); margin: 0; }

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    transition: color var(--transition-fast);
}

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

.modal-body { padding: 16px 24px 20px; overflow: auto; flex: 1; }

.modal-container .table { margin-bottom: 0; }
.modal-container .table td, .modal-container .table th { white-space: nowrap; padding: 10px 12px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .charts-grid { grid-template-columns: 1fr; }
    .tables-grid { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .top-header { left: 0; }
    .hamburger { display: flex; }
    .main-content { margin-left: 0; padding: 20px 16px 32px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }

    .form-grid { grid-template-columns: 1fr; }

    .auth-container { grid-template-columns: 1fr; }
    .auth-left { display: none; }
    .auth-right { padding: 32px 24px; }

    .header-search { display: none; }

    .notif-menu {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        border-radius: 0;
        min-width: auto;
    }

    .flash-container { right: 16px; left: 16px; max-width: none; }

    .pagination-wrapper { flex-direction: column; align-items: center; }

    .table { font-size: 13px; }
    .table th, .table td { padding: 10px 12px; }
    .table th:first-child, .table td:first-child { padding-left: 14px; }
    .table th:last-child, .table td:last-child { padding-right: 14px; }

    .page-actions .btn { padding: 6px 12px; font-size: 12px; }
    .page-actions { gap: 6px; }

    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-container { max-width: 100%; max-height: 90vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filters-form { flex-direction: column; align-items: stretch; }
    .search-box { min-width: auto; }
    .filter-select { min-width: auto; }

    .page-actions .btn span { display: none; }
    .page-actions .btn { padding: 7px; min-width: 34px; min-height: 34px; justify-content: center; }
    .page-actions .btn i { margin: 0; }
}

/* ============================================================
   INVOICE ITEMS — Mobile Card Layout
   ============================================================ */
@media (max-width: 768px) {
    #itemsTable, #itemsTable thead, #itemsTable tbody, #itemsTable tfoot,
    #itemsTable tr, #itemsTable th, #itemsTable td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    #itemsTable thead { display: none; }

    #itemsTable .item-row {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 14px;
        margin-bottom: 14px;
        box-shadow: var(--shadow-xs);
    }

    #itemsTable .item-row td { padding: 6px 0; border: none; vertical-align: middle; }
    #itemsTable .item-row td:first-child { padding-top: 0; }
    #itemsTable .item-row td:last-child { padding-bottom: 0; text-align: right; }

    #itemsTable tfoot, #itemsTable tfoot tr, #itemsTable tfoot td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    #itemsTable tfoot { margin-top: 8px; }

    #itemsTable tfoot tr {
        padding: 10px 0;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
    }

    #itemsTable tfoot td { padding: 0; border: none; width: auto; }
    #itemsTable tfoot td:first-child, #itemsTable tfoot td:nth-child(4) { display: none; }

    #itemsTable tfoot td:nth-child(2) {
        font-weight: 600;
        font-size: 13px;
        color: var(--text);
        flex: 1 1 auto;
        min-width: 80px;
    }

    #itemsTable tfoot td:nth-child(3) {
        font-weight: 700;
        font-size: 14px;
        color: var(--text);
        text-align: right;
        flex: 0 0 auto;
    }

    #itemsTable tfoot .form-input-sm {
        width: 100%;
        min-height: 44px;
        font-size: 14px;
        box-sizing: border-box;
        display: block;
        margin-top: 4px;
    }

    #itemsTable tfoot tr.grand-total-row td:nth-child(2) { font-size: 15px; font-weight: 700; }
    #itemsTable tfoot tr.grand-total-row td:nth-child(3) { font-size: 17px; }

    .form-section-header .btn { min-height: 44px; font-size: 14px; }
}

@media (max-width: 480px) {
    #itemsTable .item-row { padding: 12px; }

    #itemsTable tfoot tr {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    #itemsTable tfoot td:nth-child(2) { width: 100%; }
    #itemsTable tfoot td:nth-child(3) { width: 100%; text-align: left; padding-left: 0; }
    #itemsTable .item-row td:nth-child(5) { text-align: left; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    .sidebar, .top-header, .sidebar-overlay, .flash-container,
    .page-actions, .filters-bar, .pagination-wrapper, .btn { display: none !important; }

    .main-content { margin: 0; padding: 0; }

    body { background: #fff; color: #000; }

    .card { box-shadow: none; border: 1px solid #ddd; }
}
