/* ==========================================================================
   Lead Bot Operations Dashboard — Premium Minimalist Light Mode
   ========================================================================== */

:root {
    --bg-main: #F8FAFC;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --border-color: #E2E8F0;
    
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-muted: #64748B;
    
    --accent-blue: #1E40AF;
    --accent-blue-text: #1E40AF;
    --accent-blue-hover: #1D4ED8;
    --accent-blue-light: #EFF6FF;
    --accent-blue-border: #BFDBFE;
    --accent-blue-glow: rgba(30, 64, 175, 0.12);
    
    --accent-green: #059669;
    --accent-green-text: #059669;
    --accent-green-bg: #ECFDF5;
    --accent-green-border: #A7F3D0;
    
    --font-heading: 'Outfit', -apple-system, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 30px -4px rgba(0, 0, 0, 0.08);
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Theme */
[data-theme="dark"] {
    --bg-main: #0B0E14;
    --bg-sidebar: #121826;
    --bg-card: #121826;
    --bg-card-hover: #1A2235;
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;
    
    --accent-blue: #3B82F6;
    --accent-blue-text: #60A5FA;
    --accent-blue-light: rgba(59, 130, 246, 0.15);
    --accent-blue-border: rgba(59, 130, 246, 0.3);
    
    --accent-green: #10B981;
    --accent-green-text: #34D399;
    --accent-green-bg: rgba(16, 185, 129, 0.15);
    --accent-green-border: rgba(16, 185, 129, 0.3);
}

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

html,
body {
    overflow-x: hidden;
}

/* Keep flex/grid children from forcing the page wider than the viewport. */
.dashboard-body,
.page-view,
.content-panel,
.table-panel,
.sources-panel {
    min-width: 0;
    max-width: 100%;
}

/* Long email addresses, record URLs and agency names must wrap gracefully. */
.person-name,
.person-sub,
.source-header,
.leads-table td,
.leads-table th {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.badge {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    width: 100%;
}

.logout-form {
    margin: 0;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    border-color: #FCA5A5;
    background: #FEF2F2;
    color: #B91C1C;
}

.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    padding: 5px 10px 5px 6px;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: var(--bg-card);
}

.account-avatar {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    border-radius: 8px;
    background: linear-gradient(145deg, #1D4ED8, #1E40AF);
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .2px;
}

.account-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.account-copy strong {
    color: var(--text-primary);
    font-size: 11.5px;
    font-weight: 750;
}

.account-copy small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 9.5px;
    font-weight: 650;
}

/* Branded authentication screen */
.login-page {
    min-height: 100vh;
    background: #EEF3FA;
    color: #0F172A;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(390px, 1.08fr) minmax(430px, .92fr);
    min-height: 100vh;
}

.login-story {
    position: relative;
    overflow: hidden;
    min-height: 100vh;
    padding: clamp(36px, 5vw, 72px);
    background:
        radial-gradient(circle at 85% 16%, rgba(56, 189, 248, .25), transparent 26%),
        linear-gradient(145deg, #071B3D 0%, #123F83 58%, #146C8E 100%);
    color: #FFFFFF;
}

.login-story::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .13;
    background-image: radial-gradient(rgba(255,255,255,.9) .7px, transparent .7px);
    background-size: 26px 26px;
    mask-image: linear-gradient(to bottom, #000, transparent 75%);
}

.login-story-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - clamp(72px, 10vw, 144px));
}

.login-brand,
.login-mobile-brand {
    display: flex;
    align-items: center;
    gap: 13px;
}

.login-brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255,255,255,.27);
    border-radius: 14px;
    background: rgba(255,255,255,.13);
    color: #FFFFFF;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
    backdrop-filter: blur(12px);
}

.login-brand strong {
    display: block;
    font-size: 17px;
    letter-spacing: -.2px;
}

.login-brand span {
    display: block;
    margin-top: 1px;
    color: rgba(255,255,255,.67);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.6px;
    text-transform: uppercase;
}

.login-copy {
    margin: auto 0;
    max-width: 650px;
    padding: 72px 0;
}

.login-kicker {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 24px;
    color: #BAE6FD;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.login-kicker i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5EEAD4;
    box-shadow: 0 0 0 5px rgba(94,234,212,.12);
}

.login-copy h1 {
    max-width: 680px;
    font-family: var(--font-heading);
    font-size: clamp(42px, 5.2vw, 72px);
    font-weight: 750;
    line-height: 1.03;
    letter-spacing: -3px;
}

.login-copy p {
    max-width: 570px;
    margin-top: 28px;
    color: rgba(255,255,255,.72);
    font-size: clamp(15px, 1.4vw, 18px);
    line-height: 1.75;
}

.login-trust {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: rgba(255,255,255,.6);
    font-size: 12px;
    font-weight: 600;
}

.login-trust span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,.8);
}

.login-landscape {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 31%;
    pointer-events: none;
}

.login-orb {
    position: absolute;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 50%;
}

.login-orb-one {
    top: -170px;
    right: -190px;
    width: 470px;
    height: 470px;
}

.login-orb-two {
    top: -70px;
    right: -90px;
    width: 270px;
    height: 270px;
}

.login-form-panel {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 48px clamp(32px, 7vw, 110px);
    background: #FFFFFF;
}

.login-form-wrap {
    width: min(100%, 430px);
}

.login-mobile-brand {
    display: none;
}

.login-form-heading > span {
    color: #1D4ED8;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.4px;
    text-transform: uppercase;
}

.login-form-heading h2 {
    margin-top: 10px;
    color: #0F172A;
    font-family: var(--font-heading);
    font-size: clamp(29px, 3vw, 38px);
    line-height: 1.15;
    letter-spacing: -1.3px;
}

.login-form-heading p {
    margin-top: 12px;
    color: #64748B;
    font-size: 14px;
}

.login-error {
    display: none;
    margin-top: 24px;
    padding: 12px 14px;
    border: 1px solid #FECACA;
    border-radius: 10px;
    background: #FEF2F2;
    color: #B91C1C;
    font-size: 13px;
    font-weight: 650;
}

.login-error.visible {
    display: block;
}

.login-form {
    margin-top: 32px;
}

.login-form label {
    display: block;
    margin: 20px 0 8px;
    color: #334155;
    font-size: 12.5px;
    font-weight: 750;
}

.login-input-wrap {
    position: relative;
}

.login-input-wrap svg {
    position: absolute;
    top: 50%;
    left: 16px;
    color: #94A3B8;
    transform: translateY(-50%);
    pointer-events: none;
}

.login-input-wrap input {
    width: 100%;
    height: 52px;
    padding: 0 16px 0 48px;
    border: 1px solid #CBD5E1;
    border-radius: 11px;
    outline: none;
    background: #FFFFFF;
    color: #0F172A;
    font: inherit;
    font-size: 14px;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.login-input-wrap input::placeholder {
    color: #94A3B8;
}

.login-input-wrap input:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37,99,235,.1);
}

.login-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    height: 52px;
    margin-top: 28px;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, #1D4ED8, #1E40AF);
    color: #FFFFFF;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(30,64,175,.2);
    transition: transform .18s ease, box-shadow .18s ease;
}

.login-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(30,64,175,.27);
}

.login-submit:active {
    transform: translateY(0);
}

.login-help {
    margin-top: 24px;
    color: #94A3B8;
    font-size: 11.5px;
    line-height: 1.6;
    text-align: center;
}

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-story {
        display: none;
    }

    .login-form-panel {
        padding: 40px 24px;
        background:
            radial-gradient(circle at 100% 0, rgba(191,219,254,.55), transparent 34%),
            #F8FAFC;
    }

    .login-mobile-brand {
        display: flex;
        margin-bottom: 64px;
        color: #0F172A;
        font-size: 16px;
    }

    .login-mobile-brand .login-brand-mark {
        width: 42px;
        height: 42px;
        border: 0;
        background: #1E40AF;
    }
}

@media (max-width: 520px) {
    .login-form-panel {
        align-items: start;
        padding-top: 28px;
    }

    .login-mobile-brand {
        margin-bottom: 48px;
    }
}

/* Page Views */
.page-view {
    display: none;
}

.page-view.active {
    display: block !important;
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-main);
}

/* Sidebar — Clean Light Slate */
.sidebar {
    width: 250px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
}

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

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    box-shadow: 0 4px 10px var(--accent-blue-glow);
}

.brand-text h2 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

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

/* Nav Menu */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 13.5px;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item * {
    pointer-events: none;
}

.nav-item:hover {
    color: var(--accent-blue-text);
    background: var(--accent-blue-light);
}

.nav-item.active {
    color: var(--accent-blue-text);
    background: var(--accent-blue-light);
    border: 1px solid var(--accent-blue-border);
    font-weight: 700;
}

.nav-item svg {
    color: var(--text-muted);
    transition: var(--transition);
}

.nav-item:hover svg, .nav-item.active svg {
    color: var(--accent-blue-text);
}

/* System Status Card */
.system-status-card {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: auto;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator.online {
    background-color: var(--accent-green-text);
    box-shadow: 0 0 6px var(--accent-green);
}

.status-indicator.offline {
    background-color: #dc2626;
    box-shadow: 0 0 6px rgba(220, 38, 38, 0.35);
}

.table-message {
    padding: 28px !important;
    text-align: center;
    color: var(--text-muted);
}

.status-info .status-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-info .status-subtitle {
    font-size: 10.5px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    margin-left: 250px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--bg-main);
}

/* Header */
.top-header {
    height: 68px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 40;
}

[data-theme="dark"] .top-header {
    background: rgba(11, 14, 20, 0.95);
}

.header-search {
    position: relative;
    width: 360px;
}

.header-search > .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-results-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: min(500px, calc(100vw - 32px));
    max-height: min(520px, calc(100vh - 100px));
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 13px;
    background: var(--bg-card);
    box-shadow: 0 20px 45px rgba(15, 23, 42, .16), 0 2px 8px rgba(15, 23, 42, .06);
    z-index: 120;
}

.search-results-panel[hidden] {
    display: none;
}

.search-results-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 9px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .7px;
    text-transform: uppercase;
}

.search-result-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
}

.search-result-item:last-child {
    border-bottom: 0;
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--accent-blue-light);
}

.search-result-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-blue);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 800;
}

.search-result-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.35;
}

.search-result-copy strong,
.search-result-copy span,
.search-result-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-copy strong {
    color: var(--text-primary);
    font-size: 12.5px;
}

.search-result-copy span {
    color: var(--text-secondary);
    font-size: 11px;
}

.search-result-copy small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10.5px;
}

.search-result-location {
    max-width: 115px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 20px;
    text-align: center;
}

.search-empty-state strong {
    color: var(--text-primary);
    font-size: 13px;
}

.search-empty-state span {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 11.5px;
}

.search-more-results {
    padding: 10px 14px;
    background: var(--bg-main);
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 650;
    text-align: center;
}

.header-search input {
    width: 100%;
    padding: 9px 14px 9px 40px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.header-search input:focus {
    border-color: var(--accent-blue-text);
    background: #FFFFFF;
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

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

.theme-toggle-btn {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    background: var(--accent-blue-light);
    color: var(--accent-blue-text);
    border-color: var(--accent-blue-border);
}

.season-badge {
    background: var(--accent-green-bg);
    border: 1px solid var(--accent-green-border);
    color: var(--accent-green-text);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.season-badge .dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-green-text);
    border-radius: 50%;
}

.btn-refresh {
    background: var(--accent-blue);
    color: #FFFFFF;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 6px var(--accent-blue-glow);
    transition: var(--transition);
}

.btn-refresh:hover {
    background: var(--accent-blue-hover);
    box-shadow: 0 4px 12px var(--accent-blue-glow);
}

/* Dashboard Body */
.dashboard-body {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Welcome Banner */
.welcome-banner {
    background: linear-gradient(135deg, #1E40AF 0%, #1D4ED8 100%);
    border-radius: var(--radius-lg);
    padding: 24px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    color: #FFFFFF;
    position: relative;
    overflow: hidden;
}

.banner-content h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: #FFFFFF;
    margin-bottom: 4px;
}

.banner-content p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13.5px;
    max-width: 520px;
}

.banner-stat {
    text-align: right;
}

.banner-stat-val {
    display: block;
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    color: #A7F3D0;
    line-height: 1;
}

.banner-stat-lbl {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-top: 24px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-xs);
    transition: var(--transition);
}

.metric-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-blue-border);
}

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

.metric-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-icon.blue { background: var(--accent-blue-light); color: var(--accent-blue-text); }
.metric-icon.green  { background: var(--accent-green-bg); color: var(--accent-green-text); }

.metric-value {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.metric-value.text-sm {
    font-size: 18px;
}

.metric-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
}

.metric-footer.positive { color: var(--accent-green-text); }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 20px;
}

.content-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-xs);
    min-width: 0;
}

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

.panel-title {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-blue { background: var(--accent-blue-light); color: var(--accent-blue-text); border: 1px solid var(--accent-blue-border); }
.badge-green  { background: var(--accent-green-bg); color: var(--accent-green-text); border: 1px solid var(--accent-green-border); }

/* Table */
.table-responsive {
    overflow-x: auto;
}

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

.leads-table th {
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-main);
}

.leads-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    vertical-align: middle;
}

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

.leads-table tbody tr:hover {
    background: var(--accent-blue-light);
}

.person-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-blue-light);
    color: var(--accent-blue-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12.5px;
    border: 1px solid var(--accent-blue-border);
}

.person-name {
    font-weight: 600;
    color: var(--text-primary);
}

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

.btn-view {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-view:hover {
    background: var(--accent-blue);
    color: #FFFFFF;
    border-color: var(--accent-blue-text);
}

/* Sources List */
.sources-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.source-item {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.source-header {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 6px;
}

.source-bar-bg {
    height: 6px;
    background: #E2E8F0;
    border-radius: 3px;
    overflow: hidden;
}

[data-theme="dark"] .source-bar-bg {
    background: rgba(255, 255, 255, 0.08);
}

.source-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent-blue);
    transition: width 0.6s ease;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

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

.modal-card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 580px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

[data-theme="dark"] .modal-card {
    background: #121826;
}

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

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
}

.modal-body {
    padding: 22px;
    max-height: 70vh;
    overflow-y.auto;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

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

.modal-field p {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-notes-box {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1200px) {
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .app-layout {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        padding: 14px 16px 12px;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }

    .brand {
        padding-bottom: 12px;
        margin-bottom: 10px;
    }

    .brand-icon {
        width: 34px;
        height: 34px;
    }

    .nav-menu {
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
    }

    .nav-item {
        flex: 1 0 auto;
        justify-content: center;
        gap: 6px;
        padding: 8px 9px;
        font-size: 11.5px;
        white-space: nowrap;
    }

    .system-status-card {
        display: none;
    }

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

    .top-header {
        position: static;
        height: auto;
        padding: 12px 16px;
        display: block;
    }

    .header-search {
        width: 100%;
        margin-bottom: 10px;
    }

    .search-results-panel {
        width: 100%;
    }

    .header-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .theme-toggle-btn,
    .season-badge,
    .btn-refresh,
    .account-chip,
    .btn-logout {
        width: 100%;
        min-width: 0;
        justify-content: center;
    }

    .logout-form {
        width: 100%;
    }

    .dashboard-body {
        padding: 16px;
        gap: 16px;
    }

    .welcome-banner {
        align-items: flex-start;
        padding: 20px;
        flex-direction: column;
    }

    .banner-stat {
        margin-top: 18px;
        text-align: left;
    }

    .content-panel {
        padding: 16px;
    }

    /* On narrow or unusual browser sizes, use readable lead cards instead of
       forcing the user to horizontally scroll a six-column table. */
    .table-responsive {
        overflow-x: visible;
    }

    .leads-table,
    .leads-table thead,
    .leads-table tbody,
    .leads-table tr,
    .leads-table td {
        display: block;
        width: 100%;
    }

    .leads-table thead {
        display: none;
    }

    .leads-table tbody tr {
        padding: 14px 0;
        border-bottom: 1px solid var(--border-color);
    }

    .leads-table tbody tr:hover {
        background: transparent;
    }

    .leads-table td {
        display: grid;
        grid-template-columns: minmax(92px, 30%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        padding: 7px 0;
        border-bottom: 0;
        min-width: 0;
    }

    .leads-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .45px;
        line-height: 1.4;
        text-transform: uppercase;
    }

    .leads-table td.table-message {
        display: block;
        padding: 28px 8px !important;
    }

    .leads-table td.table-message::before {
        content: none;
    }

    .leads-table .person-cell {
        min-width: 0;
    }

    .leads-table .table-actions-cell {
        align-items: center;
    }

    .leads-table .table-actions-cell .btn-view {
        justify-self: start;
    }

    .source-header {
        gap: 10px;
        align-items: flex-start;
    }
}

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

    .panel-header {
        align-items: flex-start;
        gap: 12px;
    }

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

    .dashboard-body {
        padding: 12px;
    }

    .content-panel {
        padding: 14px;
        border-radius: 12px;
    }

    .panel-header {
        flex-wrap: wrap;
    }

    .panel-header > div {
        min-width: 0;
    }

    .panel-title,
    .panel-subtitle {
        overflow-wrap: anywhere;
    }

    .leads-table td {
        grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
    }

    /* Make each lead a compact, visually separate card on phones. */
    .leads-table tbody tr {
        margin: 0 0 10px;
        padding: 9px 10px;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: var(--bg-card);
        box-shadow: var(--shadow-xs);
    }

    .leads-table tbody tr:nth-child(even) {
        background: var(--accent-blue-light);
    }

    .leads-table td {
        grid-template-columns: minmax(78px, 31%) minmax(0, 1fr);
        gap: 8px;
        padding: 4px 0;
        font-size: 12px;
    }

    .leads-table td::before {
        font-size: 9px;
        letter-spacing: .35px;
    }

    .leads-table .person-cell {
        gap: 7px;
    }

    .leads-table .avatar {
        width: 27px;
        height: 27px;
        flex: 0 0 27px;
        font-size: 11px;
    }

    .leads-table .person-name {
        font-size: 12px;
    }

    .leads-table .person-sub {
        font-size: 10px;
    }

    .leads-table td > .badge {
        justify-self: start;
        width: fit-content;
        max-width: 100%;
        padding: 3px 8px;
        font-size: 10px;
    }

    .leads-table .btn-view {
        padding: 5px 9px;
        font-size: 11px;
    }

    .leads-table tbody tr:last-child {
        margin-bottom: 0;
    }
}

/* Medium-width windows can still be too narrow for six table columns. Keep
   the same readable card treatment before horizontal clipping begins. */
@media (min-width: 901px) and (max-width: 1200px) {
    .table-responsive {
        overflow-x: visible;
    }

    .leads-table,
    .leads-table thead,
    .leads-table tbody,
    .leads-table tr,
    .leads-table td {
        display: block;
        width: 100%;
    }

    .leads-table thead {
        display: none;
    }

    .leads-table tbody tr {
        padding: 14px 0;
        border-bottom: 1px solid var(--border-color);
    }

    .leads-table tbody tr:hover {
        background: transparent;
    }

    .leads-table td {
        display: grid;
        grid-template-columns: minmax(110px, 24%) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        padding: 7px 0;
        border-bottom: 0;
        min-width: 0;
    }

    .leads-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .45px;
        line-height: 1.4;
        text-transform: uppercase;
    }

    .leads-table td.table-message {
        display: block;
        padding: 28px 8px !important;
    }

    .leads-table td.table-message::before {
        content: none;
    }

    .leads-table .person-cell {
        min-width: 0;
    }
}
