/* acwise - CRE Acquisitions Intelligence Platform */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================
   HERO SECTION STYLES — Slim top bar
   ============================================ */

.hero-section {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    padding: 6px 24px;
    overflow: hidden; /* clips the shimmer ::after; the More dropdown escapes via position:fixed */
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    background: linear-gradient(135deg, #1E3A5F 0%, #162D4A 50%, #0F2035 100%);
    z-index: 101;
    box-shadow: 0 2px 8px rgba(15, 32, 53, 0.25);
    /* Reserve room for the fixed user menu (right:20px, ~160px wide) and the
       Evaluator status chip (right:200px) that float over the bar's right edge. */
    padding-right: 220px;
}

/* Subtle animated shimmer on header */
.hero-section::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.03) 25%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.03) 75%,
        transparent 100%
    );
    animation: headerShimmer 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes headerShimmer {
    0%, 100% { transform: translateX(-25%); }
    50% { transform: translateX(25%); }
}

/* Video elements — hidden, replaced by static header */
.hero-video,
.hero-video-a,
.hero-video-b {
    display: none !important;
}

.hero-overlay {
    display: none;
}

.hero-content {
    text-align: center;
    z-index: 2;
    padding: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.hero-logo {
    height: 40px;
    width: auto;
    margin-bottom: 0;
}

/* The Acwise fallback wordmark is wide — render it smaller than org logos. */
.hero-logo-acwise {
    height: 26px;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.01em;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Hero divider — simplified */
.hero-divider {
    display: none;
}

/* Responsive hero adjustments */
@media (max-width: 768px) {
    .hero-section {
        padding: 8px 16px;
    }

    .hero-logo {
        height: 24px;
    }

    .hero-title {
        font-size: 1rem;
    }

    .hero-subtitle {
        display: none;
    }

    .main-tabs {
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 6px 12px;
    }

    .hero-logo {
        height: 22px;
    }

    .hero-title {
        font-size: 0.9rem;
    }

    .hero-subtitle {
        display: none;
    }
}

/* Video Toggle Button - Subtle, minimal design */
.video-toggle-btn {
    position: absolute;
    bottom: 50px;
    right: 16px;
    z-index: 10;
    width: 26px;
    height: 26px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.video-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.7);
    opacity: 1;
}

.video-toggle-btn:active {
    transform: scale(0.92);
}

.video-toggle-btn svg {
    width: 100%;
    height: 100%;
    display: block;
}

.video-toggle-btn.loading {
    opacity: 0.3;
    pointer-events: none;
}

.video-toggle-btn.loading svg {
    animation: spin 1s linear infinite;
}

/* Responsive video toggle */
@media (max-width: 768px) {
    .video-toggle-btn {
        bottom: 45px;
        right: 10px;
        width: 22px;
        height: 22px;
        padding: 4px;
    }
}

@media (max-width: 480px) {
    .video-toggle-btn {
        bottom: 40px;
        right: 8px;
        width: 20px;
        height: 20px;
        padding: 3px;
    }
}

/* ============================================
   END HERO SECTION STYLES
   ============================================ */

:root {
    /* acwise Brand Colors */
    --primary-color: #1E3A5F;         /* Navy - primary buttons */
    --primary-dark: #162D4A;          /* Darker navy for hover */
    --primary-light: #2A4D7A;         /* Lighter navy */
    --accent-primary: #1E3A5F;        /* Same as primary - for active states */
    --accent-primary-hover: #162D4A;  /* Darker for hover on active */
    --secondary-color: #3B82F6;       /* Blue - secondary accent */
    --secondary-dark: #2563EB;        /* Darker blue for hover */
    --success-color: #16A34A;         /* Clean green for success */
    --error-color: #DC2626;           /* Clean red for errors */
    --warning-color: #F59E0B;         /* Amber for warnings */

    /* Background & Surface Colors */
    --bg-page: #EBEEF3;               /* Slightly cooler, richer grey */
    --bg-card: #FFFFFF;               /* Pure white for cards */
    --bg-input: #F5F7FA;              /* Slightly blue-tinted input bg */
    --bg-input-focus: #FFFFFF;        /* White on focus */

    /* Text Colors */
    --text-primary: #1F2937;          /* Dark grey - near black */
    --text-secondary: #4B5563;        /* Medium grey */
    --text-muted: #6B7280;            /* Grey, 4.8:1 on white (11/04: was #9CA3AF, 2.5:1) */
    --text-input: #2A5DB0;            /* Blue for an editable figure (11/17), 5.6:1 on white; derived values stay --text-primary */

    /* Border & Accent Colors */
    --border-color: #E5E7EB;          /* Cool grey border */
    --border-focus: #1E3A5F;          /* Navy focus */
    --light-accent: #E5E7EB;          /* Cool grey accent */

    /* Shadows - refined, subtle */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.04), 0 4px 8px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);

    /* Fonts */
    --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* --font-mono repointed to the body font: the monospace "numbery" look read
       as inconsistent / "techy code" across surfaces. Kept as a variable so the
       many existing usages stay uniform with the rest of the site. Number
       columns/metrics that used to rely on the mono font for alignment now use
       font-variant-numeric: tabular-nums instead (see .font-mono / .financial-value
       and the tabular-nums utility below). Mirrors templates/deal_card_v2.html. */
    --font-mono: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    /* One radius per role (theme pass Q5, 2026-11-12): every card, popover,
       menu and modal 10px; every control (button, input, select) 8px. */
    --radius-card: 10px;
    --radius-control: 8px;

    /* Legacy variable aliases (referenced throughout) */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F7FA;
    --accent-primary: #1E3A5F;
    --accent-primary-hover: #162D4A;

    /* Button scale variables (canonical, P2.4 2026-06-10; densified 2026-07-16) */
    --btn-xs-pad:    2px 6px;
    --btn-xs-fs:     0.7rem;
    --btn-sm-pad:    4px 10px;
    --btn-sm-fs:     0.75rem;
    --btn-pad:       6px 14px;
    --btn-fs:        0.8125rem;
    --btn-lg-pad:    10px 20px;
    --btn-lg-fs:     0.9rem;
    --btn-icon-sm-size: 28px;
    --btn-icon-size:    36px;
    --btn-icon-lg-size: 44px;

    /* Missing hover token — was undefined; referenced 15+ times across style.css.
       Without this every .btn-action hover and other bg-hover rules were invisible. */
    --bg-hover: #F3F4F6;

    /* Success variant hover (darkened #16A34A for .btn-success:hover) */
    --success-dark: #15803D;

    /* Type scale — 6 canonical steps replace 20+ ad-hoc rem/px values.
       Apply to new rules and migrate broken offenders incrementally. */
    --fs-xs:   11px;   /* sub-labels, sort indicators */
    --fs-sm:   12px;   /* table secondary text, badges */
    --fs-base: 13px;   /* table body, default body text */
    --fs-md:   14px;   /* form inputs, card metadata */
    --fs-lg:   16px;   /* section headings, nav items */
    --fs-xl:   20px;   /* page titles, modal headings */
}

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

/* Global select styling — override native browser dropdowns */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    padding-right: 32px !important;
    font-family: var(--font-body);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: white;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

select:hover {
    border-color: rgba(30, 58, 95, 0.3);
}

select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

select option {
    background: white;
    color: var(--text-primary);
    padding: 8px 12px;
}

body {
    font-family: var(--font-body);
    background: var(--bg-page);
    background-image:
        radial-gradient(circle at 1px 1px, rgba(30, 58, 95, 0.06) 1px, transparent 0);
    background-size: 20px 20px;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 32px;
    min-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

/* Adjust container when hero is present */
body:has(.hero-section) .container {
    min-height: auto;
    padding-top: 20px;
}

/* Header */
.header {
    text-align: left;
    padding: 16px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--light-accent);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    height: 48px;
    width: auto;
    flex-shrink: 0;
}

.header-text {
    display: flex;
    flex-direction: column;
}

.header h1 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 2px;
}

.header .subtitle {
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
}

/* Responsive header */
@media (max-width: 600px) {
    .header-brand {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-logo {
        height: 40px;
    }

    .header h1 {
        font-size: 1.25rem;
    }
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 36px;
    flex: 1;
}

@media (max-width: 1000px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Panels */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.panel:hover {
    box-shadow: var(--shadow-md);
}

.panel h2 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* Form Elements */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.938rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 14px;
}

.form-row .form-group {
    flex: 1;
}

.form-row .form-group.small {
    flex: 0 0 85px;
}

/* Buttons */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-base), background var(--transition-fast), border-color var(--transition-fast);
    position: relative;
    white-space: nowrap;
    line-height: 1.4;
}

/* Large CTA buttons (e.g. "Run Evaluator") — explicit opt-in */
.btn-lg {
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
}

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

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    position: relative;
    color: white;
    box-shadow: 0 2px 4px rgba(30, 58, 95, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-color) 100%);
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3), 0 0 0 2px rgba(30, 58, 95, 0.08);
    transform: translateY(-1px);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--light-accent);
    border-color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

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

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
    box-shadow: var(--shadow-md);
}

/* Orange accent button for secondary actions */
.btn-accent {
    background: var(--secondary-color);
    color: white;
}

.btn-accent:hover:not(:disabled) {
    background: var(--secondary-dark);
    box-shadow: var(--shadow-md);
}

/* Market report button - blue */
.btn-market-report {
    background: #1565c0;
    color: white;
}

.btn-market-report:hover:not(:disabled) {
    background: #0d47a1;
    box-shadow: var(--shadow-md);
}

/* Ghost button — transparent background, border only */
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

/* Form actions row */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.form-actions .btn {
    flex: 1;
}

.btn-icon {
    font-size: 0.875em;
}

/* SVG Icon Styling */
.icon {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    flex-shrink: 0;
}

.btn .icon {
    width: 1.125em;
    height: 1.125em;
}

.btn-icon-only .icon {
    width: 1.25em;
    height: 1.25em;
}

.btn-sm .icon {
    width: 1em;
    height: 1em;
}

/* Divider */
.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 28px 0;
}

/* Collapsible */
.collapsible-header {
    width: 100%;
    background: var(--light-accent);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text-secondary);
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.collapsible-header:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.collapsible-content {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

/* Status Bar */
.status-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--light-accent);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s;
}

.status-dot.running {
    background: transparent;
    border: 2px solid var(--secondary-color);
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

.status-dot.complete {
    background: var(--primary-color);
}

.status-dot.error {
    background: var(--error-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.status-text {
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.938rem;
}

/* Progress Steps */
.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 28px;
}

.step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: var(--light-accent);
    border-radius: var(--radius-md);
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
}

.step.active {
    background: rgba(30, 58, 95, 0.1);
    border-left-color: var(--primary-color);
}

.step.complete {
    background: rgba(30, 58, 95, 0.08);
    border-left-color: var(--primary-color);
}

.step-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.step.active .step-indicator {
    border-color: var(--primary-color);
    background: var(--primary-color);
}

.step.active .step-indicator::after {
    content: '';
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

.step.complete .step-indicator {
    border-color: var(--primary-color);
    background: var(--primary-color);
}

.step.complete .step-indicator::after {
    content: '';
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.step-label {
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.step.active .step-label,
.step.complete .step-label {
    color: var(--text-primary);
    font-weight: 500;
}

/* Logs */
.logs-container {
    margin-top: 24px;
}

.logs-container h3 {
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.logs {
    background: var(--light-accent);
    border-radius: var(--radius-md);
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.813rem;
}

.log-entry {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

.log-message {
    color: var(--text-secondary);
    word-break: break-word;
}

.log-entry.log-success .log-message {
    color: var(--primary-color);
}

.log-entry.log-error .log-message {
    color: var(--error-color);
}

.log-entry.log-warning .log-message {
    color: var(--secondary-color);
}

/* Evaluator running screen */
.evaluator-running-screen {
    padding: 16px 0;
}

.running-status-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--light-accent);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    margin-bottom: 24px;
}

.running-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.running-status-msg {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s steps(4, end) infinite;
}

@keyframes loadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Progress bars */
.running-progress-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.progress-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 110px;
    flex-shrink: 0;
    text-align: right;
}

.progress-bar-track {
    flex: 1;
    height: 6px;
    background: var(--light-accent);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--border-color);
    border-radius: 3px;
    transition: width 0.4s ease, background 0.3s ease;
}

.progress-bar-item.active .progress-bar-label {
    color: var(--text-primary);
    font-weight: 600;
}

.progress-bar-item.active .progress-bar-fill {
    width: 60%;
    background: var(--primary-color);
    animation: progressPulse 1.5s ease-in-out infinite;
}

.progress-bar-item.complete .progress-bar-label {
    color: var(--primary-color);
}

.progress-bar-item.complete .progress-bar-fill {
    width: 100%;
    background: var(--primary-color);
    animation: none;
}

.progress-bar-item.pending .progress-bar-fill {
    width: 0%;
}

@keyframes progressPulse {
    0%, 100% { width: 50%; }
    50% { width: 75%; }
}

/* Toggle logs button */
.btn-toggle-logs {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    transition: all 0.15s;
}

.btn-toggle-logs:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-toggle-logs.expanded .icon {
    transform: rotate(180deg);
}

/* Result Panel */
.result-panel {
    margin-top: 24px;
    padding: 18px;
    background: rgba(30, 58, 95, 0.1);
    border: 1px solid rgba(30, 58, 95, 0.25);
    border-radius: var(--radius-md);
}

.result-panel.error {
    background: rgba(196, 92, 92, 0.1);
    border-color: rgba(196, 92, 92, 0.25);
}

.result-panel h3 {
    font-family: var(--font-heading);
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.result-panel.error h3 {
    color: var(--error-color);
}

.result-content {
    font-family: var(--font-body);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.result-content p {
    margin-bottom: 8px;
}

.result-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(89, 86, 72, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
    overflow: hidden;
}

.modal-content {
    background: var(--bg-card);
    padding: 28px;
    border-radius: var(--radius-lg);
    max-width: 440px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.modal-content p {
    font-family: var(--font-body);
    color: var(--text-secondary);
    margin-bottom: 18px;
    font-size: 0.938rem;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.875rem;
}

.checkbox-label input {
    width: auto;
    accent-color: var(--primary-color);
}

.saved-key-info {
    background: rgba(30, 58, 95, 0.12);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: var(--primary-color);
    font-family: var(--font-body);
    font-size: 0.813rem;
    border: 1px solid rgba(30, 58, 95, 0.2);
}

/* Footer */
.footer {
    text-align: center;
    padding: 28px 0 0;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.813rem;
    margin-top: auto;
    border-top: 2px solid var(--light-accent);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-accent);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

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

/* Selection highlight */
::selection {
    background: rgba(30, 58, 95, 0.3);
    color: var(--text-primary);
}

/* Link styling */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   MANAGE PROPERTIES STYLES
   ============================================ */

/* Property Select Row - dropdown with manage button */
/* NOTE: .btn-icon-only below = legacy alias for canonical .btn-icon-lg (44px square).
   Do not rename; alias only. Canonical class defined in Button System section at EOF. */
.property-select-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.property-select-row select {
    flex: 1;
}

.btn-icon-only {
    flex-shrink: 0;
    width: 44px;
    height: auto;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon-only:hover {
    background: var(--light-accent);
    border-color: var(--text-muted);
}

.btn-icon-only .btn-icon {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

/* Modal Variations */
.modal-large {
    max-width: 540px;
    max-height: 80vh;
    padding: 24px;
}

.modal-small {
    max-width: 400px;
}

/* Modal Header with close button */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin-bottom: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: var(--light-accent);
    color: var(--text-primary);
}

.btn-close .icon {
    width: 1.25em;
    height: 1.25em;
}

/* .modal-close is the same affordance as .btn-close but was never styled in
   the main app, so those X buttons rendered as default browser buttons
   (off-theme bordered square — reported 8/4 on the Log Activity popover).
   Mirror the .btn-close look for every modal that uses it. */
.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

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

/* Search Group */
.search-group {
    margin-bottom: 18px;
}

.search-group input {
    width: 100%;
}

/* Properties List */
.properties-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
}

.property-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

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

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

.property-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.property-name {
    font-family: var(--font-body);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.938rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-location {
    font-family: var(--font-body);
    font-size: 0.813rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 12px;
}

/* Small Text Buttons — one step below the compact base .btn */
.btn-sm {
    padding: 3px 9px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.btn-sm .icon {
    width: 14px;
    height: 14px;
}

/* Small Icon-Only Action Buttons (squares) */
/* NOTE: .btn-action below = legacy alias for canonical .btn-icon-sm (28px square).
   Do not rename; alias only. Canonical class defined in Button System section at EOF. */
.btn-action {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action .icon {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

.btn-action:hover {
    background: var(--bg-hover);
}

.btn-action.btn-view {
    color: var(--text-secondary);
}

.btn-action.btn-view:hover {
    background: rgba(30, 58, 95, 0.15);
    border-color: var(--primary-color);
}

.btn-action.btn-view:hover .icon {
    color: var(--primary-color);
}

.btn-action.btn-edit {
    color: var(--text-secondary);
}

.btn-action.btn-edit:hover {
    background: rgba(240, 162, 84, 0.15);
    border-color: var(--secondary-color);
}

.btn-action.btn-edit:hover .icon {
    color: var(--secondary-color);
}

.btn-action.btn-delete {
    color: var(--text-secondary);
}

.btn-action.btn-delete:hover {
    background: rgba(196, 92, 92, 0.15);
    border-color: var(--error-color);
}

.btn-action.btn-delete:hover .icon {
    color: var(--error-color);
}

/* Actions cell in tables */
.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Legacy btn-sm icon support */
.btn-sm.btn-view:hover,
.btn-sm.btn-edit:hover,
.btn-sm.btn-delete:hover {
    opacity: 0.9;
}

/* No Properties Message */
.no-properties {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.938rem;
}

.error-message {
    padding: 40px 20px;
    text-align: center;
    color: var(--error-color);
    font-family: var(--font-body);
    font-size: 0.938rem;
}

/* Property Details View */
.property-details {
    max-height: 400px;
    overflow-y: auto;
}

.detail-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.detail-section h4 {
    font-family: var(--font-heading);
    font-size: 0.938rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.detail-row {
    display: flex;
    padding: 6px 0;
}

.detail-label {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
    width: 120px;
    flex-shrink: 0;
}

.detail-value {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    flex: 1;
    word-break: break-word;
}

.detail-value.path-value {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.75rem;
    background: var(--light-accent);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

/* Delete Modal Styles */
.delete-warning {
    font-family: var(--font-body);
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 8px;
}

.delete-info {
    font-family: var(--font-body);
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 16px;
}

.delete-folder-check {
    color: var(--text-secondary);
}

.delete-folder-warning {
    background: rgba(196, 92, 92, 0.1);
    border: 1px solid rgba(196, 92, 92, 0.25);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--error-color);
    font-family: var(--font-body);
    font-size: 0.813rem;
    margin-top: 12px;
}

/* Danger Button */
.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #b34848;
    box-shadow: var(--shadow-md);
}

/* ============================================
   ADD PROPERTY MODAL STYLES
   ============================================ */

#add-property-modal .modal-content {
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
}

#add-property-form .form-group {
    margin-bottom: 16px;
}

#add-property-form .form-group label {
    display: block;
    font-family: var(--font-body);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
}

#add-property-form .form-group label .required {
    color: var(--error-color);
    font-weight: 600;
}

#add-property-form .form-group input,
#add-property-form .form-group select,
#add-property-form .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

#add-property-form .form-group input:focus,
#add-property-form .form-group select:focus,
#add-property-form .form-group textarea:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

#add-property-form .form-group textarea {
    resize: vertical;
    min-height: 60px;
}

#add-property-form .form-row {
    display: flex;
    gap: 12px;
}

#add-property-form .form-row .form-group {
    flex: 1;
}

#add-property-form .form-row .form-group.small {
    flex: 0 0 80px;
}

#add-property-form .modal-buttons {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Spin animation for loading button */
.spin-icon {
    animation: spin 1s linear infinite;
}

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

/* ============================================
   TAB NAVIGATION STYLES
   ============================================ */

.main-tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 8px 24px;
    background: rgba(255,255,255,0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.tab-btn:hover {
    background: rgba(30, 58, 95, 0.06);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, #234B78 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.35), 0 1px 2px rgba(30, 58, 95, 0.2);
}

.tab-btn svg {
    width: 15px;
    height: 15px;
}

/* ============================================
   MERGED TOP BAR — nav lives inside .hero-section
   Overrides the standalone light-bar tab styles for the dark blue bar.
   ============================================ */
.hero-section .main-tabs {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    box-shadow: none;
    position: static;
    padding: 0;
    justify-content: flex-start;
    gap: 2px;
    flex-wrap: nowrap;
    min-width: 0;
}

.hero-section .tab-btn {
    color: rgba(255, 255, 255, 0.72);
    padding: 6px 12px;
    white-space: nowrap;
}

.hero-section .tab-btn:hover {
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
    transform: none;
}

.hero-section .tab-btn.active {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: none;
}

.nav-ext {
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Impersonation pill — same look as admin.css/platform-admin.css so the
   shared shell chrome can show it on pages that only load style.css
   (Markets, Listings). */
.impersonation-pill {
    position: fixed;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--status-warning, #f59e0b);
    color: white;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    white-space: nowrap;
}

.impersonation-pill .icon {
    width: 14px;
    height: 14px;
}

.impersonation-pill button {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 0 0 0 4px;
    line-height: 1;
    opacity: 0.8;
}

.impersonation-pill button:hover {
    opacity: 1;
}

.tab-content {
    background: var(--bg-page);
    position: relative;
    z-index: 2;
}

.tab-panel {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   TRACKER CONTAINER STYLES
   ============================================ */

/* Tracker Setup Overlay */
#tracker-setup-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px 20px;
}

.tracker-setup-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 48px;
    text-align: center;
    max-width: 500px;
}

.tracker-setup-card .setup-icon {
    margin-bottom: 20px;
}

.tracker-setup-card h3 {
    font-size: 22px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 12px 0;
}

.tracker-setup-card p {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 24px 0;
}

.tracker-setup-card .setup-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.tracker-setup-card .setup-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
}

.tracker-setup-card .setup-note {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 16px;
    margin-bottom: 0;
}

/* Tracker Sync Bar */
.tracker-sync-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 24px;
    background: rgba(59, 130, 246, 0.08);
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    font-size: 13px;
    color: #1e40af;
}

.tracker-sync-bar .sync-icon {
    display: flex;
    align-items: center;
}

.tracker-sync-bar .sync-icon .icon {
    width: 16px;
    height: 16px;
    color: #3b82f6;
}

.tracker-sync-bar .btn-sm {
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.tracker-sync-bar .sync-status {
    font-size: 12px;
    color: #3b82f6;
}

.tracker-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 16px 24px;
}

/* Filters */
.tracker-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 2px;   /* reduced: .tracker-status-bar below owns the gap to the table */
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    gap: 12px;
}

.filter-select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-family: var(--font-body);
    font-size: 0.875rem;
    min-width: 150px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.filter-select:hover {
    border-color: rgba(30, 58, 95, 0.3);
}

.filter-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.tracker-search-group {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    align-items: center;
    flex-wrap: nowrap;
}

.tracker-search-group .btn {
    padding: 10px 14px;
    font-size: 0.85rem;
}

/* Excel logo button */
.btn-excel-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    opacity: 0.85;
}

.btn-excel-logo:hover {
    transform: scale(1.1);
    opacity: 1;
}

.btn-excel-logo:active {
    transform: scale(0.95);
}

/* Status bar: reserved 18px slot between the filters/toolbar and the table.
   Always present in the DOM — height is claimed at first paint regardless of
   whether text content has loaded, so the updating spinner and last-updated
   text appearing here causes zero layout shift on the toolbar buttons above.
   The .tracker-filters margin-bottom was reduced from 20px to 2px (in the
   .tracker-filters rule above) to let this bar own the gap to the table. */
.tracker-status-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 18px;          /* fixed — never collapses or grows */
    margin-bottom: 8px;
    padding: 0 2px;
    overflow: hidden;      /* keeps the fixed height strict */
}

/* Last updated and updating indicators (now live in .tracker-status-bar) */
.tracker-last-updated {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    line-height: 1;
}

.tracker-last-updated.stale {
    color: var(--warning-color, #d4a574);
}

.tracker-updating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    line-height: 1;
}

.tracker-updating .spin-icon {
    width: 12px;
    height: 12px;
    animation: spin 1s linear infinite;
}

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

.search-input {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: var(--font-body);
    width: 250px;
    color: var(--text-primary);
    background: white;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* Stats Bar */
.tracker-stats {
    display: flex;
    gap: 16px;
    padding: 10px 20px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   DATA TABLE STYLES - FULL 30 COLUMN TABLE
   ============================================ */

.tracker-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: white;
    max-width: 100%;
    position: relative;
    box-shadow: var(--shadow-sm);
}

/* Fullscreen mode for tracker - TRUE fullscreen like Google Sheets */
#tracker-tab.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: white;
    padding: 0;
    margin: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
}

#tracker-tab.fullscreen .tracker-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
    min-height: 0;  /* Critical for flex children to shrink */
    height: 100%;
    overflow: hidden;  /* Container doesn't scroll, only table-wrapper does */
}

#tracker-tab.fullscreen .tracker-table-wrapper {
    flex: 1;
    max-height: none;
    height: 100%;
    min-height: 0;  /* Critical for flex children to shrink and enable scrolling */
    border-radius: 0;
    border: none;
    overflow-x: auto;
    overflow-y: auto !important;  /* Force vertical scroll */
}

#tracker-tab.fullscreen .tracker-content-row {
    flex: 1;
    min-height: 0;
}

/* Hide filters, status bar, and stats in fullscreen */
#tracker-tab.fullscreen .tracker-filters,
#tracker-tab.fullscreen .tracker-status-bar,
#tracker-tab.fullscreen .tracker-stats {
    display: none !important;
}

/* ============================================
   TRACKER MAP PANEL (Pipeline Map)
   ============================================ */

.tracker-content-row {
    display: flex;
    flex: 1;
    min-height: 0;
}

.tracker-content-row .tracker-table-wrapper {
    flex: 1;
    min-width: 0;
}

.tracker-map-panel {
    width: 35%;
    min-width: 300px;
    max-width: 500px;
    border-left: 1px solid var(--border-color, #e5e7eb);
    display: flex;
    flex-direction: column;
    background: #f9fafb;
    position: sticky;
    top: 54px; /* sits just below the merged top bar (~52px tall) */
    align-self: flex-start;
    height: calc(100vh - 70px);
    max-height: 100vh;
    z-index: 5;
}

.tracker-map-panel.collapsed {
    display: none;
}

.tracker-map-tab {
    display: none; /* shown when map is collapsed */
    width: 24px;
    background: #f3f4f6;
    border-left: 1px solid #e5e7eb;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: background 0.15s;
    flex-shrink: 0;
}
.tracker-map-tab:hover { background: #e5e7eb; color: #374151; }
.tracker-map-tab.visible { display: flex; }

.tracker-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;          /* never let controls run off the panel width */
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}

.tracker-map-title {
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

/* Contained, responsive control bar — wraps within the map width so nothing
   clips off the right edge (issue #1). */
.tracker-map-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
}

.tracker-map-ctl {
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.4;
}

.tracker-map-ctl-select {
    background: #fff;
    color: #111;
    padding: 2px 6px;
    max-width: 130px;
}

.tracker-map-ctl-btn {
    background: #f3f4f6;
}

/* Layer chips (2026-11-04): the active layer reads like the comps map's chip. */
.tracker-map-chips {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tracker-map-chip.active {
    background: #1E3A5F;
    border-color: #1E3A5F;
    color: #fff;
}

/* Active layer legend, inside the panel so fullscreen shows it too. */
.tracker-map-ov-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-top: 1px solid #e5e7eb;
    font-size: 11px;
    color: #374151;
}

.tracker-map-ov-legend .tmol-title { font-weight: 600; }
.tracker-map-ov-legend .tmol-item { display: inline-flex; align-items: center; gap: 4px; }
.tracker-map-ov-legend .tmol-swatch { width: 12px; height: 12px; display: inline-block; border: 1px solid rgba(0,0,0,0.15); }
.tracker-map-ov-legend .tmol-dot { border-radius: 50%; }
.tracker-map-ov-legend .tmol-src { color: #6b7280; margin-left: auto; }

/* MapLibre chrome on the pipeline map: no logo, attribution stays compact. */
#tracker-map .maplibregl-ctrl-logo { display: none !important; }

#tracker-map-fs-btn.tracker-map-ctl-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tracker-map-geocode-status {
    font-size: 11px;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

#tracker-map {
    flex: 1;
    min-height: 300px;
}

/* #tracker-map-legend is retained ONLY as a zero-height anchor element so the
   demographic-overlay legend (#tracker-map-demo-legend) can be inserted as its
   next sibling and render inside the map panel (incl. fullscreen). It stays
   display:none itself. The PHASE legend (reintroduced 2026-08-20, org-driven
   colors) is a separate overlay: #tracker-map-phase-legend inside #tracker-map. */
.tracker-map-legend {
    background: #fff;
}

/* Pins coverage strip under the map header: "N of M mapped" (left) plus the
   quiet locating / could-not-locate note (right). Muted, institutional. */
.tracker-map-pins-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 12px;
    font-size: 11px;
    color: #6b7280;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}
.tracker-map-pins-row .tmpr-note {
    color: #9ca3af;
    white-space: nowrap;
}

/* Phase legend overlay (bottom-left corner of the map): the org's own phase
   names/colors with pin counts; click a row to toggle that phase's pins.
   Dimmed rows are hidden phases. Scrolls if an org has many phases. */
.tracker-map-phase-legend {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 11px;
    line-height: 1.5;
    max-height: 42%;
    max-width: 60%;
    overflow-y: auto;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.tracker-map-phase-legend .tmpl-row {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 1px 0;
    color: #374151;
    user-select: none;
}
.tracker-map-phase-legend .tmpl-row:hover { color: #111827; }
.tracker-map-phase-legend .tmpl-row.off { opacity: 0.4; }
.tracker-map-phase-legend .tmpl-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
}
.tracker-map-phase-legend .tmpl-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
}
.tracker-map-phase-legend .tmpl-count {
    margin-left: auto;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    padding-left: 6px;
}

/* Demographic-overlay legend lives in #tracker-map-demo-legend (built in JS).
   It must show in BOTH normal and fullscreen views since it sits inside the
   map panel that fullscreen expands. No extra rules needed — inline styles set
   in _buildTrackerDemoLegend handle layout. */

/* Tracker map marker pins. Background + text color are set inline by app.js
   from the org's own phase colors (neutral navy + white text fallback), so no
   !important here; the text-shadow is the safety net for the dark fallback pin
   and is dropped inline when a light phase color is applied. */
.tracker-map-marker {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    transition: transform 0.15s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
    /* Score number on the pin: body font (dropped the monospace "code" look
       Carson dislikes) with tabular figures so the digits stay balanced. */
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Plain pin (the default since 2026-11-04): drawn like the phase pill
   (2026-11-11, AcwiseMap.paintPin sets the fill, the ring, the hairline and
   the size inline: 16px, 22px selected). */
.tracker-map-marker.tracker-map-marker-dot {
    width: 16px;
    height: 16px;
    font-size: 0;
    text-shadow: none;
}

/* Wide pill variant for text labels (Price) that don't fit a 30px
   circle. Auto-width with a pill radius so the label stays legible. */
.tracker-map-marker.tracker-map-marker-wide {
    width: auto;
    min-width: 30px;
    max-width: 120px;
    padding: 0 8px;
    border-radius: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tracker-map-marker:hover {
    transform: scale(1.2);
    z-index: 10;
}

/* The selected deal (its row or card): app.js paints it larger with a soft
   halo in its ring color (AcwiseMap.paintPin, selected); it sits on top. */
.tracker-map-marker.active,
.tracker-map-marker.is-selected {
    z-index: 3;
}

/* Pipeline Map fullscreen mode — overlays the whole viewport so user can
   see all pins at once, then exit back to the side-by-side tracker view. */
.tracker-map-panel.fullscreen {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    max-height: none !important;
    z-index: 9999 !important;
    border-left: 0 !important;
    background: #fff !important;
}
.tracker-map-panel.fullscreen #tracker-map {
    flex: 1 1 auto;
    min-height: 0;
}
.tracker-map-panel.fullscreen .tracker-map-marker {
    /* Slightly bigger so pin labels read comfortably at a distance */
    width: 36px;
    height: 36px;
    font-size: 13px;
}
.tracker-map-panel.fullscreen .tracker-map-marker.tracker-map-marker-wide {
    /* Keep text pills auto-width in fullscreen (don't force the 36px circle). */
    width: auto;
    min-width: 36px;
    max-width: 150px;
}

/* Narrow widths: the map is DEFAULT-COLLAPSED via JS (_initTrackerMapOnLoad,
   <1100px) instead of CSS display:none — the collapse arrow strip stays as the
   affordance to reopen it, and an explicit "shown" preference is respected.
   A hard display:none here left 1100-1280px users with no map and no way to
   get it back. */

/* Fullscreen exit button - separate element outside filters */
.fullscreen-exit-btn {
    display: none;
}

#tracker-tab.fullscreen .fullscreen-exit-btn {
    display: flex !important;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    opacity: 0.85;
    transition: all 0.2s ease;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

#tracker-tab.fullscreen .fullscreen-exit-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 1);
    transform: scale(1.02);
}

#tracker-tab.fullscreen .fullscreen-exit-btn .icon {
    width: 16px;
    height: 16px;
}

/* Table header touches top in fullscreen */
#tracker-tab.fullscreen .tracker-table th {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #F0F1F5;
}

/* Fullscreen sticky frozen columns - Excel/Sheets freeze panes behavior */
/* Fullscreen: bump all z-indexes so headers stay above body cells */
#tracker-tab.fullscreen .tracker-table th { z-index: 100; }
#tracker-tab.fullscreen .tracker-table th:nth-child(1) { z-index: 154; }
#tracker-tab.fullscreen .tracker-table th:nth-child(2) { z-index: 153; }
#tracker-tab.fullscreen .tracker-table th.col-sticky { z-index: 152; left: 72px; background: #F0F1F5 !important; }
#tracker-tab.fullscreen .tracker-table th.col-sticky-2 { z-index: 151; left: 322px; background: #F0F1F5 !important; }
#tracker-tab.fullscreen .tracker-table td:nth-child(1) { z-index: 104; }
#tracker-tab.fullscreen .tracker-table td:nth-child(2) { z-index: 103; }
#tracker-tab.fullscreen .tracker-table td.col-sticky { position: sticky; left: 72px; z-index: 102; background: white !important; }
#tracker-tab.fullscreen .tracker-table td.col-sticky-2 { position: sticky; left: 322px; z-index: 101; background: white !important; border-right: 2px solid var(--border-color); }

#tracker-tab.fullscreen .tracker-table tbody tr:hover td.col-sticky,
#tracker-tab.fullscreen .tracker-table tbody tr:hover td.col-sticky-2,
#tracker-tab.fullscreen .tracker-table tbody tr:hover td:nth-child(1),
#tracker-tab.fullscreen .tracker-table tbody tr:hover td:nth-child(2) {
    background: #f5f6f8 !important;
}

/* Hide navigation tabs and user menu when fullscreen is active */
body.fullscreen-active .main-tabs,
body.fullscreen-active .hero-section,
body.fullscreen-active .user-menu {
    display: none !important;
}

/* Body settings for fullscreen */
body.fullscreen-active {
    overflow: hidden;
}

/* Icon toggle for fullscreen button */
.fullscreen #fullscreen-tracker .fullscreen-expand {
    display: none;
}

.fullscreen #fullscreen-tracker .fullscreen-collapse {
    display: inline-block;
}

.tracker-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.tracker-table th {
    padding: 4px 8px;
    text-align: left;
    font-family: var(--font-body);
    font-size: var(--fs-xs);  /* was 0.68rem (~10.9px); raised to 11px for legibility */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6B7280;
    background: #F0F1F5;
    border-bottom: 1px solid var(--border-color);
    white-space: normal;      /* labels may wrap to two lines (2026-11-12) */
    line-height: 1.15;
    vertical-align: middle;
    --tih-bg: #F0F1F5;
    position: sticky;
    top: 0;
    z-index: 10;
}
.tracker-table th.sortable:hover { --tih-bg: #E4E6EC; }
/* Header label: two lines at most, vertically centered, never a raw key. */
.tracker-table th .tih-label {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;  /* a single word too wide for the cell ends in ... */
    overflow-wrap: normal;
    word-break: normal;
}
.tracker-table th.tih-col { padding-right: 8px; }

/* Sortable column headers */
.tracker-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.tracker-table th.sortable:hover {
    background: #E4E6EC;
}

.tracker-table th .sort-indicator {
    margin-left: 4px;
    opacity: 0.4;
    font-size: 10px;  /* was 0.55rem (~8.8px); raised to 10px — below legibility floor */
    vertical-align: middle;
}

/* Header row (2026-11-13): the label, then the sort arrow on the sorted
   column only, in one flex row so the arrow never sits on the label. The
   arrow box is 12px + a 4px gap = AcwiseColWidths.SORT_ARROW_PX, which the
   column fit reserves. Two lines tall always, so hover never moves the row. */
.tracker-table th.tih-col .tih-head {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 2.3em;
}
.tracker-table th.tih-col.col-num .tih-head { justify-content: flex-end; }
.tracker-table th.tih-col.col-doc .tih-head { justify-content: center; }
.tracker-table th.tih-col .tih-head .tih-label { flex: 0 1 auto; min-width: 0; }
.tracker-table th.tih-col .tih-head .sort-indicator {
    flex: none;
    width: 12px;
    margin-left: 4px;
    text-align: center;
    opacity: 1;
}
/* On hover the menu takes the right edge: the label narrows and truncates
   with an ellipsis before it, never under it. */
.tracker-table th.tih-col:not(.col-num):hover .tih-head { padding-right: 14px; }
.tracker-table th.tih-col.col-num:hover .tih-head { padding-right: 16px; }

.tracker-table th.sort-active .sort-indicator {
    opacity: 1;
}

.tracker-table th.sortable.col-sticky:hover,
.tracker-table th.sortable.col-sticky-2:hover {
    background: #E4E6EC !important;
}

/* ---- Inline column editing (drag-reorder, ⋮ menu, rename) ---- */
/* ⋮ affordance: hidden until header hover, then a subtle clickable glyph. */
.tracker-table th.tih-col .tih-menu-btn {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 0 5px 0 8px;
    /* Solid header background with a short fade on its left edge. */
    background: linear-gradient(to right, transparent 0, var(--tih-bg) 6px);
    opacity: 0;
    pointer-events: none;
    color: #9ca3af;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.12s ease, color 0.12s ease;
}
.tracker-table th.tih-col:hover .tih-menu-btn { opacity: 0.85; pointer-events: auto; }
.tracker-table th.tih-col .tih-menu-btn:hover { color: #374151; }
/* Drag feedback */
.tracker-table th.tih-col.tih-dragging { opacity: 0.5; }
.tracker-table th.tih-col.tih-drag-over { box-shadow: inset 3px 0 0 var(--primary-color, #6b8a5e); background: #E4E6EC; }
/* Inline rename input swapped in over the label */
.tracker-table th.tih-col .tih-rename-input {
    font: inherit;
    text-transform: none;
    letter-spacing: normal;
    color: #111827;
    padding: 1px 4px;
    border: 1px solid var(--primary-color, #6b8a5e);
    border-radius: 3px;
    width: 110px;
    max-width: 160px;
    background: #fff;
}
/* "Columns" control at the end of the header row (opens the column picker,
   app.js _tihOpenPicker). */
.tracker-table th.tih-addcol-th { cursor: default; }
.tracker-table .tih-addcol {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
    border: 1px solid var(--border-color, #E5E7EB); border-radius: 8px;
    background: var(--bg-card, #fff); color: var(--text-secondary, #4B5563);
    font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1;
    text-transform: none; letter-spacing: 0; white-space: nowrap; cursor: pointer;
}
.tracker-table .tih-addcol:hover { color: var(--text-primary, #1F2937); background: var(--bg-hover, #F3F4F6); }
.tracker-table .tih-addcol:focus-visible { outline: 2px solid var(--primary-color, #1E3A5F); outline-offset: 1px; }
.tih-hidden-chip {
    display: inline-block; padding: 2px 6px; border-radius: 6px;
    background: var(--bg-input, #F5F7FA); color: var(--text-muted, #6B7280);
    font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: normal;
}
/* Inline-header context menu reuses the .tr-menu-dropdown look */
.tih-ctx-menu { min-width: 190px; }

/* Column picker popover: the shared kit popover (10px radius, kit shadow,
   32px rows and controls). Only its list scrolls. */
.tih-picker {
    position: fixed; z-index: 9999;
    width: 272px; padding: 6px; border-radius: 10px; white-space: normal;
    background: var(--bg-card, #fff); border: 1px solid var(--border-color, #E5E7EB);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); font-family: var(--font-body, inherit);
    box-sizing: border-box;
}
.tih-picker input[type="search"], .tih-picker input[type="text"] {
    width: 100%; height: 32px; box-sizing: border-box; padding: 0 10px; margin: 0;
    border: 1px solid var(--border-color, #E5E7EB); border-radius: 8px;
    background: var(--bg-input, #F5F7FA); color: var(--text-primary, #1F2937);
    font-family: inherit; font-size: 13px; outline: none;
}
.tih-picker input[type="search"]:focus, .tih-picker input[type="text"]:focus {
    background: var(--bg-card, #fff); border-color: var(--primary-color, #1E3A5F);
}
.tih-pk-search { padding-bottom: 4px; }
.tih-pk-list {
    max-height: 320px; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent;
}
.tih-pk-list::-webkit-scrollbar { width: 8px; }
.tih-pk-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.tih-pk-list::-webkit-scrollbar-track { background: transparent; }
.tih-pk-row {
    display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 8px;
    border-radius: 6px; font-size: 13px; color: var(--text-secondary, #4B5563);
    cursor: pointer; user-select: none; margin: 0;
}
.tih-pk-row:hover { background: var(--bg-input, #F5F7FA); }
.tih-pk-row input[type="checkbox"] {
    width: 15px; height: 15px; margin: 0; flex: 0 0 auto; cursor: pointer;
    accent-color: var(--primary-color, #1E3A5F);
}
.tih-pk-row.is-locked { cursor: default; color: var(--text-muted, #6B7280); }
.tih-pk-row.is-locked input { cursor: default; }
.tih-pk-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tih-pk-empty { min-height: 32px; display: flex; align-items: center; padding: 0 8px;
    font-size: 13px; color: var(--text-muted, #6B7280); }
.tih-pk-new { display: flex; gap: 6px; padding-top: 6px; margin-top: 4px;
    border-top: 1px solid var(--border-color, #E5E7EB); }
.tih-pk-new input[type="text"] { flex: 1 1 auto; min-width: 0; }
.tih-pk-new button {
    flex: 0 0 auto; height: 32px; padding: 0 12px; border: 0; border-radius: 8px;
    background: var(--primary-color, #1E3A5F); color: #fff; font-family: inherit;
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.tih-pk-new button:hover { filter: brightness(1.1); }
.tih-pk-err { padding: 6px 2px 0; font-size: 12px; color: var(--error-color, #DC2626); }
/* Picker groups, row ⋮ and drag (2026-11-11). */
.tih-pk-group { height: 24px; display: flex; align-items: flex-end; padding: 0 8px 2px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted, #6B7280); }
.tih-pk-group:not(:first-child) { margin-top: 4px; }
.tih-pk-row { gap: 4px; padding: 0 2px 0 8px; }
.tih-pk-row[draggable="true"] { cursor: grab; }
.tih-pk-check { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; height: 32px; margin: 0; cursor: pointer; }
.tih-pk-row.is-locked .tih-pk-check { cursor: default; }
.tih-pk-more { width: 24px; height: 24px; flex: 0 0 24px; padding: 0; border: 0; border-radius: 6px;
    background: none; color: #9CA3AF; font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; }
.tih-pk-row:hover .tih-pk-more, .tih-pk-more:focus-visible { opacity: 1; }
.tih-pk-more:hover { background: var(--bg-card, #fff); color: var(--text-primary, #1F2937); }
.tih-pk-more-gap { width: 24px; flex: 0 0 24px; }
.tih-picker input.tih-pk-rename { height: 28px; margin: 2px 0; }
.tih-pk-dragging { opacity: 0.5; }
.tih-pk-drop-before { box-shadow: inset 0 2px 0 var(--primary-color, #1E3A5F); }
.tih-pk-drop-after { box-shadow: inset 0 -2px 0 var(--primary-color, #1E3A5F); }
/* Column menu: the Type row with its value; the type list's check column. */
.tih-colmenu .tih-menu-sub { justify-content: space-between; gap: 16px; }
.tih-colmenu .tih-menu-val { color: #9CA3AF; }
.tih-colmenu .tih-menu-check { width: 12px; display: inline-block; color: var(--primary-color, #1E3A5F); }
.tih-colmenu .tih-menu-back { color: #6B7280; }
.tih-colmenu .is-current { font-weight: 600; }

.tracker-table td {
    padding: 2px 8px;            /* tracker-ui: skinnier rows */
    font-size: var(--fs-base);   /* ui-system: 13px for legibility */
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    background: white;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    /* Body font (no monospace) but keep numeric columns aligned. */
    font-variant-numeric: tabular-nums;
}

.tracker-table tbody tr {
    transition: all 0.15s ease;
}

.tracker-table tbody tr:hover td {
    background: rgba(30, 58, 95, 0.04);
}

.tracker-table tbody tr:hover td:first-child {
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.tracker-table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   COLUMN WIDTH DEFINITIONS
   NOTE (2026-08-19): these .col-* widths are now the FALLBACK layer.
   renderTrackerTable auto-fits each auto-fittable column (text/number/
   currency/date/select) to its content, clamped per type, and writes
   inline width/min/max onto the <th> (table-layout:fixed sizes columns
   from the first row). See _trApplyAutoFitWidths + window.AcwiseColWidths
   in static/js/app.js. If measurement fails, or for non-auto-fit types
   (link/bool/docpresence/reports) and the FROZEN columns (.col-sticky
   Property Name / .col-sticky-2 Score, whose widths feed the freeze-pane
   left offsets below), these CSS widths still apply unchanged.
   ============================================ */

/* Sticky frozen columns — Excel "Freeze Panes" feel.
   Property Name sticks at 72px (after checkbox + actions).
   Score sticks at 322px (Property Name's 250px width + 72px). */
.col-sticky {
    position: sticky;
    left: 72px;
    z-index: 42;
    background: white !important;
    isolation: isolate;
    /* Left border acts as a clean "wall" between the 3-dot/actions column
       and Property Name. Without it, subpixel rounding on sticky elements
       could let Property Name visually slip 1px under the actions column.
       No right border — the freeze divider lives on Score (col-sticky-2)
       so the freeze pane has one clean divider line, not two. */
    border-left: 1px solid var(--border-color);
}
.col-sticky-2 {
    position: sticky;
    left: 322px;          /* 72 (chk + actions) + 250 (property name width) */
    z-index: 41;
    background: white !important;
    /* Same wall treatment as col-sticky for the Property Name → Score
       boundary. The 2px right border below is the freeze-pane divider. */
    border-left: 1px solid var(--border-color);
    border-right: 2px solid var(--border-color);
    isolation: isolate;
}
.tracker-table th.col-sticky {
    z-index: 52;
    background: #F0F1F5 !important;
}
.tracker-table th.col-sticky-2 {
    z-index: 51;
    background: #F0F1F5 !important;
}
.tracker-table tbody .col-sticky,
.tracker-table tbody .col-sticky-2 {
    background: white !important;
}

.col-property-name { width: 250px; min-width: 250px; }
.col-score { width: 70px; min-width: 70px; }

/* Half-screen: slim the frozen Property Name pane so the scrollable data
   area keeps usable width at 960px. col-sticky-2's left offset must track
   the name width (72px controls + name width). The #tracker-tab.fullscreen
   variants must be overridden too — their ID specificity beats the base
   rules and would leave Score floating 70px adrift at narrow widths. */
@media (max-width: 1280px) {
    .col-property-name { width: 180px; min-width: 180px; max-width: 180px; }
    .col-sticky-2 { left: 252px; } /* 72 + 180 */
    #tracker-tab.fullscreen .tracker-table th.col-sticky-2,
    #tracker-tab.fullscreen .tracker-table td.col-sticky-2 { left: 252px; }
}
.col-reports { width: 96px; min-width: 96px; text-align: center; }
.col-zone { width: 100px; min-width: 100px; }
.col-doc { width: 48px; min-width: 48px; text-align: center; }
/* Document indicator columns hold only a dot: narrow, label centered and small. */
.tracker-table th.col-doc { padding-left: 2px; padding-right: 2px; text-align: center; font-size: 10px; }
.tracker-table th.col-doc .tih-label { display: block; }
.col-address { width: 180px; min-width: 180px; }
.col-city { width: 130px; min-width: 130px; }
.col-state { width: 60px; min-width: 60px; }
.col-zip { width: 70px; min-width: 70px; }
.col-phase { width: 100px; min-width: 100px; }
.col-priority { width: 100px; min-width: 100px; }
.col-market { width: 100px; min-width: 100px; }
.col-date { width: 110px; min-width: 110px; }
.col-source { width: 120px; min-width: 120px; }
.col-broker { width: 140px; min-width: 140px; }
.col-link { width: 120px; min-width: 120px; }
.col-bool { width: 80px; min-width: 80px; text-align: center; }
.col-currency { width: 120px; min-width: 120px; }
.col-units { width: 80px; min-width: 80px; }
.col-vintage { width: 80px; min-width: 80px; }
.col-reason { width: 150px; min-width: 150px; }
.col-notes { width: 200px; min-width: 200px; max-width: 200px; }
.col-custom { width: 140px; min-width: 120px; max-width: 200px; }
/* Numeric columns (currency / number, from the resolved column type) read
   right aligned with tabular figures so dollars compare down the list
   (TS-05, 11/04). The header follows so the label sits over its digits. */
.tracker-table td.col-doc { text-align: center; }
.tracker-table td.col-num,
.tracker-table th.col-num { text-align: right; font-variant-numeric: tabular-nums; }
/* ============================================
   STICKY COLUMNS: 3 frozen columns on left
   Col 1: Checkbox (28px wide, left: 0)
   Col 2: Actions/3-dots (44px wide, left: 28px)
   Col 3: Property Name (250px, left: 72px) — via .col-sticky class
   Z-index: col1 (44) > col2 (43) > col3 (42) > regular headers (10) > regular cells (1)
   ============================================ */

/* Col 1: Checkbox */
.tracker-table td:nth-child(1),
.tracker-table th:nth-child(1) {
    position: sticky; left: 0; z-index: 44; background: white; isolation: isolate;
}
.tracker-table th:nth-child(1) { background: #F0F1F5; z-index: 54; }

/* Col 2: Actions (3-dot menu) */
.tracker-table td:nth-child(2),
.tracker-table th:nth-child(2) {
    position: sticky; left: 28px; z-index: 43; background: white; isolation: isolate;
}
.tracker-table th:nth-child(2) { background: #F0F1F5; z-index: 53; }

/* Hover: sticky cells get OPAQUE hover color (not transparent — content scrolls behind) */
.tracker-table tbody tr:hover td:nth-child(1),
.tracker-table tbody tr:hover td:nth-child(2),
.tracker-table tbody tr:hover .col-sticky,
.tracker-table tbody tr:hover .col-sticky-2 {
    background: #f5f6f8 !important;
}

/* Measured frozen offsets (2026-11-10): app.js _trSyncStickyOffsets sets
   --tr-sticky-a/b/c from the real header widths and adds .tr-sticky-measured.
   The hardcoded 28 / 72 / 322 px above stay as the pre-measure fallback;
   they were short of the real actions column width, so the name column
   slid a few px on a horizontal scroll before it froze. !important beats
   the fullscreen and narrow-window offsets, which carried the same numbers. */
.tracker-table.tr-sticky-measured th:nth-child(2),
.tracker-table.tr-sticky-measured td:nth-child(2) { left: var(--tr-sticky-a) !important; }
.tracker-table.tr-sticky-measured .col-sticky { left: var(--tr-sticky-b) !important; }
.tracker-table.tr-sticky-measured .col-sticky-2 { left: var(--tr-sticky-c) !important; }

.col-actions { width: 44px; min-width: 44px; max-width: 44px; padding: 0 !important; border-right: 1px solid var(--border-color, #e5e7eb); text-align: center; vertical-align: middle; }

.tr-menu-btn {
    background: none; border: none; cursor: pointer; padding: 4px;
    border-radius: 4px; color: #9ca3af; transition: color 0.15s, background 0.15s;
}
.tr-menu-btn:hover { color: #374151; background: #f3f4f6; }

.tr-menu-dropdown {
    position: fixed; z-index: 9999;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); min-width: 170px;
    padding: 4px 0; white-space: nowrap;
}
.tr-menu-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 14px; font-size: 12px; color: #374151;
    cursor: pointer; transition: background 0.1s;
}
.tr-menu-item:hover { background: #f9fafb; }
.tr-menu-item svg { flex-shrink: 0; }
.tr-menu-danger { color: #dc2626; }
.tr-menu-danger:hover { background: #fef2f2; }
.tr-menu-divider { height: 1px; background: #e5e7eb; margin: 4px 0; }

/* Archived row styling.
   NOTE: do NOT use `opacity` here — opacity on a sticky <td> makes it
   semi-transparent, so columns scrolling behind the sticky Name/Actions
   cells bleed through (the "transparent cells" bug in the Archive view).
   Instead dim via a solid muted background + muted text so every cell —
   including the sticky col 1/2 and fullscreen .col-sticky cells — stays
   fully opaque and matches the normal row background system. */
tr.tr-archived td {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
}
tr.tr-archived:hover td {
    background: #eceef1 !important;
}
/* Keep the sticky archived cells opaque in fullscreen too (those rules use
   `background: white !important`, which would otherwise win over the gray). */
#tracker-tab.fullscreen tr.tr-archived td.col-sticky,
#tracker-tab.fullscreen tr.tr-archived td.col-sticky-2,
#tracker-tab.fullscreen tr.tr-archived td:nth-child(1),
#tracker-tab.fullscreen tr.tr-archived td:nth-child(2) {
    background: #f3f4f6 !important;
}

/* Pinned row styling — subtle gold tint + thin left accent */
tr.tr-pinned td {
    background: rgba(245, 158, 11, 0.04);
}
tr.tr-pinned td:first-child {
    box-shadow: inset 3px 0 0 #f59e0b;
}
.tr-pin-btn:hover {
    color: #f59e0b !important;
}
/* The star and the row menu share one centered line (2026-11-11). */
.tracker-table td.col-actions .tr-actions-in { display: inline-flex; align-items: center; justify-content: center; gap: 2px; vertical-align: middle; }
.tracker-table td.col-actions .tr-pin-btn, .tracker-table td.col-actions .tr-menu-btn { display: inline-flex; align-items: center; justify-content: center; }

/* Show Archived toggle in filter bar */
.toggle-archived-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
    cursor: pointer;
    margin-left: 8px;
    white-space: nowrap;
    user-select: none;
}
.toggle-archived-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #2563eb;
    cursor: pointer;
}
.toggle-archived-text {
    font-weight: 500;
}

.tracker-table td.nav-focus {
    outline: 2px solid var(--primary-color, #6b8a5e);
    outline-offset: -2px;
    background: #f3f6f1 !important; /* opaque so sticky columns don't show content behind */
}

.col-readonly {
    background: rgba(0, 0, 0, 0.02) !important;
}

/* ============================================
   INLINE EDITING STYLES
   ============================================ */

.editable-cell {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s ease;
    min-height: 18px;
    display: block;
}

.editable-cell:hover {
    background: transparent;
}

.editable-cell.editing {
    background: white;
    box-shadow: inset 0 0 0 2px var(--primary-color);
    padding: 0;
}

.editable-cell.readonly {
    cursor: default;
    background: transparent;
    color: var(--text-secondary);
}

.editable-cell.readonly:hover {
    background: transparent;
}

/* Inline edit inputs */
.inline-edit-input {
    width: 100%;
    padding: 6px 8px;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 0.813rem;
    color: var(--text-primary);
    outline: none;
}

.inline-edit-input:focus {
    outline: none;
}

.inline-edit-select {
    width: 100%;
    padding: 4px 6px;
    border: none;
    background: white;
    font-family: var(--font-body);
    font-size: 0.813rem;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.inline-edit-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* ============================================
   LINK CELL STYLES
   ============================================ */

.link-cell {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-cell a {
    color: var(--primary-color);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-cell a:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.link-cell.empty {
    color: var(--text-muted);
    font-style: italic;
}

/* Link cell wrapper with edit button */
.link-cell-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.link-cell-wrapper .link-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--primary-color);
    text-decoration: none;
}

.link-cell-wrapper .link-value:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.link-edit-btn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    padding: 4px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    opacity: 0.5;
}

.link-cell-wrapper:hover .link-edit-btn {
    opacity: 1;
}

.link-edit-btn:hover {
    background: rgba(30, 58, 95, 0.15);
    color: var(--primary-color);
}

/* Link cell editing state */
.link-cell-editing {
    display: flex;
    align-items: center;
    gap: 4px;
}

.link-cell-editing input {
    flex: 1;
    min-width: 80px;
}

/* ============================================
   SAVE TOAST NOTIFICATION
   ============================================ */

.save-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.save-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.save-toast.error {
    background: var(--error-color);
}

/* Toast Notification (general purpose) */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 10000;
    max-width: 400px;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-notification.toast-success {
    background: var(--success-color, #22c55e);
}

.toast-notification.toast-error {
    background: var(--error-color, #ef4444);
}

/* ============================================
   NOTES/TEXT TRUNCATION AND EXPAND
   ============================================ */

.truncate-text {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.truncate-text:hover {
    position: relative;
}

.truncate-text[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 0;
    top: 100%;
    background: var(--text-primary);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: normal;
    max-width: 300px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

/* Notes cell with expand/collapse */
.notes-cell {
    position: relative;
    max-width: 180px;
}

.notes-content {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    line-height: 1.3;
    max-height: 1.3em;
    word-break: break-word;
}

/* Notes / Seller Story cells stay one line no matter the text length —
   wrapping here made rows uneven heights. Full text lives in the popover. */
td.col-notes .editable-cell {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.notes-content.expanded {
    -webkit-line-clamp: unset;
    max-height: none;
    overflow: visible;
}

.notes-expand-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    margin-left: 4px;
    background: var(--light-accent);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.6rem;
    color: var(--text-muted);
    transition: all 0.15s ease;
    flex-shrink: 0;
    vertical-align: middle;
}

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

.notes-expand-btn.expanded {
    transform: rotate(180deg);
}

.notes-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

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

/* Notes popover — widened and uncapped so the edit textarea fits */
.notes-popover {
    position: fixed;
    z-index: 9999;
    width: 340px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    overflow: hidden;
    animation: notesPopoverIn 0.15s ease;
}

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

.notes-popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: var(--light-accent, #f8fafc);
}

.notes-popover-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a2e);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.notes-popover-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted, #94a3b8);
    padding: 0 2px;
    line-height: 1;
}

.notes-popover-close:hover {
    color: var(--text-primary, #1a1a2e);
}

.notes-popover-body {
    padding: 10px 12px;
    font-size: 0.813rem;
    line-height: 1.5;
    color: var(--text-primary, #1a1a2e);
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Editable textarea inside the notes popover */
.notes-popover-body textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    padding: 8px;
    font-size: 0.813rem;
    line-height: 1.5;
    color: var(--text-primary, #1a1a2e);
    font-family: inherit;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s;
}

.notes-popover-body textarea:focus {
    border-color: var(--primary-color, #2d6a4f);
}

.notes-popover-actions {
    padding: 8px 12px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

/* Save button (was .notes-popover-edit — kept for selector compatibility) */
.notes-popover-edit {
    padding: 4px 12px;
    font-size: 0.75rem;
    background: var(--primary-color, #2d6a4f);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.notes-popover-edit:hover {
    opacity: 0.9;
}

/* Cancel button */
.notes-popover-cancel {
    padding: 4px 12px;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text-muted, #6b7280);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    cursor: pointer;
}

.notes-popover-cancel:hover {
    background: var(--light-accent, #f8fafc);
    color: var(--text-primary, #1a1a2e);
}

/* Save-state indicator (notes reliability, 2026-09-03) — sits on the left of
   the actions row; .failed is the persistent "Not saved — retrying" state. */
.notes-popover-status {
    margin-right: auto;
    align-self: center;
    font-size: 0.7rem;
    color: var(--text-muted, #94a3b8);
}

.notes-popover-status.failed {
    color: #b91c1c;
}

/* Draft offer-back row ("Unsaved draft from HH:MM — Restore · Dismiss") */
.notes-popover-draft {
    padding: 0 12px 8px;
    font-size: 0.7rem;
    color: var(--text-muted, #94a3b8);
}

.notes-popover-draft button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    text-decoration: underline;
}

.notes-popover-draft button:hover {
    color: var(--text-primary, #1a1a2e);
}

/* Phase/Priority badges */
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
    background: #f0f0f0;
    color: #666;
}

.badge-screener { background: #e8f4e8; color: #2d5a2d; }
.badge-loi { background: #fff3e0; color: #e65100; }
.badge-pass { background: #fce4ec; color: #c62828; }
.badge-prescreen { background: #e3f2fd; color: #1565c0; }
.badge-fulluw { background: #f3e5f5; color: #7b1fa2; }

/* Priority words without a saved org color (app.js _ddLabelHtml): one
   neutral chip, the word says the level (theme pass Q3, 2026-11-12). An
   org's own saved dropdown colors are its data and still paint. */
.badge-high, .badge-med, .badge-low, .badge-dead { background: var(--bg-input); color: var(--text-secondary); }

/* Action buttons */
.action-btn {
    padding: 3px 8px;
    border: none;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.action-btn-screener:hover {
    background: var(--primary-dark);
}

.action-btn-market-report {
    background: #1565c0;
    color: white;
    margin-right: 6px;
}

.action-btn-market-report:hover {
    background: #0d47a1;
}

/* Create Screener button */
.action-btn-create {
    background: var(--secondary-color);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-btn-create:hover {
    background: var(--secondary-dark);
}

/* View Screener button */
.action-btn-view {
    background: var(--primary-color);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-btn-view:hover {
    background: var(--primary-dark);
}

/* Promote to deals button */
.action-btn-promote {
    background: var(--secondary-color);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.action-btn-promote:hover {
    background: var(--secondary-dark);
}

/* Delete from tracker button */
.action-btn-delete {
    background: transparent;
    color: #999;
    padding: 3px 4px;
    min-width: auto;
    display: inline-flex;
    align-items: center;
}

.action-btn-delete:hover {
    background: #fee;
    color: #d32f2f;
}

/* Action button icon */
.action-btn .action-icon {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

/* ============================================
   LOADING/EMPTY STATE STYLES
   ============================================ */

.tracker-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-family: var(--font-body);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

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

/* ============================================
   RESPONSIVE TRACKER STYLES
   ============================================ */

@media (max-width: 1000px) {
    .tracker-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .tracker-search-group {
        width: 100%;
    }

    .search-input {
        flex: 1;
        width: auto;
    }
}

@media (max-width: 768px) {
    .main-tabs {
        padding: 6px 12px;
        /* Phones: the centered bar can exceed the viewport by a few px
           (More tab clipped at 390w) — scroll instead of clipping. */
        overflow-x: auto;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .tracker-container {
        padding: 12px 16px;
    }

    .tracker-stats {
        flex-wrap: wrap;
        gap: 16px;
    }

    .stat-item {
        min-width: 80px;
    }

    .filter-select {
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .tab-btn span:not(.icon) {
        display: none;
    }

    .tab-btn {
        padding: 10px 14px;
    }

    .filter-group {
        gap: 8px;
    }

    .filter-select {
        min-width: 100px;
        font-size: 0.813rem;
    }
}

/* ============================================
   EMAIL INBOX TAB STYLES
   ============================================ */

/* Full-height, full-width mail client shell.
   --email-tab-offset = chrome above the tab (the sticky .hero-section bar is
   ~52px tall; the rest is this container's own top padding). Panes fill the
   rest of the viewport and scroll INTERNALLY so there is no page-level dead
   space. Tune the offset here if the shell chrome height changes. Kept a hair
   conservative: too-small only adds a few px of internal scroll (safe), while
   too-large would reintroduce a blank gap at the bottom. */
.email-container {
    --email-tab-offset: 62px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--email-tab-offset));
    min-height: 480px;
    padding: 6px 12px 8px;
    box-sizing: border-box;
}

/* Viewport-bounded email shell (Carson 7/21, same pattern as the tasks board:
   tasks.js sizeBoardToViewport + .tasks-viewport). app.js sizeEmailToViewport
   measures the shell's TRUE top (the static calc above undercounted the
   chrome — sticky topbar + container padding + Inbox|Templates|Drafts nav —
   so the shell overflowed and the page scrolled) and sets an exact pixel
   height. The list and reading pane scroll internally; the page never
   scrolls on this tab. Class never added at <=900px (stacked layout keeps
   natural page scroll; phones included). */
.email-container.email-viewport {
    min-height: 0;
    overflow: hidden;
}

/* Inside a JS-sized shell the flex:1 chain is the sizing authority — neutral-
   ize the desktop 100vh fallback height below so it can't fight the measured
   height. */
.email-container.email-viewport #gmail-connected-section,
.email-container.email-viewport #imap-email-section {
    height: auto;
}

#gmail-connected-section,
#imap-email-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Bound the email tab height on desktop so the inbox list and the message body
   each scroll independently (Gmail/Outlook pattern). Without a fixed height the
   flex:1 chain has nothing to fill, so the whole page scrolls as one long
   column. Mobile is left to stack/scroll normally. */
@media (min-width: 769px) {
    #gmail-connected-section,
    #imap-email-section {
        height: calc(100vh - 125px);
    }
}

/* Compact toolbar — ONE tight row on desktop (Carson 7/21: the wrapped
   toolbar + its own account-identity row pushed the inbox down). */
.email-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    padding: 4px 8px;
    min-height: 38px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    flex-wrap: wrap;
    row-gap: 6px;
}

/* Desktop (split-view widths): forbid wrapping — everything, including the
   account chip, lives on the single row. Children shrink instead. */
@media (min-width: 901px) {
    .email-toolbar {
        flex-wrap: nowrap;
    }
    .gmail-toolbar-left {
        flex-wrap: nowrap;
        flex: 1 1 auto;
        min-width: 0;
    }
    .gmail-toolbar-right {
        flex-wrap: nowrap;
        flex-shrink: 0;
        min-width: 0;
    }
    .gmail-search-wrap {
        flex: 0 1 240px;
        min-width: 110px;
    }
    .email-toolbar .btn {
        white-space: nowrap;
    }
}

/* Shrink every button inside the toolbar to a compact, uniform scale so the
   bar reads like Gmail/Outlook rather than a stack of oversized buttons. */
.email-toolbar .btn {
    padding: 4px 9px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
}

.email-toolbar .btn .icon {
    width: 14px;
    height: 14px;
}

.email-stats {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.email-stats span {
    font-weight: 600;
    color: var(--text-primary);
}

/* Split view layout — fills the container, panes scroll internally. */
.email-split-view {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 8px;
    flex: 1;
    min-height: 0;
}

/* ── Personal-inbox mail-client shell ──────────────────────────────────────
   Folder rail: shown only in account view (per-user/shared mailbox), where
   #gmail-connected-section carries .has-folder-rail. The legacy org inbox
   keeps the toolbar folder dropdown and a two-column split. */
.email-folder-rail {
    display: none;
}

#gmail-connected-section.has-folder-rail .email-split-view {
    grid-template-columns: 168px 340px minmax(0, 1fr);
}

#gmail-connected-section.has-folder-rail .email-folder-rail {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow-y: auto;
    min-height: 0;
}

/* Rail replaces the toolbar dropdown in account view (dropdown returns on
   narrow screens where the rail is hidden). */
#gmail-connected-section.has-folder-rail .gmail-label-selector {
    display: none;
}

.folder-rail-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    border: none;
    border-radius: 6px;
    background: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.813rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.folder-rail-item:hover {
    background: rgba(30, 58, 95, 0.05);
}

.folder-rail-item.active {
    background: rgba(30, 58, 95, 0.12);
    font-weight: 600;
}

/* Toolbar mail search */
.gmail-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    height: 30px;
}

.gmail-search-input {
    border: none;
    outline: none;
    background: none;
    font-family: var(--font-body);
    font-size: 0.813rem;
    color: var(--text-primary);
    width: 170px;
}

.gmail-search-clear {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
}

.gmail-search-clear:hover {
    color: var(--text-primary);
}

/* Unread messages: bold + leading dot. Opening a message clears it — the UI
   clears optimistically and the provider is told to mark it read (Gmail
   UNREAD label / Graph isRead / IMAP \Seen); see markMessageReadOnOpen. */
.email-item.unread .email-item-from,
.email-item.unread .email-item-subject {
    font-weight: 700;
}

.email-item.unread .email-item-from::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-color);
    margin-right: 6px;
    vertical-align: middle;
}

/* Connect-my-inbox menu (toolbar) */
.connect-inbox-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 200;
    min-width: 190px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 4px;
}

.connect-inbox-item {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.813rem;
    color: var(--text-primary);
    text-decoration: none;
}

.connect-inbox-item:hover {
    background: rgba(30, 58, 95, 0.05);
}

/* Email list panel */
.email-list-panel {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.email-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Dense rows (Carson 7/21: ~8+ visible at 1366x636, was ~5). Three lines
   (from/date, subject, preview) at tight line-heights ≈ 58px per row. */
.email-item {
    padding: 5px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s ease;
}

/* Sender avatar in the list row: initials chip painted synchronously, then
   upgraded async to a real image (Gravatar -> corporate favicon) when the
   resolution chain finds one — see resolveEmailAvatar in app.js. */
.email-item-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    font-family: var(--font-body);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    overflow: hidden;
    margin-top: 2px;
    user-select: none;
}

.email-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.email-item:hover {
    background: rgba(30, 58, 95, 0.05);
}

.email-item.selected {
    background: rgba(30, 58, 95, 0.12);
    border-left: 3px solid var(--primary-color);
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 1px;
}

.email-item-from {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    line-height: 1.25;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.email-item-date {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.email-item-subject {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.78rem;
    line-height: 1.25;
    color: var(--text-primary);
    margin-bottom: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-item-preview {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.25;
}

/* Email detail panel */
.email-detail-panel {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.email-detail-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    padding: 60px;
}

.email-detail-placeholder .icon-large {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.email-detail-placeholder p {
    font-family: var(--font-body);
    font-size: 1rem;
    margin: 0;
}

.email-detail-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.email-detail-header {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(30, 58, 95, 0.03);
    flex-shrink: 0;
}

.email-detail-header h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 5px 0;
    line-height: 1.35;
}

.email-detail-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    margin-top: 2px;
}

/* Sender initials circle (deterministic color hash, same pattern as
   .task-avatar). Hidden until JS fills it; upgraded async to a real image
   (Gravatar -> corporate favicon) by the same chain as the list rows. */
.email-sender-avatar {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    overflow: hidden;
    user-select: none;
}

.email-meta-lines {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.email-meta-row {
    display: flex;
    gap: 12px;
    align-items: baseline;
    min-width: 0;
}

.email-from {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-date {
    color: var(--text-muted);
    flex-shrink: 0;
}

/* To/Cc line under the sender — single line, ellipsis; full list in title. */
.email-recipients {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-detail-body {
    flex: 1;
    padding: 16px 22px;
    overflow-y: auto;
    min-height: 0;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.6;
    word-wrap: break-word;
    /* white-space is set dynamically by JS: pre-wrap for plain text, normal for HTML */
}

/* Email iframe for HTML content */
.email-detail-body .email-iframe,
.email-viewer-pane .email-iframe {
    width: 100%;
    min-height: 600px;
    border: none;
    background: #fff;
    border-radius: 4px;
    display: block;
}

/* ============================================
   EMAIL REVIEW SPLIT-VIEW
   ============================================ */

/* The review panel replaces the old single-column detail panel */
.email-review-panel {
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.email-review-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Two-column split below header. The reading pane (left) takes the full
   remaining width; the extract/fields column is a fixed, narrow rail so the
   email body is comfortably WIDE (fixes the "skinny email box" complaint).
   No fixed min-height — the panel fills the container and scrolls internally. */
.email-review-split {
    display: grid;
    /* Right column is `auto`: collapses to 0 while the extracted-fields panel
       is hidden (the common case) so the email body reads FULL width, and
       expands to the panel's ~340px only after AI extraction populates it. */
    grid-template-columns: minmax(0, 1fr) auto;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
/* The fields panel defines the right column's width when it appears. */
.email-fields-right > .extracted-fields-panel { width: 340px; max-width: 42vw; }

/* LEFT: Tabbed content viewer */
.email-viewer-left {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border-right: 1px solid var(--border-color);
}

.email-viewer-tabs {
    display: flex;
    gap: 0;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(30, 58, 95, 0.02);
    flex-shrink: 0;
    overflow-x: auto;
}

.viewer-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-family: var(--font-body);
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.viewer-tab:hover {
    color: var(--text-primary);
}

.viewer-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.viewer-tab .icon-sm {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.viewer-tab .att-badge {
    font-size: 0.688rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(30, 58, 95, 0.08);
    color: var(--text-muted);
}

.email-viewer-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.email-viewer-pane {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.email-viewer-pane.active {
    display: block;
}

/* Email body pane */
.email-viewer-pane[data-pane="body"] {
    padding: 16px 22px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.6;
    word-wrap: break-word;
}

/* PDF attachment pane */
.email-viewer-pane .pdf-embed {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
    display: block;
}

/* RIGHT: Extract + fields panel */
.email-fields-right {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: rgba(30, 58, 95, 0.02);
}

.email-extract-action {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.extracted-fields-panel {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.extracted-fields-panel h4 {
    font-family: var(--font-heading);
    font-size: 0.938rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.extracted-fields-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.extracted-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.extracted-field.needs-review {
    border-color: var(--warning-color);
    background: rgba(255, 193, 7, 0.05);
}

.extracted-label {
    font-family: var(--font-body);
    font-size: 0.688rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.extracted-value {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.extracted-value a {
    color: var(--primary-color);
    text-decoration: none;
}

.extracted-value a:hover {
    text-decoration: underline;
}

.extracted-input {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.extracted-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.extracted-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.review-badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--warning-color);
    text-transform: uppercase;
}

.extract-error {
    padding: 12px;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 6px;
    color: var(--error-color);
    font-family: var(--font-body);
    font-size: 0.875rem;
}

.extracted-fields-actions {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
}

/* Attachment badge on email list items */
.email-item-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.email-att-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-family: var(--font-body);
    font-size: 0.688rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(30, 58, 95, 0.06);
    padding: 2px 6px;
    border-radius: 3px;
}

.email-att-badge .icon-xs {
    width: 11px;
    height: 11px;
}

/* OM detected toast prompt */
.om-prompt-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--primary-color);
    border-radius: 10px;
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,0.15));
    max-width: 420px;
}

.om-prompt-toast .om-prompt-text {
    flex: 1;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.om-prompt-toast .om-prompt-text strong {
    display: block;
    font-size: 0.813rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 400;
}

.om-prompt-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Legacy email detail actions (IMAP section) */
.email-detail-actions {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

/* Legacy extracted data panel (IMAP section) */
.extracted-data-panel {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(30, 58, 95, 0.03);
    max-height: 400px;
    overflow-y: auto;
}

.extracted-data-panel h4 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
}

.extracted-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.extracted-data-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.field-label {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.field-value {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.field-value a {
    color: var(--primary-color);
    text-decoration: none;
}

.field-value a:hover {
    text-decoration: underline;
}

/* Field locate button (find in email) */
.field-locate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    color: var(--text-muted);
    vertical-align: middle;
    margin-left: 4px;
    transition: all 0.15s;
}

.field-locate-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.06);
}

/* Batch mode */
.email-item-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
    margin-right: 4px;
}

.email-item.batch-mode {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.email-item.batch-mode .email-item-content {
    flex: 1;
    min-width: 0;
}

.batch-progress-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    background: rgba(99, 102, 241, 0.06);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-body);
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-primary);
}

.batch-progress-actions {
    display: flex;
    gap: 6px;
}

/* Responsive: stack the reading pane's viewer + fields on narrower screens */
@media (max-width: 1200px) {
    .email-review-split {
        grid-template-columns: minmax(0, 1fr) 260px;
    }
}

@media (max-width: 1000px) {
    .email-review-split {
        display: flex;
        flex-direction: column;
    }
    .email-viewer-left {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex: 1;
    }
    .email-fields-right {
        flex-shrink: 0;
        max-height: 40%;
    }
}

/* Email message states */
.email-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-family: var(--font-body);
}

.email-message.email-error {
    color: var(--error-color);
}

/* Email tab responsive — collapse to list-then-message (stacked) on narrow
   screens. The container drops its fixed viewport height so the page scrolls
   naturally instead of double-scrolling inside skinny panes. */
@media (max-width: 900px) {
    .email-container {
        height: auto;
        min-height: 0;
    }

    #gmail-connected-section,
    #imap-email-section {
        flex: none;
    }

    .email-split-view {
        grid-template-columns: 1fr;
        gap: 10px;
        flex: none;
    }

    /* Narrow screens: drop the folder rail, bring the toolbar dropdown back. */
    #gmail-connected-section.has-folder-rail .email-split-view {
        grid-template-columns: 1fr;
    }

    #gmail-connected-section.has-folder-rail .email-folder-rail {
        display: none;
    }

    #gmail-connected-section.has-folder-rail .gmail-label-selector {
        display: flex;
    }

    .email-list-panel {
        max-height: 320px;
    }

    .email-review-panel,
    .email-detail-panel {
        min-height: 60vh;
    }
}

@media (max-width: 600px) {
    .email-container {
        padding: 8px 10px 10px;
    }

    .email-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .extracted-data-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   GMAIL INTEGRATION STYLES
   ============================================ */

/* Gmail Sign-in Section (the "connect a mailbox" panel).
   No fixed min-height / align-items:center: the email shell is a fixed
   calc(100vh - offset) column, and on short laptop viewports (1366x768,
   Carson screenshot 8/29) a center-aligned 500px+ card overflowed the
   viewport at both ends with no scrollbar. The section now fills the shell
   and scrolls internally when the card is taller than the space; the card's
   auto margins center it whenever there IS room while keeping the top edge
   reachable when there is not. At <=900px the shell is height:auto and the
   page scrolls naturally (unchanged). */
.gmail-signin-section {
    display: flex;
    justify-content: center;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 24px 16px;
}

.gmail-signin-card {
    text-align: center;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: 36px 32px;
    max-width: 420px;
    margin: auto;
}

/* Per-user "Connect your inbox" card (Email SSO Phase 1) */
.connect-your-inbox {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.connect-your-inbox h3 {
    margin-bottom: 6px;
}

.connect-inbox-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 14px;
}

.gmail-signin-icon {
    margin-bottom: 24px;
}

.gmail-signin-icon svg {
    width: 64px;
    height: 64px;
}

.gmail-signin-card h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

.gmail-signin-card > p {
    font-family: var(--font-body);
    font-size: 0.938rem;
    color: var(--text-muted);
    margin: 0 0 28px 0;
    line-height: 1.5;
}

/* Google Sign-in Button */
.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 28px;
    background: #ffffff;
    color: #1f1f1f;
    font-family: var(--font-body);
    font-size: 0.938rem;
    font-weight: 500;
    border: 1px solid #dadce0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-google:hover {
    background: #f8f9fa;
    border-color: #c6c9cc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: #1f1f1f;
}

.btn-google .google-logo {
    flex-shrink: 0;
}

.gmail-privacy-note {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 20px !important;
    margin-bottom: 0 !important;
}

/* Gmail Toolbar */
.gmail-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    row-gap: 6px;
}

.gmail-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    row-gap: 6px;
}

.gmail-label-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gmail-label-selector label {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.gmail-label-dropdown {
    padding: 5px 10px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    min-width: 140px;
}

.gmail-label-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

/* Gmail User Info — compact account chip (Carson 7/21: the identity row
   "Name · email · Change · MICROSOFT 365" was eating its own toolbar row).
   Shows the short name + tiny provider badge; the full address is in the
   title attribute (hover). Change stays a clickable link inside the chip. */
.gmail-user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-secondary);
    max-width: 240px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

.gmail-user-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mailbox switcher (Email SSO Phase 1) — hidden unless the tenant is migrated */
.mailbox-switcher {
    display: flex;
    align-items: center;
    margin-right: 4px;
    min-width: 0;
}

.mailbox-switcher-select {
    font-family: var(--font-body);
    font-size: 0.75rem;
    padding: 3px 6px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111827);
    max-width: 170px;
    text-overflow: ellipsis;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.gmail-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.gmail-user-email {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gmail-user-email:empty {
    display: none;
}

.gmail-disconnect {
    font-size: 0.75rem;
}

.email-provider-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Gmail Stats Bar — thin inline count strip; no longer a full chrome bar with
   a big gap to the inbox. */
.gmail-stats-bar {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 0 0 4px 2px;
    padding: 0;
    flex-shrink: 0;
    line-height: 1.4;
}

.gmail-stats-bar span {
    font-weight: 600;
    color: var(--text-primary);
}

/* Gmail Pagination */
.gmail-pagination {
    padding: 16px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

/* Gmail Responsive */
@media (max-width: 768px) {
    .gmail-signin-card {
        padding: 32px 24px;
    }

    .email-toolbar {
        flex-direction: column;
        gap: 12px;
    }

    .gmail-toolbar-left,
    .gmail-toolbar-right {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .gmail-user-info {
        order: -1;
        width: 100%;
        margin-bottom: 8px;
    }
}

/* ============================================
   GMAIL CONFIRMATION MODAL
   ============================================ */

.confirm-subtitle {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 16px 0;
}

.confirm-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.confirm-field-group.full-width {
    grid-column: 1 / -1;
}

.confirm-field-group label {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.confirm-field-group input {
    padding: 8px 10px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.15s;
}

.confirm-field-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.confirm-field-group input[readonly] {
    background: var(--bg-darker, #f5f5f5);
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .confirm-fields-grid {
        grid-template-columns: 1fr;
    }
    .confirm-field-group.full-width {
        grid-column: 1;
    }
}

/* ============================================
   BLOCKED SENDERS
   ============================================ */

.blocked-senders-add {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.blocked-senders-add input {
    flex: 1;
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
}

.blocked-senders-add input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.blocked-senders-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.blocked-sender-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    gap: 8px;
}

.blocked-sender-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.blocked-sender-pattern {
    font-family: var(--font-mono, monospace);
    font-size: 0.875rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blocked-sender-type {
    font-size: 0.688rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.blocked-sender-type.domain {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.blocked-sender-type.email {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

.blocked-sender-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    font-size: 1.125rem;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.blocked-sender-remove:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   MARKET REPORT WORKFLOW MODAL STYLES
   ============================================ */

/* Form field hint text */
.field-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Optional label styling */
.label-optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.813rem;
}

/* Success card at top of modal */
.market-report-success-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: rgba(30, 58, 95, 0.12);
    border: 1px solid rgba(30, 58, 95, 0.25);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.market-report-success-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    border-radius: 50%;
}

.market-report-success-icon svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

.market-report-success-text {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-primary);
}

.market-report-success-text strong {
    font-weight: 600;
    color: var(--primary-color);
}

/* Info cards for paths */
.market-report-info-card {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 16px;
}

.market-report-info-card h4 {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.market-reports-card {
    background: rgba(240, 162, 84, 0.08);
    border-color: rgba(240, 162, 84, 0.25);
}

.market-reports-instruction {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Path display with copy button */
.market-report-path-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.market-report-path-display .path-text {
    flex: 1;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    word-break: break-all;
    line-height: 1.4;
}

.btn-copy {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

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

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

.btn-copy.copied {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-copy.copied svg {
    stroke: white;
}

/* Open folder button in Market report info card */
.btn-open-folder {
    margin-top: 12px;
    width: 100%;
}

/* Market report actions row - for the Copy Address & Open Search button */
.market-report-actions-row {
    display: flex;
    justify-content: center;
    padding: 16px 0;
    margin-bottom: 16px;
}

.market-report-actions-row .btn {
    padding: 12px 24px;
    font-size: 0.938rem;
}

/* Market report modal bottom buttons */
.market-report-modal-buttons {
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* Legacy Market report actions section (keep for compatibility) */
.market-report-actions {
    text-align: center;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin: 20px 0;
}

.market-report-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
}

.market-report-open-btn:hover {
    text-decoration: none;
}

.market-report-link-hint {
    font-family: var(--font-body);
    font-size: 0.813rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* Workflow steps */
.market-report-workflow-steps {
    background: var(--bg-page);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.market-report-workflow-steps h4 {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.market-report-workflow-steps ol {
    margin: 0;
    padding-left: 20px;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.market-report-workflow-steps li {
    margin-bottom: 6px;
}

.market-report-workflow-steps li:last-child {
    margin-bottom: 0;
}

/* Market report modal responsive */
@media (max-width: 600px) {
    .market-report-success-card {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .market-report-path-display {
        flex-direction: column;
        gap: 8px;
    }

    .market-report-path-display .path-text {
        text-align: center;
    }

    .btn-copy {
        width: 100%;
    }

    .market-report-open-btn {
        width: 100%;
        justify-content: center;
    }

    .market-report-actions-row {
        flex-direction: column;
    }

    .market-report-actions-row .btn {
        width: 100%;
    }

    .market-report-modal-buttons {
        flex-direction: column;
    }

    .market-report-modal-buttons .btn {
        width: 100%;
    }
}

/* ============================================
   Market Report Status Indicator
   ============================================ */

.market-report-status-indicator {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.market-report-status-indicator.status-found {
    background: rgba(30, 58, 95, 0.12);
    border: 1px solid rgba(30, 58, 95, 0.25);
    color: var(--primary-dark);
}

.market-report-status-indicator.status-missing {
    background: rgba(240, 162, 84, 0.12);
    border: 1px solid rgba(240, 162, 84, 0.3);
    color: #c47a30;
}

.market-report-status-indicator.status-checking {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.market-report-status-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.market-report-status-text {
    font-family: var(--font-body);
    font-weight: 500;
}

.market-report-status-text .pdf-count {
    font-weight: 600;
}

/* ============================================
   Market Report Warning Modal Styles
   ============================================ */

.market-report-warning-content {
    text-align: center;
    padding: 20px 0;
}

.market-report-warning-content .warning-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(240, 162, 84, 0.15);
    border-radius: 50%;
}

.market-report-warning-content .warning-icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--warning-color);
}

.market-report-warning-content .warning-message {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.market-report-warning-content .warning-folder-path {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-page);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    word-break: break-all;
}

.market-report-warning-buttons {
    justify-content: center;
    gap: 12px;
}

.market-report-warning-buttons .btn {
    min-width: 120px;
}

/* Warning button style */
.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: var(--secondary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* ============================================
   ADDRESS AUTOCOMPLETE STYLES
   ============================================ */

.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    display: none;
}

.autocomplete-dropdown.visible {
    display: block;
}

.autocomplete-item {
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

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

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: rgba(30, 58, 95, 0.1);
}

.autocomplete-item-main {
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.autocomplete-item-secondary {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.autocomplete-loading {
    padding: 16px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.autocomplete-loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.autocomplete-no-results {
    padding: 16px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

/* Adjust input when dropdown is open */
.autocomplete-wrapper input.dropdown-open {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom-color: transparent;
}

/* Autocomplete powered by badge */
.autocomplete-footer {
    padding: 8px 14px;
    background: var(--bg-page);
    border-top: 1px solid var(--border-color);
    text-align: right;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.autocomplete-footer img {
    height: 12px;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.6;
}

/* ============================================
   AUTHENTICATION STYLES
   ============================================ */

/* Box brand color */
:root {
    --box-blue: #0061D5;
    --box-blue-dark: #0052B4;
    --box-blue-light: #1A73E8;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0C1220;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.auth-overlay.visible {
    display: flex;
    opacity: 1;
}

.auth-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-container {
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 440px;
    padding: 40px;
    text-align: center;
    animation: authFadeIn 0.5s ease;
}

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

.auth-logo-section {
    margin-bottom: 32px;
}

.auth-logo {
    height: 64px;
    width: auto;
    margin-bottom: 16px;
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
}

.auth-content {
    margin-bottom: 32px;
}

.auth-message {
    margin-bottom: 24px;
}

.auth-message p {
    font-family: var(--font-body);
    font-size: 0.938rem;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.auth-note {
    font-size: 0.813rem !important;
    color: var(--text-muted) !important;
}

/* Box Sign In Button */
.btn-box {
    background: var(--box-blue);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    width: 100%;
    transition: all 0.2s ease;
}

.btn-box:hover:not(:disabled) {
    background: var(--box-blue-dark);
    box-shadow: 0 4px 12px rgba(0, 97, 213, 0.35);
    transform: translateY(-1px);
}

.btn-box:active:not(:disabled) {
    transform: translateY(0);
}

.btn-box .icon {
    width: 1.25em;
    height: 1.25em;
    margin-right: 8px;
}

/* Prominent Box Button (for Screener tab Open in Box) */
.btn-box-prominent {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    font-size: 1.125rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0, 97, 213, 0.25);
    width: 100%;
}

.btn-box-prominent:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(0, 97, 213, 0.4);
    transform: translateY(-2px);
}

.btn-box-prominent .box-logo {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.btn-box-prominent:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Auth Loading State */
.auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.938rem;
}

.auth-loading .loading-spinner {
    width: 24px;
    height: 24px;
    margin: 0;
    border-width: 2px;
}

/* Auth Error State */
.auth-error {
    background: rgba(196, 92, 92, 0.1);
    border: 1px solid rgba(196, 92, 92, 0.25);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
}

.auth-error-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(196, 92, 92, 0.15);
    border-radius: 50%;
}

.auth-error-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--error-color);
}

.auth-error p {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--error-color);
    margin: 0 0 16px 0;
}

.auth-error .btn {
    margin: 0 auto;
}

.auth-footer {
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.auth-footer p {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

/* ============================================
   USER MENU STYLES
   ============================================ */

.user-menu {
    position: fixed;
    top: 7px; /* centers the 32px pill in the 46px bar */
    right: 20px;
    z-index: 1000;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 10px 3px 4px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    transition: all 0.25s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.user-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.user-avatar svg {
    width: 14px;
    height: 14px;
    stroke: white;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;  /* Crop higher to show more of face/head top */
}

.user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-chevron {
    width: 14px;
    height: 14px;
    color: rgba(255,255,255,0.6);
    transition: transform 0.2s ease;
}

.user-menu.open .user-menu-chevron {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-email {
    display: block;
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.box-connection {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--box-blue);
}

.icon-sm {
    width: 14px;
    height: 14px;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.user-dropdown-item:hover {
    background: var(--bg-page);
}

.user-dropdown-item .icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.user-dropdown-item:hover .icon {
    color: var(--text-primary);
}

/* ============================================
   AUTH CHECK LOADING STATE
   ============================================ */

/* Initial loading state for the entire app */
.app-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Hide main content while checking auth */
body.auth-checking .hero-section,
body.auth-checking .main-tabs,
body.auth-checking .tab-content,
body.auth-checking .user-menu {
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.auth-ready .hero-section,
body.auth-ready .main-tabs,
body.auth-ready .tab-content,
body.auth-ready .user-menu {
    opacity: 1;
}

/* ============================================
   RESPONSIVE AUTH STYLES
   ============================================ */

@media (max-width: 600px) {
    .auth-container {
        padding: 28px 24px;
        max-width: 100%;
        margin: 16px;
        border-radius: var(--radius-md);
    }

    .auth-logo {
        height: 48px;
    }

    .auth-title {
        font-size: 1.5rem;
    }

    .auth-subtitle {
        font-size: 0.875rem;
    }

    .user-menu {
        right: 16px;
        top: 12px;
    }

    .user-menu-toggle {
        padding: 6px 10px;
    }

    .user-name {
        display: none;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
    }

    .user-menu-chevron {
        display: none;
    }

    .user-dropdown {
        min-width: 200px;
    }
}

/* ============================================
   TRACKER CHANGELOG STYLES
   ============================================ */

.changelog-container {
    max-height: 70vh;
    overflow-y: auto;
    padding: 0 4px;
}

.changelog-loading,
.changelog-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--text-secondary);
    gap: 16px;
}

.changelog-empty .icon-large {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
}

.changelog-empty p {
    margin: 0;
    font-size: 1rem;
}

.changelog-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.changelog-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    transition: background-color 0.2s ease;
}

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

.changelog-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.changelog-user {
    font-weight: 600;
    color: var(--text-primary);
}

.changelog-action {
    color: var(--text-secondary);
}

.changelog-field {
    font-weight: 500;
    color: var(--primary);
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.changelog-property {
    color: var(--text-secondary);
}

.changelog-property::before {
    content: '';
}

.changelog-time {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: auto;
    white-space: nowrap;
}

.changelog-action-create .changelog-action {
    color: var(--success);
    font-weight: 500;
}

.changelog-action-delete .changelog-action {
    color: var(--error);
    font-weight: 500;
}

.changelog-values {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-radius: 6px;
    font-size: 0.85rem;
}

.changelog-old {
    color: var(--text-muted);
    text-decoration: line-through;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.changelog-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.changelog-new {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.changelog-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 16px;
}

.changelog-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .changelog-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .changelog-time {
        margin-left: 0;
        margin-top: 4px;
    }

    .changelog-values {
        flex-direction: column;
        gap: 4px;
    }

    .changelog-old,
    .changelog-new {
        width: 100%;
    }

    .changelog-arrow {
        transform: rotate(90deg);
    }
}

/* ============================================
   TRACKER LINK STYLES
   ============================================ */

/* Tracker Link Indicator in Screener Tab */
.tracker-link-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(30, 58, 95, 0.1);
    border: 1px solid rgba(30, 58, 95, 0.25);
    border-radius: var(--radius-md);
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--primary-color);
}

.tracker-link-indicator .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tracker-link-indicator .btn-sm {
    margin-left: auto;
    padding: 4px 8px;
    font-size: 0.75rem;
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.tracker-link-indicator .btn-sm:hover {
    background: var(--primary-color);
    color: white;
}

/* Selected Tracker Link Badge (in forms) */
.tracker-link-selected {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(30, 58, 95, 0.08);
    border: 1px solid rgba(30, 58, 95, 0.2);
    border-radius: var(--radius-md);
}

.tracker-link-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
}

.tracker-link-badge .icon {
    width: 14px;
    height: 14px;
}

/* Unlink button */
.btn-unlink {
    margin-left: auto;
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-unlink:hover {
    background: rgba(196, 92, 92, 0.1);
    color: var(--error-color);
}

.btn-unlink .icon {
    width: 14px;
    height: 14px;
}

/* Tracker Search Dropdown Styling */
.tracker-dropdown .autocomplete-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tracker-dropdown .tracker-item-id {
    font-weight: 600;
    color: var(--primary-color);
}

.tracker-dropdown .tracker-item-name {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.tracker-dropdown .tracker-item-location {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tracker Auto-Suggest Banner */
.tracker-suggest-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(30, 58, 95, 0.1);
    border: 1px solid rgba(30, 58, 95, 0.25);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    animation: slideDown 0.2s ease;
}

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

.tracker-suggest-banner .suggest-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.tracker-suggest-banner .suggest-icon svg {
    width: 16px;
    height: 16px;
}

.tracker-suggest-banner .suggest-text {
    flex: 1;
    color: var(--text-secondary);
}

.tracker-suggest-banner .suggest-text strong {
    color: var(--primary-color);
    font-weight: 600;
}

.tracker-suggest-banner .btn-suggest-link {
    padding: 5px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.tracker-suggest-banner .btn-suggest-link:hover {
    background: var(--primary-dark);
}

.tracker-suggest-banner .btn-suggest-dismiss {
    padding: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.tracker-suggest-banner .btn-suggest-dismiss:hover {
    color: var(--text-primary);
}

.tracker-suggest-banner .btn-suggest-dismiss svg {
    width: 14px;
    height: 14px;
}

/* Screener Link Icon in Tracker Table */
.screener-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--primary-color);
    margin-left: 4px;
    vertical-align: middle;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.screener-link-icon:hover {
    opacity: 1;
}

.screener-link-icon svg {
    width: 14px;
    height: 14px;
}

/* No screener indicator (greyed out) */
.no-screener-icon {
    opacity: 0.3;
    color: var(--text-muted);
    cursor: default;
}

.no-screener-icon:hover {
    opacity: 0.3;
}

/* Small link button */
.btn-link {
    background: transparent;
    border: none;
    padding: 2px 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-link:hover {
    text-decoration: none;
}

/* Field hint styling */
.field-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Row highlight animation for navigation */
.row-highlight {
    animation: rowHighlight 2s ease-out;
}

@keyframes rowHighlight {
    0% {
        background-color: rgba(30, 58, 95, 0.3);
    }
    100% {
        background-color: transparent;
    }
}

/* ============================================
   DOCUMENT PARSER STYLES
   ============================================ */

/* Documents Tab Container */
.documents-container {
    padding: 20px;
}

.documents-header {
    margin-bottom: 24px;
}

.documents-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.documents-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
}

/* Upload Section */
.documents-upload-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.upload-type-select {
    display: flex;
    gap: 16px;
}

.upload-type-select label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.upload-type-select input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.upload-buttons {
    display: flex;
    gap: 10px;
}

.property-link-select {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 250px;
    position: relative;
}

.property-link-select label {
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.property-link-select input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.property-link-select input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 4px;
}

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s ease;
}

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

.autocomplete-item .prop-id {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.autocomplete-item .prop-name {
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Documents Table */
.documents-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.documents-table-container .tracker-table {
    margin: 0;
}

.documents-table-container .tracker-table th,
.documents-table-container .tracker-table td {
    padding: 12px 16px;
}

.documents-table-container .actions-cell {
    white-space: nowrap;
}

.documents-table-container .actions-cell .btn {
    margin-right: 6px;
}

.documents-table-container .actions-cell .btn:last-child {
    margin-right: 0;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-pending {
    background: rgba(156, 163, 175, 0.2);
    color: #6b7280;
}

.status-parsing {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.status-review {
    background: rgba(234, 179, 8, 0.2);
    color: #ca8a04;
}

.status-approved {
    background: rgba(30, 58, 95, 0.2);
    color: var(--primary-color);
}

.status-error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-hover);
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid #ef444440;
    color: #ef4444;
}

.btn-outline-danger:hover {
    background: #ef444415;
    border-color: #ef4444;
}

.btn-danger {
    color: #ef4444;
    border-color: #ef444430;
}

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

/* Mapping Modal - Must appear above deal-detail-fullscreen (z-index: 1000) */
#mapping-modal {
    position: fixed !important;
    z-index: 10000 !important; /* Very high z-index to ensure it appears above all other layers including deal-detail-fullscreen */
}

#mapping-modal .modal-content {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#mapping-modal .modal-large {
    max-width: 900px;
}

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

#mapping-modal .modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

#mapping-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

#mapping-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 16px;
}

/* Progress Bar */
#mapping-progress {
    text-align: center;
    padding: 60px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* Acwise Logo Loader Animation */
.acwise-logo-loader {
    width: 120px;
    height: 120px;
    position: relative;
}

.acwise-logo-loader .logo-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.acwise-logo-loader .solid-circle {
    fill: #f4a258;
    transform-origin: center;
    opacity: 0;
    animation: blobToCircle 1.5s ease-out forwards;
}

@keyframes blobToCircle {
    0% { opacity: 0; transform: scale(0); filter: blur(8px); }
    20% { opacity: 1; transform: scale(0.3) rotate(-10deg); filter: blur(4px); }
    50% { transform: scale(1.1) rotate(5deg); filter: blur(1px); }
    70% { transform: scale(0.95) rotate(-2deg); filter: blur(0); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); filter: blur(0); }
}

.acwise-logo-loader .tree-knockout {
    fill: black;
}

.acwise-logo-loader .glow-ring {
    fill: none;
    stroke: rgba(244, 162, 88, 0.5);
    stroke-width: 3;
    opacity: 0;
    transform-origin: center;
    animation: ringPulse 0.8s ease-out 0.8s forwards;
}

@keyframes ringPulse {
    0% { opacity: 0.8; transform: scale(0.8); stroke-width: 15; }
    100% { opacity: 0; transform: scale(1.4); stroke-width: 1; }
}

.acwise-logo-loader .logo-main {
    animation: gentlePulse 3s ease-in-out 3s infinite;
}

@keyframes gentlePulse {
    0%, 100% { filter: brightness(1) drop-shadow(0 0 0px rgba(244, 162, 88, 0)); }
    50% { filter: brightness(1.05) drop-shadow(0 0 20px rgba(244, 162, 88, 0.5)); }
}

.acwise-logo-loader .orbit-container {
    transform-origin: 79px 79px;
    animation: orbit 2.5s linear 3s infinite;
}

.acwise-logo-loader .orbit-dot {
    fill: #f4a258;
    opacity: 0;
    animation: fadeInOrbit 0.5s ease-out 3s forwards;
}

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

@keyframes fadeInOrbit {
    to { opacity: 0.8; }
}

.progress-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--bg-hover);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.progress-bar {
    width: 100%;
    max-width: 400px;
    height: 12px;
    background: var(--bg-hover);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #6366f1);
    border-radius: 6px;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255,255,255,0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#mapping-progress-text {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}

.progress-percent {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: -10px;
}

/* Mapping Table */
.mapping-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.mapping-table th,
.mapping-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.mapping-table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.mapping-table .source-col {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.mapping-table .sample-values {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mapping-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.mapping-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Confidence Badges */
.confidence-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 500;
}

.confidence-high {
    background: rgba(30, 58, 95, 0.2);
    color: var(--primary-color);
}

.confidence-medium {
    background: rgba(234, 179, 8, 0.2);
    color: #ca8a04;
}

.confidence-low {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Duplicate Mapping Warning */
.mapping-row-duplicate {
    background: rgba(245, 158, 11, 0.10) !important;
    border-left: 3px solid #f59e0b;
}

.mapping-row-duplicate td {
    background: rgba(245, 158, 11, 0.06);
}

.duplicate-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #92400e;
    background: rgba(245, 158, 11, 0.22);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 10px;
    vertical-align: middle;
    cursor: help;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Confidence Warning Icons */
.conf-warn-icon {
    font-size: 1rem;
    margin-right: 4px;
    vertical-align: middle;
    cursor: help;
}

.conf-warn-icon-yellow {
    color: #ca8a04;
}

.conf-warn-icon-red {
    color: #ef4444;
}

.conf-warn-yellow {
    background: rgba(234, 179, 8, 0.06);
}

.conf-warn-red {
    background: rgba(239, 68, 68, 0.06);
}

/* Skip / Ignore styling for mapping dropdown */
.mapping-select option[value=""] {
    color: var(--text-muted);
    font-style: italic;
}

/* Duplicate Warnings Tip Banner */
.mapping-warnings-tip {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 0.88rem;
    color: #92400e;
    line-height: 1.5;
}

/* Preview Table */
#mapping-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 24px 0 12px 0;
    color: var(--text-primary);
}

.preview-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

#preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#preview-table th,
#preview-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

#preview-table th {
    background: var(--bg-hover);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

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

#preview-table td {
    color: var(--text-primary);
}

/* Text utilities */
.text-muted {
    color: var(--text-muted);
}

/* ============================================
   FOLDER PICKER MODAL
   ============================================ */

.modal-medium {
    max-width: 500px;
    width: 90%;
}

.folder-breadcrumb {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.breadcrumb-item {
    cursor: pointer;
    color: var(--accent-primary);
}

.breadcrumb-item:hover {
    text-decoration: underline;
}

.folder-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.folder-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

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

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

.folder-item.selected {
    background: var(--accent-primary);
    color: white;
}

.folder-item.folder-back {
    color: var(--text-secondary);
    font-style: italic;
}

.folder-icon {
    font-size: 1rem;
}

.folder-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* ============================================
   COLUMN MAPPING REVIEW STYLES
   ============================================ */

.cmr-table tr {
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.cmr-table td {
    padding: 8px 6px;
    vertical-align: middle;
}

.cmr-field-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #111);
}

.cmr-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.cmr-badge-high {
    background: #d1fae5;
    color: #065f46;
}

.cmr-badge-med {
    background: #dbeafe;
    color: #1e40af;
}

.cmr-badge-low {
    background: #fef3c7;
    color: #92400e;
}

/* ============================================
   ZONE MANAGER STYLES
   ============================================ */

.zone-filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-zone-settings {
    padding: 6px !important;
    min-width: 36px !important;
    height: 36px !important;
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 6px !important;
}

.btn-zone-settings:hover {
    background: var(--bg-hover) !important;
    border-color: var(--accent-primary) !important;
}

.btn-zone-settings .icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.btn-zone-settings:hover .icon {
    color: var(--accent-primary);
}

.zone-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.zone-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
}

.zone-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.zone-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.zone-item-actions {
    display: flex;
    gap: 8px;
}

.zone-item-actions button {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.zone-item-states {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.zone-state-tag {
    background: var(--accent-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.zone-item.editing .zone-item-display {
    display: none;
}

.zone-item:not(.editing) .zone-item-edit {
    display: none;
}

.zone-item-edit {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zone-item-edit .form-group {
    margin-bottom: 0;
}

.zone-item-edit .form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.zone-item-edit .form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.zone-item-edit .form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.add-zone-form {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

.add-zone-form h4 {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.add-zone-form .form-group {
    margin-bottom: 12px;
}

.add-zone-form .form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.add-zone-form .form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.add-zone-form .form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.zone-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
}

.zone-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ============================================
   BROKER CRM TAB STYLES
   ============================================ */

.brokers-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

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

.brokers-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-family: var(--font-heading);
}

.brokers-header-actions {
    display: flex;
    gap: 12px;
}

.brokers-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

/* Labeled filter fields (Search | Location | State | Firm) — one organized
   row instead of controls scattered with placeholder-only hints. */
.bf-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bf-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.brokers-search-input {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 300px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.brokers-search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(205, 127, 50, 0.1);
}

.brokers-state-filter {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 140px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.brokers-state-filter:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(205, 127, 50, 0.1);
}

.brokers-state-filter option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.brokers-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-left: auto;
}

.brokers-table-wrapper {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    /* Scroll inside the card on narrow windows — the page never widens and
       columns never squeeze into wrapped phone numbers / 3-line titles. */
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.brokers-table {
    width: 100%;
    min-width: 1020px;
    border-collapse: collapse;
}

.brokers-table th {
    padding: 14px 16px;
    text-align: left;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.brokers-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.brokers-table th.sortable:hover {
    background: rgba(255, 255, 255, 0.1);
}

.brokers-table th .sort-indicator {
    margin-left: 6px;
    opacity: 0;
    font-size: 0.625rem;
    vertical-align: middle;
    transition: opacity 0.15s;
}

.brokers-table th.sortable:hover .sort-indicator {
    opacity: 0.4;
}

.brokers-table th.sortable:hover .sort-indicator::after {
    content: '▲';
}

.brokers-table th.sort-active .sort-indicator {
    opacity: 1;
}

.brokers-table th.sort-active.sort-asc .sort-indicator::after {
    content: '▲';
}

.brokers-table th.sort-active.sort-desc .sort-indicator::after {
    content: '▼';
}

.brokers-table td {
    /* One line per row, uniform height: denser padding + nowrap/ellipsis on
       the text columns below. Full values live in title tooltips. */
    padding: 10px 14px;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    white-space: nowrap;
}

.col-broker-name, .col-broker-title, .col-broker-email, .col-broker-coverage {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

/* Labeled "Log" touch action (replaces the phone glyph that read as a call
   button — the phone number itself is the tel: link). */
.btn-log-touch {
    appearance: none;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--color-primary, #2563eb);
    border-radius: 6px;
    padding: 3px 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.btn-log-touch:hover { background: var(--bg-tertiary); }

/* "Last touch:" prefix before the recency pills */
.broker-pill-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    align-self: center;
    margin-right: 2px;
    white-space: nowrap;
}

/* Archived deals in the broker drawer: kept (relationship history) but muted */
.broker-deal-archived { opacity: 0.55; }
.broker-deals-divider {
    margin: 10px 0 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-light);
    padding-top: 8px;
}

/* Per-firm column header row (added 2026-06 so Title/Coverage etc. are
   clearly labeled). Lighter than the legacy full-table .brokers-table th
   so it reads as a compact section sub-header repeated under each firm. */
.brokers-table thead .brokers-table-head th {
    padding: 6px 16px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
}

.brokers-table tbody tr {
    transition: background-color 0.15s;
    cursor: pointer;
}

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

.brokers-table tbody tr:last-child td {
    border-bottom: none;
}

.col-broker-name {
    width: 200px;
    font-weight: 500;
}

.col-broker-source {
    width: 180px;
}

.col-broker-email {
    width: 220px;
}

.col-broker-phone {
    width: 140px;
}
/* M3: tel: link in broker table — neutral on desktop (no underline/blue); mobile
   styles in the @media block below give it the tap-to-call treatment. */
body:not(.mobile) .col-broker-phone a {
    color: inherit;
    text-decoration: none;
    pointer-events: none;
}

.col-broker-states {
    width: 150px;
}

.col-broker-title {
    width: 180px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
}

.col-broker-coverage {
    width: 140px;
}

/* Coverage status tag (rolodex "Reviewed" / "On Acwise listings" / etc.) */
.broker-coverage-pill {
    /* Neutral by design: coverage is a category label, not a status.
       Color in pills is reserved for state (phase, priority, CA status). */
    display: inline-block;
    background: rgba(30, 58, 95, 0.07);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

/* "+N more" toggle for collapsed coverage pills */
.broker-coverage-more {
    display: inline-block;
    font-size: 11px;
    color: var(--color-primary, #2563eb);
    cursor: pointer;
    margin-left: 4px;
    font-weight: 500;
}
.broker-coverage-more:hover { text-decoration: underline; }
.broker-coverage-rest { display: inline; }

/* State badges kept as a small secondary cue beside the broker name (metros
   now drive the tabs). */
.broker-name-states {
    margin-left: 6px;
    white-space: nowrap;
}

.col-broker-deals {
    width: 80px;
    text-align: center;
}

.col-broker-last-contact {
    width: 140px;
}

.col-broker-actions {
    width: 100px;
    text-align: center;
}

.broker-deal-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 8px;
    background: var(--accent-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
}

.broker-deal-badge.zero {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.state-badge {
    display: inline-block;
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-right: 3px;
}

/* Source badge for broker table and deal cards */
.brokers-table .source-badge,
.broker-deals-list .source-badge,
.col-broker-source .source-badge {
    display: inline-block;
    background: rgba(155, 89, 182, 0.2);
    color: #9b59b6;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-right: 3px;
}

.broker-actions-cell {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* ── Broker CRM: market tabs + company (firm) sections ───────────────────── */
.brokers-market-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.broker-market-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

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

.broker-market-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.broker-market-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
}

.broker-market-tab.active .broker-market-tab-count {
    background: rgba(255, 255, 255, 0.25);
}

.broker-firm-section {
    border-bottom: 1px solid var(--border-color);
}

.broker-firm-section:last-child {
    border-bottom: none;
}

.broker-firm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
}

/* Subtle per-section banding to echo the Excel rolodex firm blocks */
.broker-firm-section:nth-child(even) .broker-firm-header {
    background: var(--bg-input, var(--bg-tertiary));
}

.broker-firm-name {
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-primary);
}

.broker-firm-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.brokers-section-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.broker-actions-cell .btn-icon {
    padding: 6px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.broker-actions-cell .btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.broker-actions-cell .btn-icon.delete:hover {
    color: var(--status-dead);
}

.brokers-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.brokers-message .loading-spinner {
    margin-bottom: 16px;
}

/* Broker Detail Modal - Must appear above main-tabs (z-index: 100) and tab-content stacking context */
#broker-detail-modal {
    position: fixed !important;
    z-index: 10000 !important; /* Very high z-index to ensure it appears above all other layers including main-tabs */
}

#broker-detail-modal .modal-large {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.broker-detail-content {
    padding: 20px;
}

/* Broker Detail Header with Photo */
.broker-detail-header {
    display: flex;
    align-items: center;
}

.broker-photo-container {
    width: 60px;
    height: 60px;
    margin-right: 16px;
    flex-shrink: 0;
}

.broker-photo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

.broker-photo-placeholder {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498db, #2980b9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    color: white;
}

/* Broker Avatar in Table */
.col-broker-photo {
    width: 40px;
    padding: 8px !important;
}

.broker-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3498db, #2980b9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
}

/* Suggested value indicator */
input.suggested {
    border-color: #f39c12 !important;
}
input.suggested::placeholder {
    color: #f39c12;
}

.broker-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
}

.broker-info-section h4,
.broker-deals-section h4 {
    margin: 0 0 16px 0;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.broker-info-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.broker-info-form .form-group {
    margin-bottom: 0;
}

.broker-info-form .form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.broker-info-form .form-group label .label-hint {
    font-weight: 400;
    color: var(--text-muted);
    font-style: italic;
}

.broker-info-form .form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.broker-info-form .form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(205, 127, 50, 0.1);
}

/* ── Call Sheet (Brokers tab, redesigned 7/21): grouped by reason — quiet
   uppercase section headers, ONE compact line per entry, co-listed brokers
   stacked inside a single merged deal entry. No pills: plain text + spacing
   does the work; urgency is red date text only. ── */
.call-sheet-section-header {
    padding: 11px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.call-sheet-section-header:not(:first-child) {
    margin-top: 5px;
    border-top: 1px solid var(--border-color);
}

.call-sheet-entry {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 6px 14px;
    font-size: 13px;
}

.call-sheet-entry + .call-sheet-entry {
    border-top: 1px solid var(--border-color);
}

.call-sheet-entry:last-child {
    padding-bottom: 9px;
}

/* Left cell: one line per broker (merged co-listed entries stack lines).
   Line height matches .cs-action-line so the right cell aligns per broker. */
.cs-brokers {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 0 230px;    /* fixed so the reason column aligns down the sheet */
    min-width: 0;
}

.cs-broker-line {
    line-height: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.call-sheet-name {
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text-primary);
    cursor: pointer;
}

.call-sheet-name:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.cs-firm {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 6px;
}

/* Middle cell: the single plain-text reason. Deal names are plain links. */
.cs-reason {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12.5px;
    color: var(--text-primary);
}

.cs-due-urgent {
    color: #b91c1c;
}

/* Right cell: phone + compact text actions, one line per broker. */
.cs-right {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
    flex: 0 0 auto;
}

.cs-action-line {
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 20px;
    white-space: nowrap;
    font-size: 12px;
}

.cs-phone {
    font-weight: 600;
}

.cs-no-phone {
    color: var(--text-muted);
    font-size: 11.5px;
}

.cs-link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 12px;
    color: var(--primary-color);
    cursor: pointer;
}

.cs-link-btn:hover {
    text-decoration: underline;
}

.cs-link-btn:disabled {
    color: var(--text-muted);
    cursor: default;
    text-decoration: none;
}

/* Firm-deals section in the broker drawer (deals at the same shop that this
   broker is NOT yet linked to — one-click Link attaches as co-broker). */
.broker-deal-firm {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Firm-section divider: quieter than the shouty uppercase default — reads
   as a section note, not a heading (Carson 7/20 drawer-polish pass). */
.broker-deals-divider-firm {
    text-transform: none;
    letter-spacing: 0;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 2px 16px 0;
}

/* Breathing room so the last deal row's meta line never touches or clips
   against the list's bounding box. */
#drawer-deals-list {
    padding-bottom: 14px;
}

.broker-deal-firm .broker-deal-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.broker-deal-via {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.broker-firm-link-btn {
    flex: none;
    font-size: 12px;
    padding: 3px 10px;
}

.broker-notes-section {
    margin-bottom: 24px;
}

.broker-notes-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-body);
    resize: vertical;
    margin-bottom: 12px;
}

.broker-notes-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(205, 127, 50, 0.1);
}

/* Broker Deals List */
.broker-deals-list {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.broker-deal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

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

.broker-deal-item:hover {
    background: var(--bg-tertiary);
}

.broker-deal-clickable {
    cursor: pointer;
}

.broker-deal-clickable:hover .broker-deal-name {
    color: var(--accent-color);
}

.broker-deal-info {
    flex: 1;
}

.broker-deal-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.broker-deal-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.broker-deal-phase {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.broker-deal-phase.screener { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.broker-deal-phase.full-uw { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.broker-deal-phase.loi { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.broker-deal-phase.pass { background: rgba(156, 163, 175, 0.15); color: #9ca3af; }
.broker-deal-phase.dead { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.broker-deals-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Broker Activity */
.broker-activity-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.broker-activity-form .form-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 140px;
}

.broker-activity-textarea {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-body);
    resize: none;
    height: 36px;
}

.broker-activity-log {
    max-height: 300px;
    overflow-y: auto;
}

.broker-activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.broker-activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.broker-activity-icon svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.broker-activity-icon.note { background: rgba(59, 130, 246, 0.15); }
.broker-activity-icon.note svg { color: #3b82f6; }
.broker-activity-icon.call { background: rgba(34, 197, 94, 0.15); }
.broker-activity-icon.call svg { color: #22c55e; }
.broker-activity-icon.email { background: rgba(139, 92, 246, 0.15); }
.broker-activity-icon.email svg { color: #8b5cf6; }
.broker-activity-icon.meeting { background: rgba(245, 158, 11, 0.15); }
.broker-activity-icon.meeting svg { color: #f59e0b; }

.broker-activity-content {
    flex: 1;
}

.broker-activity-text {
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.broker-activity-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.broker-activity-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Broker Emails Section */
.broker-emails-section {
    margin-top: 24px;
}

.broker-emails-section h4 {
    margin-bottom: 12px;
}

.broker-emails-list {
    max-height: 300px;
    overflow-y: auto;
}

.broker-email-item {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.broker-email-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

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

.broker-email-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 4px;
}

.broker-email-subject {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.broker-email-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.broker-email-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.broker-email-snippet {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.4;
}

.broker-email-item.expanded .broker-email-snippet {
    display: block;
}

.broker-email-actions {
    display: none;
    margin-top: 8px;
    gap: 8px;
}

.broker-email-item.expanded .broker-email-actions {
    display: flex;
}

.broker-email-link {
    font-size: 0.75rem;
    color: var(--accent-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.broker-email-link:hover {
    text-decoration: underline;
}

.broker-email-link svg {
    width: 12px;
    height: 12px;
}

.broker-emails-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.broker-emails-error {
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    color: #ef4444;
    font-size: 0.875rem;
}

/* Broker Sync Spinner */
#btn-sync-brokers .spin-icon {
    animation: spin 1s linear infinite;
}

/* Subtle syncing indicator (auto-sync in background) */
#btn-sync-brokers.syncing {
    opacity: 0.7;
}

#btn-sync-brokers.syncing .icon {
    animation: spin 1s linear infinite;
}

/* Responsive Brokers */
@media (max-width: 1024px) {
    .broker-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .brokers-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .brokers-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .brokers-search-input {
        width: 100%;
    }

    .brokers-state-filter {
        width: 100%;
    }

    .brokers-count {
        margin-left: 0;
    }

    .brokers-table-wrapper {
        overflow-x: auto;
    }

    .brokers-table {
        min-width: 800px;
    }
}

/* ============================================
   DEALS TAB STYLES
   ============================================ */

.deals-container {
    padding: 20px;
}

/* Compact deals toolbar — single row */
.deals-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding: 0 4px;
}

.deals-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.deals-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.deals-toolbar-search {
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-body);
    width: 180px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.deals-toolbar-search:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.btn-toolbar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-toolbar-icon:hover {
    background: var(--bg-input);
    border-color: rgba(30, 58, 95, 0.3);
    color: var(--text-primary);
}

.btn-toolbar-icon .icon {
    width: 16px;
    height: 16px;
}

/* Collapsible filter drawer */
.deals-filter-drawer {
    display: none;
    gap: 10px;
    padding: 10px 16px;
    margin-bottom: 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    align-items: center;
    flex-wrap: wrap;
}

.deals-filter-drawer.open {
    display: flex;
}

.deals-filter-drawer select {
    padding: 7px 12px;
    min-width: 140px;
    font-size: 0.85rem;
}

/* Legacy class compat */
.deals-header { display: none; }
.deals-header-actions { display: none; }

.deals-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Deals Sort Controls */
.deals-sort-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.deals-sort-controls .sort-label {
    display: none;
}

.deals-sort-controls .sort-buttons {
    display: flex;
    gap: 4px;
}

.deals-sort-controls .sort-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.deals-sort-controls .sort-btn:hover {
    background: var(--bg-input);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.deals-sort-controls .sort-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.deals-sort-controls .sort-btn .icon {
    width: 14px;
    height: 14px;
}

.deals-sort-controls .sort-btn .sort-text {
    font-weight: 500;
}

.deals-sort-controls .sort-btn .sort-direction {
    font-size: 0.75rem;
    opacity: 0.8;
    min-width: 12px;
}

.deals-sort-controls .sort-btn .sort-direction[data-dir="asc"]::after {
    content: '\2191'; /* Up arrow */
}

.deals-sort-controls .sort-btn .sort-direction[data-dir="desc"]::after {
    content: '\2193'; /* Down arrow */
}

/* Hide direction arrow on inactive buttons */
.deals-sort-controls .sort-btn:not(.active) .sort-direction::after {
    content: '';
}

/* View Toggle (Grid/Map) */
.deals-view-toggle {
    display: flex;
    gap: 4px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

.deals-view-toggle .view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.deals-view-toggle .view-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.deals-view-toggle .view-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.deals-view-toggle .view-btn .icon {
    width: 18px;
    height: 18px;
}

/* Portfolio Map Container */
.deals-map-container {
    width: 100%;
    height: calc(100vh - 180px);
    max-height: 900px;
    min-height: 500px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: relative;
}

#deals-portfolio-map {
    width: 100%;
    height: 100%;
}

/* Mini Map Preview (Grid View) - inline with toggle buttons */
.deals-mini-map-container {
    flex: 1;
    margin-left: 16px;
    display: block;
    max-width: 400px;
}

.deals-mini-map {
    width: 100%;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: relative;
    cursor: pointer;
}

.deals-mini-map .mapboxgl-canvas {
    cursor: pointer;
}

.deals-mini-map .mapboxgl-ctrl-bottom-left,
.deals-mini-map .mapboxgl-ctrl-bottom-right {
    display: none;
}

/* Mini Cards Preview (Map View) */
.deals-mini-cards {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 280px;
    max-height: calc(100% - 20px);
    background: white;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    display: none;
    z-index: 1;
}

.deals-mini-cards::-webkit-scrollbar {
    width: 6px;
}

.deals-mini-cards::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.deals-mini-cards::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.deals-mini-cards::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.mini-card {
    background: #F5F7FA;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

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

.mini-card:hover {
    border-color: var(--primary-color);
    background: white;
    transform: translateX(-2px);
}

.mini-card-thumbnail {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.mini-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-card-thumbnail .thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.mini-card-thumbnail .thumbnail-placeholder svg {
    width: 24px;
    height: 24px;
    opacity: 0.4;
}

.mini-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mini-card-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-card-location {
    font-size: 11px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-card-zone {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    color: white;
}

.mini-card-zone.zone-1 { background: #27ae60; }
.mini-card-zone.zone-2 { background: #3498db; }
.mini-card-zone.zone-3 { background: #f39c12; }
.mini-card-zone.zone-4 { background: #e74c3c; }
.mini-card-zone.zone-default { background: #95a5a6; }

/* Portfolio Map Markers */
.portfolio-marker {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: white;
}

.portfolio-marker:hover {
    transform: scale(1.15);
    z-index: 10;
}

.portfolio-marker.zone-1 { background: #27ae60; }
.portfolio-marker.zone-2 { background: #3498db; }
.portfolio-marker.zone-3 { background: #f39c12; }
.portfolio-marker.zone-4 { background: #e74c3c; }
.portfolio-marker.zone-default { background: #95a5a6; }

/* Portfolio Map Popup */
.portfolio-popup {
    padding: 0;
    max-width: 280px;
}

.portfolio-popup .mapboxgl-popup-content {
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.portfolio-popup-content {
    padding: 12px;
}

.portfolio-popup-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.portfolio-popup-location {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.portfolio-popup-details {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.portfolio-popup-details span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.portfolio-popup-btn {
    display: block;
    width: 100%;
    padding: 10px;
    text-align: center;
    background: var(--accent-primary);
    color: white;
    font-weight: 500;
    font-size: 13px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.portfolio-popup-btn:hover {
    background: var(--accent-primary-hover);
}

/* Cluster markers */
.portfolio-cluster {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.portfolio-cluster:hover {
    transform: scale(1.1);
}

/* Map loading state */
.deals-map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

/* Map no data overlay */
.map-no-data-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.map-no-data-message {
    background: white;
    padding: 32px 48px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.map-no-data-message svg {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.map-no-data-message p {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.map-no-data-message span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.deals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

.deal-card {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.15s ease;
}

.deal-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.deal-card:active {
    transform: translateY(-1px);
    transition: transform 50ms ease;
}

.deal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.deal-title h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.deal-id {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: normal;
}

.zone-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.zone-badge.zone-1 { background: #e3f2fd; color: #1565c0; }
.zone-badge.zone-2 { background: #f3e5f5; color: #7b1fa2; }
.zone-badge.zone-3 { background: #e8f5e9; color: #2e7d32; }
.zone-badge.zone-NA { background: #fff3e0; color: #e65100; }
.zone-badge.zone-\? { background: var(--bg-secondary); color: var(--text-secondary); }

.deal-location {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 12px;
    min-height: 1.2em;
}

.deal-metrics {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.deal-metrics span strong {
    font-weight: 600;
}

.deal-status {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.phase-badge,
.priority-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.phase-badge {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.phase-badge.phase-pre-screen { background: #fff3e0; color: #e65100; }
.phase-badge.phase-screener { background: #e3f2fd; color: #1565c0; }
.phase-badge.phase-full-uw { background: #f3e5f5; color: #7b1fa2; }
.phase-badge.phase-loi { background: #e8f5e9; color: #2e7d32; }
.phase-badge.phase-pass { background: #fbe9e7; color: #bf360c; }
.phase-badge.phase-dead { background: #f5f5f5; color: #757575; }

/* Priority is the user's own label: a neutral chip that says its word
   (theme pass Q3, 2026-11-12), never a red / amber / green tint. */
.priority-badge {
    background: var(--bg-input);
    color: var(--text-secondary);
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 600;
}

.deal-documents {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.doc-status {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 2px;
}

.doc-status.complete {
    color: var(--success-color, #2e7d32);
}

.doc-status.missing {
    color: var(--text-tertiary, #999);
}

.deal-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

/* Deal card kebab (3-dot) menu */
.deal-card-menu {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.deal-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    color: #555;
    cursor: pointer;
    opacity: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.deal-card:hover .deal-menu-btn,
.deal-card-menu:has(.deal-menu-dropdown.show) .deal-menu-btn,
.deal-card-menu:focus-within .deal-menu-btn {
    opacity: 1;
}

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

.deal-menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 140px;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    padding: 4px;
    z-index: 20;
}

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

.deal-menu-dropdown button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: none;
    color: #333;
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.deal-menu-dropdown button:hover {
    background: #f5f5f5;
}

.deal-menu-dropdown button.danger {
    color: var(--danger-color, #e53e3e);
}

.deal-menu-dropdown button.danger:hover {
    background: rgba(229, 62, 62, 0.08);
}

/* Deal Detail Modal */
.modal-large {
    max-width: 700px;
    width: 95%;
}

.deal-detail-section {
    margin-bottom: 24px;
}

.deal-detail-section h4 {
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1rem;
}

.deal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.detail-item span {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.deal-docs-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.doc-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.doc-row.complete span {
    color: var(--success-color, #2e7d32);
}

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

.deal-parsed-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parsed-doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.parsed-doc-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.parsed-doc-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.doc-type-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.doc-type-badge.rent_roll { background: #e8f5e9; color: #2e7d32; }
.doc-type-badge.t12 { background: #fff3e0; color: #e65100; }

.parsed-doc-name {
    font-size: 0.8rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.status-pending { background: #fff8e1; color: #f57f17; }
.status-badge.status-parsing { background: #e3f2fd; color: #1565c0; }
.status-badge.status-review { background: #f3e5f5; color: #7b1fa2; }
.status-badge.status-approved { background: #e8f5e9; color: #2e7d32; }
.status-badge.status-error { background: #ffebee; color: #c62828; }

.btn-xs {
    padding: 3px 8px;
    font-size: 0.75rem;
}

.deal-notes {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    min-height: 40px;
}

/* Loading/Empty/Error States */
.loading-state,
.empty-state,
.error-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

.empty-state::before {
    content: '';
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    background: rgba(30, 58, 95, 0.06);
    border-radius: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'%3E%3C/path%3E%3Cpolyline points='13 2 13 9 20 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
}

.error-state {
    color: var(--error-color, #c62828);
}

.error-state::before {
    background: rgba(220, 38, 38, 0.06);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23DC2626' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px;
}

.loading-state::before {
    background: rgba(30, 58, 95, 0.06);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(30, 58, 95, 0.1);
    border-top-color: var(--primary-color);
    background-image: none;
    animation: spin 0.8s linear infinite;
}

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

/* Document Upload Modal */
#doc-upload-modal .form-group {
    margin-bottom: 16px;
}

#doc-upload-modal .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

#doc-upload-modal .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
}

#doc-upload-modal .upload-type-select {
    display: flex;
    gap: 20px;
}

#doc-upload-modal .radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .deals-grid {
        grid-template-columns: 1fr;
    }

    .deals-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .deals-filters select,
    .deals-filters input[type="text"] {
        width: 100%;
    }

    .deals-count {
        margin-left: 0;
        text-align: center;
    }

    .deal-metrics {
        flex-wrap: wrap;
        gap: 8px;
    }

    .deals-sort-controls {
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 8px;
        border-top: 1px solid var(--border-color);
        justify-content: center;
    }

    .deals-sort-controls .sort-btn .sort-text {
        display: none;
    }

    .deals-sort-controls .sort-btn {
        padding: 8px 10px;
    }

    .deals-view-toggle {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }

    .deals-map-container {
        height: 450px;
    }

    .deals-mini-map-container {
        display: none;
    }

    .deals-mini-cards {
        width: 240px;
    }
}

/* ============================================
   PROMOTE TO DEAL MODAL
   ============================================ */

.promote-property-info {
    background: var(--bg-input);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.promote-property-info h4 {
    margin: 0 0 4px 0;
    font-size: 1.1rem;
}

.promote-property-info p {
    margin: 0 0 8px 0;
}

.promote-option {
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.promote-option:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(30, 58, 95, 0.05);
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.promote-option-content {
    margin-top: 12px;
    padding-left: 26px;
}

/* Folder search */
.search-container {
    position: relative;
}

#promote-folder-search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--bg-input);
    color: var(--text-primary);
}

#promote-folder-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
    background: var(--bg-input-focus);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: var(--bg-input);
}

.search-result-item.no-results {
    color: var(--text-secondary);
    cursor: default;
}

.search-result-item.no-results:hover {
    background: transparent;
}

.promote-folder-icon {
    font-size: 1.1rem;
}

/* Selected folder display */
.selected-folder {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

.selected-folder .promote-folder-icon {
    color: var(--primary-color);
}

#promote-selected-folder-name {
    flex: 1;
    font-weight: 500;
}

.btn-clear {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-clear:hover {
    color: var(--error-color);
}

/* Folder structure preview */
.folder-preview {
    background: var(--bg-input);
    padding: 12px;
    border-radius: var(--radius-sm);
}

.folder-preview p {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.folder-preview code {
    display: block;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Tracker promote button */
.btn-promote {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-promote:hover {
    background: var(--primary-dark);
}

.btn-promote:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Already linked indicator */
.linked-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(30, 58, 95, 0.15);
    color: var(--success-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.linked-badge::before {
    content: '\2713';
}

/* ============================================
   TRACKER SEARCH MODAL (Add Deal from Deals tab)
   ============================================ */

.tracker-search-results {
    margin-top: 16px;
    max-height: 350px;
    overflow-y: auto;
}

.tracker-search-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tracker-search-item:hover {
    background: var(--bg-input);
    border-color: var(--primary-color);
}

.tracker-search-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.tracker-search-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Add Deal button in Deals header */
#btn-add-deal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* In Deals badge for tracker table */
.in-deals-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(30, 58, 95, 0.15);
    color: var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.in-deals-badge:hover {
    background: rgba(30, 58, 95, 0.25);
}

.in-deals-badge .action-icon {
    width: 14px;
    height: 14px;
}

/* ============================================
   ENHANCED DEAL DETAIL MODAL
   ============================================ */

.modal-xlarge {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
}

.deal-modal-body {
    max-height: calc(90vh - 140px);
    overflow-y: auto;
    padding: 0 24px 24px;
}

/* Deal Sections */
.deal-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.deal-section:last-child {
    border-bottom: none;
}

.deal-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.deal-section-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

/* Map Section */
.deal-map-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 24px;
}

.deal-map-container {
    position: relative;
    width: 100%;
    height: 300px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
}

.deal-map-iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: auto;  /* Enable map interaction (zoom, pan, click) */
}

.map-loading,
.map-unavailable {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-secondary);
}

/* Detail Grid */
.deal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item .detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.detail-item .detail-input {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.detail-item .detail-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Auto-detect Address Button */
.btn-auto-address {
    margin-top: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    background: var(--bg-accent);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.btn-auto-address:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-auto-address:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-auto-address i {
    font-size: 0.7rem;
}

/* Financial Grid */
.financial-grid {
    grid-template-columns: repeat(4, 1fr);
}

.financial-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.financial-item .detail-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Documents Grid */
.deal-docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.doc-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.doc-status-item.complete {
    color: var(--success-color);
}

.doc-status-item.missing {
    color: var(--text-secondary);
}

.doc-check {
    font-size: 1.1rem;
}

/* Parsed Documents List */
.deal-parsed-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Notes Textarea */
.deal-notes-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
}

.deal-notes-textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

.deal-notes-textarea:disabled {
    background: var(--bg-card);
    cursor: not-allowed;
}

/* Actions Grid */
.deal-actions-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
}

.deal-actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.deal-actions-grid .btn {
    flex: 1;
    min-width: 140px;
}

/* Modal Footer */
.deal-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   FULL-SCREEN DEAL DETAIL VIEW
   ============================================ */

.deal-detail-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-page);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Ensure video is hidden when deal detail is open */
body.deal-detail-open .hero-video,
body.deal-detail-open .hero-video-a,
body.deal-detail-open .hero-video-b {
    display: none !important;
}

/* Header Bar */
.deal-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
    flex-shrink: 0;
}

.deal-detail-header-left {
    flex-shrink: 0;
}

.deal-detail-header-center {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.deal-detail-header-center h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deal-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.deal-detail-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
}

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

.btn-back svg {
    flex-shrink: 0;
}

/* Back to Broker Button */
.back-to-broker-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #aaa;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    margin-left: 8px;
}

.back-to-broker-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

.back-to-broker-btn svg {
    flex-shrink: 0;
}

/* Deal Detail Tabs */
.deal-detail-tabs {
    display: flex;
    gap: 2px;
    padding: 0 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.deal-detail-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: -1px;
}

.deal-detail-tab:hover {
    color: var(--text-primary);
    background: rgba(30, 58, 95, 0.05);
}

.deal-detail-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: transparent;
}

.deal-detail-tab svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.deal-detail-tab.active svg {
    color: var(--primary-color);
}

.deal-tab-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    background: rgba(30, 58, 95, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.deal-detail-tab.active .deal-tab-badge {
    background: var(--primary-color);
    color: white;
}

/* Tab Panels */
.deal-tab-panel {
    display: none;
}

.deal-tab-panel.active {
    display: grid;
}

/* Responsive Deal Detail Tabs */
@media (max-width: 768px) {
    .deal-detail-tabs {
        padding: 0 12px;
    }

    .deal-detail-tab {
        padding: 12px 14px;
        font-size: 0.85rem;
    }

    .deal-detail-tab svg {
        width: 14px;
        height: 14px;
    }

    .deal-tab-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .comp-viewer-container {
        padding: 16px;
    }

    .comp-tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .comp-tab-title h2 {
        font-size: 1.25rem;
    }

    .comp-import-section {
        flex-direction: column;
    }

    .comp-import-section .btn {
        width: 100%;
    }
}

/* Main Content Layout */
.deal-detail-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    padding: 24px;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.deal-detail-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.deal-detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

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

.deal-card-header h3 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.deal-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Key Metrics Card */
.deal-metrics-card .deal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
}

.deal-metric-item {
    padding: 20px;
    text-align: center;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.deal-metric-item:nth-child(4n) {
    border-right: none;
}

.deal-metric-item:nth-last-child(-n+4) {
    border-bottom: none;
}

.deal-metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.deal-metric-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

/* Property Details Grid */
.deal-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 12px 14px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.detail-item label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.detail-item span,
.detail-item input {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.detail-item input {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    font-size: 0.85rem;
}

/* Street View Hero Card */
.deal-streetview-card {
    overflow: hidden;
    border-radius: var(--radius-lg);
}

.deal-streetview-container {
    height: 280px;
    position: relative;
    background: var(--bg-secondary);
}

.deal-streetview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.streetview-loading,
.streetview-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.streetview-placeholder svg {
    opacity: 0.4;
}

.streetview-placeholder p {
    margin: 0;
    font-size: 0.9rem;
}

.streetview-search-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 8px;
    transition: all 0.2s ease;
}

.streetview-search-link:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

/* Interactive Map Embed */
.deal-interactive-map {
    width: 100%;
    height: 100%;
    border: none;
}

/* Location Controls (Save Center button) */
.location-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
}

.location-controls .btn {
    box-shadow: var(--shadow-md);
}

/* ============================================
   DEAL MAPS TAB
   ============================================ */

/* Maps Card */
.deal-maps-card {
    overflow: hidden;
}

/* Map Type Tabs */
.deal-maps-tabs {
    display: flex;
    gap: 0;
    padding: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.deal-maps-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.deal-maps-tab:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.deal-maps-tab.active {
    background: var(--bg-primary);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.deal-maps-tab svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.deal-maps-tab.active svg {
    opacity: 1;
}

/* Map Refresh Button */
.deal-maps-refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-left: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.deal-maps-refresh-btn:hover {
    background: var(--bg-primary);
    color: var(--primary-color);
}

.deal-maps-refresh-btn:hover svg {
    transform: rotate(180deg);
}

.deal-maps-refresh-btn svg {
    transition: transform 0.3s ease;
}

.deal-maps-refresh-btn.refreshing svg {
    animation: spin 1s linear infinite;
}

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

/* Maps Container */
.deal-maps-container {
    position: relative;
    width: 100%;
    height: 400px;
    background: var(--bg-secondary);
}

.deal-maps-canvas {
    width: 100%;
    height: 100%;
}

/* The maps card on the shared map module (2026-11-11): the layer chips row,
   the active layer's legend, and the card in browser fullscreen. */
.deal-maps-head {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}
.deal-maps-ovlegend {
    padding: 4px 12px 6px;
}
.deal-maps-card:fullscreen {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
}
.deal-maps-card:fullscreen .deal-maps-container {
    flex: 1;
    height: auto;
}

.deal-maps-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    z-index: 5;
}

/* Data loading overlay for income/flood data */
.deal-maps-data-loading {
    position: absolute;
    top: 10px;
    right: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 6px;
    color: #fff;
    font-size: 0.85rem;
    z-index: 10;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.deal-maps-data-loading .loading-spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* Maps Legend */
.deal-maps-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-md);
    z-index: 10;
    font-size: 0.75rem;
    max-width: 200px;
}

/* Dark mode legend */
[data-theme="dark"] .deal-maps-legend {
    background: rgba(30, 30, 30, 0.95);
    color: var(--text-primary);
}

.deal-maps-legend .legend-title {
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.deal-maps-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    color: var(--text-secondary);
}

.deal-maps-legend .legend-color {
    width: 16px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.deal-maps-legend .legend-footer {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Fullscreen Maps Modal */
.deal-maps-fullscreen-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-page);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

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

.deal-maps-fullscreen-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.deal-maps-fullscreen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.deal-maps-fullscreen-content .deal-maps-tabs {
    flex-shrink: 0;
}

.deal-maps-fullscreen-content .deal-maps-container {
    flex: 1;
    height: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .deal-maps-container {
        height: 300px;
    }

    .deal-maps-tab {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .deal-maps-tab span {
        display: none;
    }

    .deal-maps-legend {
        bottom: 8px;
        left: 8px;
        padding: 8px 10px;
        font-size: 0.7rem;
    }
}

/* Address Input Section */
.address-input-section {
    margin-top: 16px;
    width: 100%;
    max-width: 400px;
}

.address-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.address-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text-primary);
}

.address-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(112, 134, 81, 0.15);
}

.address-input::placeholder {
    color: var(--text-muted);
}

.streetview-provider-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ================================================
   Property Image Gallery
   ================================================ */

.property-image-gallery {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.property-image-gallery .gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.property-image-gallery .gallery-image.loading {
    opacity: 0.5;
}

/* Gallery Navigation Arrows */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    z-index: 10;
    color: var(--text-primary);
}

.gallery-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.gallery-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.gallery-nav.prev {
    left: 12px;
}

.gallery-nav.next {
    right: 12px;
}

.gallery-nav svg {
    width: 20px;
    height: 20px;
}

/* Gallery Dots Indicator */
.gallery-dots {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
}

.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    padding: 0;
}

.gallery-dot:hover {
    background: rgba(255, 255, 255, 0.8);
}

.gallery-dot.active {
    background: white;
    transform: scale(1.2);
}

.gallery-dot.main {
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Image Counter */
.gallery-counter {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    z-index: 10;
}

/* Top Right Controls Container (Set as Main + Add Image) */
.gallery-top-right-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

/* Set as Main Button */
.gallery-set-main {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.gallery-set-main:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.gallery-set-main.is-main {
    background: #4CAF50;
    cursor: default;
}

.gallery-set-main svg {
    width: 14px;
    height: 14px;
}

/* Gallery Loading State */
.gallery-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* No Images Placeholder */
.gallery-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.gallery-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.4;
}

.gallery-placeholder p {
    margin: 0;
    font-size: 0.9rem;
}

/* Custom Image Badge */
.streetview-provider-badge.custom-badge {
    background: rgba(112, 134, 81, 0.9);
}

/* Delete Image Button */
.gallery-delete-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
    z-index: 10;
}

.gallery-delete-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.gallery-delete-btn svg {
    width: 18px;
    height: 18px;
}

/* Add Custom Image Button (inside top-right controls) */
.gallery-add-custom-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.gallery-add-custom-btn:hover {
    background: white;
    transform: translateY(-1px);
}

.gallery-add-custom-btn svg {
    width: 14px;
    height: 14px;
}

/* Add Image Button positioned at bottom of gallery (below dots/main selector) */
.gallery-add-custom-btn.gallery-add-bottom {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 10;
}

/* No Images Placeholder with Add Button - Compact Version */
.property-image-placeholder {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 16px 20px;
    height: 150px;
    max-height: 150px;
    border-radius: 8px;
    margin: 8px;
}

.property-image-placeholder .placeholder-icon {
    width: 32px;
    height: 32px;
    opacity: 0.4;
    flex-shrink: 0;
}

.property-image-placeholder .placeholder-icon svg {
    width: 100%;
    height: 100%;
}

.property-image-placeholder .placeholder-message {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
}

.property-image-placeholder .placeholder-query {
    display: none; /* Hide the search query to save space */
}

.property-image-placeholder .placeholder-add-btn {
    margin-left: auto;
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.85rem;
}

/* Custom Image Modal */
.custom-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-image-modal-content {
    position: relative;
    z-index: 10001;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.custom-image-modal h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.custom-image-modal .modal-subtitle {
    margin: 0 0 24px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.custom-image-modal .form-group {
    margin-bottom: 20px;
}

.custom-image-modal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.custom-image-modal .form-group input[type="url"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
}

.custom-image-modal .form-group input[type="url"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(112, 134, 81, 0.15);
}

.custom-image-modal .form-group small {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.custom-image-modal .form-group input[type="checkbox"] {
    margin-right: 8px;
}

.custom-image-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

/* ================================================
   Deal Card Thumbnail
   ================================================ */

.deal-card-thumbnail {
    position: relative;
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: var(--bg-secondary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    margin: -16px -16px 12px -16px;
    width: calc(100% + 32px);
}

.deal-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.deal-card:hover .deal-card-thumbnail img {
    transform: scale(1.05);
}

.deal-card-thumbnail .thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-muted);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
}

.deal-card-thumbnail .thumbnail-placeholder svg {
    width: 32px;
    height: 32px;
    opacity: 0.4;
}

.deal-card-thumbnail .thumbnail-placeholder span {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
}

.deal-card-thumbnail .thumbnail-loading {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
}

.deal-card-thumbnail .thumbnail-loading .loading-spinner {
    width: 24px;
    height: 24px;
}

/* Adjust deal card header when thumbnail is present */
.deal-card.has-thumbnail .deal-header {
    margin-top: 0;
}

/* Map Card */
.deal-map-card .deal-map-container {
    height: 350px;
    position: relative;
}

.deal-map-iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: auto;  /* Enable map interaction (zoom, pan, click) */
}

.map-loading,
.map-unavailable {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* Expandable Map Styles */
.btn-expand-map {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

.deal-map-container {
    cursor: pointer;
    position: relative;
}

.map-click-hint {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
    /* pointer-events on hint doesn't matter - clicks go to parent overlay */
}

.deal-map-container:hover .map-click-hint {
    opacity: 1;
}

/* Fullscreen Map Modal */
.fullscreen-map-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-page);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

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

.fullscreen-map-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.btn-close-fullscreen {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.15s ease;
}

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

.fullscreen-map-content {
    flex: 1;
    padding: 24px;
    overflow: hidden;
}

.fullscreen-map-iframe {
    width: 100%;
    height: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: white;
    pointer-events: auto;  /* Enable interaction in fullscreen mode */
}

/* Documents List in Sidebar */
.deal-docs-card .deal-docs-list {
    padding: 12px;
}

.deal-doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--bg-secondary);
}

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

.deal-doc-item.complete {
    background: rgba(30, 58, 95, 0.1);
}

.deal-doc-item.missing {
    background: var(--bg-secondary);
}

.deal-doc-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.deal-doc-status {
    font-size: 1.1rem;
}

.deal-doc-status.complete {
    color: var(--success-color);
}

.deal-doc-status.missing {
    color: var(--text-tertiary);
}

/* Parsed Documents */
.deal-parsed-list {
    padding: 16px;
}

.parsed-doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

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

.parsed-doc-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.parsed-doc-type.rent_roll {
    background: rgba(30, 58, 95, 0.2);
    color: var(--success-color);
}

.parsed-doc-type.t12 {
    background: rgba(230, 81, 0, 0.15);
    color: #e65100;
}

/* Screener Score Card - v2 Acwise */
.deal-scorecard .deal-card-header {
    background: #1a5e3a;
}
.deal-scorecard .deal-card-header h3 {
    color: white;
}

/* Overall score display */
.scorecard-overall {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 14px 10px;
}
.scorecard-overall-number {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    min-width: 56px;
    text-align: center;
}
.scorecard-overall-meta {
    flex: 1;
    min-width: 0;
}
.scorecard-overall-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.scorecard-completeness {
    margin-top: 6px;
}
.scorecard-completeness-label {
    font-size: 0.7rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 3px;
}
.scorecard-completeness-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color, #e2e8f0);
    border-radius: 3px;
    overflow: hidden;
}
.scorecard-completeness-fill {
    height: 100%;
    background: #1a5e3a;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Warnings banner */
.scorecard-warnings {
    padding: 6px 12px;
    background: #fef3c7;
    border-top: 1px solid #f59e0b;
    border-bottom: 1px solid #f59e0b;
}
.scorecard-warning-item {
    font-size: 0.72rem;
    color: #92400e;
    padding: 2px 0;
    line-height: 1.3;
}
.scorecard-warning-item::before {
    content: '\f071';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.6rem;
    margin-right: 5px;
    color: #d97706;
}

/* Sections container */
.scorecard-sections {
    padding: 4px 0;
}

/* Collapsible section */
.scorecard-section {
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}
.scorecard-section:last-child {
    border-bottom: none;
}
.scorecard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.scorecard-section-header:hover {
    background: rgba(0, 0, 0, 0.03);
}
.scorecard-section-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.scorecard-section-toggle {
    font-size: 0.6rem;
    color: var(--text-secondary, #64748b);
    transition: transform 0.2s;
    width: 10px;
    text-align: center;
}
.scorecard-section.expanded .scorecard-section-toggle {
    transform: rotate(90deg);
}
.scorecard-section-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.scorecard-section-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.scorecard-section-score {
    font-size: 0.9rem;
    font-weight: 700;
    min-width: 28px;
    text-align: right;
}
.scorecard-section-coverage {
    font-size: 0.62rem;
    color: var(--text-secondary, #94a3b8);
    white-space: nowrap;
}

/* Expandable individual scores */
.scorecard-section-body {
    display: none;
    padding: 0 12px 6px 30px;
}
.scorecard-section.expanded .scorecard-section-body {
    display: block;
}
.scorecard-score-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.75rem;
}
.scorecard-score-item-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
}
.scorecard-score-item-name {
    color: var(--text-secondary, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.score-tag {
    display: inline-block;
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.3;
    flex-shrink: 0;
}
.score-tag-market-report {
    background: #dbeafe;
    color: #1e40af;
}
.score-tag-public {
    background: #dcfce7;
    color: #166534;
}
.score-tag-manual {
    background: #f3e8ff;
    color: #6b21a8;
}
.score-tag-asking_price {
    background: #fef3c7;
    color: #92400e;
}
.scorecard-score-item-value {
    font-weight: 600;
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

/* Score color classes */
.score-good { color: #16a34a; }
.score-ok { color: #ca8a04; }
.score-bad { color: #dc2626; }
.score-none { color: #94a3b8; }

/* Market Reports Card */
.deal-market-report-card .deal-card-header {
    background: var(--primary-color);
}

.deal-market-report-card .deal-card-header h3 {
    color: white;
}

.market-report-count-badge {
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.market-report-count-badge.has-files {
    background: rgba(255, 255, 255, 0.3);
}

.market-report-upload-section {
    padding: 12px;
}

.market-report-status-display {
    display: none; /* Hide status - redundant with badge */
}

.market-report-dropzone {
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.market-report-dropzone:hover,
.market-report-dropzone.dragover {
    border-color: var(--primary-color);
    background: rgba(30, 58, 95, 0.05);
}

.market-report-dropzone svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    opacity: 0.6;
}

.market-report-dropzone .dropzone-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.market-report-dropzone .dropzone-hint {
    display: none; /* Hide hint - clutters UI */
}

.market-report-button-group {
    display: flex;
    gap: 6px;
}

.market-report-button-group .btn {
    flex: 1;
    justify-content: center;
    gap: 4px;
    font-size: 0.8rem;
    padding: 8px 10px;
}

.btn-open-market-report {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-open-market-report:hover {
    background: var(--bg-page);
    border-color: var(--text-secondary);
}

.market-report-files-list {
    margin-top: 12px;
}

.market-report-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.market-report-file-item:last-child {
    margin-bottom: 0;
}

.market-report-file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.market-report-file-name svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.market-report-file-actions {
    display: flex;
    gap: 4px;
}

.market-report-file-actions button {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.market-report-file-actions button:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

/* Notes Textarea */
.deal-notes-textarea {
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 60px;
}

.deal-notes-textarea:focus {
    outline: none;
    background: var(--bg-secondary);
}

/* Quick Actions */
.deal-actions-card .deal-actions-list {
    padding: 8px;
}

.deal-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 6px;
}

.deal-action-btn:last-child {
    margin-bottom: 0;
}

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

.deal-action-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
}

.deal-action-btn:hover svg {
    opacity: 1;
}

.deal-actions-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}

.deal-action-btn.deal-action-warning {
    color: var(--warning-color, #f59e0b);
}

.deal-action-btn.deal-action-warning:hover {
    background: rgba(245, 158, 11, 0.1);
    border-color: var(--warning-color, #f59e0b);
}

.deal-action-btn.deal-action-danger {
    color: var(--danger-color, #ef4444);
}

.deal-action-btn.deal-action-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color, #ef4444);
}

/* Empty states */
.deal-empty-state {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .deal-detail-content {
        grid-template-columns: 1fr 320px;
    }

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

@media (max-width: 900px) {
    .deal-detail-content {
        grid-template-columns: 1fr;
    }

    .deal-detail-sidebar {
        order: -1;
    }

    .deal-detail-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .deal-detail-header-left,
    .deal-detail-header-right {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .deal-detail-header {
        padding: 12px 16px;
    }

    .deal-detail-content {
        padding: 16px;
    }

    .deal-detail-header-center h1 {
        font-size: 1.2rem;
    }

    .deal-metrics-card .deal-metrics-grid {
        grid-template-columns: 1fr;
    }

    .deal-metric-item {
        border-right: none;
    }
}

/* Responsive (original deal modal) */
@media (max-width: 768px) {
    .modal-xlarge {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .deal-map-container {
        height: 200px;
    }

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

    .deal-actions-grid {
        flex-direction: column;
    }

    .deal-actions-grid .btn {
        width: 100%;
    }
}

/* No address styling */
.no-address {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9em;
}

/* Icon button styling */
.btn-icon {
    padding: 6px 8px;
    min-width: unset;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Map click overlay - small expand button, doesn't block map interaction */
.map-click-overlay {
    position: absolute;
    bottom: 12px;
    right: 12px;
    cursor: pointer;
    z-index: 100;
    pointer-events: auto;
    /* No longer covers entire map - just a small button area */
}

.map-click-overlay:hover {
    /* No background change needed since it's just a button now */
}

.map-click-overlay .map-click-hint {
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.85;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.map-click-overlay:hover .map-click-hint {
    opacity: 1;
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.02);
}

/* ============================================
   DOCUMENTS TAB STYLES
   ============================================ */

.documents-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.documents-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.documents-title h2 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
}

.documents-title .text-secondary {
    margin: 0;
    font-size: 0.9rem;
}

.documents-actions {
    display: flex;
    gap: 12px;
}

.documents-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

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

.documents-stats .stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 8px;
}

.documents-stats .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.documents-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

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

.documents-table th {
    background: var(--bg-hover);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.documents-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

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

.documents-table .loading-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

@media (max-width: 768px) {
    .documents-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .documents-header {
        flex-direction: column;
        gap: 16px;
    }
}

/* ============================================
   DEAL PAGE - DOCUMENT MANAGEMENT INTEGRATION
   ============================================ */

/* Document Management Card */
.deal-document-management-card {
    display: flex;
    flex-direction: column;
}

.deal-document-management-card .deal-card-header {
    border-bottom: 1px solid var(--border-color);
}

/* Document Upload Section */
.deal-doc-upload-section {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Doc Type Selector */
.deal-doc-type-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-type-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 500;
}

.doc-type-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.doc-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 54px;
    flex: 1;
}

.doc-type-btn:hover {
    border-color: var(--primary-color);
    background: rgba(112, 134, 81, 0.08);
}

.doc-type-btn i {
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.doc-type-btn:hover i {
    color: var(--primary-color);
}

.doc-type-btn span {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.doc-type-btn:hover span {
    color: var(--text-primary);
}

/* Doc type button colors by type */
.doc-type-btn[data-type="rent_roll"]:hover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}
.doc-type-btn[data-type="rent_roll"]:hover i { color: #3b82f6; }

.doc-type-btn[data-type="t12"]:hover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}
.doc-type-btn[data-type="t12"]:hover i { color: #10b981; }

.doc-type-btn[data-type="costar"]:hover {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}
.doc-type-btn[data-type="costar"]:hover i { color: #f59e0b; }

.doc-type-btn[data-type="om"]:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}
.doc-type-btn[data-type="om"]:hover i { color: #ef4444; }

.doc-type-btn[data-type="other"]:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.08);
}
.doc-type-btn[data-type="other"]:hover i { color: #8b5cf6; }

.deal-doc-dropzone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.15s ease;
}

.deal-doc-dropzone:hover,
.deal-doc-dropzone.dragover {
    border-color: var(--primary-color);
    background: rgba(112, 134, 81, 0.05);
}

.deal-doc-dropzone svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.deal-doc-dropzone:hover svg,
.deal-doc-dropzone.dragover svg {
    color: var(--primary-color);
}

.deal-doc-dropzone .dropzone-text {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.deal-doc-dropzone .dropzone-hint {
    display: none;
}

.deal-doc-upload-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    justify-content: flex-start;
}

.deal-doc-upload-actions .btn {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 6px 10px;
}

/* Document Status Section */
.deal-doc-status-section {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.deal-doc-status-section h4 {
    margin: 0 0 8px 0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* Parsed Documents Section */
.deal-parsed-section {
    padding: 10px 12px;
}

.deal-parsed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.deal-parsed-header h4 {
    margin: 0;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.parsed-count-badge {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Enhanced Parsed Document Rows */
.deal-parsed-list .parsed-doc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: background 0.15s ease;
}

.deal-parsed-list .parsed-doc-row:last-child {
    margin-bottom: 0;
}

.deal-parsed-list .parsed-doc-row:hover {
    background: var(--bg-hover);
}

/* Status Badge Styles for Documents */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.status-badge.status-parsing {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.status-badge.status-review {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.status-badge.status-approved {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-badge.status-error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Document Type Badge */
.doc-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.doc-type-badge.rent_roll {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.doc-type-badge.t12 {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

/* Deal Page View - Enhanced Layout */
.deal-detail-fullscreen.deal-page-view {
    /* Override fixed positioning for proper page behavior */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

/* Hide main content when deal page is open */
body.deal-page-active .hero-section,
body.deal-page-active .main-tabs,
body.deal-page-active .tab-content,
body.deal-page-active .user-menu {
    visibility: hidden;
    pointer-events: none;
}

body.deal-page-active .deal-detail-fullscreen {
    visibility: visible;
    pointer-events: auto;
}

/* Responsive adjustments for document management */
@media (max-width: 1024px) {
    .deal-detail-content {
        grid-template-columns: 1fr;
    }

    .deal-detail-sidebar {
        order: -1;
    }
}

@media (max-width: 640px) {
    .deal-doc-upload-actions {
        flex-direction: column;
    }

    .deal-doc-upload-actions .btn {
        width: 100%;
        justify-content: center;
    }
}


/* ============================================
   MAPPING FIELDS CONFIGURATION MODAL
   ============================================ */

#field-config-modal .mapping-table {
    font-size: 13px;
}

#field-config-modal .mapping-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    padding: 8px 10px;
    background: var(--bg-tertiary, #f1f5f9);
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    white-space: nowrap;
}

#field-config-modal .mapping-table td {
    padding: 6px 10px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color-light, #f1f5f9);
}

#field-config-modal .mapping-table tr:hover {
    background: rgba(59, 130, 246, 0.03);
}

.fc-row-disabled {
    opacity: 0.5;
}

.fc-row-disabled td {
    text-decoration: line-through;
    text-decoration-color: var(--text-muted, #94a3b8);
}

.fc-row-disabled td:nth-child(5),
.fc-row-disabled td:nth-child(6),
.fc-row-disabled td:nth-child(8) {
    text-decoration: none;
}

#fc-add-field-section .form-input,
#fc-add-field-section .filter-select {
    width: 100%;
}

#field-config-modal .form-input {
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1e293b);
    transition: border-color 0.15s;
}

#field-config-modal .form-input:focus {
    border-color: var(--accent-color, #3b82f6);
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}


/* =============================================================================
   Parser Trainer Dashboard
   ============================================================================= */

.trainer-container {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.trainer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.trainer-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary, #1e293b);
}

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

.trainer-header-actions select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1e293b);
    font-size: 0.85rem;
}

/* Overview Cards */
.trainer-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.trainer-card {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    padding: 1.25rem;
    text-align: center;
}

.trainer-card-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.trainer-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

/* Subtabs */
.trainer-subtabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    margin-bottom: 1rem;
    overflow-x: auto;
}

.trainer-subtab {
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s;
}

.trainer-subtab:hover {
    color: var(--text-primary, #1e293b);
}

.trainer-subtab.active {
    color: var(--accent-color, #3b82f6);
    border-bottom-color: var(--accent-color, #3b82f6);
}

/* Tables */
.trainer-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.trainer-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    color: var(--text-secondary, #64748b);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.trainer-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-primary, #1e293b);
}

.trainer-table tr:hover td {
    background: var(--bg-secondary, #f8fafc);
}

.trainer-table .empty-state,
.trainer-table .loading-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary, #64748b);
}

/* Accuracy Badges */
.accuracy-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
}

.accuracy-high {
    background: #dcfce7;
    color: #166534;
}

.accuracy-medium {
    background: #fef3c7;
    color: #92400e;
}

.accuracy-low {
    background: #fee2e2;
    color: #991b1b;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-muted {
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text-secondary, #64748b);
}

/* Examples filters */
.trainer-examples-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.trainer-examples-filters select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    font-size: 0.85rem;
}

#trainer-examples-count {
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
}

/* Pagination */
.trainer-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
}

/* Aliases info */
.trainer-aliases-info {
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Trend Chart */
.trainer-trend {
    margin-top: 2rem;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    padding: 1.25rem;
}

.trainer-trend h3 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--text-primary, #1e293b);
}

.trainer-trend-chart {
    min-height: 120px;
}

.trend-chart-inner {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    padding: 0 0 20px 0;
    position: relative;
}

.trend-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    min-width: 16px;
    cursor: default;
}

.trend-bar {
    width: 100%;
    max-width: 40px;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s;
}

.trend-bar.accuracy-high {
    background: #22c55e;
}

.trend-bar.accuracy-medium {
    background: #f59e0b;
}

.trend-bar.accuracy-low {
    background: #ef4444;
}

.trend-label {
    font-size: 0.65rem;
    color: var(--text-secondary, #64748b);
    margin-top: 4px;
    white-space: nowrap;
}

/* Small buttons */
.btn-sm {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.btn-danger:hover {
    background: #fca5a5;
}

/* ============================================
   SCREENER TAB - DEAL SELECTOR
   ============================================ */

.screener-deal-selector {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

.screener-deal-selector-header {
    margin-bottom: 1.5rem;
}

.screener-deal-selector-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.screener-deal-selector-title .icon {
    width: 28px;
    height: 28px;
    color: var(--primary-color, #1E3A5F);
}

.screener-deal-selector-title h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-color, #333);
    font-weight: 600;
}

.screener-deal-selector-subtitle {
    color: var(--text-muted, #666);
    margin: 0 0 1rem 0;
    font-size: 0.95rem;
}

.screener-deal-selector-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.screener-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.screener-search-wrapper .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted, #999);
    pointer-events: none;
}

.screener-deal-search {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.5rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
}

.screener-deal-search:focus {
    outline: none;
    border-color: var(--primary-color, #1E3A5F);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.screener-deal-legend {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted, #666);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.legend-item .icon {
    width: 16px;
    height: 16px;
}

.legend-ready .icon {
    color: var(--success-color, #2e7d32);
}

.legend-missing .icon {
    color: var(--warning-color, #f57c00);
}

/* Screener Deals Grid */
.screener-deals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.screener-deal-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #ddd);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.screener-deal-card:hover {
    border-color: var(--primary-color, #1E3A5F);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.screener-deal-card.ready {
    border-left: 4px solid var(--success-color, #2e7d32);
}

.screener-deal-card.ready:hover {
    background: linear-gradient(to right, rgba(46, 125, 50, 0.03), transparent);
}

.screener-deal-card.not-ready {
    border-left: 4px solid var(--warning-color, #f57c00);
    opacity: 0.85;
}

.screener-deal-card.not-ready:hover {
    opacity: 1;
    background: linear-gradient(to right, rgba(245, 124, 0, 0.03), transparent);
}

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

.screener-deal-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color, #333);
    margin: 0;
    line-height: 1.3;
    flex: 1;
    margin-right: 0.5rem;
}

.screener-deal-card-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.screener-deal-card-status.status-ready {
    background: rgba(46, 125, 50, 0.1);
    color: var(--success-color, #2e7d32);
}

.screener-deal-card-status.status-missing {
    background: rgba(245, 124, 0, 0.1);
    color: var(--warning-color, #f57c00);
}

.screener-deal-card-status .icon {
    width: 12px;
    height: 12px;
}

.screener-deal-card-address {
    font-size: 0.85rem;
    color: var(--text-muted, #666);
    margin-bottom: 0.75rem;
}

.screener-deal-card-address.missing {
    color: var(--warning-color, #f57c00);
    font-style: italic;
}

.screener-deal-card-requirements {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.requirement-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-secondary, #f5f5f5);
}

.requirement-badge .icon {
    width: 12px;
    height: 12px;
}

.requirement-badge.met {
    background: rgba(46, 125, 50, 0.08);
    color: var(--success-color, #2e7d32);
}

.requirement-badge.unmet {
    background: rgba(245, 124, 0, 0.08);
    color: var(--warning-color, #f57c00);
}

.screener-deal-card-action {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color, #eee);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--primary-color, #1E3A5F);
    font-weight: 500;
}

.screener-deal-card.ready .screener-deal-card-action {
    color: var(--success-color, #2e7d32);
}

.screener-deal-card.not-ready .screener-deal-card-action {
    color: var(--text-muted, #999);
}

.screener-deal-card-action .icon {
    width: 16px;
    height: 16px;
}

/* Empty state for screener deals */
.screener-deals-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted, #666);
}

.screener-deals-empty .icon-large {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.screener-deals-empty p {
    margin: 0;
    font-size: 0.95rem;
}

/* Loading state in screener deals grid */
.screener-deals-grid .loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-muted, #666);
}

/* Legacy overlay styles - kept for backward compatibility */
.screener-no-deal-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 2rem;
}

.screener-no-deal-content {
    text-align: center;
    max-width: 500px;
    padding: 3rem;
    background: var(--card-bg, #fff);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.screener-no-deal-icon {
    width: 80px;
    height: 80px;
    color: var(--primary-color, #1E3A5F);
    margin-bottom: 1.5rem;
    opacity: 0.7;
}

.screener-no-deal-content h2 {
    font-size: 1.5rem;
    color: var(--text-color, #333);
    margin-bottom: 1rem;
    font-weight: 600;
}

.screener-no-deal-content p {
    color: var(--text-muted, #666);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
}

/* Current Deal Display in Screener */
.screener-current-deal {
    background: linear-gradient(135deg, var(--primary-color, #1E3A5F) 0%, #162D4A 100%);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: white;
}

.screener-deal-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-bottom: 0.25rem;
}

.screener-deal-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    word-break: break-word;
}

.screener-current-deal .btn-outline {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 0.75rem;
    padding: 0.35rem 0.75rem;
}

.screener-current-deal .btn-outline:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   EVALUATOR TEMPLATES PANEL
   ============================================ */

.evaluator-templates-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

.evaluator-template-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary, #fff);
    transition: background 0.1s;
    border: none;
    width: 100%;
    text-align: left;
}

.evaluator-template-option:hover {
    background: var(--bg-hover, #f3f4f6);
}

.evaluator-template-option.selected {
    background: var(--primary-bg-subtle, #f0f7ed);
    font-weight: 500;
}

.evaluator-template-option input[type="radio"] {
    accent-color: var(--primary-color, #6b8a5e);
    margin: 0;
    flex-shrink: 0;
}

.evaluator-template-option .template-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.evaluator-template-option .template-meta {
    font-size: 11px;
    color: var(--text-tertiary, #9ca3af);
    flex-shrink: 0;
}

/* ============================================
   BOX OPEN DROPDOWN (Split Button)
   ============================================ */

.box-open-dropdown {
    position: relative;
    display: inline-flex;
}

.box-open-dropdown .box-open-main {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.box-open-dropdown .box-open-toggle {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: 8px 10px;
    min-width: 32px;
}

.box-open-dropdown .box-open-toggle i {
    transition: transform 0.2s ease;
}

.box-open-dropdown.open .box-open-toggle i {
    transform: rotate(180deg);
}

.box-open-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.box-open-dropdown.open .box-open-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.box-open-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.box-open-option:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.box-open-option:hover {
    background: var(--bg-page);
}

.box-open-option i {
    width: 18px;
    color: var(--text-muted);
    text-align: center;
}

.box-open-option:hover i {
    color: var(--primary-color);
}

.box-open-option.active {
    background: rgba(var(--primary-rgb, 37, 99, 235), 0.08);
}

.box-open-option.active i {
    color: var(--primary-color);
}

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

.box-open-preference {
    padding: 10px 16px;
}

.box-open-preference .checkbox-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.box-open-preference input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .box-open-menu {
        min-width: 180px;
    }
}


/* ============================================
   ADMIN SETTINGS MODAL
   ============================================ */

/* Admin Tabs */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0;
}

.admin-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.admin-tab:hover {
    color: var(--text-primary);
}

.admin-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Admin Tab Content */
.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

/* Admin Sections */
.admin-section {
    margin-bottom: 32px;
}

.admin-section h4 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.admin-help {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 16px 0;
}

.admin-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 4px 0 0 0;
}

.admin-note {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 12px;
}

/* Admin Add Row */
.admin-add-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-add-row .input-field {
    flex: 1;
}

/* Admin List */
.admin-list {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.admin-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

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

.admin-list-item:hover {
    background: var(--bg-page);
}

.admin-list-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.admin-list-item-secondary {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.admin-list-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Admin Role Select */
.admin-role-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    font-size: 0.85rem;
    cursor: pointer;
}

.admin-role-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Admin Form Groups */
.admin-form-group {
    margin-bottom: 20px;
}

.admin-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Admin Status */
.admin-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-badge.status-connected {
    background: rgba(46, 125, 50, 0.1);
    color: var(--success-color);
}

.status-badge.status-disconnected {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

/* Role badges */
.role-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.role-super-admin {
    background: rgba(156, 39, 176, 0.1);
    color: #9c27b0;
}

.role-badge.role-admin {
    background: rgba(33, 150, 243, 0.1);
    color: #2196f3;
}

.role-badge.role-user {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
}

/* Admin empty state */
.admin-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
}

/* Delete button */
.btn-delete {
    padding: 6px 10px;
    background: none;
    border: 1px solid var(--error-color);
    border-radius: 6px;
    color: var(--error-color);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ============================================
   AI TRAINING DASHBOARD STYLES
   ============================================ */

.training-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.filter-select {
    padding: 6px 32px 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

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

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

/* Loading State */
.training-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.training-loading span {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Stats Cards */
.training-stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-primary .stat-icon {
    background: linear-gradient(135deg, #1E3A5F 0%, #2A4D7A 100%);
}

.stat-card-success .stat-icon {
    background: linear-gradient(135deg, #28a745 0%, #34ce57 100%);
}

.stat-card-warning .stat-icon {
    background: linear-gradient(135deg, #ffc107 0%, #ffcd38 100%);
}

.stat-card-info .stat-icon {
    background: linear-gradient(135deg, #17a2b8 0%, #1fc8df 100%);
}

.stat-icon svg {
    width: 24px;
    height: 24px;
    stroke: white;
}

.stat-content {
    flex: 1;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Training Sections */
.training-section {
    margin-bottom: 32px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
}

.training-section h5 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.section-help {
    margin: 0 0 16px 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Training Chart */
.training-chart {
    margin-top: 16px;
    min-height: 200px;
}

/* Training Tables */
.training-table-wrapper {
    overflow-x: auto;
}

.training-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.training-table thead {
    background: var(--bg-page);
}

.training-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.training-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.text-success {
    color: #28a745;
}

.text-warning {
    color: #ffc107;
}

/* Accuracy Bar */
.accuracy-bar {
    position: relative;
    width: 100%;
    height: 24px;
    background: var(--bg-page);
    border-radius: 12px;
    overflow: hidden;
}

.accuracy-fill {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 12px;
}

.accuracy-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Mistakes List */
.training-mistakes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mistake-item {
    background: var(--bg-page);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

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

.mistake-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 4px 8px;
    background: #dc3545;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 12px;
}

.mistake-source {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.mistake-body {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.mistake-mapping {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mistake-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.mistake-ai, .mistake-user {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

.mistake-ai {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.mistake-user {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.mistake-arrow {
    width: 24px;
    height: 24px;
    stroke: var(--text-secondary);
    flex-shrink: 0;
}

/* Corrections List */
.training-corrections-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.correction-item {
    background: var(--bg-page);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
}

.correction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.correction-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.correction-doc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

.correction-body strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.correction-change {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.correction-from, .correction-to {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: 'Courier New', monospace;
}

.correction-from {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.correction-to {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.correction-arrow {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    flex-shrink: 0;
}

/* Empty State */
.training-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    stroke: var(--border-color);
    margin-bottom: 20px;
}

.training-empty-state h5 {
    margin: 0 0 12px 0;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.training-empty-state p {
    margin: 8px 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 500px;
}

.empty-state-hint {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-style: italic;
}

/* ============================================
   FEEDBACK BUTTON & MODAL
   ============================================ */

/* Feedback Button - Fixed position, bottom-right corner */
.feedback-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--accent-primary, #1E3A5F);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 999;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.feedback-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25), 0 3px 6px rgba(0, 0, 0, 0.15);
    background: var(--accent-primary-hover, #162D4A);
}

.feedback-btn:active {
    transform: translateY(0);
}

.feedback-btn svg {
    flex-shrink: 0;
}

/* Hide text on smaller screens, show icon only */
@media (max-width: 600px) {
    .feedback-btn {
        padding: 12px;
        border-radius: 50%;
    }
    .feedback-btn span {
        display: none;
    }
}

/* Feedback Modal Styling */
.feedback-modal-content {
    max-width: 480px;
    width: 90%;
}

.feedback-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 20px 0;
}

.feedback-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.feedback-type {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-input, #F9FAFB);
    border: 2px solid var(--border-color, #e2d8c8);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-body);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.feedback-type:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: var(--bg-card);
}

.feedback-type.active {
    background: var(--accent-primary, #1E3A5F);
    border-color: var(--accent-primary, #1E3A5F);
    color: white;
}

.feedback-type i {
    font-size: 14px;
}

/* Feedback form elements */
.feedback-modal .form-group {
    margin-bottom: 16px;
}

.feedback-modal .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.feedback-modal .form-group label .required {
    color: var(--error-color, #dc3545);
}

.feedback-modal .input-field {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color, #e2d8c8);
    border-radius: 6px;
    background: var(--bg-input, #F9FAFB);
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: border-color 0.15s, background 0.15s;
}

.feedback-modal .input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-input-focus, #ffffff);
}

.feedback-modal textarea.input-field {
    resize: vertical;
    min-height: 100px;
}

.char-counter {
    text-align: right;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Submit button with icon */
#feedback-submit-btn i {
    margin-right: 6px;
}

/* Loading state for submit button */
#feedback-submit-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

#feedback-submit-btn.loading i::before {
    content: "\f110"; /* fa-spinner */
    animation: fa-spin 1s infinite linear;
}

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

/* ============================================
   SOURCE LOGOS FOR DEAL SOURCES
   ============================================ */

/* Container for source with logo */
.source-with-logo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Source logo image */
.source-logo {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    object-fit: contain;
    background: white;
    flex-shrink: 0;
}

/* Larger logo in deal detail view */
.deal-detail .source-logo,
.broker-item .source-logo {
    width: 20px;
    height: 20px;
}

/* Source badge with logo (for compact display) */
.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}

.source-badge .source-logo {
    width: 14px;
    height: 14px;
}

/* Extracted data source field */
.extracted-field .source-with-logo {
    gap: 8px;
}

.extracted-field .source-logo {
    width: 18px;
    height: 18px;
}

/* ============================================
   BROKER DUPLICATES REVIEW MODAL
   ============================================ */

.duplicates-modal-content {
    max-width: 700px;
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
}

.duplicates-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.duplicates-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.duplicates-loading,
.duplicates-empty,
.duplicates-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.duplicates-error {
    color: var(--error-color);
}

.duplicates-empty {
    color: var(--success-color);
}

.duplicate-group {
    background: rgba(30, 58, 95, 0.08);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: opacity 0.3s, transform 0.3s;
}

.duplicate-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.duplicate-reason {
    font-weight: 600;
    color: var(--text-primary);
}

.duplicate-confidence {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
}

.duplicate-confidence.high {
    background: rgba(231, 76, 60, 0.15);
    color: #c0392b;
}

.duplicate-confidence.medium {
    background: rgba(243, 156, 18, 0.15);
    color: #d68910;
}

.duplicate-brokers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duplicate-broker-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}

.duplicate-broker-option:hover {
    background: rgba(30, 58, 95, 0.1);
}

.duplicate-broker-option:has(input:checked) {
    background: rgba(30, 58, 95, 0.15);
    border-color: var(--primary-color);
}

.duplicate-broker-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.duplicate-broker-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

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

.duplicate-broker-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-merge {
    margin-top: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.15s, transform 0.1s;
}

.btn-merge:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

/* Responsive adjustments for duplicates modal */
@media (max-width: 600px) {
    .duplicates-modal-content {
        max-width: 100%;
        max-height: 90vh;
        margin: 10px;
    }

    .duplicate-group-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .duplicate-broker-meta {
        font-size: 0.75rem;
    }
}


/* ============================================
   COMP VIEWER SECTION (TAB-BASED)
   ============================================ */

/* Comps Tab Full Container */
.comp-viewer-container {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    overflow-y: auto;
}

/* Comps Tab - Full Width Layout */
#deal-tab-comps {
    display: none;
    grid-template-columns: 1fr;
    padding: 0;
}

#deal-tab-comps.active {
    display: block;
}

/* Comp Tab Header */
.comp-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.comp-tab-title {
    display: flex;
    align-items: center;
    gap: 16px;
}

.comp-tab-title svg {
    color: var(--primary-color);
    flex-shrink: 0;
}

.comp-tab-title h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comp-tab-actions {
    display: flex;
    gap: 12px;
}

/* Comp Import Section - Collapsible */
.comp-import-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.comp-import-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    border-radius: var(--radius-lg);
}

.comp-import-toggle:hover {
    background: rgba(30, 58, 95, 0.05);
}

.comp-import-toggle-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.comp-import-toggle-left svg {
    width: 18px;
    height: 18px;
    color: var(--accent-green);
}

.comp-import-chevron {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.comp-import-wrapper.collapsed .comp-import-chevron {
    transform: rotate(-90deg);
}

.comp-import-wrapper.collapsed .comp-import-content {
    display: none;
}

.comp-import-content {
    padding: 0 16px 16px 16px;
    border-top: 1px solid var(--border-color);
}

.comp-import-section {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding-top: 16px;
}

.comp-import-section .comp-address-input {
    flex: 1;
}

.comp-import-section .btn {
    align-self: flex-end;
    white-space: nowrap;
}

/* Legacy collapsible styles (for backwards compatibility) */
.comp-viewer-section {
    margin-top: 16px;
}

.comp-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s;
    user-select: none;
}

.comp-viewer-header:hover {
    background: rgba(30, 58, 95, 0.08);
}

.comp-viewer-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.comp-viewer-title .icon {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

.comp-viewer-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.comp-viewer-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.comp-count-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(30, 58, 95, 0.12);
    padding: 4px 10px;
    border-radius: 12px;
}

.toggle-icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.comp-viewer-section.expanded .toggle-icon {
    transform: rotate(180deg);
}

.comp-viewer-content {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

/* Add Comp Form */
.add-comp-form {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.comp-address-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    resize: none;
    transition: border-color 0.15s, background 0.15s;
}

.comp-address-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-input-focus);
}

.comp-address-input::placeholder {
    color: var(--text-muted);
}

.add-comp-form .btn {
    align-self: flex-start;
    white-space: nowrap;
}

/* Comp Grid */
.comp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

/* Comp Card */
.comp-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.2s, transform 0.15s;
}

.comp-card:hover {
    box-shadow: var(--shadow-md);
}

.comp-card.subject {
    border: 2px solid var(--primary-color);
}

.comp-label-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    background: var(--primary-color);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.comp-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    line-height: 1;
    transition: background 0.15s, transform 0.1s;
}

.comp-remove:hover {
    background: rgba(196, 92, 92, 0.9);
    transform: scale(1.1);
}

/* Comp Gallery */
.comp-gallery {
    height: 180px;
    position: relative;
    background: #f5f0e8;
    overflow: hidden;
}

.comp-gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.comp-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.comp-photo.active {
    display: block;
}

.comp-gallery-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
}

.comp-gallery-nav button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: background 0.15s;
}

.comp-gallery-nav button:hover {
    background: rgba(255, 255, 255, 0.4);
}

.comp-gallery-nav button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.photo-counter {
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
}

.comp-no-photo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 8px;
}

.comp-no-photo svg {
    width: 40px;
    height: 40px;
    opacity: 0.5;
}

.comp-no-photo span {
    font-size: 0.8rem;
}

/* Comp Info */
.comp-info {
    padding: 12px;
}

.comp-info h5 {
    margin: 0 0 4px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comp-address {
    margin: 0 0 4px 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Comp Address Edit Row */
.comp-address-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.comp-address-row .comp-address {
    flex: 1;
    margin: 0;
}

.comp-edit-address-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.7rem;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.comp-address-row:hover .comp-edit-address-btn {
    opacity: 1;
}

.comp-edit-address-btn:hover {
    color: var(--primary-color);
}

/* Comp Address Edit Form */
.comp-address-edit-form {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.comp-address-edit-form .comp-address-input {
    flex: 1;
    padding: 4px 8px;
    font-size: 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    color: var(--text-primary);
}

.comp-address-edit-form .comp-address-input:focus {
    outline: none;
}

.comp-address-save-btn,
.comp-address-cancel-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 0.75rem;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.comp-address-save-btn {
    color: var(--success-color, #10b981);
}

.comp-address-save-btn:hover {
    background: rgba(16, 185, 129, 0.1);
}

.comp-address-cancel-btn {
    color: var(--text-muted);
}

.comp-address-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.comp-meta {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Comp Website Link */
.comp-website-link {
    color: var(--primary-color);
    margin-left: 8px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.comp-website-link:hover {
    color: var(--primary-color-hover, #5a7550);
}

.comp-website-link i {
    font-size: 0.85em;
}

/* Website column in table */
.comp-website-cell {
    text-align: center;
}

.comp-website-cell .comp-website-link {
    margin-left: 0;
    font-size: 14px;
}

/* Comp Notes */
.comp-notes {
    padding: 0 12px 12px;
}

.comp-notes textarea {
    width: 100%;
    background: rgba(30, 58, 95, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    resize: none;
    height: 60px;
    transition: border-color 0.15s, background 0.15s;
}

.comp-notes textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-card);
}

.comp-notes textarea::placeholder {
    color: var(--text-muted);
}

/* Comp Empty State */
.comp-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
}

.comp-empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
    color: var(--primary-color);
}

.comp-empty-state h3 {
    margin: 0 0 8px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comp-empty-state p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 400px;
}

.comp-empty-state span {
    font-size: 0.85rem;
}

/* Loading state for add comps button */
#btn-add-comps.loading {
    opacity: 0.7;
    pointer-events: none;
}

#btn-add-comps.loading .icon {
    animation: spin 1s linear infinite;
}

/* Add Comp Buttons Row */
.add-comp-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* View Mode Toggle */
.comp-view-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    width: fit-content;
}

.comp-view-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.comp-view-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.5);
}

.comp-view-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.comp-view-btn .icon {
    width: 16px;
    height: 16px;
}

/* Comp Table Styles */
/* Matches .brokers-table-wrapper pattern for consistent scrolling */
.comp-table-container {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: var(--shadow-sm);
    margin-top: 0;
}

.comp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 1200px;
}

.comp-table th,
.comp-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.comp-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.comp-table tbody tr:hover {
    background: rgba(30, 58, 95, 0.05);
}

.comp-table tbody tr:last-child td {
    border-bottom: none;
}

/* Comp Table Cell Styles */
.comp-mini-photo {
    width: 60px;
    height: 45px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.comp-mini-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.comp-mini-photo svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
}

.comp-property-cell {
    min-width: 200px;
    max-width: 280px;
}

.comp-property-cell strong {
    display: block;
    white-space: normal;
    word-wrap: break-word;
    margin-bottom: 2px;
}

.comp-address-small {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: normal;
    word-wrap: break-word;
}

.comp-location {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.comp-notes-input {
    width: 120px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    color: inherit;
    font-size: 12px;
    transition: border-color 0.15s, background 0.15s;
}

.comp-notes-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-card);
}

.comp-notes-input::placeholder {
    color: var(--text-muted);
}

/* Delete button in table */
.comp-table-delete {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.comp-table-delete:hover {
    background: rgba(196, 92, 92, 0.1);
    border-color: rgba(196, 92, 92, 0.3);
    color: #c45c5c;
}

.comp-table-delete svg {
    width: 16px;
    height: 16px;
}

/* Numeric cells right-align */
.comp-table td:nth-child(4),
.comp-table td:nth-child(5),
.comp-table td:nth-child(6),
.comp-table td:nth-child(7),
.comp-table td:nth-child(8),
.comp-table td:nth-child(9),
.comp-table td:nth-child(10),
.comp-table td:nth-child(11),
.comp-table td:nth-child(12),
.comp-table td:nth-child(13),
.comp-table td:nth-child(14) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.comp-table th:nth-child(4),
.comp-table th:nth-child(5),
.comp-table th:nth-child(6),
.comp-table th:nth-child(7),
.comp-table th:nth-child(8),
.comp-table th:nth-child(9),
.comp-table th:nth-child(10),
.comp-table th:nth-child(11),
.comp-table th:nth-child(12),
.comp-table th:nth-child(13),
.comp-table th:nth-child(14) {
    text-align: right;
}

/* Comp table responsive - matches broker table pattern */
@media (max-width: 768px) {
    .comp-table-container {
        overflow-x: auto;
    }

    .comp-table {
        min-width: 800px;
    }
}

/* Market report paste detection indicator */
.market-report-detected-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.1), rgba(30, 58, 95, 0.05));
    border: 1px solid rgba(30, 58, 95, 0.3);
    border-radius: 8px;
    margin-bottom: 16px;
}

.market-report-detected-banner .icon {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
}

.market-report-detected-banner span {
    flex: 1;
    font-size: 0.9rem;
}

.market-report-detected-banner .btn {
    flex-shrink: 0;
}

/* Responsive adjustments for comp viewer */
@media (max-width: 768px) {
    .add-comp-form {
        flex-direction: column;
    }

    .add-comp-form .btn {
        align-self: stretch;
    }

    .add-comp-buttons {
        flex-direction: column;
    }

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

    .comp-view-toggle {
        width: 100%;
    }

    .comp-view-btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .comp-viewer-header {
        padding: 10px 12px;
    }

    .comp-viewer-content {
        padding: 12px;
    }

    .comp-gallery {
        height: 160px;
    }
}

/* ============================================
   COMP COMPARE VIEW STYLES
   ============================================ */

.comp-compare-view {
    height: 600px;
    min-height: 500px;
}

.compare-layout {
    display: flex;
    gap: 20px;
    height: 100%;
}

.compare-cards-panel {
    flex: 0 0 45%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.compare-map-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Compare Cards */
.compare-card {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.compare-card-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.compare-card-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.compare-card-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Subject Card - Gold theme */
.subject-card {
    border: 2px solid #d4a843;
}

.subject-header {
    background: linear-gradient(135deg, #d4a843, #b8942f);
}

.subject-header .compare-card-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

/* Comp Card - Red theme */
.comp-card {
    border: 2px solid #c0392b;
}

.comp-header {
    background: linear-gradient(135deg, #c0392b, #a33025);
}

.comp-header .compare-card-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.compare-card-body {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
}

.compare-card-photo {
    flex: 0 0 120px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.compare-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.compare-card-photo .no-photo {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
}

.compare-card-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.compare-card-details .detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin: 0;
}

.compare-card-details .label {
    color: var(--text-secondary);
}

.compare-card-details .highlight {
    font-weight: 600;
}

.compare-card-details .highlight span:last-child {
    color: var(--primary-color);
}

/* Comp diff indicator */
.diff-positive {
    color: #27ae60 !important;
}

.diff-negative {
    color: #e74c3c !important;
}

/* Comp Selection List */
.compare-comp-list {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 150px;
}

.compare-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.compare-list-header h5 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

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

.compare-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.compare-list-item:hover {
    background: var(--bg-tertiary);
}

.compare-list-item.selected {
    background: rgba(192, 57, 43, 0.1);
    border-left: 3px solid #c0392b;
}

.compare-list-item .marker-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.compare-list-item .marker-dot.has-coords {
    background: #c0392b;
}

.compare-list-item .marker-dot.no-coords {
    background: #ccc;
    border: 2px dashed #999;
}

.compare-list-item .item-info {
    flex: 1;
    min-width: 0;
}

.compare-list-item .item-name {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-list-item .item-address {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Compare Map */
.compare-map-container {
    flex: 1;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    min-height: 300px;
}

.compare-map-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.legend-marker.subject-marker {
    background: #fff;
    border: 3px solid #1E3A5F;
    border-radius: 3px;
    box-sizing: border-box;
}

.legend-marker.comp-marker {
    background: #1E3A5F;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #1E3A5F;
    box-sizing: border-box;
}

.legend-marker.selected-marker {
    background: #1E3A5F;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.3);
}

/* Compare map pins (shared map module, 2026-11-11): the navy pin drawing
   (AcwiseMap.paintPin) numbered, with the comp's rent under it. */
.compare-map-head {
    padding: 0 0 6px;
}
.compare-map-container {
    position: relative;
}
.compare-map-marker {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.compare-map-marker.selected {
    z-index: 3;
}
.compare-pin-dot {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font: 700 11px/1 var(--font-body, sans-serif);
    font-variant-numeric: tabular-nums;
}
.compare-pin-price {
    margin-top: 2px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, .94);
    color: #1f2937;
    font: 600 10.5px/1.3 var(--font-body, sans-serif);
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .25);
    font-variant-numeric: tabular-nums;
}

/* Reports pipeline map key */
.reports-map-key {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.reports-key-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1E3A5F;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #1E3A5F;
    box-sizing: border-box;
    margin-left: 6px;
}
.reports-key-dot.is-approx {
    background: rgba(156, 163, 175, .5);
    border-color: #6b7280;
    box-shadow: none;
}
.reports-key-dot.is-cluster {
    width: 13px;
    height: 13px;
}

/* Responsive compare view */
@media (max-width: 992px) {
    .compare-layout {
        flex-direction: column;
    }

    .compare-cards-panel {
        flex: none;
    }

    .compare-map-panel {
        min-height: 300px;
    }
}

/* ==============================================================================
   API Usage Tracking Styles
   ============================================================================== */

.api-badge {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(30, 58, 95, 0.1);
    color: var(--accent-green);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.admin-table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.admin-table tbody tr:hover {
    background: rgba(30, 58, 95, 0.03);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table .text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#platform-tab-api-usage .platform-stats-grid {
    margin-bottom: 24px;
}

#platform-tab-api-usage .admin-section {
    margin-bottom: 24px;
}

#platform-tab-api-usage .admin-section h4 {
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 600;
}

/* ============================================
   UTILITY CLASSES - Animation & Typography
   ============================================ */

/* Financial Data Typography */
/* .font-mono / .financial-value keep the historical class name but --font-mono
   now resolves to the body font (see :root). tabular-nums keeps digit columns
   aligned WITHOUT the monospace "code" look. .tabular-nums is a standalone
   utility for number containers that never used the mono variable. */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

.font-mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.financial-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    letter-spacing: -0.02em;
}

.financial-positive {
    color: var(--success-color);
}

.financial-negative {
    color: var(--error-color);
}

/* Staggered Animation Classes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-in {
    animation: fadeIn var(--transition-slow) ease-out forwards;
}

.animate-fade-in-up {
    animation: fadeInUp var(--transition-slow) ease-out forwards;
}

.animate-slide-in-right {
    animation: slideInRight var(--transition-slow) ease-out forwards;
}

/* Stagger delays for list items */
.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }
.stagger-6 { animation-delay: 300ms; }
.stagger-7 { animation-delay: 350ms; }
.stagger-8 { animation-delay: 400ms; }

/* Skeleton tracker rows — match the real .tracker-table td (2px 8px padding,
   line-height 1.3 at 13px ≈ 21px row height) so real rows replace skeletons
   with no layout jump.  Alternating tint mirrors the subtle banding effect
   of even rows so the placeholder reads as a live table. */
.tr-skeleton td {
    padding: 2px 8px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    vertical-align: middle;
    /* Override the background:white on .tracker-table td so the alternating
       tint below can actually apply without a specificity fight. */
    background: transparent !important;
}
.tr-skeleton:nth-child(even) td {
    background: #fafbfc !important;
}
/* Give skeleton cells the same min-height as a real data row so the
   shimmer bars (12-14px) sit in a properly-sized slot. */
.tr-skeleton td > .skeleton {
    display: block;
    margin-top: 3px;
    margin-bottom: 3px;
}

/* Skeleton Loading — concrete colors so the shimmer is visible on a white
   background regardless of whether --bg-secondary / --bg-tertiary are defined. */
.skeleton {
    background: linear-gradient(
        90deg,
        #e3e6ea 25%,
        #f1f3f5 50%,
        #e3e6ea 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm, 4px);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-card {
    height: 200px;
    border-radius: var(--radius-md);
}

/* Enhanced Card Hover States */
.card-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Interactive Button Enhancements */
.btn-interactive {
    position: relative;
    overflow: hidden;
}

.btn-interactive::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.btn-interactive:hover::after {
    transform: translateX(100%);
}

/* Tab Content Transitions */
.tab-panel {
    opacity: 0;
    animation: fadeIn 0.2s ease-out forwards;
}

.tab-panel.active {
    opacity: 1;
}

/* Number Formatting Classes */
.num-positive::before {
    content: '+';
}

.num-currency::before {
    content: '$';
}

.num-percent::after {
    content: '%';
}

/* Focus States - Accessibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Smooth scroll for the whole page */
html {
    scroll-behavior: smooth;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* =============================================================================
   Chat Assistant
   ============================================================================= */

.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    background: var(--primary-color, #1E3A5F);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg, 0 4px 12px rgba(0,0,0,0.15));
    z-index: 9999;
    transition: transform var(--transition-base, 200ms), background var(--transition-base, 200ms);
}
.chat-fab:hover {
    transform: scale(1.08);
    background: var(--secondary-color, #3B82F6);
}
.chat-fab.active {
    display: none;
}

.chat-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 420px;
    height: 600px;
    max-height: calc(100vh - 48px);
    background: #1a1f2e;
    border-radius: var(--radius-lg, 10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.08);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #141828;
    color: #e8ecf4;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-header h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
}
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}
.chat-header-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast, 150ms), background var(--transition-fast, 150ms);
}
.chat-header-btn:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}
.chat-status {
    font-size: 0.688rem;
    opacity: 0.7;
    font-weight: 400;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #1a1f2e;
}
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

.chat-welcome {
    text-align: center;
    padding: 32px 16px;
    color: #8892a8;
}
.chat-welcome p:first-child {
    color: #d0d6e2;
    font-size: 0.938rem;
    margin-bottom: 6px;
}
.chat-welcome-hint {
    font-size: 0.813rem;
    line-height: 1.5;
}
.chat-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(26, 86, 219, 0.12);
    color: #7ba4f0;
    border: 1px solid rgba(26, 86, 219, 0.25);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    margin: 2px 0;
}
.chat-nav-link:hover {
    background: rgba(26, 86, 219, 0.22);
    border-color: rgba(26, 86, 219, 0.4);
    color: #a0c0ff;
}
.chat-deal-ref {
    color: #7ba4f0;
    text-decoration: none;
    border-bottom: 1px dotted rgba(123, 164, 240, 0.4);
}
.chat-deal-ref:hover {
    color: #a0c0ff;
    border-bottom-color: #a0c0ff;
}
.progress-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.progress-actions button {
    background: rgba(26, 86, 219, 0.12);
    color: #7ba4f0;
    border: 1px solid rgba(26, 86, 219, 0.25);
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}
.progress-actions button:hover {
    background: rgba(26, 86, 219, 0.22);
    border-color: rgba(26, 86, 219, 0.4);
    color: #a0c0ff;
}

.chat-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.838rem;
    line-height: 1.55;
    word-wrap: break-word;
}
.chat-msg-user {
    align-self: flex-end;
    background: #2A4D7A;
    color: #e8ecf4;
    border-bottom-right-radius: 4px;
}
.chat-msg-assistant {
    align-self: flex-start;
    background: #232839;
    color: #d0d6e2;
    border-bottom-left-radius: 4px;
}
.chat-msg-assistant p {
    margin: 0 0 8px 0;
}
.chat-msg-assistant p:last-child {
    margin-bottom: 0;
}
.chat-msg-assistant strong {
    font-weight: 600;
    color: #e8ecf4;
}
.chat-msg-assistant ul, .chat-msg-assistant ol {
    margin: 4px 0;
    padding-left: 18px;
}
.chat-msg-assistant li {
    margin-bottom: 2px;
}
.chat-msg-assistant code {
    background: rgba(255,255,255,0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #b8c0d2;
}

.chat-tool-indicator {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #7a8499;
    padding: 4px 0;
}
.chat-tool-indicator .tool-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--secondary-color, #3B82F6);
    animation: chat-pulse 1s infinite;
}
@keyframes chat-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Screener progress card in chat */
.screener-progress-card {
    align-self: flex-start;
    margin: 6px 0;
    padding: 10px 14px;
    background: #1e2338;
    border-left: 3px solid var(--secondary-color, #3B82F6);
    border-radius: 6px;
    font-size: 0.8rem;
    max-width: 85%;
}
.screener-progress-card .progress-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}
.screener-progress-card .progress-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--secondary-color, #3B82F6);
    animation: chat-pulse 1s infinite;
    flex-shrink: 0;
}
.screener-progress-card .progress-dot.stopped {
    animation: none;
    opacity: 1;
}
.screener-progress-card .progress-status {
    font-weight: 600;
    color: var(--secondary-color, #3B82F6);
}
.screener-progress-card .progress-step {
    color: #7a8499;
    padding-left: 12px;
}
.screener-progress-card.completed {
    border-left-color: #059669;
}
.screener-progress-card.completed .progress-status {
    color: #059669;
}
.screener-progress-card.completed .progress-dot {
    background: #059669;
}
.screener-progress-card.error {
    border-left-color: #dc2626;
}
.screener-progress-card.error .progress-status {
    color: #dc2626;
}
.screener-progress-card.error .progress-dot {
    background: #dc2626;
}

.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #232839;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6b7590;
    animation: chat-bounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

.chat-cost {
    text-align: center;
    font-size: 0.688rem;
    color: #5a6478;
    padding: 2px 0;
}

.chat-quick-replies {
    display: flex;
    gap: 8px;
    padding: 4px 0 8px;
    justify-content: flex-start;
}
.chat-quick-reply-btn {
    padding: 6px 18px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: #d0d6e2;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}
.chat-quick-reply-btn:hover {
    background: rgba(91, 155, 247, 0.15);
    border-color: #5b9bf7;
    color: #5b9bf7;
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    background: #1a1f2e;
}
.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #232839;
    border-radius: 10px;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: border-color var(--transition-fast, 150ms);
}
.chat-input-wrapper:focus-within {
    border-color: var(--secondary-color, #3B82F6);
}
#chat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.838rem;
    font-family: var(--font-body, 'Plus Jakarta Sans', sans-serif);
    color: #d0d6e2;
    resize: none;
    max-height: 120px;
    line-height: 1.45;
}
#chat-input::placeholder {
    color: #5a6478;
}
.chat-send-btn {
    background: none;
    border: none;
    color: #5b9bf7;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: background var(--transition-fast, 150ms);
    flex-shrink: 0;
}
.chat-send-btn:hover {
    background: rgba(59, 130, 246, 0.15);
}
.chat-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chat-attach-btn {
    background: none;
    border: none;
    color: #5a6478;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color var(--transition-fast, 150ms);
}
.chat-attach-btn:hover {
    color: #5b9bf7;
}

.chat-messages.chat-drag-over {
    background: rgba(59, 130, 246, 0.1);
    border: 2px dashed #5b9bf7;
    border-radius: 8px;
}

@media (max-width: 500px) {
    .chat-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 8px;
        height: calc(100vh - 80px);
    }
}

/* ============================================
   TABLE SETTINGS WINDOW (compact, 2026-11-11)
   The kit popover look at window size: 600px, 10px radius, kit shadow,
   tabs across the top, 32px rows. Was a near-fullscreen modal with a left
   rail and explanatory paragraphs.
   ============================================ */
.ts-modal {
    width: 600px; max-width: calc(100vw - 32px);
    height: min(600px, calc(100vh - 48px)); max-height: none;
    padding: 0; border-radius: 10px; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    font-family: var(--font-body, inherit); font-size: 13px;
}
.ts-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px 0;
}
.ts-header h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.ts-tabs {
    display: flex; gap: 2px; padding: 8px 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.ts-tab {
    height: 32px; padding: 0 10px; margin-bottom: -1px;
    background: none; border: 0; border-bottom: 2px solid transparent;
    font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text-muted);
    cursor: pointer; white-space: nowrap;
}
.ts-tab:hover { color: var(--text-primary); }
.ts-tab.active { color: var(--text-primary); border-bottom-color: var(--primary-color); font-weight: 600; }
.ts-pane { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 12px 12px; }
.ts-section { display: none; }
.ts-section.active { display: block; }
.ts-footer {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 10px 12px; border-top: 1px solid var(--border-color);
}
.ts-btn {
    height: 32px; padding: 0 12px; border-radius: 8px;
    border: 1px solid var(--border-color); background: var(--bg-card, #fff);
    color: var(--text-secondary); font-family: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
}
.ts-btn:hover { color: var(--text-primary); background: var(--bg-hover, #F3F4F6); }
.ts-btn:disabled { opacity: 0.6; cursor: default; }
.ts-btn-primary { background: var(--primary-color); border-color: var(--primary-color); color: #fff; font-weight: 600; }
.ts-btn-primary:hover { background: var(--primary-color); color: #fff; filter: brightness(1.1); }
.ts-btn-danger { color: var(--error-color, #DC2626); }
.ts-link { font-size: 13px; color: var(--primary-color); text-decoration: none; }
.ts-link:hover { text-decoration: underline; }
.ts-modal input[type="text"], .ts-select {
    height: 32px; box-sizing: border-box; padding: 0 8px;
    border: 1px solid var(--border-color); border-radius: 8px;
    background: var(--bg-input); color: var(--text-primary);
    font-family: inherit; font-size: 13px; outline: none;
}
.ts-modal input[type="text"]:focus, .ts-select:focus { background: #fff; border-color: var(--primary-color); }
.ts-modal input[type="checkbox"] { width: 15px; height: 15px; margin: 0; flex: 0 0 auto; accent-color: var(--primary-color); cursor: pointer; }
.ts-switch { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.ts-grip { width: 12px; flex: 0 0 12px; display: inline-flex; justify-content: center; color: #9CA3AF; cursor: grab; }
.ts-grip svg { fill: currentColor; }
.ts-icon {
    width: 28px; height: 28px; flex: 0 0 28px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 6px; background: none; color: var(--text-muted);
    font-size: 16px; line-height: 1; cursor: pointer;
}
.ts-icon:hover { background: var(--bg-input); color: var(--text-primary); }
.ts-icon-danger:hover { color: var(--error-color, #DC2626); }
.ts-icon-spacer { width: 28px; flex: 0 0 28px; }
.ts-add-row { display: flex; gap: 6px; margin-top: 8px; }
.ts-add-row input[type="text"] { flex: 1 1 auto; min-width: 0; }
.ts-dragging { opacity: 0.5; }
.ts-drop-before { box-shadow: inset 0 2px 0 var(--primary-color); }
.ts-drop-after { box-shadow: inset 0 -2px 0 var(--primary-color); }

/* Columns tab: grip, show, name, type, delete data. */
.ts-col-row {
    display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 2px 4px;
    border-radius: 6px;
}
.ts-col-row:hover { background: var(--bg-input); }
.ts-modal .ts-col-row input.ts-col-name {
    flex: 1 1 auto; min-width: 0; height: 28px;
    background: transparent; border-color: transparent;
}
.ts-modal .ts-col-row input.ts-col-name:hover { border-color: var(--border-color); }
.ts-modal .ts-col-row input.ts-col-name:focus { background: #fff; border-color: var(--primary-color); }
.ts-col-row.is-hidden .ts-col-name { color: var(--text-muted); }
.ts-col-row.is-core .ts-grip { cursor: default; }
.ts-type { width: 108px; flex: 0 0 108px; height: 28px; box-sizing: border-box; }
select.ts-type {
    padding: 0 6px; border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--bg-card, #fff); color: var(--text-secondary); font-family: inherit; font-size: 12px;
}
select.ts-type:not(:hover):not(:focus) { border-color: transparent; background-color: transparent; }
select.ts-type { cursor: pointer; }
.ts-type-fixed { display: inline-flex; align-items: center; padding: 0 7px; font-size: 12px; color: var(--text-muted); }

/* Dropdowns & colors tab. */
.ts-dd-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 8px; }
.ts-dd-head .ts-select { flex: 1 1 auto; min-width: 0; max-width: 320px; }
.ts-opt-list { display: flex; flex-direction: column; }
.ts-opt-row {
    position: relative; display: flex; align-items: center; gap: 8px;
    min-height: 32px; padding: 2px 4px; border-radius: 6px;
}
.ts-opt-row:hover { background: var(--bg-input); }
.ts-opt-swatch {
    width: 18px; height: 18px; flex: 0 0 18px; padding: 0;
    border: 1px solid rgba(15, 23, 42, 0.15); border-radius: 5px; cursor: pointer;
}
.ts-modal input.ts-opt-input {
    flex: 0 1 260px; min-width: 0; height: 24px; padding: 0 10px;
    border: 1px solid transparent; border-radius: 6px; font-size: 12px; font-weight: 500;
}
.ts-modal input.ts-opt-input:focus { border-color: var(--primary-color); }
.ts-opt-row .ts-icon { margin-left: auto; }
.ts-palette {
    position: absolute; left: 28px; top: 100%; z-index: 5; margin-top: 2px;
    width: 216px; padding: 8px; box-sizing: border-box;
    background: var(--bg-card, #fff); border: 1px solid var(--border-color);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.ts-palette-grid { display: grid; grid-template-columns: repeat(8, 20px); gap: 5px; }
.ts-palette-grid button {
    width: 20px; height: 20px; padding: 0; border-radius: 5px; cursor: pointer;
    border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}
.ts-palette-grid button.is-on { border-color: var(--primary-color); }
.ts-palette-custom {
    display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px;
    border-top: 1px solid var(--border-color); font-size: 12px; color: var(--text-secondary); cursor: pointer;
}
.ts-palette-custom input[type="color"] { width: 26px; height: 22px; padding: 0; border: 1px solid var(--border-color); border-radius: 5px; background: none; cursor: pointer; }

/* Document indicators tab. */
.ts-docind-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 8px; }
.ts-docind-list { display: flex; flex-direction: column; }
/* The document scan's state (owner, 11/13): running with progress and Cancel,
   or how the last one ended. */
.ts-docind-scan { font-size: var(--fs-xs); color: var(--text-secondary); padding: 0 0 8px; }
.ts-docind-scan .ts-link { margin-left: 6px; }
.ts-docind-row {
    display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 6px;
    border-radius: 6px; cursor: pointer;
}
.ts-docind-row:hover { background: var(--bg-input); }
.ts-docind-name { flex: 0 0 auto; font-weight: 500; color: var(--text-primary); }
.ts-docind-desc { flex: 1 1 auto; min-width: 0; text-align: right; font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Export tab. */
.ts-export-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; flex-wrap: wrap; }
.ts-export-info { min-width: 0; }
.ts-export-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.ts-export-file { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-top: 2px; overflow-wrap: anywhere; }
.ts-export-status { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ts-export-actions, .ts-unlink { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ============================================
   BUTTON SYSTEM — canonical scale (P2.4, 2026-06-10)
   Variables defined in :root above as --btn-* vars.
   Legacy classes (.btn-action, .btn-icon-only) are aliased above;
   do NOT remove them. New code should use these canonical classes.
   ============================================ */

/* btn-xs: smallest inline actions (toolbar chips, tag removals) */
.btn-xs {
    /* Formalized: was padding:3px 8px; font-size:0.75rem with no explicit
       alignment. Now a full self-contained variant. */
    padding: var(--btn-xs-pad);      /* 3px 8px */
    font-size: var(--btn-xs-fs);     /* 0.75rem */
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

/* btn-icon-sm: 28x28 square icon-only button (canonical equiv of .btn-action) */
.btn-icon-sm {
    width: var(--btn-icon-sm-size);    /* 28px */
    height: var(--btn-icon-sm-size);
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-icon-sm i,
.btn-icon-sm .icon {
    font-size: 13px;
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

.btn-icon-sm:hover {
    background: var(--bg-hover, var(--light-accent));
    border-color: var(--text-muted);
}

/* btn-icon-sq: 36x36 square icon-only button (mid-tier, spec "btn-icon 36")
   NOTE: Named .btn-icon-sq rather than .btn-icon to avoid overriding the two
   existing .btn-icon rules (~line 594 font-size modifier; ~line 11316 compact
   flex button) which have different semantics. The canonical variable is still
   --btn-icon-size: 36px. Rename to .btn-icon only after those legacy usages
   are consolidated (commit 5 cleanup). */
.btn-icon-sq {
    width: var(--btn-icon-size);     /* 36px */
    height: var(--btn-icon-size);
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-icon-sq i,
.btn-icon-sq .icon {
    font-size: 15px;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.btn-icon-sq:hover {
    background: var(--light-accent);
    border-color: var(--text-muted);
}

/* btn-icon-lg: 44x44 square icon-only button (canonical equiv of .btn-icon-only) */
.btn-icon-lg {
    width: var(--btn-icon-lg-size);   /* 44px */
    height: var(--btn-icon-lg-size);
    padding: 0;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.btn-icon-lg i,
.btn-icon-lg .icon {
    font-size: 1.125rem;
    width: 1.25em;
    height: 1.25em;
    color: var(--text-secondary);
}

.btn-icon-lg:hover {
    background: var(--light-accent);
    border-color: var(--text-muted);
}

/* ============================================================
   MOBILE — tracker card list (body.mobile)
   Phase A migration (MOBILE_OVERHAUL_SPEC.md §1): every layout-swap
   rule here is scoped under body.mobile — set by mobile.js from
   matchMedia('(pointer: coarse) and (max-width: 900px)') — instead
   of a raw width query, so a narrow FINE-pointer desktop window
   keeps the desktop grid (the July regression) and CSS can never
   disagree with the isMobileView() JS gate. Desktop rendering is
   byte-identical: body.mobile never exists there.
   ============================================================ */

/* Card-list container exists in the markup on every viewport but only
   displays on phones; _renderTrackerCards also gates on isMobileView so
   the node is empty on desktop. */
.tracker-card-list { display: none; }

/* The grid is desktop-only on phones: hidden, never destroyed. */
body.mobile #tracker-tab .tracker-content-row .tracker-table-wrapper { display: none; }
/* Side collapse-strip is a desktop affordance; toolbar Map button owns
   the toggle on phones. */
body.mobile #tracker-tab .tracker-map-tab { display: none !important; }

body.mobile .tracker-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 2px 0 24px;
}
body.mobile .tr-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.04));
    cursor: pointer;
}
body.mobile .tr-card:active { background: #f9fafb; }
body.mobile .tr-card.tr-archived { opacity: 0.6; }
body.mobile .tr-card-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
body.mobile .tr-card-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #111827);
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body.mobile .trc-pin { color: #f59e0b; margin-right: 4px; font-size: 12px; }
/* Phase A line-1 chip: score (metric-coloured inline) or Est. Profit. */
body.mobile .trc-score {
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
body.mobile .tr-card-price {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    color: var(--primary-color, #1E3A5F);
    font-variant-numeric: tabular-nums;
}
/* Phase 2: per-card quick-actions kebab (⋮ — monochrome text glyph).
   Negative margins keep the visual row height while growing the tap
   target beyond the glyph (44px floor via min sizes below). */
body.mobile .tr-card-menu {
    appearance: none;
    border: none;
    background: none;
    color: var(--text-muted, #9ca3af);
    font-size: 17px;
    line-height: 1;
    padding: 6px 8px;
    margin: -6px -8px -6px -2px;
    min-width: 44px;
    min-height: 44px;
    margin-top: -14px;
    margin-bottom: -14px;
    cursor: pointer;
    flex-shrink: 0;
    align-self: center;
}
body.mobile .tr-card-menu:active { color: var(--text-primary, #111827); }
body.mobile .tr-card-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
}
body.mobile .tr-card-badges .badge { font-size: 11px; padding: 3px 9px; font-weight: 600; }
body.mobile .tr-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
}
body.mobile .tr-card-place { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.mobile .trc-docs { display: inline-flex; gap: 4px; flex-shrink: 0; }
body.mobile .trc-doc {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #6B7280);
    line-height: 1.5;
}
/* Status as a dot plus the word (2026-11-12): hollow until the doc is in,
   then a green dot. No pill fill. */
body.mobile .trc-doc::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%;
    box-sizing: border-box; border: 1px solid var(--text-muted, #6B7280);
}
body.mobile .trc-doc.on { color: var(--text-primary, #111827); }
body.mobile .trc-doc.on::before { border: 0; background: var(--success-color, #16A34A); }
body.mobile .tr-card-empty {
    color: var(--text-muted, #9ca3af);
    font-size: 13px;
    text-align: center;
    padding: 24px 0;
}

/* M2: offer-due amber pill badge */
body.mobile .trc-due-badge {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

/* Phase A: days-in-pipeline pill (card line 2) */
body.mobile .trc-days-badge {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

/* Phase A: res-org ARV / MAO chips (card line 4) */
body.mobile .tr-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}
body.mobile .trc-chip {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    background: var(--bg-input, #f3f4f6);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 2px 8px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* M2: notes preview — 1 line, ellipsis, muted */
body.mobile .trc-notes-preview {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted, #9ca3af);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* M2: search input takes full row width so it is not crushed by filter chips */
body.mobile #tracker-tab #tracker-search {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
}

/* Pipeline map: full-screen sheet under the 52px top bar, opened from
   the toolbar Map button; its own header Hide button closes it. Stops
   above the Phase A bottom tab bar (--bnav-h set on body.mobile). */
body.mobile #tracker-tab .tracker-map-panel {
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: var(--bnav-h, 0px);
    width: 100%;
    max-width: none;
    min-width: 0;
    /* Explicit height + align-self reset: the desktop rule's
       align-self:flex-start makes an inset-positioned box with auto
       height shrink to content (CSS Box Alignment) — the "full-screen"
       sheet actually ended mid-screen. Phase 2 fix. */
    align-self: auto;
    height: calc(100vh - 52px - var(--bnav-h, 0px));
    height: calc(100dvh - 52px - var(--bnav-h, 0px));
    border-left: none;
    z-index: 950;
}

/* Layout hygiene: everything wraps inside the viewport — no horizontal
   page scroll on the tracker. overflow-x: clip (not hidden) so no new
   scroll container is created and the filter popup still escapes
   vertically. */
body.mobile #tracker-tab .tracker-container { padding: 10px 12px; overflow-x: clip; }
body.mobile #tracker-tab .tracker-filters { row-gap: 8px; }
body.mobile #tracker-tab .tracker-toolbar { width: 100%; }

/* ============================================================
   MOBILE PASS — all tabs (body.mobile)
   Strip each page to phone essentials; desktop layout unchanged.
   Phase A migration: these blocks swap LAYOUT, so they are scoped
   under body.mobile (mobile.js gate) rather than raw width queries
   — a narrow fine-pointer desktop window keeps desktop layout.
   ============================================================ */

/* ── TRACKER TOOLBAR: hide desktop-only controls ── */
/* Remove: undo/redo, zoom, Stats, Excel open, history (clock),
   settings gear, fullscreen. Keep: Search input, + New button,
   Filters popup button, Map toggle, and the Active/Archive view tabs.
   The spacer flex:1 div stays so search + new push left, map right. */

/* Undo / redo cluster */
body.mobile #tracker-tab button[onclick="_performUndo()"],
body.mobile #tracker-tab button[onclick="_performRedo()"] { display: none !important; }

/* Zoom control cluster (the div wrapping − / 100% / +) */
body.mobile #tracker-tab .tracker-toolbar > div[style*="border:1px solid #e5e7eb"] { display: none !important; }

/* Stats button */
body.mobile #tracker-stats-btn { display: none !important; }

/* Vertical dividers in the toolbar */
body.mobile #tracker-tab .tracker-toolbar > div[style*="width:1px"] { display: none !important; }

/* Excel open button */
body.mobile #open-tracker-excel { display: none !important; }

/* History / clock button */
body.mobile #show-changelog { display: none !important; }

/* Settings gear button */
body.mobile #tracker-tab button[onclick="_openTrackerSettings()"] { display: none !important; }

/* Fullscreen button (expand icon, not the map one) */
body.mobile #fullscreen-tracker { display: none !important; }

/* Tracker toolbar: compact the remaining row so search + new + filters +
   map fit cleanly without horizontal overflow. */
body.mobile #tracker-tab .tracker-toolbar {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    overflow: visible;  /* allow filter popup to escape */
}

/* Map toggle stays — useful on phone */
body.mobile #tracker-map-toggle { display: inline-flex !important; }

/* Onboarding banner: compact on phone, margin so it reads below toolbar */
body.mobile #tracker-onboarding-card { margin-top: 4px; }
body.mobile .onboarding-banner-inner { padding: 10px 12px; gap: 10px; }
body.mobile .onboarding-banner-title { font-size: 0.8125rem; }
body.mobile .onboarding-checklist { font-size: 0.75rem; }

/* ── BROKERS HEADER ACTIONS: strip to Add + Refresh on phone ── */
/* Hide: Activity stats, Review Duplicates, Import CSV.
   Keep: Refresh (btn-sync-brokers), Add Broker (btn-add-broker). */
body.mobile #btn-broker-activity-stats,
body.mobile #btn-review-duplicates,
body.mobile #btn-import-brokers,
body.mobile #btn-scan-touches { display: none !important; }

body.mobile .brokers-header h2 { font-size: 1rem; margin: 0; }

/* Market filter input: full width on phone */
body.mobile #broker-market-filter-row { flex-direction: column; align-items: stretch; }
body.mobile #broker-market-filter-input { max-width: 100%; min-width: 0; width: 100%; box-sizing: border-box; }

/* Broker drawer: full-screen on phone (top bar height already reserved) */
body.mobile .broker-drawer {
    top: 0;
    width: 100%;
    max-width: 100%;
    border-left: none;
    box-shadow: none;
}

/* ── EMAIL TAB: full-width sub-nav tabs, compact toolbar ── */
/* Sub-nav (Inbox | Templates | Drafts): stretch tabs to fill the bar */
body.mobile #email-suite-nav > div {
    width: 100%;
    display: flex;
}
body.mobile .email-suite-tab-btn {
    flex: 1;
    text-align: center;
    padding: 10px 8px !important;
    font-size: 12px !important;
}

/* Email toolbar: stack vertically, compact gap */
body.mobile .email-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
}
body.mobile .gmail-toolbar-left,
body.mobile .gmail-toolbar-right {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
/* Right toolbar: hide verbose controls on phone (user email, provider badge,
   Blocked button). Keep: Compose (when visible), Disconnect. */
body.mobile .gmail-user-info { display: none !important; }
body.mobile #gmail-blocked-senders-btn { display: none !important; }
body.mobile #mailbox-switcher { width: 100%; }
body.mobile #mailbox-switcher .mailbox-switcher-select { width: 100%; }

/* Folder label selector: compact */
body.mobile .gmail-label-selector label { display: none; }

/* Split view: stack email list + detail vertically on mobile.
   On phone the user picks an email from the list, then the detail
   fills the view (JS already does this — CSS supports it). */
body.mobile .email-split-view { flex-direction: column; }
body.mobile .email-list-panel {
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}
body.mobile .email-review-panel,
body.mobile .email-detail-panel { min-height: 40vh; }

/* Landscape phones (769-900px) also match the DESKTOP height bound above
   (@media min-width:769px → height: calc(100vh - 125px)) while the panes
   stack — the stacked content overflowed that fixed box and its bottom sat
   flush under the fixed bottom tab bar (no page padding after overflow).
   On body.mobile the tab flows naturally instead; the body's --bnav-h
   padding (Phase A floor below) then keeps the last pane clear of the bar,
   same as the tracker. */
body.mobile #gmail-connected-section,
body.mobile #imap-email-section {
    height: auto;
}

/* Stats bar: compact */
body.mobile .gmail-stats-bar { font-size: 12px; padding: 4px 10px; }

/* Email-suite panels (Drafts / Templates): tighten padding */
body.mobile #es-drafts-panel,
body.mobile #es-templates-panel { padding: 12px 10px !important; }

/* Draft / template header row: stack if needed */
body.mobile #es-drafts-panel > div:first-child,
body.mobile #es-templates-panel > div:first-child { flex-wrap: wrap; gap: 8px; }

/* ── TASKS BOARD: additional phone polish ── */
@media (max-width: 600px) {
    /* Board: full width, columns scroll horizontally (already works),
       min column width slightly narrower for easier one-thumb scrolling. */
    .tasks-board {
        gap: 8px;
        padding: 0 0 8px;
    }
    .board-col { min-width: 200px; }

    /* Tasks heading: slightly smaller on phone */
    .tasks-heading { font-size: 18px; }

    /* Task check circle: larger hit target (22px) */
    .task-check { width: 22px; height: 22px; }

    /* Column delete: larger hit target (already done in tasks.css Phase 3) */

    /* Task card: larger touch target for the check + title */
    .board-card { padding: 11px 12px; }
}

/* ── MODELS PAGE (evaluator_v2.js, .ds-scope): compact header ── */
/* Page header: stack title + actions vertically */
body.mobile .ds-scope .ds-page { padding: 12px; }
body.mobile .ds-scope .ds-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}
body.mobile .ds-scope .ds-page-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
}

/* Model select: full width when visible */
body.mobile #evv2-model-select { width: 100%; min-width: 0 !important; box-sizing: border-box; }

/* Run row: drop the score column on mobile — name + status + actions are enough */
body.mobile .ds-scope .ds-run-row {
    grid-template-columns: 1fr auto;
}
body.mobile .ds-scope .ds-run-score { display: none; }

/* Stat strip: 2-col grid on narrow */
body.mobile .ds-scope .ds-stat-strip { grid-template-columns: repeat(2, 1fr); }

/* Sub-nav: equal tabs */
body.mobile .ds-scope .ds-subnav { gap: 0; }
body.mobile .ds-scope .ds-subnav-tab {
    flex: 1;
    text-align: center;
    padding: 8px 6px;
    font-size: 11px;
}

/* Run heading title: smaller */
body.mobile .ds-scope .ds-page-header h1 { font-size: 16px; }

/* Drawer: full screen on mobile */
body.mobile .ds-scope .ds-drawer {
    width: 100%;
    max-width: 100%;
}

/* ============================================================
   MOBILE PHASE 2 — tracker map sheet (body.mobile)
   Pin tap opens a compact bottom sheet inside the full-screen
   map panel; the header gains an explicit close ×. Desktop is
   byte-identical: the × is display:none outside body.mobile
   and the pin sheet is only ever created under isMobileView.
   ============================================================ */
.tracker-map-close-x { display: none; }

/* Fullscreen is meaningless on phones — the panel is already a fixed
   full-screen sheet. Hiding it keeps Hide + × on one header row. */
body.mobile #tracker-tab #tracker-map-fs-btn { display: none; }

body.mobile .tracker-map-close-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #f3f4f6;
    color: #374151;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

    /* Pin bottom sheet — anchored to the bottom of the (fixed, full-screen)
       map panel. Created/removed by _openTrackerPinSheet in app.js. */
    body.mobile .tracker-pin-sheet {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;               /* above the Mapbox canvas + controls */
        background: var(--bg-card, #fff);
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
        padding: 6px 16px calc(14px + env(safe-area-inset-bottom, 0px));
        touch-action: none;        /* the sheet owns its swipe-down gesture */
    }
    body.mobile .tps-grab {
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--border-color, #d6dae3);
        margin: 4px auto 8px;
    }
    body.mobile .tps-top {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
    }
    body.mobile .tps-name {
        font-size: 15px;
        font-weight: 700;
        color: var(--text-primary, #111827);
        min-width: 0;
    }
    body.mobile .tps-close {
        appearance: none;
        border: none;
        background: none;
        color: var(--text-muted, #6b7280);
        font-size: 22px;
        line-height: 1;
        padding: 0 2px;
        cursor: pointer;
        flex-shrink: 0;
    }
    body.mobile .tps-place {
        font-size: 12px;
        color: var(--text-secondary, #6b7280);
        margin-top: 2px;
    }
    body.mobile .tps-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        margin-top: 8px;
    }
    body.mobile .tps-meta .badge { font-size: 11px; padding: 3px 9px; font-weight: 600; }
    body.mobile .tps-fact {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-primary, #111827);
        font-variant-numeric: tabular-nums;
    }
    body.mobile .tps-open {
        display: block;
        width: 100%;
        margin-top: 12px;
        padding: 11px 0;
        font-size: 14px;
    }

/* ============================================================
   MOBILE PHASE 1 — brokers page (body.mobile)
   Table rows become tappable cards (name, coverage pill, last
   touch; row tap opens the drawer exactly as on desktop). All
   rules under the body.mobile gate; desktop untouched.
   ============================================================ */
body.mobile .brokers-container { padding: 12px; }
body.mobile .brokers-header { flex-wrap: wrap; gap: 10px; }
body.mobile .brokers-header-actions { flex-wrap: wrap; gap: 8px; }
body.mobile .brokers-filters { flex-wrap: wrap; gap: 8px; row-gap: 8px; }
body.mobile .brokers-search-input { width: 100%; }

/* Firm sections stay as group headers; each broker row is a card.
   min-width:0 beats the older responsive rule above (min-width:800px
   + wrapper scroll) — cards must fit the phone, not scroll sideways. */
body.mobile .brokers-table { display: block; min-width: 0; }
body.mobile .brokers-table thead { display: none; }
body.mobile .brokers-table tbody { display: flex; flex-direction: column; gap: 8px; padding: 8px 0 12px; }
body.mobile .brokers-table tbody tr {
    display: block;
    position: relative;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 11px 13px;
    cursor: pointer;
}
body.mobile .brokers-table tbody tr:active { background: #f9fafb; }
body.mobile .brokers-table tbody td { display: block; border: none; padding: 0; }
/* Phase 1 card fields: name, coverage, last touch (+ actions). The rest
   lives one tap away in the drawer. */
body.mobile .brokers-table td.col-broker-title,
body.mobile .brokers-table td.col-broker-email,
body.mobile .brokers-table td.col-broker-deals { display: none; }
/* M3: phone is shown on mobile as a tap-to-call line (tel: link already
   rendered by renderBrokerRow); suppress the hidden-by-desktop column rule. */
body.mobile .brokers-table td.col-broker-phone {
    display: block;
    margin-top: 5px;
    font-size: 12px;
}
body.mobile .brokers-table td.col-broker-phone a {
    color: var(--primary-color, #1E3A5F);
    text-decoration: none;
    font-weight: 500;
}
body.mobile .brokers-table td.col-broker-phone a:hover { text-decoration: underline; }
body.mobile .brokers-table td.col-broker-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary, #111827);
    padding-right: 84px;   /* room for the actions cluster */
    /* Neutralize the desktop column sizing (width:200px/max-width:240px
       + ellipsis) — the card is the full row width on phones. */
    width: auto;
    max-width: none;
    white-space: normal;
}
body.mobile .brokers-table td.col-broker-coverage { margin-top: 6px; }
body.mobile .brokers-table td.col-broker-last-contact {
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary, #6b7280);
}
body.mobile .brokers-table td.col-broker-last-contact::before { content: 'Last touch: '; }
body.mobile .brokers-table td.col-broker-actions {
    position: absolute;
    top: 8px;
    right: 10px;
}

/* ============================================================
   MOBILE PHASE A — bottom tab bar + global floors
   (MOBILE_OVERHAUL_SPEC.md §1 detection, §3 navigation, §2.3
   sizing floors.) body.mobile is set by mobile.js from
   matchMedia('(pointer: coarse) and (max-width: 900px)').
   Desktop is byte-identical: the bar ships display:none and
   every other rule is body.mobile-scoped.
   ============================================================ */

/* Bar markup renders on every shell page (templates/_shell/topbar.html)
   but only body.mobile shows it. */
.bottom-nav { display: none; }

body.mobile {
    /* Shared bar height — content padding and the tracker map sheet key
       off this so nothing hides behind the fixed bar. */
    --bnav-h: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: var(--bnav-h);
}

body.mobile .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10040;                /* above page content + map sheet (950);
                                      below the aw-sheet (100080+) so More
                                      and quick-action sheets cover it */
    height: var(--bnav-h);
    box-sizing: border-box;
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-card, #fff);
    border-top: 1px solid var(--border-color, #e5e7eb);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.08);
}
/* Slot buttons/links. The SPA slots also carry .tab-btn (for switchTab
   wiring + active sync), so neutralize every .tab-btn cosmetic here. */
body.mobile .bottom-nav .bnav-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;              /* touch-target floor */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    appearance: none;
    background: none;
    border: none;
    border-radius: 8px;
    margin: 0;
    padding: 2px 0;
    font-family: var(--font-body, inherit);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    text-decoration: none;
    cursor: pointer;
    transition: none;
    transform: none;
    position: static;
    white-space: nowrap;
}
body.mobile .bottom-nav .bnav-item:hover {
    background: none;
    color: var(--text-secondary, #6b7280);
    transform: none;
}
body.mobile .bottom-nav .bnav-item:active { background: var(--bg-input, #f3f4f6); }
body.mobile .bottom-nav .bnav-item svg,
body.mobile .bottom-nav .bnav-item .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
body.mobile .bottom-nav .bnav-item.active,
body.mobile .bottom-nav .bnav-item.active:hover {
    background: none;
    border-color: transparent;
    box-shadow: none;
    color: var(--primary-color, #1E3A5F);
}
body.mobile .bottom-nav .bnav-label {
    /* display:block beats the legacy 480px ".tab-btn span:not(.icon)
       { display:none }" rule (SPA slots carry .tab-btn for wiring). */
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* The bar follows the same shell-visibility states as the topbar nav. */
body.fullscreen-active .bottom-nav { display: none !important; }
body.auth-checking .bottom-nav { opacity: 0; transition: opacity 0.3s ease; }
body.auth-ready .bottom-nav { opacity: 1; }
body.deal-page-active .bottom-nav { visibility: hidden; pointer-events: none; }

/* Topbar on mobile shrinks to logo + org/user affordance + the existing
   in-page search — primary nav lives in the bottom bar (spec §3). */
body.mobile .hero-section .main-tabs { display: none; }
/* Sticky-bar safe areas (spec §2.3): top inset on the sticky topbar; the
   bottom bar handles its own inset above. */
body.mobile .hero-section { padding-top: calc(8px + env(safe-area-inset-top, 0px)); }

/* ── Global floors (spec §2.3) ─────────────────────────────── */
/* 16px inputs everywhere: anything smaller triggers iOS auto-zoom on
   focus. !important so inline styles on legacy inputs can't undercut
   the floor. */
body.mobile input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body.mobile select,
body.mobile textarea {
    font-size: 16px !important;
}
/* 44px minimum touch targets on nav, cards and modal controls. */
body.mobile .modal .btn,
body.mobile .modal-buttons button,
body.mobile .modal-content button:not(.tr-menu-item),
body.mobile .user-menu-toggle,
body.mobile .user-dropdown-item {
    min-height: 44px;
}
body.mobile #tracker-tab .tracker-toolbar .btn,
body.mobile #tracker-tab .tracker-view-tab,
body.mobile #tracker-tab .tr-seg-btn,
body.mobile #tracker-tab #filter-btn {
    min-height: 44px;
}
body.mobile #tracker-tab #tracker-search { min-height: 44px; box-sizing: border-box; }

/* Email templates: merge field editor (2026-11-04). Fields show as pills
   with their label; the user never sees a {{slug}}. Quiet grays only. */
.es-merge-wrap { position: relative; }
.es-merge-editor { width: 100%; box-sizing: border-box; padding: 6px 10px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 4px; font-size: 13px; line-height: 1.6; background: #fff; color: var(--text-primary, #111827); outline: none; white-space: pre-wrap; word-break: break-word; }
.es-merge-editor:focus { border-color: #94a3b8; box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.18); }
.es-merge-editor-single { min-height: 33px; }
.es-merge-editor-multi { min-height: 170px; }
.es-merge-editor:empty::before { content: attr(data-placeholder); color: var(--text-muted, #9ca3af); pointer-events: none; }
.es-pill { display: inline-block; padding: 0 7px; margin: 0 1px; border-radius: 4px; background: #eef2f7; border: 1px solid #d9e0ea; color: var(--text-primary, #111827); font-size: 12px; line-height: 19px; vertical-align: baseline; white-space: nowrap; cursor: default; user-select: all; }
.es-pill-mini { font-size: 11px; line-height: 16px; padding: 0 5px; }
.es-field-bank { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.es-field-bank-label { font-size: 11px; color: var(--text-secondary, #6b7280); margin-right: 2px; }
.es-field-chip { border: 1px solid var(--border-color, #e5e7eb); background: #fff; border-radius: 12px; padding: 2px 10px; font-size: 12px; color: var(--text-primary, #111827); cursor: pointer; line-height: 18px; }
.es-field-chip:hover { background: #f3f4f6; }
.es-field-popup { position: absolute; z-index: 1100; min-width: 240px; max-height: 240px; overflow: auto; background: #fff; border: 1px solid var(--border-color, #e5e7eb); border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); padding: 4px; }
.es-field-popup-item { display: flex; justify-content: space-between; gap: 14px; padding: 6px 10px; font-size: 12px; border-radius: 4px; cursor: pointer; color: var(--text-primary, #111827); }
.es-field-popup-item.active, .es-field-popup-item:hover { background: #f3f4f6; }
.es-field-popup-item .ex { color: var(--text-muted, #9ca3af); white-space: nowrap; }

/* Field validation (field_rules.js, 2026-11-11): the short inline error a
   tracker cell shows when a typed value fails its rule (nothing is saved),
   and the county record value a blank residential fact cell shows muted
   until the user types over it. */
.tr-cell-err {
    position: fixed;
    z-index: 400;
    max-width: 280px;
    padding: 5px 9px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.10);
    font-family: var(--font-body, inherit);
    font-size: 12px;
    line-height: 1.35;
    color: var(--error-color, #DC2626);
    pointer-events: none;
}
.tr-county-ghost {
    color: var(--text-muted, #9CA3AF);
}

/* Tracker view switch (2026-11-11, every org): Active | Archive | All
   (templates/index.html #tracker-view-tabs, app.js setTrackerView). The
   look of the Active | Archive tabs it replaces (their inline styles moved
   here); residential orgs restyle it in res_ui.css. The count span stays
   empty unless a module fills it. */
.tr-seg { display: inline-flex; flex-shrink: 0; border: 1px solid #e5e7eb; border-radius: 6px; overflow: hidden; }
.tr-seg-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 5px 12px;
    border: none; background: #fff; color: #374151; cursor: pointer; font-family: inherit; white-space: nowrap; }
.tr-seg-btn + .tr-seg-btn { border-left: 1px solid #e5e7eb; }
.tr-seg-btn.is-active { background: #1E3A5F; color: #fff; }
.tr-seg-btn:focus-visible { outline: 2px solid #1E3A5F; outline-offset: -2px; }
.tr-seg-btn .tr-count:empty { display: none; }
.tr-seg-btn .tr-count { font-weight: 500; font-variant-numeric: tabular-nums; opacity: 0.75; }

.brokers-table th.broker-th-sortable { cursor: pointer; user-select: none; }
.brokers-table th.broker-th-sortable:hover { color: var(--text-primary); }
.brokers-table td.col-broker-deals { font-variant-numeric: tabular-nums; white-space: nowrap; }
.broker-deal-pair { color: var(--text-primary); }

/* Multi pill columns (2026-11-13): each value a pill; a value without a
   colour in the column's list reads in the palette's Light Gray. */
.tr-pills-cell { display: flex; flex-wrap: nowrap; gap: 4px; overflow: hidden; }
.badge-dd.tr-pill { background: #EDEDED; color: #444444; }

/* ============================================
   APP SKIN (theme pass Batch 0, 2026-11-12)
   body.acw-skin is on every app page (templates/_shell/kit_css.html pages;
   not the auth and public pages). Under it the legacy controls above take
   the kit look of res_ui.css (.ui-btn, .ui-input, .ui-modal), so a page
   adopts the theme without touching its markup: 32px buttons and inputs,
   8px radius, 13px text, flat fills, no gradient, no hover lift; modals
   take the popover look (10px radius, soft shadow, slate scrim, no blur).
   Each selector keeps the specificity of the legacy rule it restyles
   (:where() adds none), so a page rule that sizes its own control still
   wins. Inputs inside table cells keep their in-cell editors' look.
   Controls take min-height (not height) 32px: a page rule that keeps its
   own padding (an id scoped form) grows the box instead of clipping text.
   ============================================ */

/* Buttons. .btn-action (the 28px square row actions) keeps its own size. */
:where(body.acw-skin) .btn:not(:where(.btn-action)) {
    height: 32px; box-sizing: border-box; padding: 0 12px; gap: 6px;
    border: 1px solid var(--border-color); border-radius: var(--radius-control);
    background: var(--bg-card); color: var(--text-primary);
    font-family: var(--font-body); font-size: 13px; font-weight: 600; line-height: 1;
    box-shadow: none; transform: none;
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
:where(body.acw-skin) .btn:hover:not(:disabled) { border-color: var(--primary-color); color: var(--primary-color); }
:where(body.acw-skin) .btn:active:not(:disabled) { transform: none; }
:where(body.acw-skin) .btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 1px; }
:where(body.acw-skin) .btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: var(--radius-control); gap: 6px; }
:where(body.acw-skin) .btn-lg { height: 32px; padding: 0 16px; font-size: 13px; border-radius: var(--radius-control); }
/* The one filled button. .btn-success fills the same: success is said in
   words, not in green. */
:where(body.acw-skin) :is(.btn-primary, .btn-success) {
    background: var(--primary-color); border-color: var(--primary-color); color: #fff; box-shadow: none; }
:where(body.acw-skin) .btn-primary:hover:not(:disabled),
:where(body.acw-skin) .btn-success:hover:not(:disabled) {
    background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; box-shadow: none; transform: none; }
:where(body.acw-skin) :is(.btn-secondary, .btn-outline, .btn-warning) {
    background: var(--bg-card); border-color: var(--border-color); color: var(--text-primary); }
:where(body.acw-skin) .btn-secondary:hover:not(:disabled),
:where(body.acw-skin) .btn-warning:hover:not(:disabled) {
    background: var(--bg-card); border-color: var(--primary-color); color: var(--primary-color); box-shadow: none; }
:where(body.acw-skin) .btn-outline:hover:not(:disabled) { background: var(--bg-card); border-color: var(--primary-color); color: var(--primary-color); }
:where(body.acw-skin) .btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
:where(body.acw-skin) .btn-ghost:hover:not(:disabled) { background: var(--bg-input); border-color: transparent; color: var(--text-primary); }
/* Destructive: the error ink on the plain button, never a red fill. */
:where(body.acw-skin) :is(.btn-danger, .btn-outline-danger) {
    background: var(--bg-card); border-color: var(--border-color); color: var(--error-color); }
:where(body.acw-skin) .btn-danger:hover:not(:disabled),
:where(body.acw-skin) .btn-outline-danger:hover:not(:disabled) { background: var(--bg-card); border-color: var(--error-color); color: var(--error-color); box-shadow: none; }
:where(body.acw-skin) .btn-close { border-radius: var(--radius-control); }
:where(body.acw-skin) .btn-close:hover { background: var(--bg-input); }

/* Form controls: text-like inputs, selects and textareas. */
:where(body.acw-skin) :is(input:where(:not([type]), [type="text"], [type="email"], [type="url"],
        [type="number"], [type="password"], [type="search"], [type="tel"], [type="date"],
        [type="datetime-local"], [type="month"], [type="time"]), select, textarea):not(:where(td *, th *)) {
    height: auto; min-height: 32px; box-sizing: border-box; padding: 0 10px;
    border: 1px solid var(--border-color); border-radius: var(--radius-control);
    background-color: var(--bg-card); color: var(--text-primary);
    font-family: var(--font-body); font-size: 13px; line-height: 1;
}
:where(body.acw-skin) textarea:not(:where(td *, th *)) {
    height: auto; min-height: 64px; padding: 8px 10px; line-height: 1.45; }
:where(body.acw-skin) :is(input:where(:not([type]), [type="text"], [type="email"], [type="url"],
        [type="number"], [type="password"], [type="search"], [type="tel"], [type="date"],
        [type="datetime-local"], [type="month"], [type="time"]), select, textarea):where(:focus):not(:where(td *, th *)) {
    outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.08); }
/* The legacy labelled field (.form-group): the kit field, a 12px muted
   label over a 32px control. */
:where(body.acw-skin) .form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
:where(body.acw-skin) .form-group :is(input, select) {
    height: auto; min-height: 32px; padding: 0 10px; background: var(--bg-card); border-radius: var(--radius-control); font-size: 13px; }
:where(body.acw-skin) .form-group select { padding-right: 32px; background-color: var(--bg-card); }
:where(body.acw-skin) .form-group :is(input, select):focus { background: var(--bg-card); box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.08); }
:where(body.acw-skin) .form-group select:focus { background-color: var(--bg-card); }
:where(body.acw-skin) .form-group :is(input[type="checkbox"], input[type="radio"]) { min-height: 0; padding: 0; }

/* Modals: the popover look on the existing markup. */
:where(body.acw-skin) .modal { background: rgba(15, 23, 42, 0.32); backdrop-filter: none; }
:where(body.acw-skin) .modal-content {
    padding: 16px 18px; border-radius: var(--radius-card);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); }
:where(body.acw-skin) .modal-content h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
:where(body.acw-skin) .modal-content p { font-size: 13px; margin-bottom: 12px; }
:where(body.acw-skin) .modal-buttons { gap: 8px; margin-top: 16px; }
:where(body.acw-skin) .modal-large { padding: 16px 18px; }
:where(body.acw-skin) .modal-header { margin-bottom: 12px; padding-bottom: 10px; }
:where(body.acw-skin) .modal-close { border-radius: var(--radius-control); }
:where(body.acw-skin) .modal-close:hover { background: var(--bg-input); }

/* Brokers table (2026-11-12, owner): a header that sorts shows the pointer,
   not the text cursor; Deals reads "active / total" as a plain number in
   the column's alignment. */
