/* =============================================
   FLARVA CRM - Theme Engine & Global Styles
   Modern, sleek sans-serif design system
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- LIGHT THEME (Default) ---- */
:root, [data-theme="light"] {
    --font-primary: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --bg-body: #f4f2ee;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f8f7f5;
    --bg-active: #f0eee9;
    --bg-badge: #f4f2ee;
    --bg-modal-overlay: rgba(0,0,0,0.35);
    --bg-tooltip: #1a1a1a;

    --text-primary: #1a1a1a;
    --text-secondary: #6b6966;
    --text-tertiary: #9b9894;
    --text-inverse: #ffffff;
    --text-link: #2563eb;

    --border-primary: #e2e0db;
    --border-secondary: #d1cfc9;
    --border-light: #eeece7;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --accent-text: #1e40af;

    --success: #059669;
    --success-light: #ecfdf5;
    --success-text: #065f46;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --warning-text: #92400e;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --danger-text: #991b1b;
    --info: #0891b2;
    --info-light: #ecfeff;
    --info-text: #155e75;
    --purple: #7c3aed;
    --purple-light: #f5f3ff;
    --purple-text: #5b21b6;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: 0.2s ease;
}

/* ---- DARK THEME ---- */
[data-theme="dark"] {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --bg-sidebar: #171717;
    --bg-input: #2a2a2a;
    --bg-hover: #2a2a2a;
    --bg-active: #333333;
    --bg-badge: #2a2a2a;
    --bg-modal-overlay: rgba(0,0,0,0.6);
    --bg-tooltip: #f0f0f0;

    --text-primary: #f0eeeb;
    --text-secondary: #a3a09b;
    --text-tertiary: #706d68;
    --text-inverse: #121212;
    --text-link: #60a5fa;

    --border-primary: #333333;
    --border-secondary: #444444;
    --border-light: #262626;

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: #172554;
    --accent-text: #93c5fd;

    --success: #34d399;
    --success-light: #052e16;
    --success-text: #6ee7b7;
    --warning: #fbbf24;
    --warning-light: #422006;
    --warning-text: #fcd34d;
    --danger: #f87171;
    --danger-light: #450a0a;
    --danger-text: #fca5a5;
    --info: #22d3ee;
    --info-light: #083344;
    --info-text: #67e8f9;
    --purple: #a78bfa;
    --purple-light: #2e1065;
    --purple-text: #c4b5fd;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

/* ---- MIDNIGHT BLUE THEME ---- */
[data-theme="midnight"] {
    --bg-body: #0c1425;
    --bg-card: #131d33;
    --bg-sidebar: #0f1829;
    --bg-input: #1a2744;
    --bg-hover: #1a2744;
    --bg-active: #223356;
    --bg-badge: #1a2744;
    --bg-modal-overlay: rgba(4,10,24,0.7);
    --bg-tooltip: #e0e7f1;

    --text-primary: #e4eaf3;
    --text-secondary: #8899b4;
    --text-tertiary: #5a6e8a;
    --text-inverse: #0c1425;
    --text-link: #60a5fa;

    --border-primary: #1e2e4a;
    --border-secondary: #2a3d5e;
    --border-light: #162038;

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-light: #172554;
    --accent-text: #93c5fd;

    --success: #34d399;
    --success-light: #042f1e;
    --success-text: #6ee7b7;
    --warning: #fbbf24;
    --warning-light: #332200;
    --warning-text: #fcd34d;
    --danger: #f87171;
    --danger-light: #3b0e0e;
    --danger-text: #fca5a5;
    --info: #22d3ee;
    --info-light: #062c3d;
    --info-text: #67e8f9;
    --purple: #a78bfa;
    --purple-light: #1e0f4a;
    --purple-text: #c4b5fd;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}

/* ---- ROYAL PURPLE THEME ---- */
[data-theme="purple"] {
    --bg-body: #120e1f;
    --bg-card: #1a1530;
    --bg-sidebar: #140f26;
    --bg-input: #231d3e;
    --bg-hover: #231d3e;
    --bg-active: #2e2654;
    --bg-badge: #231d3e;
    --bg-modal-overlay: rgba(8,4,18,0.7);
    --bg-tooltip: #e8e2f4;

    --text-primary: #eae5f5;
    --text-secondary: #9b8fbc;
    --text-tertiary: #6b5d8e;
    --text-inverse: #120e1f;
    --text-link: #a78bfa;

    --border-primary: #2a2248;
    --border-secondary: #382e60;
    --border-light: #1e1838;

    --accent: #8b5cf6;
    --accent-hover: #a78bfa;
    --accent-light: #2e1065;
    --accent-text: #c4b5fd;

    --success: #34d399;
    --success-light: #042f1e;
    --success-text: #6ee7b7;
    --warning: #fbbf24;
    --warning-light: #332200;
    --warning-text: #fcd34d;
    --danger: #f87171;
    --danger-light: #3b0e0e;
    --danger-text: #fca5a5;
    --info: #22d3ee;
    --info-light: #062c3d;
    --info-text: #67e8f9;
    --purple: #a78bfa;
    --purple-light: #2e1065;
    --purple-text: #c4b5fd;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}

/* ---- GREEN APPLE THEME ---- */
[data-theme="green"] {
    --bg-body: #0e1a12;
    --bg-card: #142119;
    --bg-sidebar: #101c14;
    --bg-input: #1c2e22;
    --bg-hover: #1c2e22;
    --bg-active: #24392b;
    --bg-badge: #1c2e22;
    --bg-modal-overlay: rgba(4,12,6,0.7);
    --bg-tooltip: #e2f0e6;

    --text-primary: #e5f0e8;
    --text-secondary: #8fb498;
    --text-tertiary: #5d8a68;
    --text-inverse: #0e1a12;
    --text-link: #6ee7b7;

    --border-primary: #1e3525;
    --border-secondary: #2a4832;
    --border-light: #182c1e;

    --accent: #22c55e;
    --accent-hover: #4ade80;
    --accent-light: #052e16;
    --accent-text: #86efac;

    --success: #34d399;
    --success-light: #042f1e;
    --success-text: #6ee7b7;
    --warning: #fbbf24;
    --warning-light: #332200;
    --warning-text: #fcd34d;
    --danger: #f87171;
    --danger-light: #3b0e0e;
    --danger-text: #fca5a5;
    --info: #22d3ee;
    --info-light: #062c3d;
    --info-text: #67e8f9;
    --purple: #a78bfa;
    --purple-light: #1e0f4a;
    --purple-text: #c4b5fd;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--text-link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

/* ---- LAYOUT ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}

.sidebar-brand .brand-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

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

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-tertiary);
    padding: 0 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 450;
    transition: all var(--transition);
    cursor: pointer;
    text-decoration: none;
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 550;
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-item .nav-icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.nav-item .pro-badge {
    margin-left: auto;
    background: var(--purple-light);
    color: var(--purple-text);
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-light);
}

/* ---- MAIN CONTENT ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

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

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.page-content {
    flex: 1;
    padding: 28px;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    transition: box-shadow var(--transition);
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.card-body { padding: 22px; }
.card-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---- STAT CARDS ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-card .stat-change {
    font-size: 12px;
    font-weight: 500;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
}

.btn svg { width: 16px; height: 16px; }

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

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

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

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 14px;
    font-family: var(--font-primary);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input::placeholder { color: var(--text-tertiary); }
.form-textarea { min-height: 100px; resize: vertical; }

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

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

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

/* ---- TABLES ---- */
.table-wrapper {
    overflow: visible;
    -webkit-overflow-scrolling: touch;
}

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

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

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

.data-table tr:hover td {
    background: var(--bg-hover);
}

.data-table .text-muted { color: var(--text-secondary); font-size: 12px; }

/* ---- BADGES & STATUS ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

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

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--text-tertiary); }
.status-dot.warning { background: var(--warning); }
.status-dot.danger { background: var(--danger); }

/* ---- AVATAR ---- */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }

.avatar-blue { background: var(--accent-light); color: var(--accent-text); }
.avatar-green { background: var(--success-light); color: var(--success-text); }
.avatar-purple { background: var(--purple-light); color: var(--purple-text); }
.avatar-amber { background: var(--warning-light); color: var(--warning-text); }
.avatar-red { background: var(--danger-light); color: var(--danger-text); }

/* ---- SEARCH BAR ---- */
.search-bar {
    position: relative;
}

.search-bar input {
    padding-left: 40px;
    width: 280px;
}

.search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-bar .search-icon svg { width: 16px; height: 16px; }

/* ---- MODAL ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 4px;
    transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

/* ---- DROPDOWN ---- */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 9999;
    padding: 6px;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item svg { width: 15px; height: 15px; color: var(--text-tertiary); }
.dropdown-divider { border-top: 1px solid var(--border-light); margin: 4px 0; }
.dropdown-item.danger { color: var(--danger); }

/* ---- TABS ---- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 24px;
}

.tab {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    text-decoration: none;
    margin-bottom: -1px;
}

.tab:hover { color: var(--text-primary); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---- ALERTS ---- */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    animation: alertIn 0.3s ease;
}

@keyframes alertIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-light); color: var(--success-text); border: 1px solid var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning-text); border: 1px solid var(--warning); }
.alert-danger { background: var(--danger-light); color: var(--danger-text); border: 1px solid var(--danger); }
.alert-info { background: var(--info-light); color: var(--info-text); border: 1px solid var(--info); }

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
    justify-content: center;
}

.pg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all var(--transition);
}

.pg-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    color: var(--text-tertiary);
    opacity: 0.5;
}

.empty-state h4 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }

/* ---- THEME SWITCHER ---- */
.theme-switcher {
    position: relative;
}

.theme-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-secondary);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-card);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle-btn:hover { border-color: var(--accent); }

.theme-dropdown {
    display: none;
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 170px;
    z-index: 9999;
    padding: 6px;
}
.theme-dropdown.show { display: block; }

.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.theme-option:hover { background: var(--bg-hover); }
.theme-option.active { background: var(--bg-active); font-weight: 500; }

.theme-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.theme-dot.swatch-light { background: #f4f2ee; }
.theme-dot.swatch-dark { background: #1e1e1e; }
.theme-dot.swatch-midnight { background: #131d33; }
.theme-dot.swatch-purple { background: #1a1530; border-color: #8b5cf6; }
.theme-dot.swatch-green { background: #142119; border-color: #22c55e; }

/* ---- USER MENU ---- */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition);
}

.user-menu:hover { background: var(--bg-hover); }

.user-menu .user-info {
    text-align: right;
}

.user-menu .user-name {
    font-size: 13px;
    font-weight: 550;
    line-height: 1.2;
}

.user-menu .user-plan {
    font-size: 10.5px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- CHART CONTAINERS ---- */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

/* ---- UTILITIES ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

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

/* ---- TOAST NOTIFICATIONS ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 4.7s forwards;
    max-width: 380px;
}

@keyframes toastIn { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: translateX(0); } }
@keyframes toastOut { to { opacity:0; transform: translateX(40px); } }

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .stat-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .search-bar input { width: 180px; }
}

/* ---- AUTH PAGES ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-body);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: var(--shadow-md);
}

.auth-card .auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card .auth-brand .brand-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    margin: 0 auto 14px;
}

.auth-card .auth-brand h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.auth-card .auth-brand p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.auth-divider {
    text-align: center;
    position: relative;
    margin: 24px 0;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border-light);
}

.auth-divider span {
    position: relative;
    background: var(--bg-card);
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---- PLAN SELECTION ---- */
.plan-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.plan-card {
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.plan-card:hover { border-color: var(--accent); }
.plan-card.selected { border-color: var(--accent); background: var(--accent-light); }
.plan-card.featured { border-color: var(--purple); }
.plan-card .plan-name { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.plan-card .plan-price { font-size: 24px; font-weight: 700; color: var(--accent); }
.plan-card .plan-price span { font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.plan-card .plan-features { list-style: none; margin-top: 12px; font-size: 12.5px; color: var(--text-secondary); text-align: left; }
.plan-card .plan-features li { padding: 4px 0; display: flex; align-items: center; gap: 6px; }
.plan-card .plan-features li::before { content: '✓'; color: var(--success); font-weight: 700; }

@media (max-width: 640px) {
    .plan-cards { grid-template-columns: 1fr; }
}

/* ---- LOADING SPINNER ---- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-primary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    opacity: 0.7;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
