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

:root {
    --primary-red: #bb161c;
    --primary-red-dark: #a51319;
    --primary-red-light: #d4343a;
    --primary-blue: #bb161c;
    --secondary-blue: #d4343a;
    --accent-orange: #f97316;
    --bg-body: #141213;
    --bg-card: #1e1c1d;
    --bg-card-hover: #2a2728;
    --bg-surface: #252223;
    --bg-input: #2a2728;
    --border-color: #3a3738;
    --border-light: #4a4748;
    --text-primary: #f5f5f5;
    --text-secondary: #a8a3a4;
    --text-muted: #7a7576;
    --gray-50: #252223;
    --gray-100: #2a2728;
    --gray-200: #3a3738;
    --gray-300: #4a4748;
    --gray-400: #7a7576;
    --gray-500: #7a7576;
    --gray-600: #a8a3a4;
    --gray-700: #d4d0d1;
    --gray-800: #e8e5e6;
    --gray-900: #f5f5f5;
    --green-500: #22c55e;
    --red-500: #ef4444;
    --yellow-500: #eab308;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --primary-color: #bb161c;
}

[data-theme="light"] {
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-card-hover: #f9fafb;
    --bg-surface: #f9fafb;
    --bg-input: #ffffff;
    --border-color: #e5e7eb;
    --border-light: #d1d5db;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

body {
    font-family: var(--font-ui);
    font-size: 0.875rem;              /* 14px: dense staff tool, not a marketing page */
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Enhanced Button Styles with Loading States */
.btn {
    padding: 0.5rem 0.875rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    position: relative;
    min-width: fit-content;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn.loading {
    color: transparent;
    pointer-events: none;
}

.btn.loading > * {
    visibility: hidden;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    color: white;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-red-light);
}

.btn-primary.loading::after {
    border-top-color: white;
}

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

.btn-success:hover:not(:disabled) {
    background: #16a34a;
}

.btn-success.loading::after {
    border-top-color: white;
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-danger.loading::after {
    border-top-color: white;
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-400);
}

.btn-secondary.loading::after {
    border-top-color: white;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    border-left: 3px solid;
    animation: slideIn 0.3s ease-out;
    min-width: 280px;
    max-width: 500px;
}

.toast.success {
    border-left-color: var(--green-500);
}

.toast.error {
    border-left-color: var(--red-500);
}

.toast.info {
    border-left-color: var(--primary-red);
}

.toast.slide-out {
    animation: slideOut 0.3s ease-in forwards;
}

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

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

/* Login Section */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--bg-body) 0%, #1a0a0b 50%, var(--bg-body) 100%);
}

.login-card {
    background: var(--bg-card);
    padding: 1.75rem;
    border-radius: var(--radius);
    box-shadow: 0 0 40px rgba(187,22,28,0.1);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 400px;
}

.login-logo-img {
    max-width: 180px;
    height: auto;
}

/* The logo's "Team" is black: on the dark theme it sits on a light pill so it stays readable. */
.login-logo-img,
.sidebar-logo-img {
    background: #fff;
    border-radius: 10px;
    padding: 6px 12px;
    box-sizing: border-box;
}

[data-theme="light"] .login-logo-img,
[data-theme="light"] .sidebar-logo-img {
    background: none;
    padding: 0;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.2s;
    background: var(--bg-input);
    color: var(--text-primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(187,22,28,0.2);
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

.app-container.hidden {
    display: none;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-logo-img {
    max-width: 160px;
    height: auto;
}

.sidebar-logo {
    width: 160px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
    border-left: 2px solid transparent;
}

.nav-item .nav-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.nav-item:hover,
.nav-item.active {
    background: var(--bg-surface);
    color: var(--primary-red);
    border-left-color: var(--primary-red);
}

/* Mobile Navigation */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    background: var(--primary-red);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 998;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content-header {
        padding-right: 4rem; /* Space for hamburger button */
    }
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-footer-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sidebar-footer-actions .btn {
    flex: 1;
}

.theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.theme-icon-dark { display: inline-block; }
.theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline-block; }

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
}

.content-header {
    background: var(--bg-card);
    padding: 0.875rem 1.5rem;
    min-height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.content-body {
    padding: 1.5rem;
}

/* Dashboard Sections */
.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

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

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

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

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

.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

/* Lead Cards */
.leads-container {
    display: grid;
    gap: 0.75rem;
}

.lead-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s, border-color 0.2s;
    position: relative;
}

.lead-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
}

/* Lead aging indicator */
.lead-aging-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.aging-green { background: #22c55e; }
.aging-yellow { background: #eab308; }
.aging-red { background: #ef4444; }
.aging-red-pulse { background: #ef4444; animation: pulse-red 1s infinite; }
@keyframes pulse-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.aging-label { font-size: 0.7rem; color: var(--text-secondary); margin-left: 2px; }

/* Hot lead flame */
.hot-lead-flame { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; font-size: 0.8rem; vertical-align: middle; }
.flame-1 { opacity: 0.3; } .flame-2 { opacity: 0.45; } .flame-3 { opacity: 0.6; }
.flame-4 { opacity: 0.8; } .flame-5 { opacity: 1.0; }

/* Today's priorities widget */
.todays-widget { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 0.875rem 1.125rem; margin-bottom: 1rem; }
.todays-widget h3 { font-size: 0.6875rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0 0 0.6rem 0; }
.todays-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; }
.todays-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border-radius: 8px; background: var(--bg-secondary); font-size: 0.85rem; cursor: pointer; transition: background 0.15s; }
.todays-item:hover { background: var(--border-color); }
.todays-count { font-size: 1.125rem; font-weight: 600; min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.todays-label { color: var(--text-secondary); }
.todays-count.urgent { color: #ef4444; }
.todays-count.warning { color: #eab308; }
.todays-count.good { color: #22c55e; }

/* Communication timeline modal */
.timeline-modal-content { max-height: 500px; overflow-y: auto; }
.timeline-entry { display: flex; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.timeline-entry:last-child { border-bottom: none; }
.timeline-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; flex-shrink: 0; }
.timeline-icon.note { background: rgba(234,179,8,0.15); color: #eab308; }
.timeline-icon.sms { background: rgba(168,85,247,0.15); color: #a855f7; }
.timeline-icon.status { background: rgba(59,130,246,0.15); color: #3b82f6; }
.timeline-icon.app { background: rgba(34,197,94,0.15); color: #22c55e; }
.timeline-time { color: var(--text-secondary); font-size: 0.8rem; white-space: nowrap; }

.lead-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.75rem;
}

.lead-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.lead-contact {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.lead-actions {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
}

.status-new { background: #ddd6fe; color: #7c3aed; }
.status-contacted { background: #dbeafe; color: #2563eb; }
.status-appointment { background: #fef3c7; color: #d97706; }
.status-qualified { background: #d1fae5; color: #059669; }
.status-negotiating { background: #fed7aa; color: #ea580c; }
.status-sold { background: #dcfce7; color: #16a34a; }
.status-delivered { background: #e0e7ff; color: #4338ca; }
.status-no_answer { background: #fef9c3; color: #a16207; }
.status-lost { background: #fee2e2; color: #dc2626; }
.status-stale { background: #f1f5f9; color: #64748b; }

.test-drive-badge {
    background: #dbeafe;
    color: #2563eb;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.test-drive-badge.requested {
    background: #fef3c7;
    color: #d97706;
}

.test-drive-badge.completed {
    background: #d1fae5;
    color: #059669;
}

.td-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.td-month-header {
    background: var(--bg-surface);
    padding: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.td-month-day {
    background: var(--bg-card);
    min-height: 90px;
    padding: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    flex-direction: column;
}
.td-month-day:hover { background: var(--bg-card-hover, var(--bg-surface)); }
.td-month-day.other-month { opacity: 0.35; }
.td-month-day.today { background: var(--bg-surface); }
.td-month-day.today .td-day-number span {
    background: var(--primary-red);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.td-month-day.weekend { background: var(--bg-surface); opacity: 0.6; }
.td-day-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}
.td-day-events { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow: hidden; }
.td-day-event {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.td-day-event.chatbot { background: rgba(37,99,235,0.15); color: #2563eb; }
.td-day-event.staff { background: rgba(22,163,74,0.15); color: #16a34a; }
.td-day-event.block { background: var(--bg-surface); color: var(--text-muted); }
.td-day-more { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; }
.td-view-active { background: var(--primary-red) !important; color: white !important; }
.td-slot-available { cursor: pointer; transition: background-color 0.15s; }
.td-slot-available:hover { background: var(--bg-surface) !important; opacity: 1 !important; }
@media (max-width: 768px) {
    .td-month-day { min-height: 60px; padding: 0.25rem; }
    .td-day-number { font-size: 0.7rem; }
    .td-day-event { font-size: 0.6rem; }
}

/* Grouped Leads */
.inquiry-count-badge {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.inquiries-toggle {
    color: var(--primary-color);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.5rem;
    user-select: none;
}

.inquiries-toggle:hover {
    text-decoration: underline;
}

.inquiries-timeline {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-surface);
    border-radius: 8px;
    border-left: 3px solid var(--primary-red);
}

.inquiries-timeline.hidden {
    display: none;
}

.inquiry-item {
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
}

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

.inquiry-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

.inquiry-content {
    color: var(--gray-700);
    font-size: 0.875rem;
    line-height: 1.5;
}

.inquiry-source {
    display: inline-block;
    background: var(--bg-surface);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Bulk Actions */
.bulk-actions {
    background: var(--bg-surface);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.bulk-actions.hidden {
    display: none;
}

.checkbox-input {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* Brand Logos */
.brand-logo {
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.25rem;
}

.brand-logo svg {
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.brand-logo-large svg {
    width: 20px;
    height: 20px;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.textarea {
    width: 100%;
    min-height: 96px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    line-height: 1.4;
    font-family: inherit;
    resize: vertical;
    background: var(--bg-input);
    color: var(--text-primary);
}

.textarea:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(187,22,28,0.2);
}

.select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    line-height: 1.4;
}

.select:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(187,22,28,0.2);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: modalFadeIn 0.2s ease-out;
}

.modal-content.closing {
    animation: modalFadeOut 0.2s ease-in forwards;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes modalFadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

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

.modal-header {
    margin-bottom: 1rem;
    padding-right: 2rem;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* Email List Styles */
.email-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

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

.email-address {
    font-weight: 500;
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        width: 100%;
    }

    .content-header {
        padding: 1rem;
        padding-right: 4rem; /* keep the hamburger clear of the header actions (the shorthand above resets the earlier rule) */
    }

    .content-body {
        padding: 1rem;
    }

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

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

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

    .analytics-filter-bar {
        gap: 0.375rem;
    }

    .filter-pill {
        padding: 0.35rem 0.75rem;
        font-size: 0.75rem;
    }

    .custom-date-inputs {
        width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }

    .pagination-bar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .header-actions {
        flex-direction: column;
    }

    .header-actions .form-input,
    .header-actions .select {
        width: 100% !important;
    }

    .lead-actions {
        flex-direction: column;
    }

    .lead-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .analytics-filter-bar {
        justify-content: center;
    }

    .toast {
        min-width: auto;
        margin: 0 1rem;
    }
}

/* Loading States */
div.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

/* Hide admin sections for regular users */
.admin-only {
    display: none;
}

.admin-only.visible {
    display: block;
}

.admin-only.visible-flex {
    display: flex;
}

/* Staff Activity section styles */
.activity-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.activity-table th, .activity-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.activity-table th { font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; }
.activity-table tr:hover { background: var(--bg-secondary); }
.activity-feed { max-height: 400px; overflow-y: auto; }
.activity-feed-item { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.activity-feed-item:last-child { border-bottom: none; }
.activity-feed-time { color: var(--text-secondary); white-space: nowrap; min-width: 70px; font-size: 0.8rem; }
.activity-feed-user { font-weight: 600; min-width: 60px; }
.activity-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.7rem; font-weight: 600; }
.activity-badge.login { background: rgba(59,130,246,0.15); color: #3b82f6; }
.activity-badge.lead { background: rgba(34,197,94,0.15); color: #22c55e; }
.activity-badge.sms { background: rgba(168,85,247,0.15); color: #a855f7; }
.activity-badge.note { background: rgba(234,179,8,0.15); color: #eab308; }
.activity-badge.credit { background: rgba(239,68,68,0.15); color: #ef4444; }
.activity-badge.review { background: rgba(14,165,233,0.15); color: #0ea5e9; }
.activity-badge.page { background: rgba(107,114,128,0.15); color: #6b7280; }
.staff-activity-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.staff-activity-tab { padding: 0.3rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; font-size: 0.75rem; font-family: inherit; color: var(--text-secondary); }
.staff-activity-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Profile specific styles */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Notes Modal Styles */
.notes-modal .modal-content {
    max-width: 700px;
    max-height: 80vh;
}

.notes-timeline {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
}

.note-item {
    background: var(--bg-surface);
    border-left: 3px solid var(--primary-red);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    position: relative;
}

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

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.note-author {
    font-weight: 600;
    color: var(--primary-red);
}

.note-date {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.note-content {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.note-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.note-edited {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-style: italic;
    margin-top: 0.25rem;
}

.add-note-section {
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.note-textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.note-textarea:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(187,22,28,0.2);
}

.char-counter {
    font-size: 0.875rem;
    color: var(--gray-500);
    text-align: right;
    margin-bottom: 0.5rem;
}

.char-counter.warning {
    color: var(--yellow-500);
}

.char-counter.error {
    color: var(--red-500);
}

.empty-notes {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
}

.notes-badge {
    background: var(--primary-red);
    color: white;
    border-radius: 50%;
    padding: 0.125rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.25rem;
}

/* SMS Modal Styles */
.sms-modal .modal-content {
    max-width: 700px;
    max-height: 85vh;
}

.sms-compose-section {
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.sms-textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

.sms-textarea:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(187,22,28,0.2);
}

.sms-char-counter {
    font-size: 0.875rem;
    color: var(--gray-600);
    text-align: right;
    margin-bottom: 1rem;
    font-weight: 600;
}

.sms-char-counter.warning {
    color: var(--yellow-500);
}

.sms-char-counter.long {
    color: var(--accent-orange);
}

.sms-char-counter.too-long {
    color: var(--red-500);
}

.sms-preview-section {
    margin-bottom: 1.5rem;
}

.sms-preview {
    background: var(--bg-input);
    border: 2px solid var(--primary-red);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 60px;
}

.sms-history {
    max-height: 300px;
    overflow-y: auto;
}

.sms-history-item {
    background: var(--bg-surface);
    border-left: 3px solid var(--green-500);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
}

.sms-history-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.sms-history-sender {
    font-weight: 600;
    color: var(--green-500);
}

.sms-history-date {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.sms-history-message {
    color: var(--gray-700);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.875rem;
}

.sms-history-info {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
}

.empty-sms {
    text-align: center;
    padding: 2rem;
    color: var(--gray-500);
}

/* Analytics Charts */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    min-width: 0;
}

.chart-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

/* Fixed-height chart area so Chart.js never resizes the card unpredictably */
.chart-wrap { position: relative; height: 240px; }
.chart-card.chart-wide .chart-wrap { height: 280px; }

.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 0.875rem 1.125rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0.2rem;
}

.metric-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.metric-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Analytics Date Filter */
.analytics-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-pill:hover {
    border-color: var(--primary-red);
    color: var(--primary-red);
}

.filter-pill.active {
    background: var(--primary-red);
    border-color: var(--primary-red);
    color: #fff;
}

.custom-date-inputs {
    display: none;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
}

.custom-date-inputs.visible {
    display: flex;
}

.custom-date-inputs input[type="date"] {
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
}

.custom-date-inputs input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-red);
}

.custom-date-inputs span {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Pagination */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
}

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

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-pages {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    min-width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn:hover {
    border-color: var(--primary-red);
    color: var(--primary-red);
}

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

/* Review Dropdown */
.review-dropdown {
    position: relative;
    display: inline-block;
}

.review-dropdown-content {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    z-index: 10;
    min-width: 150px;
    padding: 0.25rem;
    margin-bottom: 0.25rem;
}

.review-dropdown-content.show {
    display: block;
}

.review-dropdown-content .btn {
    width: 100%;
    justify-content: flex-start;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

/* Utility Classes */
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mr-1 { margin-right: 0.5rem; }

.lead-inquiry {
    margin: 1rem 0;
    color: var(--text-secondary);
}

.lead-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.prequal-details {
    margin: 0.5rem 0 1rem 0;
    padding: 0.75rem;
    background: var(--bg-surface);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.prequal-details strong.prequal-title {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.prequal-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

/* Website-form extra answers (lead.formFields) reuse the pre-qual layout with a neutral tint */
.prequal-details.form-fields {
    background: #f8fafc;
    border-left: 3px solid #64748b;
}
.prequal-details.form-fields .prequal-title {
    color: #475569;
}
.prequal-details.form-fields .prequal-grid span {
    overflow-wrap: anywhere;
}

/* Sign-in enrollment */
.enroll-title { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); margin: 0 0 0.35rem; text-align: center; }
.enroll-sub { font-size: 0.9rem; color: var(--text-secondary); text-align: center; margin: 0 0 1.5rem; line-height: 1.5; }
.enroll-option { display: flex; gap: 0.9rem; align-items: flex-start; width: 100%; text-align: left; padding: 1rem; margin-bottom: 0.75rem; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-surface); color: var(--text-primary); cursor: pointer; transition: border-color 0.15s, background 0.15s; font: inherit; }
.enroll-option:hover:not(:disabled) { border-color: var(--primary-red); background: var(--bg-card-hover); }
.enroll-option:disabled { cursor: default; opacity: 0.75; }
.enroll-option .enroll-icon { flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border-color); }
.enroll-option strong { display: block; font-size: 0.95rem; margin-bottom: 0.15rem; }
.enroll-option span.enroll-desc { display: block; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.enroll-option.done { border-color: var(--green-500); }
.enroll-done-mark { margin-left: auto; color: var(--green-500); font-weight: 700; align-self: center; }
.enroll-status { min-height: 1.25rem; font-size: 0.85rem; text-align: center; margin: 0.25rem 0 0.75rem; color: var(--text-secondary); }
.signin-method { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); margin-bottom: 0.75rem; }
.signin-method .team-meta { word-break: normal; }

/* Admin panel: team table */
.admin-stack { display: flex; flex-direction: column; gap: 1.5rem; }
.admin-section-label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin: 0.5rem 0 -0.5rem; }
.admin-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.5rem; align-items: start; }
.team-header { flex-wrap: wrap; gap: 0.75rem 1rem; }
.team-header .card-title { margin: 0; }
.team-subtitle { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.2rem; }
.team-tools { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.team-tools .form-input { width: 220px; padding: 0.45rem 0.75rem; font-size: 0.875rem; }
.team-table-wrap { overflow-x: auto; }
.team-table { width: 100%; border-collapse: collapse; }
.team-table th { text-align: left; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.team-table td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; font-size: 0.875rem; color: var(--text-primary); }
.team-table tbody tr:last-child td { border-bottom: none; }
.team-table tbody tr:hover { background: var(--bg-card-hover); }
.team-user { display: flex; align-items: center; gap: 0.75rem; min-width: 220px; }
.team-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.8rem; color: #fff; background: var(--primary-red); }
.team-avatar.is-user { background: var(--gray-500); }
.team-name { font-weight: 600; line-height: 1.3; }
.team-meta { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.35; word-break: break-all; }
.team-you { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); margin-left: 0.35rem; }
.team-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.72rem; font-weight: 500; border: 1px solid var(--border-color); color: var(--text-secondary); background: var(--bg-surface); white-space: nowrap; }
.team-chip.ms { color: #2563eb; border-color: rgba(37,99,235,0.35); background: rgba(37,99,235,0.08); }
.team-chip.ok { color: #16a34a; border-color: rgba(22,163,74,0.35); background: rgba(22,163,74,0.08); }
.team-chip.warn { color: #ca8a04; border-color: rgba(202,138,4,0.4); background: rgba(202,138,4,0.1); }
.team-chip.bad { color: var(--red-500); border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.08); }
.team-role { font-size: 0.8rem; padding: 0.3rem 0.5rem; border-radius: 6px; border: 1px solid var(--border-light); background: var(--bg-input); color: var(--text-primary); cursor: pointer; }
.team-perms { display: flex; flex-wrap: wrap; gap: 0.35rem; min-width: 250px; }
.perm-toggle { position: relative; display: inline-flex; }
.perm-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.perm-toggle span { display: inline-block; padding: 0.25rem 0.6rem; border-radius: 999px; font-size: 0.75rem; border: 1px solid var(--border-light); color: var(--text-secondary); cursor: pointer; user-select: none; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.perm-toggle span::before { content: '\2715'; margin-right: 0.35rem; font-size: 0.65rem; opacity: 0.6; }
/* ON = green with a check mark; OFF = grey with an x. Red read as "revoked" to admins, so it is not used here. */
.perm-toggle input:checked + span { background: rgba(22,163,74,0.12); border-color: #16a34a; color: #16a34a; font-weight: 600; }
.perm-toggle input:checked + span::before { content: '\2713'; opacity: 1; }
.perm-toggle input:focus-visible + span { outline: 2px solid var(--primary-red); outline-offset: 2px; }
.perm-note { font-size: 0.75rem; color: var(--text-muted); }
.team-actions { display: flex; gap: 0.25rem; justify-content: flex-end; white-space: nowrap; }
.team-empty { text-align: center; padding: 2rem; color: var(--text-muted); }
.removed-toggle { background: none; border: none; color: var(--text-secondary); font-size: 0.85rem; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 0.35rem; }
.removed-toggle:hover { color: var(--text-primary); }
.removed-list { margin-top: 0.75rem; border: 1px solid var(--border-color); border-radius: 8px; }
.removed-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-color); font-size: 0.85rem; }
.removed-row:last-child { border-bottom: none; }
.remove-consequences { margin: 0.75rem 0 1rem 1.1rem; font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }
@media (max-width: 900px) {
    .team-table thead { display: none; }
    .team-table, .team-table tbody, .team-table tr, .team-table td { display: block; width: 100%; }
    .team-table tr { padding: 0.75rem 0; border-bottom: 1px solid var(--border-color); }
    .team-table tbody tr:last-child { border-bottom: none; }
    .team-table td { border: none; padding: 0.35rem 1rem; }
    .team-table td[data-label]::before { content: attr(data-label); display: block; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.2rem; }
    .team-actions { justify-content: flex-start; }
    .team-tools, .team-tools .form-input { width: 100%; }
    .team-tools .form-input { flex: 1; }
    .admin-settings-grid { grid-template-columns: 1fr; }
}

/* Delete button subtle style */
.btn-delete-subtle {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    padding: 0.5rem;
}

.btn-delete-subtle:hover:not(:disabled) {
    background: rgba(239,68,68,0.1);
    color: var(--red-500);
    border-color: var(--red-500);
}

/* Print button styling */
.print-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-family: inherit;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s, border-color 0.2s;
}
.print-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-primary);
}


/* ===================================================================
   Design tokens (2026-09 density pass)
   One radius, one control radius, one UI font, tabular numerals for
   every metric. The aliases below define variables that older rules
   referenced but that were never declared (they silently rendered as
   "no border" / "no background" before).
   =================================================================== */
:root {
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --border: var(--border-color);
    --bg-secondary: var(--bg-surface);
    --bg: var(--bg-card);
    --accent: var(--primary-red);
    --error-red: var(--red-500);
}
h1, h2, h3, h4 { line-height: 1.25; }
button, input, select, textarea { font-family: inherit; }

/* Browser autofill painted the dark login fields light blue */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
    transition: background-color 9999s ease-out;
}

/* Sign-in provider buttons (were inline-styled) */
.btn-provider {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    transition: background 0.15s, border-color 0.15s;
}
.btn-provider + .btn-provider { margin-top: 0.5rem; }
.btn-provider:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--text-muted); }
.login-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--text-muted); font-size: 0.75rem; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border-color); }
.login-error { display: none; color: var(--red-500); font-size: 0.8125rem; text-align: center; margin-top: 0.5rem; }

/* Section heading inside a page (e.g. "Staff Activity") */
.section-heading { font-size: 0.6875rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 1.5rem 0 0.75rem; }
.section-heading:first-child { margin-top: 0; }

/* Card header tools (select + note + print) */
.card-tools { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.card-tools .select { width: auto; padding: 0.3rem 1.75rem 0.3rem 0.6rem; font-size: 0.75rem; }
.card-tools .note { font-size: 0.75rem; color: var(--text-muted); }
.chart-title.with-tools { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* Review requests table */
.review-table { width: 100%; border-collapse: collapse; }
.review-table th { text-align: left; font-size: 0.6875rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.review-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; font-size: 0.875rem; }
.review-table tbody tr:last-child td { border-bottom: none; }
.review-table tbody tr:hover { background: var(--bg-card-hover); }
.review-table .checkbox-input { width: 1rem; height: 1rem; display: block; }
.review-name { font-weight: 600; color: var(--text-primary); }
.review-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.1rem; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-platform { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.review-when { color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.review-table td.review-actions { text-align: right; white-space: nowrap; }
.review-table-wrap { overflow-x: auto; }
.review-empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
@media (max-width: 640px) {
    .review-table .review-when, .review-table th.review-when { display: none; }
}

/* Credit-app funnel: one glanceable bar row above the detail tables */
.funnel-bars { display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 64px; align-items: center; gap: 0.75rem; font-size: 0.8125rem; }
.funnel-row .funnel-label { color: var(--text-secondary); }
.funnel-row .funnel-track { height: 10px; border-radius: 999px; background: var(--bg-surface); overflow: hidden; }
.funnel-row .funnel-fill { height: 100%; border-radius: 999px; background: var(--primary-red); opacity: 0.85; }
.funnel-row .funnel-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.funnel-sub { font-size: 0.6875rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 1rem 0 0.4rem; }

.print-btn.print-all { margin-left: auto; }
.login-logo { margin-bottom: 1.5rem; }

/* Lead-card actions: one quiet row, not six coloured buttons competing with the status badges.
   The card's primary action (Notes) keeps the brand colour; everything else is a bordered surface button. */
.lead-actions .btn:not(.btn-primary):not(.btn-delete-subtle) {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.lead-actions .btn:not(.btn-primary):not(.btn-delete-subtle):hover:not(:disabled) {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
}
.lead-actions .btn.is-scheduled { color: #f59e0b; border-color: rgba(245,158,11,0.5); }
.lead-actions .select { width: auto; padding: 0.35rem 1.75rem 0.35rem 0.6rem; font-size: 0.75rem; }
.review-dropdown-content .btn { border: none !important; background: transparent !important; }
.review-dropdown-content .btn:hover { background: var(--bg-surface) !important; }

/* Header controls sit on one 34px baseline */
.header-actions .form-input, .header-actions .select { padding-top: 0.4rem; padding-bottom: 0.4rem; font-size: 0.8125rem; }

/* Print styles */
@media print {
    body { background: white !important; color: black !important; }
    .sidebar, .mobile-header, .content-header, .analytics-filter-bar,
    .custom-date-inputs, .print-btn, .modal-actions, .modal-close { display: none !important; }

    /* Print single card mode. #analyticsSection is itself a .dashboard-section and the ancestor of every
       .print-target, so it must stay visible or the per-chart print is a blank page. */
    body.print-single-card .dashboard-section:not(#analyticsSection),
    body.print-single-card .main-content > *:not(#analyticsSection),
    body.print-single-card .analytics-grid > *:not(.print-target),
    body.print-single-card .analytics-grid:not(:has(.print-target)) { display: none !important; }
    body.print-single-card #analyticsSection { display: block !important; }
    body.print-single-card .print-target { break-inside: avoid; border: 1px solid #ccc !important; }

    /* Print all analytics mode */
    body.print-all-analytics .main-content > *:not(#analyticsSection) { display: none !important; }
    body.print-all-analytics .dashboard-section:not(#analyticsSection) { display: none !important; }
    body.print-all-analytics #analyticsSection { display: block !important; }
    body.print-all-analytics .chart-card,
    body.print-all-analytics .metric-card {
        break-inside: avoid;
        border: 1px solid #ccc !important;
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }

    /* Print credit app modal mode */
    body.print-credit-app * { display: none !important; }
    body.print-credit-app #creditAppModal,
    body.print-credit-app #creditAppModal .modal-content,
    body.print-credit-app #creditAppModal .modal-content *,
    body.print-credit-app #creditAppModal .modal-header,
    body.print-credit-app #creditAppModal .modal-header *,
    body.print-credit-app #creditAppModal #creditAppContent,
    body.print-credit-app #creditAppModal #creditAppContent * {
        display: block !important;
        color: black !important;
        background: white !important;
    }
    body.print-credit-app #creditAppModal {
        position: static !important;
        overflow: visible !important;
    }
    body.print-credit-app #creditAppModal .modal-content {
        max-width: 100% !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
    }
    body.print-credit-app #creditAppModal .modal-close,
    body.print-credit-app #creditAppModal .modal-actions { display: none !important; }
    body.print-credit-app #creditAppModal .modal-header {
        border-bottom: 2px solid black !important;
        margin-bottom: 1rem !important;
        padding-bottom: 0.5rem !important;
    }
    body.print-credit-app #creditAppModal [style*="background:var(--bg-surface)"],
    body.print-credit-app #creditAppModal [style*="background: var(--bg-surface)"] {
        border: 1px solid #ccc !important;
    }

    .main-content { margin-left: 0 !important; padding: 0 !important; }
    canvas { max-width: 100% !important; }
}


/* Chatbot conversation log (Analytics) */
.chat-sessions { display: grid; gap: 0.4rem; }
.chat-session { border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-surface); }
.chat-session summary { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.85rem; }
.chat-when { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }
.chat-first { flex: 1 1 240px; color: var(--text-primary); }
.chat-badges { color: var(--text-secondary); font-size: 0.75rem; white-space: nowrap; }
.chat-transcript { padding: 0.25rem 0.75rem 0.75rem; display: grid; gap: 0.4rem; }
.chat-turn { display: grid; gap: 0.2rem; }
.chat-user, .chat-bot { padding: 0.4rem 0.6rem; border-radius: 8px; font-size: 0.85rem; line-height: 1.35; max-width: 90%; overflow-wrap: anywhere; }
.chat-user { background: rgba(187,22,28,0.10); justify-self: end; }
.chat-bot { background: var(--bg-card); border: 1px solid var(--border-color); justify-self: start; }
.chat-bot.chat-error { border-color: #dc2626; }
.chat-tools { display: block; margin-top: 0.25rem; font-size: 0.7rem; color: var(--text-muted); font-family: monospace; }
