/* ==========================================================================
   Enterprise SaaS Design System (Premium Zoho & Salesforce Inspired)
   ========================================================================== */

:root {
    /* Color Palette - Premium HSL Indigo/Violet 2026 Theme */
    --bg-main: #f8fafc;          /* Sleek ultra-light slate */
    --bg-surface: rgba(255, 255, 255, 0.7); /* Translucent glass surface */
    --bg-sidebar: #090d16;       /* Deep obsidian dark */
    --bg-sidebar-hover: #131929;
    --border-color: rgba(15, 23, 42, 0.05); /* Precision thin borders */
    
    /* Variable design system tokens for light / dark toggle */
    --bg-card: #ffffff;
    --bg-input: #f8fafc;
    --bg-th: #f1f5f9;
    --bg-hover: #f8fafc;
    --bg-topbar: rgba(248, 250, 252, 0.75);
    --bg-drawer: rgba(255, 255, 255, 0.85);
    
    /* Typography colors */
    --text-primary: #0f172a;     /* Deep slate for readability */
    --text-secondary: #475569;   /* Slate gray */
    --text-muted: #94a3b8;       /* Placeholders */
    --text-sidebar: #cbd5e1;     /* Contrast text on dark sidebar */
    
    /* Branding Colors */
    --accent-primary: #6366f1;   /* Violet Indigo */
    --accent-hover: #4f46e5;     /* Deep Indigo */
    --accent-light: rgba(99, 102, 241, 0.06);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 50%, #312e81 100%);
    --accent-sidebar-gradient: linear-gradient(180deg, #090d16 0%, #020617 100%);
    --ambient-glow: radial-gradient(circle at 80% 0%, rgba(99, 102, 241, 0.05) 0%, transparent 50%);
    
    /* Semantic Status Colors (Highly curated) */
    --color-success: #10b981;    /* Emerald */
    --color-success-bg: rgba(16, 185, 129, 0.06);
    --color-success-border: rgba(16, 185, 129, 0.12);

    --color-warning: #f59e0b;    /* Amber */
    --color-warning-bg: rgba(245, 158, 11, 0.06);
    --color-warning-border: rgba(245, 158, 11, 0.12);

    --color-danger: #f43f5e;     /* Rose Red */
    --color-danger-bg: rgba(244, 63, 94, 0.06);
    --color-danger-border: rgba(244, 63, 94, 0.12);

    --color-info: #0ea5e9;       /* Sky Blue */
    --color-info-bg: rgba(14, 165, 233, 0.06);
    --color-info-border: rgba(14, 165, 233, 0.12);
    
    --color-neutral: #64748b;    
    --color-neutral-bg: rgba(100, 116, 139, 0.06);

    /* Layout & Shadow Tokens (Modern Softness) */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --border-radius-lg: 14px;    /* Fine rounded */
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); /* Ultra-smooth ease-out */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.02);
    --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 20px 48px -15px rgba(0, 0, 0, 0.08), 0 1px 5px rgba(0, 0, 0, 0.02);
}

body.dark-theme {
    /* Color Palette - Obsidian Slate Dark Theme */
    --bg-main: #020617;          /* Obsidian void background */
    --bg-surface: rgba(15, 23, 42, 0.55); /* Obsidian glass */
    --border-color: rgba(59, 130, 246, 0.12); /* Translucent faint blue outline */
    
    /* Variable overrides */
    --bg-card: #1a2744;          /* Sleek card base with more visible lift */
    --bg-input: #12182c;
    --bg-th: #040816;
    --bg-hover: #12182c;
    --bg-topbar: rgba(2, 6, 23, 0.75);
    --bg-drawer: rgba(9, 13, 31, 0.85);
    
    /* Typography colors */
    --text-primary: #f8fafc;     /* Clear high contrast text */
    --text-secondary: #94a3b8;   /* Slate blue */
    --text-muted: #475569;
    --text-sidebar: #cbd5e1;
    
    --ambient-glow: radial-gradient(circle at 80% 0%, rgba(99, 102, 241, 0.15) 0%, transparent 60%);
    
    /* Semantic Status Colors (Highly visible for dark background) */
    --color-success: #34d399;    
    --color-success-bg: rgba(52, 211, 153, 0.06);
    --color-success-border: rgba(52, 211, 153, 0.15);
 
    --color-warning: #fbbf24;    
    --color-warning-bg: rgba(251, 191, 36, 0.06);
    --color-warning-border: rgba(251, 191, 36, 0.15);
 
    --color-danger: #fb7185;     
    --color-danger-bg: rgba(251, 113, 133, 0.06);
    --color-danger-border: rgba(251, 113, 133, 0.15);
 
    --color-info: #38bdf8;       
    --color-info-bg: rgba(56, 189, 248, 0.06);
    --color-info-border: rgba(56, 189, 248, 0.15);
    
    --color-neutral: #94a3b8;
    --color-neutral-bg: rgba(148, 163, 184, 0.08);
    
    /* Shadow glow adjustments for dark mode */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   Core Reset & General Layout
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow: auto;
    scroll-behavior: smooth;
}

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    background-image: var(--ambient-glow);
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
    overflow: auto;
}

/* Global Form Controls Styling for Theme Adaptability */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="time"],
input[type="date"],
select,
textarea {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-md);
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="time"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15) !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==========================================================================
   Sidebar Navigation
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--accent-sidebar-gradient);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

.logo-container {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.logo-container h2 {
    font-size: 18px;
    color: white;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.nav-menu {
    padding: 24px 16px;
    flex: 1;
    overflow-y: auto;
}

.nav-group {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 10px;
    padding-left: 12px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--border-radius-md);
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    margin-bottom: 6px;
}

.nav-item i {
    font-size: 18px;
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    transform: translateX(4px);
}

.nav-item:hover i {
    color: #ffffff;
    transform: scale(1.1);
}

.nav-item.active {
    background: #6366f1;
    color: #ffffff;
    border: 1px solid #4f46e5;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    border-radius: var(--border-radius-md);
    margin-left: 0;
    padding-left: 14px;
    font-weight: 600;
}

.nav-item.active i {
    color: #ffffff;
}


/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.01);
}

.search-container {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 8px 16px;
    width: 380px;
    transition: var(--transition);
}

.search-container:focus-within {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.search-container i {
    color: var(--text-secondary);
    margin-right: 10px;
    font-size: 16px;
}

.search-container input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
}

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

.topbar-actions i {
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.topbar-actions i:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(15, 98, 254, 0.3);
}

/* ==========================================================================
   Dashboard Module
   ========================================================================== */
.dashboard-wrapper {
    padding: 32px;
}

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

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* Button UI Components - Modernized with gradients & micro-shadows */
.primary-btn {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
    transition: var(--transition);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(1px);
}

.primary-btn:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

/* Button loading spinner */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}
.btn-loading > *:not(.btn-spinner) {
    visibility: hidden;
}
.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    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); }
}

.secondary-btn {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.secondary-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
    transform: translateY(-1px);
}

/* Metrics Grid styling - Lift transition and accent shadow glows */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: var(--shadow-lg);
    border-color: rgba(99, 102, 241, 0.2);
}

.metric-info h3 {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    margin-bottom: 8px;
}

.metric-info h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.metric-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.bg-blue { background: rgba(99, 102, 241, 0.08); color: var(--accent-primary); }
.bg-green { background: var(--color-success-bg); color: var(--color-success); }
.bg-orange { background: var(--color-warning-bg); color: var(--color-warning); }
.bg-red { background: var(--color-danger-bg); color: var(--color-danger); }

/* Dashboard layout grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 32px;
    margin-bottom: 32px;
}

.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.card-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

/* Collection progress widget styling - Modern gradient progress */
.collection-progress-container {
    padding: 8px 0;
}

.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.progress-bar-bg {
    flex: 1;
    height: 10px;
    background: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 5px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label {
    font-weight: 700;
    font-size: 18px;
    color: var(--accent-primary);
    min-width: 50px;
    text-align: right;
}

.analytics-subtext {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Compliance tracker dashboard stats */
.compliance-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.compliance-stat {
    text-align: center;
    padding: 20px;
    border-radius: var(--border-radius-md);
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.compliance-stat:hover {
    background: var(--bg-card);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-number {
    display: block;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.stat-number.text-green { color: var(--color-success); }
.stat-number.text-orange { color: var(--color-warning); }

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

/* ==========================================================================
   Data Toolbar and Filter Controls
   ========================================================================== */
.data-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-toolbar {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-th);
    gap: 16px;
}

.toolbar-search {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 6px 14px;
    width: 320px;
    transition: var(--transition);
}

.toolbar-search:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.toolbar-search i {
    color: var(--text-secondary);
    margin-right: 8px;
    font-size: 14px;
}

.toolbar-search input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 13px;
    font-family: inherit;
    background: transparent;
    color: var(--text-primary);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-actions select {
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: var(--border-radius-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-input);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.toolbar-actions select:hover {
    border-color: var(--text-muted);
}

.toolbar-actions select:focus {
    border-color: var(--accent-primary);
}

/* ==========================================================================
   Premium Table Design
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 16px 24px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    background: var(--bg-th);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

td {
    padding: 16px 24px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    transition: background-color 0.2s ease;
}

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

tr:last-child td {
    border-bottom: none;
}

/* Table helper layouts */
.client-name-cell {
    display: flex;
    flex-direction: column;
}

.client-name {
    font-weight: 600;
    color: var(--accent-primary);
    cursor: pointer;
    transition: var(--transition);
}

.client-name:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.client-id {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: monospace;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    padding: 1px 6px;
    border-radius: 4px;
    width: fit-content;
    margin-top: 4px;
}

.client-contact-cell {
    font-size: 13px;
    color: var(--text-secondary);
}

.client-contact-cell i {
    margin-right: 4px;
    font-size: 14px;
}

.client-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.financial-cell {
    font-weight: 600;
    font-size: 14px;
}

.pending-text {
    color: var(--color-danger);
    font-size: 12px;
    font-weight: 500;
    display: block;
    margin-top: 2px;
}

.settled-text {
    color: var(--color-success);
    font-size: 12px;
    font-weight: 500;
    display: block;
    margin-top: 2px;
}

/* Status Badges - Rounded and clean */
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.status-active {
    background: var(--color-info-bg);
    color: var(--color-info);
    border-color: var(--color-info-border);
}
.status-active::before { background: var(--color-info); }

.status-paid {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-color: var(--color-success-border);
}
.status-paid::before { background: var(--color-success); }

.status-pending {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border-color: var(--color-warning-border);
}
.status-pending::before { background: var(--color-warning); }

.status-overdue {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-color: var(--color-danger-border);
}
.status-overdue::before { background: var(--color-danger); }

.status-waived {
    background: var(--color-neutral-bg);
    color: var(--color-neutral);
    border-color: var(--border-color);
}
.status-waived::before { background: var(--color-neutral); }

.status-inactive {
    background: var(--color-neutral-bg);
    color: var(--color-neutral);
    border-color: var(--border-color);
}
.status-inactive::before { background: var(--color-neutral); }

/* Table action buttons */
.row-action-btn {
    color: var(--accent-primary);
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
}

.row-action-btn:hover {
    background: var(--accent-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.row-action-btn.danger {
    color: var(--color-danger);
    border-color: var(--color-danger-border);
}

.row-action-btn.danger:hover {
    background: var(--color-danger);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 10px rgba(244, 63, 94, 0.2);
}

.icon-action-btn {
    color: var(--text-secondary);
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-action-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.icon-action-btn.whatsapp-btn:hover {
    color: #25d366;
    background: rgba(37, 211, 102, 0.1);
}

/* Compact dashboard table formatting */
.compact-table td {
    padding: 12px 20px;
    font-size: 13px;
}
.compact-table th {
    padding: 10px 20px;
}

/* ==========================================================================
   Slide-out Detail Drawer
   ========================================================================== */
.drawer-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 999;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: -520px;
    width: 500px;
    height: 100vh;
    background: var(--bg-drawer);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 1px solid var(--border-color);
    box-shadow: -12px 0 40px rgba(99, 102, 241, 0.08);
    z-index: 1000;
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.drawer.active {
    right: 0;
}

.drawer-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-th);
}

.drawer-title h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.drawer-id {
    font-size: 11px;
    color: var(--text-secondary);
    font-family: monospace;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.close-drawer {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    transition: var(--transition);
}

.close-drawer:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.drawer-content {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

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

.drawer-section h3 {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
    margin-bottom: 16px;
}

.drawer-divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
}

/* Slide-out Drawer Tab Navigation styles */
.drawer-tabs {
    display: flex;
    border-bottom: 1.5px solid var(--border-color);
    margin-bottom: 20px;
    background: var(--bg-th);
    padding: 0 4px;
    gap: 4px;
    border-radius: 8px;
}
.drawer-tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 4px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    outline: none;
}
.drawer-tab-btn:hover {
    color: var(--text-primary);
}
.drawer-tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}
.drawer-tab-content {
    display: none;
}
.drawer-tab-content.active {
    display: block;
}

/* Profile details grid styling */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.profile-item {
    font-size: 13px;
    color: var(--text-primary);
}

.profile-item strong {
    display: block;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 2px;
}

/* Compliance Badges Layout */
.compliance-badges {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.compliance-badge-item {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.compliance-badge-item span {
    font-size: 13px;
    font-weight: 600;
}

.compliance-status {
    font-size: 11px !important;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.comp-filed { background: var(--color-success-bg); color: var(--color-success); }
.comp-pending { background: var(--color-warning-bg); color: var(--color-warning); }
.comp-na { background: var(--color-neutral-bg); color: var(--color-neutral); }

/* Timeline vertical checklist */
.timeline {
    position: relative;
    padding-left: 28px;
}

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

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--border-color);
    z-index: 1;
}

.timeline-item.paid::before {
    border-color: var(--color-success);
    background: var(--color-success);
}

.timeline-item.pending::before {
    border-color: var(--color-warning);
    background: var(--bg-card);
}

.timeline-item.overdue::before {
    border-color: var(--color-danger);
    background: var(--color-danger);
}

.timeline-item.waived::before {
    border-color: var(--color-neutral);
    background: var(--color-neutral);
}

.timeline-item h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.timeline-item p {
    font-size: 12px;
    color: var(--text-secondary);
}

.amount-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--border-radius-sm);
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
}

.amount-badge.paid { background: var(--color-success-bg); color: var(--color-success); }
.amount-badge.pending { background: var(--color-warning-bg); color: var(--color-warning); }
.amount-badge.overdue { background: var(--color-danger-bg); color: var(--color-danger); }
.amount-badge.waived { background: var(--color-neutral-bg); color: var(--color-neutral); }

/* ==========================================================================
   Reports / Analytics View Layout
   ========================================================================== */
.reports-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 32px;
    margin-bottom: 32px;
}

.report-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.report-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

/* Custom CSS Segment Bar Charts */
.segment-chart-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chart-bar-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chart-bar-label-grid {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.chart-bar-bg {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
}

/* Aging receivables summary card slots */
.aging-bar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    text-align: center;
}

.aging-slot {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px 16px;
    transition: var(--transition);
}

.aging-slot:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.aging-duration {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 12px;
}

.aging-slot h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.aging-slot:nth-child(1) h2 { color: var(--accent-primary); }
.aging-slot:nth-child(2) h2 { color: var(--color-warning); }
.aging-slot:nth-child(3) h2 { color: var(--color-danger); }

.aging-count {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1001;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -43%);
    width: 480px;
    max-height: 90vh;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.close-modal {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 50%;
    display: flex;
    transition: var(--transition);
}

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

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

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

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

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.modal-footer {
    padding: 18px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-th);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* ==========================================================================
   Animations & Transition Effects
   ========================================================================== */
.view-section {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.view-section.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

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

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* Compliance Dropdown Selectors */
.compliance-select {
    border: none;
    outline: none;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    appearance: none; /* Hide default browser arrow */
    -webkit-appearance: none;
    text-align: center;
}

.compliance-select.comp-filed {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.compliance-select.comp-pending {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.compliance-select:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* ==========================================================================
   AI Assistant Chatbot Widgets
   ========================================================================== */
.ai-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
    z-index: 1000;
    transition: var(--transition);
}

.ai-chat-toggle:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5);
}

.ai-pulse {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid white;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: ai-pulse-anim 2s infinite;
}

@keyframes ai-pulse-anim {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.ai-chat-card {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 360px;
    height: 460px;
    max-height: calc(100vh - 140px);
    max-width: calc(100vw - 48px);
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.18);
    border: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    transform: translateY(20px);
    opacity: 0;
    /* Allow user to drag the bottom-left corner to resize */
    resize: both;
    min-width: 280px;
    min-height: 320px;
}

/* Compact mode toggle: clicking the minimize button shrinks card to a small bar */
.ai-chat-card.compact {
    height: 56px !important;
    min-height: 56px;
    overflow: hidden;
}
.ai-chat-card.compact .ai-chat-body,
.ai-chat-card.compact .ai-chat-footer {
    display: none;
}

/* On narrow screens, make it dock to bottom and use full width minus margin */
@media (max-width: 768px) {
    .ai-chat-card {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 90px;
        height: 60vh;
    }
}

.ai-chat-card.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.ai-chat-header {
    padding: 16px 20px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-chat-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #60a5fa;
}

.ai-chat-header-title h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    letter-spacing: 0.3px;
    color: white;
}

.ai-status {
    font-size: 11px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
}

.ai-chat-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    transition: var(--transition);
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-main);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.chat-message.bot {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.chat-message.user {
    align-self: flex-end;
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 12px;
}

.chat-message th, .chat-message td {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    text-transform: none;
    font-weight: normal;
    letter-spacing: normal;
    font-size: 11px;
}

.chat-message th {
    background: var(--bg-th);
    font-weight: 600;
}

.chat-message .profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-light);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    padding: 6px 12px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
    margin-top: 10px;
    transition: var(--transition);
}

.chat-message .profile-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
}

.suggest-tag {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.suggest-tag:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-light);
}

.ai-chat-footer {
    padding: 14px 20px;
    background: var(--bg-th);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-footer input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    background: var(--bg-input);
    color: var(--text-primary);
}

.ai-chat-footer input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.ai-chat-footer button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.ai-chat-footer button:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

/* Inline Installment Editing Styles */
.edit-inst-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm, 4px);
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-input);
    outline: none;
    transition: var(--transition);
}

.edit-inst-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Settings view grid layout and card headers */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

.card-icon-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.card-icon-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==========================================================================
   Print Styles (@media print)
   ========================================================================== */
@media print {
    /* Hide layout chrome like sidebar, topbar, buttons, search, and float buttons */
    .sidebar,
    .topbar,
    .primary-btn,
    .secondary-btn,
    .row-action-btn,
    .icon-action-btn,
    .table-toolbar,
    .page-header div,
    .ai-chat-bubble-container,
    .settings-grid,
    .ai-chat-widget,
    #ai-assistant-toggle-btn,
    .no-print,
    .page-actions,
    .btn,
    button,
    input,
    select,
    .drawer,
    .drawer-overlay,
    .modal,
    .modal-overlay,
    .view-section:not(.active) {
        display: none !important;
    }

    /* Reset main content alignment */
    body {
        background: white !important;
        color: black !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .dashboard-wrapper {
        padding: 0 !important;
    }

    .page-header h1 {
        font-size: 24px !important;
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #333;
        padding-bottom: 8px;
    }

    /* Table styling for print */
    .data-table-container {
        border: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    th, td {
        border: 1px solid #ddd !important;
        padding: 8px !important;
        font-size: 11px !important;
        color: black !important;
    }

    th {
        background-color: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Status badge adjustments */
    .status-badge {
        border: 1px solid #000 !important;
        background: transparent !important;
        color: black !important;
        padding: 2px 6px !important;
        border-radius: 4px !important;
        font-size: 9px !important;
    }
}





/* ===== Toggle Switch (used in client drawer) ===== */
.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-primary, #6366f1) !important;
}
.toggle-switch .toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: .2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}
.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Muted client badge in lists */
.muted-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
    margin-left: 6px;
}


/* ===== Modern Toast Notifications ===== */
#toastContainer {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 380px;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transform: translateX(120%) scale(0.96);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
    position: relative;
    overflow: hidden;
}

.toast.show {
    transform: translateX(0) scale(1);
    opacity: 1;
}

.toast.hide {
    transform: translateX(120%) scale(0.96);
    opacity: 0;
}

/* Accent strip on the left edge */
.toast::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}
.toast-success::before { background: linear-gradient(180deg, #10b981, #059669); }
.toast-error::before   { background: linear-gradient(180deg, #ef4444, #dc2626); }
.toast-warning::before { background: linear-gradient(180deg, #f59e0b, #d97706); }
.toast-info::before    { background: linear-gradient(180deg, #6366f1, #4f46e5); }

.toast-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.toast-success .toast-icon { background: linear-gradient(135deg, #10b981, #059669); }
.toast-error   .toast-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast-warning .toast-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.toast-info    .toast-icon { background: linear-gradient(135deg, #6366f1, #4f46e5); }

.toast-content {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.toast-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
    white-space: pre-line;
    word-wrap: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 2px;
    line-height: 1;
    transition: color 0.15s;
}
.toast-close:hover { color: var(--text-primary); }

/* Progress bar that shows time-to-dismiss */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: left;
}
.toast-success .toast-progress { background: #10b981; }
.toast-error   .toast-progress { background: #ef4444; }
.toast-warning .toast-progress { background: #f59e0b; }
.toast-info    .toast-progress { background: #6366f1; }

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ===== Modern Confirm Dialog ===== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.confirm-overlay.show { opacity: 1; pointer-events: auto; }

.confirm-box {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px;
    width: 420px;
    max-width: calc(100vw - 48px);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transform: scale(0.92) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}
.confirm-overlay.show .confirm-box { transform: scale(1) translateY(0); }

.confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: #fff;
}
.confirm-icon.warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.confirm-icon.danger  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.confirm-icon.info    { background: linear-gradient(135deg, #6366f1, #4f46e5); }

.confirm-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.confirm-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 24px;
    white-space: pre-line;
}
.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.confirm-btn {
    padding: 10px 24px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}
.confirm-btn-cancel {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.confirm-btn-cancel:hover { background: var(--border-color); }
.confirm-btn-confirm {
    background: var(--accent-primary, #6366f1);
    color: #fff;
}
.confirm-btn-confirm:hover { filter: brightness(1.08); }
.confirm-btn-confirm.danger { background: #dc2626; }
.confirm-btn-confirm.danger:hover { background: #b91c1c; }


/* ===== Clickable metric cards ===== */
.clickable-metric {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}
.clickable-metric:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}
.clickable-metric::after {
    content: "View →";
    position: absolute;
    bottom: 10px;
    right: 14px;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-primary, #6366f1);
    opacity: 0;
    transition: opacity 0.15s;
}
.clickable-metric:hover::after { opacity: 0.7; }

/* ===== Metric detail slide-over panel ===== */
.metric-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.metric-detail-overlay.active { opacity: 1; pointer-events: auto; }

.metric-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 560px;
    max-width: calc(100vw - 40px);
    background: var(--bg-drawer);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.2);
    border-left: 1px solid var(--border-color);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}
.metric-detail-panel.active { transform: translateX(0); }

.metric-detail-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-th);
    color: var(--text-primary);
}
.metric-detail-header h2 { color: var(--text-primary); margin: 0; font-size: 18px; }
.metric-detail-header .secondary-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.metric-detail-header .secondary-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.metric-detail-header .close-drawer { color: var(--text-secondary); }

.metric-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}
.metric-detail-body table { width: 100%; border-collapse: collapse; }
.metric-detail-body th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-th);
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--border-color);
}
.metric-detail-body td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}
.metric-detail-body tr:hover td { background: var(--bg-hover); }

/* Reminder Tab Buttons */
.reminder-tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.reminder-tab-btn:hover {
    color: var(--text-primary);
}
.reminder-tab-btn.active {
    border-bottom: 3px solid var(--accent-primary);
    color: var(--text-primary);
}

/* ==========================================================================
   Campaign and Reminder Search/Filter Core Form Controls
   ========================================================================== */
#campaignName,
#campaignAudience,
#campaignChannel,
#campaignTemplate,
#campaignPrompt,
#campaignTemplate:focus,
#clientsSearch,
#clientsFilter {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--border-radius-md) !important;
    outline: none !important;
    font-family: inherit;
    transition: var(--transition);
}

#campaignName:focus,
#campaignAudience:focus,
#campaignChannel:focus,
#campaignTemplate:focus,
#campaignPrompt:focus,
#clientsSearch:focus,
#clientsFilter:focus {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

/* Disable inner/outer spin button scrollers on number inputs */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}
input[type="number"] {
    -moz-appearance: textfield !important;
}


/* ==========================================================================
   Hybrid Live Chat Layout
   ========================================================================== */
#view-live-chat {
    padding: 24px 32px 32px 32px;
    height: calc(100vh - var(--topbar-height));
    box-sizing: border-box;
}

.chat-wrapper {
    display: grid;
    grid-template-columns: 320px 1fr 300px;
    height: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    box-sizing: border-box;
}

/* Sidebar List */
.chat-sidebar {
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    height: 100%;
    min-height: 0;
}

.sidebar-search {
    padding: 15px;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search input {
    width: 100%;
    padding: 10px 12px 10px 35px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    transition: var(--transition);
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.sidebar-search .search-icon {
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--accent-light);
    border-left: 4px solid var(--accent-primary);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
}

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

.chat-details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-details-header h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.chat-time {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-snippet-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.chat-snippet {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.ai-badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.ai-badge.active {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-success-border);
}

.ai-badge.manual {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border: 1px solid var(--color-warning-border);
}

/* Chat Main Panel */
.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.client-title-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 2px 0;
}

.client-phone-sub {
    font-size: 12px;
    color: var(--text-secondary);
}

.toggle-ai-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Toggle Switch Styling */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    cursor: pointer;
}

.switch-toggle input {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    cursor: pointer;
    margin: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 34px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

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

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

/* WhatsApp Theme Variables */
:root {
    --wa-bg-inbound: #ffffff;
    --wa-text-inbound: #111b21;
    --wa-bg-outbound: #d9fdd3;
    --wa-text-outbound: #111b21;
    --wa-meta-color: #667781;
    --wa-tick-blue: #53bdeb;
}

body.dark-theme {
    --wa-bg-inbound: #202c33;
    --wa-text-inbound: #e9edef;
    --wa-bg-outbound: #005c4b;
    --wa-text-outbound: #e9edef;
    --wa-meta-color: #8696a0;
    --wa-tick-blue: #53bdeb;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-anchor: auto; /* Dynamic height scroll-jumping prevention */
    background-color: #efeae2 !important; /* Classic WhatsApp light background */
    background-image: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 0) !important;
    background-size: 16px 16px !important;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-media-attachment, .chat-img-preview, .message-bubble img {
    min-height: 140px;
    max-height: 320px;
    width: auto;
    max-width: 100%;
    aspect-ratio: auto;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
}

body.dark-theme .chat-messages {
    background-color: #0b141a !important; /* Classic WhatsApp dark background */
    background-image: radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 0) !important;
}

.empty-chat-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

/* WhatsApp Date Dividers */
.chat-date-header-row {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 16px 0 8px 0;
    pointer-events: none;
}
.chat-date-header-badge {
    background: #ffffff;
    color: #54656f;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}
body.dark-theme .chat-date-header-badge {
    background: #182229;
    color: #8696a0;
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* Message Bubbles */
.message-bubble-row {
    display: flex;
    width: 100%;
    margin-bottom: 2px;
}

.message-bubble-row.inbound {
    justify-content: flex-start;
}

.message-bubble-row.outbound,
.message-bubble-row.outbound_manual,
.message-bubble-row.outbound_reminder {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px 6px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.45;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
    word-break: break-word;
}

.message-bubble-row.inbound .message-bubble {
    background: var(--wa-bg-inbound);
    color: var(--wa-text-inbound);
    border-top-left-radius: 0;
}

.message-bubble-row.outbound .message-bubble,
.message-bubble-row.outbound_manual .message-bubble,
.message-bubble-row.outbound_reminder .message-bubble {
    background: var(--wa-bg-outbound);
    color: var(--wa-text-outbound);
    border-top-right-radius: 0;
}

.message-content {
    margin-bottom: 2px;
    white-space: pre-wrap;
}

.message-meta {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    float: right;
    gap: 4px;
    font-size: 10px;
    color: var(--wa-meta-color);
    margin-left: 12px;
    margin-top: 4px;
    user-select: none;
}

body:not(.dark-theme) .message-bubble-row.outbound .message-meta,
body:not(.dark-theme) .message-bubble-row.outbound_manual .message-meta,
body:not(.dark-theme) .message-bubble-row.outbound_auto .message-meta {
    color: rgba(255, 255, 255, 0.9);
}

body:not(.dark-theme) .message-bubble-row.outbound_reminder .message-meta {
    color: #475569;
}

/* Ticks style */
.message-status-tick {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
}
.message-status-tick.read {
    color: var(--wa-tick-blue);
}
.message-status-tick.sent,
.message-status-tick.delivered {
    color: inherit;
    opacity: 0.6;
}

/* Tags in Bubbles */
.bubble-tag {
    font-size: 8.5px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1.5px 4.5px;
    border-radius: 4px;
    letter-spacing: 0.3px;
    border: none;
}
.bubble-tag.mira {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}
.bubble-tag.agent {
    background: rgba(245, 158, 11, 0.12);
    color: var(--color-warning);
}
.bubble-tag.reminder {
    background: rgba(14, 165, 233, 0.12);
    color: var(--color-info);
}

/* Chat Input Footer */
.chat-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-footer textarea {
    flex: 1;
    height: 40px;
    min-height: 40px;
    max-height: 120px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-primary);
    border-radius: var(--border-radius-md);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    transition: var(--transition);
}

.chat-footer textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.send-message-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.send-message-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-message-btn:active {
    transform: scale(0.95);
}

/* Column 3: Info Panel */
.chat-info-panel {
    border-left: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    width: 300px;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
}

.info-card-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.info-card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.info-card-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.info-group span {
    font-size: 13px;
    color: var(--text-primary);
    word-break: break-all;
}

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 10px 0;
}

.financial-snippet {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fin-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.fin-row span {
    color: var(--text-secondary);
}

.fin-row strong {
    color: var(--text-primary);
    font-weight: 600;
}

.compliance-snippet {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comp-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 6px 8px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-input);
}

.comp-item .comp-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* ==========================================================================
   Notification Bell & Dropdown Styles
   ========================================================================== */
.notification-bell-wrapper {
    position: relative;
    display: inline-block;
}

.notification-badge {
    position: absolute;
    top: 0px;
    right: 0px;
    background: var(--color-danger, #f43f5e);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
    transform: translate(25%, -25%);
    animation: notification-pulse 2s infinite;
}

@keyframes notification-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(244, 63, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(244, 63, 94, 0);
    }
}

.notification-dropdown {
    display: none;
    position: absolute;
    top: 45px;
    right: 0;
    width: 340px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
    animation: slide-down 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.notification-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.notification-header-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-danger);
    background: var(--color-danger-bg);
    padding: 2px 8px;
    border-radius: 12px;
}

.notification-list {
    max-height: 320px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: var(--bg-hover);
}

.notification-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-warning-bg);
    color: var(--color-warning);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.notification-icon-wrapper.danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

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

.notification-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-time {
    font-size: 11px;
    color: var(--text-muted);
}

.notification-empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.notification-empty i {
    font-size: 32px;
    margin-bottom: 10px;
    color: var(--border-color);
    display: block;
}

.live-chat-badge {
    display: inline-block;
    background: var(--color-danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    animation: notification-pulse 2s infinite;
}

/* ==========================================================================
   Mobile Bottom Sheet Drawers (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* 1. Client Detail Drawer */
    .drawer {
        width: 100% !important;
        max-width: 100% !important;
        height: 85vh !important;
        top: auto !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-left: none !important;
        border-top: 1px solid var(--border-color) !important;
        border-radius: 24px 24px 0 0 !important;
        transform: translateY(100%) !important;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15) !important;
    }
    
    .drawer.active {
        transform: translateY(0) !important;
        right: 0 !important;
    }

    /* 2. Metric Detail Panel */
    .metric-detail-panel {
        width: 100% !important;
        max-width: 100% !important;
        height: 85vh !important;
        top: auto !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-left: none !important;
        border-top: 1px solid var(--border-color) !important;
        border-radius: 24px 24px 0 0 !important;
        transform: translateY(100%) !important;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15) !important;
    }
    
    .metric-detail-panel.active {
        transform: translateY(0) !important;
    }

    /* 3. Drag Handle decoration at the top of drawers on mobile */
    .drawer::before,
    .metric-detail-panel::before {
        content: "";
        display: block;
        width: 48px;
        height: 5px;
        background: var(--text-muted, #94a3b8);
        opacity: 0.4;
        border-radius: 3px;
        margin: 10px auto 0;
        flex-shrink: 0;
    }
}

/* ==========================================================================
   Spreadsheet Style Print Reports
   ========================================================================== */
@media print {
    body.has-print-report {
        background: white !important;
        color: black !important;
    }
    body.has-print-report * {
        visibility: hidden !important;
        height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }
    body.has-print-report #printReportContainer,
    body.has-print-report #printReportContainer * {
        visibility: visible !important;
        height: auto !important;
        overflow: visible !important;
    }
    body.has-print-report #printReportContainer {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        padding: 10px !important;
        margin: 0 !important;
    }
    @page {
        size: landscape;
        margin: 8mm;
    }
}

#printReportContainer {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
    background: white;
    color: black;
}

.print-report-header {
    margin-bottom: 16px;
    border-bottom: 2px solid #1f2937;
    padding-bottom: 8px;
}

.print-report-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px 0;
}

.print-report-meta {
    font-size: 10.5px;
    color: #4b5563;
}

.print-report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    color: #1f2937;
}

.print-report-table th,
.print-report-table td {
    border: 0.5px solid #000000 !important;
    padding: 5px 6px !important;
    text-align: left;
    white-space: nowrap;
}

.print-report-table th {
    background-color: #e5e7eb !important; /* Slightly darker gray for better header visual separation */
    font-weight: bold !important;
    color: #000000 !important;
    text-transform: uppercase;
    font-size: 8.5px;
    letter-spacing: 0.05em;
}

.print-report-table td {
    color: #000000 !important;
}

.print-report-table tr:nth-child(even) td {
    background-color: #f9fafb !important;
}

.print-report-table td.num,
.print-report-table th.num {
    text-align: right;
    font-family: 'SF Mono', monospace;
}

.print-report-table td.name {
    white-space: normal;
    font-weight: 500;
}

.print-report-table tr.total-row td {
    font-weight: 700;
    background-color: #d1d5db !important;
    color: #000000 !important;
    border-top: 1.5px solid #000000 !important;
    border-bottom: 1.5px solid #000000 !important;
}

/* Pagination controls styling */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1.5px solid var(--border-color);
    background: var(--bg-th);
    border-bottom-left-radius: var(--border-radius-lg);
    border-bottom-right-radius: var(--border-radius-lg);
}

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

.pagination-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn i {
    font-size: 14px;
}

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

.pagination-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #ffffff;
}

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

/* ════════════════════════════════════════════════════════════════ */
/* 🎨 UNIVERSAL DROPDOWN (SELECT & OPTION) THEME FIX                */
/* Ensures high contrast visibility in Light & Dark mode across all tabs */
/* ════════════════════════════════════════════════════════════════ */

/* Light Theme (Morning Mode / Default) */
select,
option,
select option,
.input select,
.topbar select,
.topbar option,
.toolbar-actions select,
.card select,
.view-section select {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

select option,
option {
    background-color: #ffffff !important;
    color: #0f172a !important;
    padding: 8px 12px;
}

select option:checked,
select option:hover {
    background-color: #e2e8f0 !important;
    color: #020617 !important;
}

/* Dark Theme (Night Mode) */
body.dark-theme select,
body.dark-theme option,
body.dark-theme select option,
body.dark-theme .input select,
body.dark-theme .topbar select,
body.dark-theme .topbar option,
body.dark-theme .toolbar-actions select,
body.dark-theme .card select,
body.dark-theme .view-section select {
    background-color: #18181a !important;
    color: #f8fafc !important;
}

body.dark-theme select option,
body.dark-theme option {
    background-color: #18181a !important;
    color: #f8fafc !important;
    padding: 8px 12px;
}

body.dark-theme select option:checked,
body.dark-theme select option:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

/* ════════════════════════════════════════════════════════════════ */
/* ⚡ RAZORPAY-GRADE SKELETON LOADERS & RESILIENCE STYLES           */
/* ════════════════════════════════════════════════════════════════ */

/* Global Top Slim Progress Bar */
#global-progress-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #3b82f6, #10b981);
    z-index: 99999;
    transition: width 0.25s ease-out, opacity 0.4s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.6);
    opacity: 0;
    pointer-events: none;
}
#global-progress-loader.active {
    opacity: 1;
}

/* Shimmer Animation */
@keyframes amcShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton-box {
    display: inline-block;
    height: 1em;
    position: relative;
    overflow: hidden;
    background-color: #e2e8f0;
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0) 100%);
    background-size: 200% 100%;
    background-repeat: no-repeat;
    animation: amcShimmer 1.5s infinite;
    border-radius: 4px;
}

body.dark-theme .skeleton-box {
    background-color: #27272a;
    background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0) 100%);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 6px;
    border-radius: 4px;
}

.skeleton-title {
    height: 20px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-row td {
    padding: 14px 16px !important;
}

/* Pagination Bar Styling */
.amc-pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-card, #ffffff);
    border-top: 1px solid var(--border-color, #e2e8f0);
    border-bottom-left-radius: var(--border-radius-lg, 12px);
    border-bottom-right-radius: var(--border-radius-lg, 12px);
    font-size: 13px;
    color: var(--text-secondary, #64748b);
}

.amc-pagination-info {
    font-weight: 500;
}

.amc-pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.amc-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color, #cbd5e1);
    background: var(--bg-input, #ffffff);
    color: var(--text-primary, #1e293b);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.amc-page-btn:hover:not(:disabled) {
    background: var(--accent-light, #eef2ff);
    border-color: var(--accent-primary, #6366f1);
    color: var(--accent-primary, #6366f1);
}

.amc-page-btn.active {
    background: var(--accent-primary, #6366f1) !important;
    border-color: var(--accent-primary, #6366f1) !important;
    color: #ffffff !important;
}

.amc-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

body.dark-theme .amc-pagination-bar {
    background: var(--bg-card, #18181b);
    border-color: var(--border-color, #27272a);
}

body.dark-theme .amc-page-btn {
    border-color: #3f3f46;
    background: #27272a;
    color: #f4f4f5;
}

/* ════════════════════════════════════════════════════════════════ */
/* 🛡️ ZOHO CRM-GRADE LAYERED SETTINGS PORTAL STYLES                */
/* ════════════════════════════════════════════════════════════════ */

.settings-portal-wrapper {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 24px;
    margin-top: 16px;
    align-items: start;
}

.settings-nav-sidebar {
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--border-radius-lg, 12px);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.settings-nav-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--border-radius-md, 8px);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: all 0.2s ease;
}

.settings-nav-tab i {
    font-size: 18px;
    color: var(--text-tertiary, #94a3b8);
}

.settings-nav-tab:hover {
    background: var(--bg-hover, #f1f5f9);
    color: var(--text-primary, #0f172a);
}

.settings-nav-tab.active {
    background: var(--accent-light, #eef2ff);
    color: var(--accent-primary, #6366f1);
    font-weight: 600;
}

.settings-nav-tab.active i {
    color: var(--accent-primary, #6366f1);
}

.settings-panel-content {
    display: none;
}

.settings-panel-content.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

.secret-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.secret-input-wrapper input {
    padding-right: 42px !important;
}

.secret-toggle-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.secret-toggle-btn:hover {
    color: var(--accent-primary, #6366f1);
}

.settings-nav-sidebar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.settings-nav-tab {
    color: #334155;
    font-weight: 500;
}

.settings-nav-tab:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.settings-nav-tab.active {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
    border-left: 3px solid #6366f1;
    font-weight: 600;
}

body.dark-theme .settings-nav-sidebar {
    background: var(--bg-card, #18181b);
    border-color: var(--border-color, #27272a);
}

body.dark-theme .settings-nav-tab {
    color: #a1a1aa;
}

body.dark-theme .settings-nav-tab:hover {
    background: #27272a;
    color: #f4f4f5;
}

body.dark-theme .settings-nav-tab.active {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border-left: 3px solid #818cf8;
}


/* ════════════════════════════════════════════════════════════════ */
/* ⚡ SPOTLIGHT COMMAND PALETTE (CMD + K) STYLES                    */
/* ════════════════════════════════════════════════════════════════ */

.cmd-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.cmd-palette-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.cmd-palette-modal {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translate(-50%, -10px) scale(0.98);
    width: 90%;
    max-width: 640px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--border-radius-lg, 14px);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.cmd-palette-modal.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0) scale(1);
}

.cmd-palette-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    gap: 12px;
}

.cmd-palette-icon {
    font-size: 20px;
    color: var(--accent-primary, #6366f1);
}

.cmd-palette-header input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary, #0f172a);
}

.cmd-kbd {
    background: var(--bg-input, #f1f5f9);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    font-family: var(--mono);
}

.cmd-palette-body {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px 12px;
}

.cmd-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.cmd-item:hover, .cmd-item.selected {
    background: var(--accent-light, #eef2ff);
}

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

.cmd-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-input, #f1f5f9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary, #6366f1);
    font-size: 16px;
}

.cmd-item-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
}

.cmd-item-sub {
    font-size: 11.5px;
    color: var(--text-secondary, #64748b);
}

.cmd-palette-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    font-size: 11.5px;
    color: var(--text-secondary, #64748b);
    background: var(--bg-input, #f8fafc);
}

body.dark-theme .cmd-palette-modal {
    background: var(--bg-card, #18181b);
    border-color: var(--border-color, #27272a);
}

body.dark-theme .cmd-palette-header {
    border-color: #27272a;
}

body.dark-theme .cmd-item:hover, body.dark-theme .cmd-item.selected {
    background: rgba(99, 102, 241, 0.15);
}

body.dark-theme .cmd-palette-footer {
    background: #121215;
    border-color: #27272a;
}

body.dark-theme .cmd-kbd {
    background: #27272a;
    border-color: #3f3f46;
    color: #a1a1aa;
}



