/* ============================================================================
   SPHERELY DESIGN SYSTEM v2.0
   A premium SaaS interface with depth, clarity and precision
   ============================================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300..700&display=swap");

/* ============================================================================
   DESIGN TOKENS — Dark Theme (default)
   ============================================================================ */
:root {
    color-scheme: dark;

    /* Brand */
    --primary: #2dd4bf;
    --primary-dark: #14b8a6;
    --primary-light: #5eead4;
    --primary-glow: rgba(45, 212, 191, 0.18);
    --primary-ghost: rgba(45, 212, 191, 0.06);

    /* Semantic */
    --secondary: #3b82f6;
    --secondary-light: #60a5fa;
    --accent: #2dd4bf;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Surfaces — layered depth system */
    --bg-base: #050d18;
    --bg-primary: #0a1628;
    --bg-secondary: #0e1e36;
    --bg-card: #111f38;
    --bg-elevated: #152844;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-active: rgba(255, 255, 255, 0.07);

    /* Text — 4-tier hierarchy */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.07);
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-strong: rgba(255, 255, 255, 0.12);
    --border-interactive: rgba(45, 212, 191, 0.3);

    /* Radius */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.24), 0 1px 2px rgba(0, 0, 0, 0.16);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.28), 0 2px 4px rgba(0, 0, 0, 0.16);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.32), 0 4px 8px rgba(0, 0, 0, 0.16);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4), 0 8px 16px rgba(0, 0, 0, 0.2);
    --shadow-glow:
        0 0 24px rgba(45, 212, 191, 0.12), 0 0 80px rgba(45, 212, 191, 0.04);
    --shadow-card:
        0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-card-hover:
        0 8px 30px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.08);

    /* Legacy aliases */
    --border-radius: var(--radius-md);
    --border-radius-lg: var(--radius-lg);
    --border-radius-sm: var(--radius-sm);
    --shadow-lg-compat: var(--shadow-lg);

    /* Typography */
    --font-family:
        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
        sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", monospace;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Transitions */
    --transition-fast: 100ms ease;
    --transition-base: 180ms ease;
    --transition-slow: 280ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Sidebar */
    --sidebar-width: 230px;
    --sidebar-collapsed-width: 64px;
}

/* ============================================================================
   LIGHT THEME
   ============================================================================ */
[data-theme="light"] {
    --logo-invert: invert(1);
    color-scheme: light;

    --bg-base: #e2e6f0;
    --bg-primary: #e8ebf4;
    --bg-secondary: #eef0f7;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.03);
    --bg-active: rgba(0, 0, 0, 0.06);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-faint: #cbd5e1;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-strong: rgba(0, 0, 0, 0.12);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg:
        0 12px 40px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 20px rgba(45, 212, 191, 0.08);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.05);
    --shadow-card-hover:
        0 4px 16px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.06);

    --primary-glow: rgba(45, 212, 191, 0.1);
    --primary-ghost: rgba(45, 212, 191, 0.04);
}

[data-theme="light"] .sidebar {
    background: #ffffff;
    box-shadow: 1px 0 0 var(--border-color);
}
[data-theme="light"] .card {
    box-shadow: var(--shadow-card);
}
[data-theme="light"] .nav-link.active {
    background: var(--primary-ghost);
}
[data-theme="light"] .table th {
    background: #f8fafc;
}
[data-theme="light"] .form-control,
[data-theme="light"] .form-select {
    background: #ffffff;
    border-color: var(--border-strong);
}
[data-theme="light"] .form-control:focus,
[data-theme="light"] .form-select:focus {
    background: #ffffff;
}
[data-theme="light"] .btn-secondary {
    background: #f1f5f9;
    color: var(--text-primary);
    border-color: var(--border-strong);
}
[data-theme="light"] .btn-secondary:hover {
    background: #e2e8f0;
}
/* Theme logo visibility: .sidebar-logo-for-dark / .sidebar-logo-for-light / .sidebar-logo-icon */
[data-theme="light"] .stat-card,
[data-theme="light"] .kpi-card {
    box-shadow: var(--shadow-card);
}

/* Light theme - sidebar section titles: stronger colors */
[data-theme="light"] .nav-section-title {
    filter: saturate(1.2) contrast(1.1);
}

/* Light theme - stat card labels: darker text */
[data-theme="light"] .stat-label {
    color: #475569;
    font-weight: 600;
}

/* Light theme - stat card values: bolder */
[data-theme="light"] .stat-value {
    color: #0f172a;
    font-weight: 800;
}

/* Light theme - TikTok icon: black background with white icon */
[data-theme="light"] .nav-link .fab.fa-tiktok {
    background: #000;
    color: #fff !important;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 10px;
}

/* Light theme - TikTok filter chip icon */
[data-theme="light"] .chip-content .fab.fa-tiktok {
    background: #000;
    color: #fff !important;
    border-radius: 3px;
    font-size: 10px;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
    flex-shrink: 0;
}
[data-theme="light"] .page-header {
    background: rgba(255, 255, 255, 0.85);
}
[data-theme="light"] ::selection {
    color: #ffffff;
    background-color: var(--primary);
}

/* Light theme badges */
[data-theme="light"] .badge-new {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #bfdbfe;
}
[data-theme="light"] .badge-contacted {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}
[data-theme="light"] .badge-qualified {
    background: #ccfbf1;
    color: #0f766e;
    border-color: #99f6e4;
}
[data-theme="light"] .badge-appointment {
    background: #ede9fe;
    color: #6d28d9;
    border-color: #ddd6fe;
}
[data-theme="light"] .badge-converted {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}
[data-theme="light"] .badge-lost {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}
[data-theme="light"] .badge-not_qualified {
    background: #f3f4f6;
    color: #4b5563;
    border-color: #e5e7eb;
}
[data-theme="light"] .badge-pending {
    background: #f59e0b;
    color: #fff;
    border-color: #d97706;
}
[data-theme="light"] .badge-scheduled {
    background: #2563eb;
    color: #fff;
    border-color: #1d4ed8;
}
[data-theme="light"] .badge-confirmed,
[data-theme="light"] .badge-done,
[data-theme="light"] .badge-completed {
    background: #16a34a;
    color: #fff;
    border-color: #15803d;
}
[data-theme="light"] .badge-cancelled {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}
[data-theme="light"] .badge-no_show {
    background: #f3f4f6;
    color: #4b5563;
    border-color: #e5e7eb;
}
[data-theme="light"] .badge-active {
    background: #dcfce7;
    color: #15803d;
    border-color: #bbf7d0;
}
[data-theme="light"] .badge-paused {
    background: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}
[data-theme="light"] .badge-primary {
    background: #0d9488;
    color: #fff;
    border-color: #0f766e;
}


/* Light theme - Platform rows in creative table */
[data-theme="light"] .platform-row {
    background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .platform-row td {
    color: #64748b;
}
[data-theme="light"] .platform-badge.fb {
    background: rgba(24, 119, 242, 0.15);
    color: #1558b0;
}
[data-theme="light"] .platform-badge.ig {
    background: rgba(228, 64, 95, 0.15);
    color: #b03050;
}

/* Light theme - Appointments page improvements */
[data-theme="light"] .stat-card-mini {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);

}
[data-theme="light"] .stat-card-mini:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .stat-card-mini .stat-label {
    color: #64748b;
    font-weight: 600;
}
[data-theme="light"] .stat-card-mini .stat-value {
    color: #0f172a;
    font-weight: 800;
}
[data-theme="light"] .stat-card-mini .stat-icon {
    filter: saturate(1.5) contrast(1.2);
}
[data-theme="light"] .filter-bar {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);

}
[data-theme="light"] .filter-bar input,
[data-theme="light"] .filter-bar select {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #1e293b;
}
[data-theme="light"] .tabs {
    background: #fff;

    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .tab {
    color: #64748b;
}
[data-theme="light"] .tab:hover {
    color: #1e293b;
    background: #f1f5f9;
}

[data-theme="light"] .appointments-table-wrapper .table tbody td {
    color: #334155;
    border-bottom-color: #e2e8f0;
}
[data-theme="light"] .date-group-header {
    background: #f8fafc;
}
[data-theme="light"] .date-group-header .count {
    background: rgba(0, 0, 0, 0.08);
    color: #334155;
}
[data-theme="light"] .section-row td .count {
    background: rgba(0, 0, 0, 0.08);
    color: #334155;
}
[data-theme="light"] .type-badge {
    filter: saturate(1.3) contrast(1.1);
}

/* Light theme - Planning page improvements */
[data-theme="light"] .p-stat {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);

}
[data-theme="light"] .p-stat:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .p-stat .val {
    color: #0f172a;
    font-weight: 800;
}
[data-theme="light"] .p-stat .lbl {
    color: #64748b;
    font-weight: 600;
}
[data-theme="light"] .planning-grid {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);

}
[data-theme="light"] .planning-table th {
    background: #dde1ed !important;
    color: #1e293b !important;
    font-weight: 700 !important;
    border-bottom-color: #cbd5e1;
    border-right: 1px solid #cbd5e1 !important;
}
[data-theme="light"] .planning-table th.today {
    color: #0d9488 !important;
    background: rgba(45, 212, 191, 0.15) !important;
    border-bottom-color: #0d9488;
}
[data-theme="light"] .planning-table th.col-hover {    color: #0d9488 !important;    background: rgba(45, 212, 191, 0.15) !important;    border-bottom: 2px solid #0d9488 !important;}[data-theme="light"] .planning-table td.col-hover {    background: rgba(45, 212, 191, 0.08) !important;}
[data-theme="light"] .planning-table td {
    border-color: #cbd5e1 !important;

}
[data-theme="light"] .resource-cell {
    background: #fff;
    color: #1e293b;
}
[data-theme="light"] .resource-badge.INTERNE {
    background: rgba(16, 185, 129, 0.2);
    color: #047857;
    font-weight: 700;
}
[data-theme="light"] .resource-badge.SOUS_TRAITANT {
    background: rgba(249, 115, 22, 0.2);
    color: #c2410c;
    font-weight: 700;
}
[data-theme="light"] .day-off {
    color: #94a3b8;
    opacity: 0.8;
}
[data-theme="light"] .cal-btn,
[data-theme="light"] .week-nav button {
    background: #fff;
    color: #334155;
    border-color: #cbd5e1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .cal-btn:hover,
[data-theme="light"] .week-nav button:hover {
    background: #f1f5f9;
    color: #0d9488;
    border-color: #0d9488;
}
[data-theme="light"] .week-label {
    color: #0f172a;
}
[data-theme="light"] .inv-card {
    border-color: rgba(0, 0, 0, 0.15);
}
[data-theme="light"] .inv-card .card-client {
    color: #1e293b;
}
[data-theme="light"] .inv-card .card-section {
    border-top-color: rgba(0, 0, 0, 0.1);
    color: #64748b;
}

/* Light theme - Planning intervention cards */
[data-theme="light"] .inv-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .inv-card.TERMINE {
    background: rgba(34, 197, 94, 0.25);
    border-color: rgba(21, 128, 61, 0.4);
}
[data-theme="light"] .inv-card.TERMINE .card-status {
    color: #15803d;
    font-weight: 800;
}
[data-theme="light"] .inv-card.PLANIFIE {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(29, 78, 216, 0.4);
}
[data-theme="light"] .inv-card.PLANIFIE .card-status {
    color: #1d4ed8;
    font-weight: 800;
}
[data-theme="light"] .inv-card.EN_COURS {
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(194, 65, 12, 0.4);
}
[data-theme="light"] .inv-card.EN_COURS .card-status {
    color: #c2410c;
    font-weight: 800;
}
[data-theme="light"] .inv-card.REPORTE {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(185, 28, 28, 0.4);
}
[data-theme="light"] .inv-card.REPORTE .card-status {
    color: #b91c1c;
    font-weight: 800;
}
[data-theme="light"] .inv-card .card-client {
    color: #0f172a;
    font-weight: 800;
}
[data-theme="light"] .inv-card .card-line {
    color: #334155;
}
[data-theme="light"] .inv-card .card-line b {
    color: #1e293b;
}
[data-theme="light"] .inv-card .card-section {
    color: #475569;
    border-top-color: rgba(0, 0, 0, 0.15);
    font-weight: 800;
}

/* Light theme - Score page improvements */
[data-theme="light"] .global-score-card {
    background: #e8ebf4 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .tunnel-card {
    background: #e8ebf4 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .score-table {
    background: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .score-circle.orange {
    background: rgba(249, 115, 22, 0.2);
}
[data-theme="light"] .stat-box .value {
    color: #0f172a;
    font-weight: 800;
}
[data-theme="light"] .stat-box .label {
    color: #64748b;
    font-weight: 600;
}
[data-theme="light"] .tunnel-step .count {
    color: #0f172a;
    font-weight: 800;
}
[data-theme="light"] .tunnel-step .label {
    color: #64748b;
    font-weight: 600;
}
[data-theme="light"] .tunnel-step .rate {
    color: #0d9488;
    font-weight: 700;
}
[data-theme="light"] .tunnel-arrow {
    color: #94a3b8;
}
[data-theme="light"] .tunnel-step {
    background: #ffffff !important;
}
[data-theme="light"] .stat-box {
    background: #ffffff !important;
}

[data-theme="light"] .score-table td {
    color: #334155;
}
[data-theme="light"] .filters-section select {
    border-color: #cbd5e1;
    color: #1e293b;
}

/* Light theme - Mailing page */
[data-theme="light"] .stat-card {
    background: #ffffff !important;
}
[data-theme="light"] .stat-card .stat-value {
    color: #0f172a !important;
    font-weight: 800;
}
[data-theme="light"] .stat-card .stat-label {
    color: #475569 !important;
    font-weight: 700;
    text-transform: uppercase;
}
[data-theme="light"] .campaign-card {
    background: #ffffff !important;
}
[data-theme="light"] .campaign-card h4 {
    color: #0f172a !important;
}
[data-theme="light"] .campaign-card p {
    color: #475569 !important;
}
[data-theme="light"] .campaign-card .fa-users,
[data-theme="light"] .campaign-card .fa-paper-plane,
[data-theme="light"] .campaign-card .fa-envelope-open,
[data-theme="light"] .campaign-card .fa-paperclip,
[data-theme="light"] .campaign-card .fa-clock {
    color: #475569 !important;
}
[data-theme="light"] .campaign-status.sent {
[data-theme="light"] .campaign-card > div > div span {
    color: #475569 !important;
}
    background: rgba(22, 163, 74, 0.2) !important;
[data-theme="light"] .campaign-card > div > div span {
    color: #475569 !important;
}
    color: #15803d !important;
[data-theme="light"] .campaign-card > div > div span {
    color: #475569 !important;
}
    font-weight: 700;
[data-theme="light"] .campaign-card > div > div span {
    color: #475569 !important;
}
}
[data-theme="light"] .campaign-card > div > div span {
    color: #475569 !important;
}

/* Light theme - ALL table headers: gray tint (3rd level between page bg and cards) */
[data-theme="light"] th,
[data-theme="light"] thead th,
[data-theme="light"] .table th,
[data-theme="light"] .table thead th {
    background: #dde1ed !important;
    color: #1e293b !important;
    font-weight: 700 !important;
}

/* Light theme - Appointments: filter bar white */
[data-theme="light"] .filter-bar {
    background: #fff;

}
/* Light theme - Appointments: section headers more visible */
[data-theme="light"] .date-group-header {
    background: #f1f5f9;
    font-weight: 700;
}
[data-theme="light"] .date-group-header .count {
    background: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}
[data-theme="light"] .section-row td {
    background: #f1f5f9;
}
[data-theme="light"] .section-row td .count {
    background: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}

/* Light theme - Danger button: darker red + white icon */
[data-theme="light"] .btn-danger {
    background: rgba(239, 68, 68, 0.25);
    color: #dc2626;
    border-color: rgba(239, 68, 68, 0.4);
}
[data-theme="light"] .btn-danger i {
    color: #dc2626;
}
[data-theme="light"] .btn-danger:hover {
    background: #dc2626;
    color: #fff;
}
[data-theme="light"] .btn-danger:hover i {
    color: #fff;
}
/* ============================================================================
   RESET & BASE
   ============================================================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    font-size: 0.875rem;
    letter-spacing: -0.011em;
}

::selection {
    color: #ffffff;
    background-color: var(--primary);
}

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

/* ============================================================================
   SIDEBAR
   ============================================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    transition:
        transform var(--transition-slow),
        width 0.2s ease;
    overflow: visible;
}

.sidebar-header {
    padding: var(--space-2) var(--space-2);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 65px;
    overflow: hidden;
}

.sidebar-logo-full {
    height: 90px;
    width: auto;
    transition: opacity var(--transition-fast);
}

/* Theme-based logo switching: dark theme shows dark logo, light theme shows light logo */
.sidebar-logo-for-dark {
    display: block;
}
.sidebar-logo-for-light {
    display: none;
}

[data-theme="light"] .sidebar-logo-for-dark {
    display: none;
}
[data-theme="light"] .sidebar-logo-for-light {
    display: block;
}

.sidebar-logo-icon {
    display: none;
    height: 36px;
    width: 36px;
    object-fit: contain;
}

/* Collapsed: show icon, hide full logo */
.sidebar.collapsed .sidebar-logo-full {
    display: none !important;
}

.sidebar.collapsed .sidebar-logo-icon {
    display: block;
}

.sidebar-logo {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-brand-sub {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    padding: var(--space-2) 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.nav-section {
    margin-bottom: var(--space-1);
}

.nav-section-title {
    padding: var(--space-4) var(--space-5) var(--space-2);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0.4375rem var(--space-5);
    margin: 1px var(--space-2);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 450;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
    position: relative;
}

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

.nav-link.active {
    background: var(--primary-ghost);
    color: var(--primary);
    font-weight: 500;
}

.nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 18px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.nav-link i {
    width: 16px;
    text-align: center;
    font-size: 0.8125rem;
    opacity: 0.6;
    flex-shrink: 0;
}

.nav-link.active i {
    opacity: 1;
}

/* Section-specific active colors - colored bar + tinted bg, white text */
/* nav-menu keeps its own teal color */
.nav-link.active.nav-menu {
    color: #fff;
    background: rgba(5, 139, 140, 0.15);
}
.nav-link.active.nav-menu::before {
    background: #058b8c;
}
.nav-link.active.nav-menu:hover {
    color: #fff;
}

/* All other sections - unified Spherely blue */
.nav-link.active.nav-platforms,
.nav-link.active.nav-config,
.nav-link.active.nav-renovation,
.nav-link.active.nav-monitoring,
.nav-link.active.nav-features {
    color: #fff;
    background: rgba(60, 170, 201, 0.15);
}
.nav-link.active.nav-platforms::before,
.nav-link.active.nav-config::before,
.nav-link.active.nav-renovation::before,
.nav-link.active.nav-monitoring::before,
.nav-link.active.nav-features::before {
    background: #3caac9;
}
.nav-link.active.nav-platforms:hover,
.nav-link.active.nav-config:hover,
.nav-link.active.nav-renovation:hover,
.nav-link.active.nav-monitoring:hover,
.nav-link.active.nav-features:hover {
    color: #fff;
}

/* Light theme */
[data-theme=light] .nav-link.active.nav-menu {
    color: var(--text-primary);
    background: rgba(5, 139, 140, 0.1);
}
[data-theme=light] .nav-link.active.nav-platforms,
[data-theme=light] .nav-link.active.nav-config,
[data-theme=light] .nav-link.active.nav-renovation,
[data-theme=light] .nav-link.active.nav-monitoring,
[data-theme=light] .nav-link.active.nav-features {
    color: var(--text-primary);
    background: rgba(60, 170, 201, 0.1);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-3) var(--space-3);
    padding-bottom: var(--space-5);
    border-top: 1px solid var(--border-color);
    overflow: hidden;
}

.sidebar-footer-actions {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.sidebar-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.sidebar-action-btn span {
    display: none;
}

.sidebar-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-interactive);
}

.sidebar-action-btn i {
    font-size: 0.8125rem;
}

.sidebar-action-logout {
    border-color: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.sidebar-action-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
}

/* Collapsed footer actions */
.sidebar.collapsed .sidebar-footer-actions {
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar.collapsed .sidebar-action-btn {
    padding: 0.4375rem;
}

.sidebar.collapsed .sidebar-action-btn span {
    display: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.user-avatar {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: #0a1628;
    flex-shrink: 0;
}

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

.user-name {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
}

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

/* Sidebar Collapse Toggle */
.sidebar-collapse-btn {
    position: absolute;
    top: 18px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: rgba(148, 163, 184, 0.25);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 101;
    color: var(--text-primary);
    font-size: 0.625rem;
    transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
    background: var(--text-primary);
    color: var(--bg-base);
    border-color: var(--text-primary);
}

/* Collapsed Sidebar State */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

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

.sidebar.collapsed .sidebar-header {
    padding: var(--space-3);
    justify-content: center;
}

.sidebar.collapsed .sidebar-logo-img {
    height: 24px;
}

.sidebar.collapsed .nav-section-title {
    display: none;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.5rem;
    margin: 1px var(--space-1);
}

.sidebar.collapsed .nav-link span {
    display: none;
}

.sidebar.collapsed .nav-link i {
    width: 20px;
    font-size: 0.9375rem;
}

.sidebar.collapsed .nav-link.active::before {
    left: 0;
}

.sidebar.collapsed .sidebar-footer {
    padding: var(--space-3) var(--space-2);
    padding-bottom: var(--space-5);
}

.sidebar.collapsed .user-info {
    flex-direction: column;
    gap: var(--space-2);
}

.sidebar.collapsed .user-info > div:not(.user-avatar) {
    display: none;
}

.sidebar.collapsed .user-name,
.sidebar.collapsed .user-role {
    display: none;
}

.sidebar.collapsed .user-avatar {
    width: 32px;
    height: 32px;
}

.sidebar.collapsed .btn-icon {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

.sidebar.collapsed .sidebar-collapse-btn {
    opacity: 1;
}

/* Tooltip for collapsed sidebar links */
.sidebar.collapsed .nav-link {
    position: relative;
}

.sidebar.collapsed .nav-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-xs);
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 200;
}

.sidebar.collapsed .nav-link:hover::after {
    opacity: 1;
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    transition: margin-left 0.2s ease;
}

/* Page Header */
.page-header {
    padding: var(--space-4) var(--space-8);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(14, 30, 54, 0.6);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 56px;
    gap: var(--space-4);
}

.page-title {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: 0;
}

.main-header {
    margin-bottom: 0;
}

.menu-toggle {
    display: none !important;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.125rem;
    cursor: pointer;
    padding: var(--space-2);
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex !important;
    }
}

/* Content Area */
.page-content {
    flex: 1;
    padding: var(--space-6) var(--space-8);
    padding-bottom: 4rem;
}

.content-area {
    flex: 1;
    padding: var(--space-6) var(--space-8);
    background: var(--bg-base);
}

/* ============================================================================
   TOGGLE SWITCH
   ============================================================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-hover);
    transition: var(--transition-fast);
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: var(--space-5);
    overflow: hidden;
    transition:
        border-color var(--transition-base),
        box-shadow var(--transition-base);
}

.card:last-child {
    margin-bottom: 0;
}

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

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.card-title i {
    font-size: 0.8125rem;
    opacity: 0.7;
}

.card-body {
    padding: var(--space-5);
}

/* ============================================================================
   STAT / KPI CARDS
   ============================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-1px);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: rgba(45, 212, 191, 0.1);
    color: var(--primary);
}
.stat-icon.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}
.stat-icon.warning {
    background: rgba(234, 179, 8, 0.1);
    color: var(--warning);
}
.stat-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

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

.stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font-family);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: -0.006em;
    user-select: none;
}

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

.btn-primary {
    background: var(--primary);
    color: #0a1628 !important;
    border-color: var(--primary);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-light);
    color: #0a1628 !important;
    border-color: var(--primary-light);
    box-shadow: 0 0 16px rgba(45, 212, 191, 0.15);
}

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

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

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

.btn-success:hover {
    background: #16a34a;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.15);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

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

.btn-warning {
    background: #f59e0b;
    color: #1a1a1a;
    border-color: #f59e0b;
    font-weight: 600;
}

.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-xs);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================================================
   FORMS
   ============================================================================ */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.006em;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    font-family: var(--font-family);
    background: var(--bg-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    line-height: 1.5;
}

.form-control:hover {
    border-color: var(--text-faint);
}

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

.form-control::placeholder {
    color: var(--text-faint);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%2364748B' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.625rem center;
    background-size: 1rem;
    padding-right: 2.25rem;
}

.form-row {
    display: flex;
    gap: var(--space-4);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ============================================================================
   TABLES
   ============================================================================ */
.table-container {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.table th,
.table td {
    padding: 0.625rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.table th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.5rem 0.75rem;
}

.table td {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

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

.table tbody tr:hover td {
    color: var(--text-primary);
}

.table td .cell-wrap {
    word-break: break-word;
    line-height: 1.3;
}

.table td .cell-truncate {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================================
   BADGES
   ============================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    box-sizing: border-box;
    line-height: 1.4;
}

/* Lead statuses */
.badge-new {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.18);
}
.badge-contacted {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.18);
}
.badge-qualified {
    background: rgba(45, 212, 191, 0.12);
    color: var(--primary);
    border: 1px solid rgba(45, 212, 191, 0.18);
}
.badge-appointment {
    background: rgba(139, 92, 246, 0.12);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.18);
}
.badge-converted {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.18);
}
.badge-lost {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.18);
}
.badge-not_qualified {
    background: rgba(107, 114, 128, 0.12);
    color: #9ca3af;
    border: 1px solid rgba(107, 114, 128, 0.18);
}

/* Appointment statuses */
.badge-pending {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.18);
}
.badge-scheduled {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.18);
}
.badge-confirmed {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.18);
}
.badge-done,
.badge-completed {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.18);
}
.badge-cancelled {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.18);
}
.badge-no_show {
    background: rgba(107, 114, 128, 0.12);
    color: #9ca3af;
    border: 1px solid rgba(107, 114, 128, 0.18);
}

/* Campaign statuses */
.badge-active {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.18);
}
.badge-paused {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.18);
}

/* Generic badges */
.badge-primary {
    background: rgba(45, 212, 191, 0.12);
    color: var(--primary);
    border: 1px solid rgba(45, 212, 191, 0.18);
}
.badge-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ============================================================================
   ALERTS
   ============================================================================ */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.8125rem;
    font-weight: 500;
}

.alert-success {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.18);
    color: var(--success);
}
.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.18);
    color: var(--danger);
}
.alert-warning {
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.18);
    color: var(--warning);
}
.alert-info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.18);
    color: var(--info);
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 360px;
    backdrop-filter: blur(12px);
    font-size: 0.8125rem;
}

.toast-success {
    border-left: 3px solid var(--success);
}
.toast-danger {
    border-left: 3px solid var(--danger);
}
.toast-warning {
    border-left: 3px solid var(--warning);
}

@keyframes toast-in {
    from {
        transform: translateX(100%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* ============================================================================
   LOGIN PAGE
   ============================================================================ */
.login-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: "";
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(45, 212, 191, 0.05) 0%,
        transparent 70%
    );
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: var(--space-10);
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.login-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto var(--space-5);
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--space-2);
    letter-spacing: -0.025em;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* ============================================================================
   EMPTY STATES
   ============================================================================ */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: var(--space-4);
    color: var(--text-faint);
}

.empty-state h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

/* ============================================================================
   PAGINATION
   ============================================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    margin-top: var(--space-6);
}

.pagination-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--primary);
    color: #0a1628;
    border-color: var(--primary);
    font-weight: 600;
}

/* ============================================================================
   LINKS
   ============================================================================ */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

/* ============================================================================
   SCROLLBAR
   ============================================================================ */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-faint);
}

/* ============================================================================
   HTMX & LOADING
   ============================================================================ */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}
.htmx-request.htmx-indicator {
    display: inline-block;
}

.spinner {
    animation: spin 0.8s linear infinite;
}

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

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */
.flex {
    display: flex;
}
.flex-col {
    flex-direction: column;
}
.items-center {
    align-items: center;
}
.justify-between {
    justify-content: space-between;
}
.gap-1 {
    gap: var(--space-1);
}
.gap-2 {
    gap: var(--space-2);
}
.gap-3 {
    gap: var(--space-3);
}
.gap-4 {
    gap: var(--space-4);
}
.mt-2 {
    margin-top: var(--space-2);
}
.mt-3 {
    margin-top: var(--space-6);
}
.mt-4 {
    margin-top: var(--space-4);
}
.mb-2 {
    margin-bottom: var(--space-2);
}
.mb-3 {
    margin-bottom: var(--space-3);
}
.mb-4 {
    margin-bottom: var(--space-4);
}
.text-center {
    text-align: center;
}
.text-muted {
    color: var(--text-muted);
}
.text-success {
    color: var(--success);
}
.text-danger {
    color: var(--danger);
}
.text-primary {
    color: var(--primary);
}

/* ============================================================================
   MOBILE RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
    .sidebar {
        z-index: 1001;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

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

    .page-header {
        padding: var(--space-3) var(--space-4);
        flex-wrap: wrap;
        min-height: 48px;
    }

    .page-content,
    .content-area {
        padding: var(--space-2) var(--space-2);
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-3);
    }

    .table th,
    .table td {
        padding: 0.5rem 0.4rem;
        font-size: 0.75rem;
    }

    .header-actions {
        gap: var(--space-2);
    }

    .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }

    .card-body {
        padding: var(--space-4);
    }

    .card-header {
        padding: var(--space-3) var(--space-4);
    }
}

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

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

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

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: rgba(128, 128, 128, 0.12);
    border: 1px solid rgba(128, 128, 128, 0.2);
    color: var(--text-primary);
    font-size: 1.0625rem;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-xs);
    transition:
        background var(--transition-fast),
        border-color var(--transition-fast);
}

.mobile-menu-toggle:hover {
    background: rgba(128, 128, 128, 0.2);
    border-color: rgba(128, 128, 128, 0.35);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: inline-flex;
    }
}

/* ============================================================================
   GRID LAYOUTS
   ============================================================================ */
.dashboard-grid {
    display: grid;
    gap: var(--space-6);
}

.grid {
    display: grid;
    gap: var(--space-6);
}

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

@media (max-width: 1024px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   WHATSAPP BUTTON
   ============================================================================ */
.btn-whatsapp,
.btn-primary .fa-whatsapp,
.btn-icon .fa-whatsapp {
    color: white !important;
}

.btn-icon:has(.fa-whatsapp) {
    background: #25d366 !important;
    border-color: #25d366 !important;
    color: white !important;
}

.btn-icon:has(.fa-whatsapp):hover {
    background: #1da851 !important;
    border-color: #1da851 !important;
}

/* ============================================================================
   USERS MANAGEMENT
   ============================================================================ */
.users-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

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

.users-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow: auto;
    margin: var(--space-4);
    box-shadow: var(--shadow-lg);
}

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

.users-modal-header h3 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
}

.users-modal-body {
    padding: var(--space-5);
}

.users-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
}

/* Desktop table */
.users-table-desktop {
    display: block;
}
/* Mobile cards */
.users-cards-mobile {
    display: none;
}

.user-card {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    transition: border-color var(--transition-fast);
}

.user-card:hover {
    border-color: var(--border-strong);
}

.user-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.user-card-info {
    flex: 1;
}

.user-card-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.user-card-role {
    margin-top: var(--space-1);
}

.user-card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.user-card-details span {
    display: block;
}
.user-card-details strong {
    color: var(--text-primary);
}

.user-card-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

/* Users responsive */
@media (max-width: 768px) {
    .users-table-desktop {
        display: none !important;
    }
    .users-cards-mobile {
        display: block !important;
    }
    .users-modal-content {
        max-width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        margin: 0;
    }
    .users-header-mobile {
        flex-direction: column;
        gap: var(--space-4);
        align-items: flex-start !important;
    }
    .users-header-mobile .btn {
        width: 100%;
    }
}

@media screen and (max-width: 768px) {
    .settings-section .users-table-desktop,
    .card-body .users-table-desktop,
    div.users-table-desktop {
        display: none !important;
        visibility: hidden !important;
    }
    .settings-section .users-cards-mobile,
    .card-body .users-cards-mobile,
    div.users-cards-mobile {
        display: block !important;
        visibility: visible !important;
    }
}

/* ============================================================================
   SETTINGS — Hide tabs (navigation via sidebar)
   ============================================================================ */
.tabs {
    display: none !important;
}

@media (max-width: 768px) {
    .settings-section,
    .card-body {
        padding: var(--space-4) !important;
    }
    .card {
        border-radius: var(--radius);
    }
}

/* Light theme - KPI card icons: more visible */
[data-theme="light"] .kpi-icon.blue {
    background: rgba(59, 130, 246, 0.25);
    color: #1d4ed8;
}
[data-theme="light"] .kpi-icon.green {
    background: rgba(34, 197, 94, 0.25);
    color: #15803d;
}
[data-theme="light"] .kpi-icon.orange {
    background: rgba(245, 158, 11, 0.25);
    color: #b45309;
}
[data-theme="light"] .kpi-icon.purple {
    background: rgba(139, 92, 246, 0.25);
    color: #6d28d9;
}
[data-theme="light"] .kpi-icon.teal {
    background: rgba(45, 212, 191, 0.25);
    color: #0d9488;
}
[data-theme="light"] .kpi-icon.red {
    background: rgba(239, 68, 68, 0.25);
    color: #b91c1c;
}
