/* ==========================================
   0. GLOBAL VARIABLES & RESET
   ========================================== */
:root {
    /* Brand & UI Colors */
    --primary: #1e293b;
    --secondary: #3b82f6;
    --surface: #ffffff;
    --bg-traditional: #f8fafc;
    --bg-algorithmic: #f0fdf4;
    
    /* Text & Borders */
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    
    /* Semantic Colors */
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    
    /* Print Specific */
    --print-primary: #1a365d;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    background-color: var(--bg-traditional);
    color: var(--text-dark);
    transition: background-color 0.5s ease;
    overflow: hidden; /* App shell handles scrolling to support no-scroll Command Center */
}

.hidden { display: none !important; }

/* ==========================================
   1. MAIN DASHBOARD SHELL & HEADER
   ========================================== */
.app-header {
    padding: 20px 40px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    background: var(--surface); 
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02); 
    position: sticky; 
    top: 0; 
    z-index: 100;
    height: 85px;
}

.header-info h1 { margin: 0; font-size: 22px; color: var(--text-dark); }
.header-info p { margin: 4px 0 0 0; color: var(--text-muted); font-size: 13px; font-weight: 500; }

.dashboard-content {
    padding: 30px 40px;
    height: calc(100vh - 85px); 
    overflow-y: auto;
}

.stage-header { font-size: 1.8rem; color: var(--primary); margin-bottom: 20px; }

/* Header Toggle Switch */
.toggle-container {
    display: flex; align-items: center; gap: 15px; font-weight: 600;
    background: #f1f5f9; padding: 8px 16px; border-radius: 30px; border: 1px solid var(--border);
}
.toggle-label { color: var(--text-muted); transition: color 0.3s; font-size: 14px; }
.toggle-label.active { color: var(--secondary); }
.switch { position: relative; display: inline-block; width: 60px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 30px; }
.slider:before { position: absolute; content: ""; height: 22px; width: 22px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(30px); }

/* --- EXTRACTED UTILITIES & ALERTS --- */
.msg-success { color: var(--success); font-weight: bold; margin-bottom: 10px; }

/* Alert Boxes */
.alert-box { padding: 15px; border-radius: 6px; text-align: center; font-size: 13px; margin-bottom: 15px; }
.alert-box.danger { border: 1px solid var(--danger); background: var(--danger-light); text-align: left; }
.alert-box.warning { background: #fffbeb; border: 1px solid #fde68a; color: #b45309; font-weight: bold; }
.alert-box.warning.large { padding: 20px; border-radius: 8px; font-size: 1rem; }
.alert-box.neutral { background: #f8fafc; border: 1px dashed var(--border); color: var(--text-muted); }

/* Layout & Button Utilities */
.flex-row { display: flex; gap: 10px; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.btn-success { background: var(--success) !important; color: white !important; }
.btn-danger { background: var(--danger) !important; color: white !important; }
.btn-secondary { background: #475569 !important; color: white !important; }
.btn-outline { background: var(--bg-traditional) !important; color: var(--text-dark) !important; border: 1px solid var(--border) !important; }

/* Dictionary & Tooltip Additions */
.dict-desc { font-size: 0.9em; text-align: left; line-height: 1.5; margin-top: 15px; color: var(--text-muted); }
.dict-verdict-box { font-size: 0.95em; text-align: center; line-height: 1.6; margin-top: 15px; padding: 15px; background: white; border: 1px dashed var(--border); border-radius: 4px; }
.origins-tooltip-desc { display: block; margin-top: 5px; font-weight: normal; line-height: 1.4; }
.origins-trigger {
    cursor: help;
    font-size: 0.75em;
    vertical-align: super;
    color: var(--text-muted);
    user-select: none;
}
.origins-trigger:hover { color: var(--primary); }
.origins-trigger.error { color: var(--danger); }

/* Chart Modifiers */
.chart-wrapper.small { height: 110px; margin-top: 10px; }
.chart-annotation.small { font-size: 11px; margin-top: 10px; color: var(--text-muted); text-align: center; }

/* Loader Modifier */
.theatrical-loader.large { height: 400px; border: none; }

/* Telemetry & Presence Utilities */
.presence-indicator { font-weight: bold; margin-bottom: 8px; }
.telemetry-text { font-style: italic; color: var(--text-muted); }
.presence-log { margin-top: 6px; font-size: 0.78em; color: var(--text-muted); }
.presence-log-entry { display: flex; gap: 8px; padding: 2px 0; }
.log-time { opacity: 0.6; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Tooltip value display & arithmetic rows */
.tooltip-value-header {
    display: block;
    font-size: 1.05em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.tooltip-calc-rows { margin-top: 10px; font-size: 0.88em; }
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.calc-row span:last-child { font-weight: 600; white-space: nowrap; }
.calc-total {
    display: flex; justify-content: space-between; gap: 12px;
    padding-top: 5px; margin-top: 4px;
    border-top: 1px solid var(--border, #e2e8f0);
    font-weight: 700;
}
.negotiation-locked {
    opacity: 0.72;
    background: var(--surface-muted, #f8fafc);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    pointer-events: none;
}
.negotiation-locked #btn-view-dossier-inline {
    pointer-events: auto;
}
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ==========================================
   2. SHARED COMPONENTS & ANIMATIONS
   ========================================== */
.panel {
    background: var(--surface); 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    padding: 20px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.comp-list { list-style: none; padding: 0; margin: 15px 0; }
.comp-list li { padding: 10px 0; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; font-size: 13px; }
.comp-list li:last-child { border: none; }
.comp-meta { color: var(--text-muted); }
.comp-price { font-weight: bold; color: var(--text-dark); }
.comp-img-trigger { position: relative; cursor: pointer; margin-right: 4px; font-size: 0.85em; }
.comp-img-preview {
    display: none; position: absolute; left: 20px; top: 0; z-index: 999;
    background: white; border: 1px solid var(--border);
    border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 4px;
}
.comp-img-trigger:hover .comp-img-preview { display: block; }
.comp-snapshot-link { color: inherit; text-decoration: none; }
.comp-snapshot-link:hover { text-decoration: underline; }

.chart-wrapper { height: 180px; background: var(--bg-traditional); border: 1px dashed #cbd5e1; border-radius: 8px; margin-top: 15px; position: relative; padding: 10px; }
.chart-annotation { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 8px; font-style: italic; }

@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInRow { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.fade-in-row { animation: fadeInRow 0.35s ease-out forwards; }

/* Leaflet Map Tooltips */
.custom-map-tooltip {
    background-color: var(--primary) !important;
    color: white !important;
    border: none !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

/* ==========================================
   PDF VIEWER MODAL & FLOATING BUTTON
   ========================================== */
.floating-side-btn {
    position: fixed; 
    top: 96%; 
    right: -5px; 
    transform: translateY(-50%);
    background: var(--primary); 
    color: white; 
    border: none; 
    padding: 15px 20px;
    border-radius: 8px 0 0 8px; 
    cursor: pointer; 
    font-weight: bold;
    box-shadow: -2px 2px 10px rgba(0,0,0,0.2); 
    z-index: 600; 
    transition: right 0.2s;
}
.floating-side-btn:hover { right: 0; }

.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.7); 
    display: flex; justify-content: center; align-items: center; 
    z-index: 2000;
}
.modal-content { background: var(--surface); padding: 30px; border-radius: 12px; position: relative; }
.large-modal { width: 90vw !important; max-width: 1200px !important; height: 90vh; display: flex; flex-direction: column; }
.close-btn { position: absolute; top: 15px; right: 20px; font-size: 1.8rem; cursor: pointer; color: var(--text-muted); }

.pdf-tabs { display: flex; gap: 10px; margin-bottom: 15px; border-bottom: 2px solid var(--border); padding-bottom: 10px; }
.pdf-tab { padding: 10px 20px; background: transparent; border: none; font-size: 1rem; font-weight: bold; color: var(--text-muted); cursor: pointer; border-radius: 4px; }
.pdf-tab.active { background: #f1f5f9; color: var(--primary); }
.pdf-view-container { flex-grow: 1; position: relative; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-traditional); overflow: hidden; }
.pdf-frame { width: 100%; height: 100%; border: none; }

/* ==========================================
   3. STAGE 1: LOCAL MARKET
   ========================================== */
.stage-1-layout { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; animation: fadein 0.5s ease forwards; }
.dual-lens-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.panel h2 { margin-top: 0; border-bottom: 2px solid var(--border); padding-bottom: 10px; font-size: 16px; }

/* Map Spacer to preserve layout without blowing the reveal */
.map-spacer { width: 100%; height: 60px; }

/* The Thesis Statement / Call to Action */
.thesis-statement {
    text-align: center;
    font-size: 15px;
    color: var(--text-muted);
    max-width: 800px;
    margin: 30px auto;
    padding: 20px;
    background: #f1f5f9;
    border-radius: 8px;
    border-left: 4px solid var(--secondary);
}

/* --- EXTRACTED STAGE 1 TYPOGRAPHY --- */
.stage-header.center { margin-bottom: 0; text-align: center; }
.panel-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 15px; }

/* ACV Display Variants */
.acv-display { font-size: 32px; font-weight: bold; margin-bottom: 20px; }
.acv-display.danger { color: var(--danger); }
.acv-display.secondary { color: var(--secondary); }
.acv-display.muted { font-size: 20px; color: var(--text-muted); }

/* Panel Header Colors */
.panel.insurer h2 { color: var(--danger); }
.panel.insured h2 { color: var(--secondary); }

/* ==========================================
   4. STAGE 2: COMMAND CENTER & NEGOTIATION
   ========================================== */
.stage-2-cc-layout {
    display: grid;
    grid-template-columns: 1fr 400px; 
    gap: 20px;
    height: 100%; 
    overflow: hidden; 
    animation: fadein 0.5s ease forwards;
}

.cc-left-col { 
    display: flex; flex-direction: column; gap: 20px; height: 100%; 
    min-height: 0; 
}
.cc-right-col { 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
    height: 100%; 
    overflow-y: auto; 
    overflow-x: hidden; /* Mathematically locks the horizontal axis so scrollbars never spawn */
    padding-right: 10px; 
    min-height: 0; 
}

/* Map gets a fixed height, Table takes the remaining space */
.map-container { 
    width: 100%; height: 380px; flex-shrink: 0; 
    background: #e2e8f0; border-radius: 8px; border: 1px solid var(--border); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
}
.table-scroll-wrapper { 
    flex: 1; min-height: 0; overflow-y: auto; 
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); 
}


.ingestion-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ingestion-table th { background: var(--bg-traditional); padding: 10px; text-align: left; position: sticky; top: 0; z-index: 2; color: var(--text-muted); font-weight: 600; box-shadow: 0 1px 0 var(--border); }
.ingestion-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; font-variant-numeric: tabular-nums; }
.highlight-row { background-color: #d1fae5 !important; transition: background-color 0.8s ease; } /* Green for local clicks */
.remote-highlight-row { background-color: #fef08a !important; transition: background-color 0.8s ease; } /* Yellow for remote partner clicks */

/* The Ghost Panel — local market mirror, slightly faded vs macro card */
.ghost-panel { opacity: 0.78; transform: scale(0.97); transition: all 0.4s ease; filter: grayscale(15%); padding: 15px; }
.ghost-panel:hover { opacity: 1; filter: grayscale(0%); }
.ghost-panel .local-hero-title { color: var(--text-muted, #94a3b8); }

/* Macro Market Hero Panel */
.macro-hero-panel { border: 2px solid var(--success); background: var(--success-light); }
.temporal-trend-panel { border: 2px solid #f59e0b; background: #fffbeb; }
.approx-icon { cursor: help; color: var(--text-muted); font-style: italic; font-size: 0.9em; }
.country-badge { font-size: 0.75em; font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; white-space: nowrap; }
.pre-loss-value { font-size: 28px; font-weight: 900; color: #d97706; font-family: "Georgia", serif; margin-bottom: 8px; }
.macro-hero-panel .live-acv { font-size: 36px; font-weight: 900; color: var(--success); font-family: "Georgia", serif; display: flex; align-items: baseline; gap: 10px; }
.live-counter-n { font-size: 14px; color: var(--text-muted); font-family: sans-serif; }
.live-counter-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

/* Negotiation Sandbox UI */
.negotiation-panel { 
    background: var(--surface); 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    padding: 25px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); 
    z-index: 10;
}
.negotiation-panel h3 { margin-top: 0; color: var(--primary); font-size: 1.2rem; margin-bottom: 15px; }
.negotiation-text { font-size: 14px; color: #334155; line-height: 1.5; margin-bottom: 20px; }

.input-group { display: flex; flex-direction: column; gap: 10px; }
.input-group input { padding: 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }
.input-group input:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }

.submit-btn { padding: 12px; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; transition: background 0.2s; width: 100%; background: var(--primary); color: white; }
.submit-btn:hover:not(:disabled) { background: #334155; }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.msg-error { color: var(--danger); font-weight: bold; margin-top: 10px; font-size: 0.95rem; }

/* ==========================================
   GLOBAL TOOLTIP OVERRIDE
   ========================================== */

/* 1. Hide the inline tooltips completely (they are now just data stores) */
.origins-trigger .origins-tooltip {
    display: none !important;
}

/* 2. The detached Global Tooltip attached to the body */
#global-origins-tooltip {
    position: fixed; 
    z-index: 2147483647; 
    pointer-events: none; 
    
    background-color: var(--primary, #1e293b);
    color: #fff;
    text-align: left;
    border-radius: 8px;
    padding: 15px;
    
    width: max-content;
    max-width: 480px;
    font-size: 13px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    
    /* Default hidden state */
    top: -9999px;
    left: -9999px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

/* Display state triggered by JS */
#global-origins-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* Default Upward Arrow */
#global-origins-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    /* Dynamically targets the trigger element based on JS math */
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--primary, #1e293b) transparent transparent transparent;
}

/* Flipped Downward Arrow (if forced off top of screen) */
#global-origins-tooltip.flipped::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent var(--primary, #1e293b) transparent;
}

/* Theatrical Loader */
.theatrical-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; background: #f8fafc; border-radius: 8px; border: 1px dashed var(--border); }
.mini-spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--secondary); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
.loading-text { font-size: 13px; color: var(--text-muted); font-weight: 600; animation: pulse 1.5s infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* --- EXTRACTED STAGE 2 UI COMPONENTS --- */
.comp-importer-wrapper { margin-top: 25px; padding-top: 20px; border-top: 1px dashed var(--border); }
.comp-importer-title { margin: 0 0 10px 0; color: var(--text-muted); font-size: 13px; text-transform: uppercase; }

.negotiation-warning { color: var(--danger); font-weight: bold; margin-top: 10px; }
.action-desc { font-size: 13px; margin-bottom: 15px; color: var(--text-muted); }

.portal-section { margin-top: 20px; }
.portal-title { margin: 0 0 10px 0; color: var(--primary); font-size: 14px; }

.panel-subtitle-upper { font-size: 13px; margin-bottom: 5px; color: var(--text-muted); text-transform: uppercase; }
.macro-hero-title { color: var(--success); font-size: 14px; margin-bottom: 5px; text-transform: uppercase; }

/* ==========================================
   5. STAGE 3: UMPIRE DOSSIER (INFOGRAPHIC)
   ========================================== */
.dossier-wrapper {
    background: white;
    width: 100%;
    max-width: 900px;
    margin: 0 auto 40px auto;
    padding: 50px 60px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border-top: 8px solid var(--print-primary);
    border-radius: 4px;
    color: #2d3748;
}

.dossier-wrapper h1, .dossier-wrapper h2, .dossier-wrapper h3 { font-family: "Georgia", serif; color: var(--print-primary); margin-top: 0; }

.dossier-header { border-bottom: 2px solid var(--print-primary); padding-bottom: 20px; margin-bottom: 30px; }
.header-meta { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 15px; font-weight: bold; }

/* Hero Metrics */
.hero-metrics { display: flex; gap: 20px; margin-top: 30px; }
.metric-box { flex: 1; padding: 25px; border-radius: 4px; text-align: center; }
.metric-box.empirical { background: #f0fff4; border: 1px solid #9ae6b4; }
.metric-box.insurer { background: #fff5f5; border: 1px solid #feb2b2; }
.metric-box.pre-loss { background: #fffbeb; border: 1px solid #fcd34d; }
.pre-loss .metric-value { color: #d97706; }
.metric-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 10px; font-weight: bold;}
.metric-value { font-size: 3em; font-weight: bold; font-family: "Georgia", serif; }
.empirical .metric-value { color: var(--success); }
.insurer .metric-value { color: var(--danger); }

/* The Solid Deficit Bar */
.deficit-bar { background: var(--print-primary); color: white; text-align: center; padding: 12px; font-weight: bold; font-size: 1.1em; margin-top: 20px; border-radius: 4px; letter-spacing: 0.05em; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }

/* Narrative Sections */
.dossier-section { margin-top: 40px; padding-top: 30px; border-top: 1px solid var(--border); }
.split-section { display: flex; gap: 40px; }
.col { flex: 1; font-size: 14px; line-height: 1.6; color: #4a5568;}

/* Integrity Grids & Math Blocks */
.integrity-grid { background: #f8fafc; border: 1px solid var(--border); border-radius: 4px; padding: 15px; margin-top: 15px; }
.integrity-grid h4 { margin-bottom: 10px; font-family: -apple-system, sans-serif; font-size: 13px; text-transform: uppercase; color: var(--text-muted); }
.math-block { background: #f8fafc; padding: 20px; border-radius: 6px; border-left: 4px solid var(--print-primary); margin: 20px 0; overflow-x: auto; font-size: 14px; color: var(--text-dark); }

/* Print Button */
.print-btn-container { display: flex; justify-content: flex-end; margin-bottom: 20px; max-width: 900px; margin: 0 auto 20px; }
.btn-print { background: var(--print-primary); color: white; border: none; padding: 12px 24px; border-radius: 6px; cursor: pointer; font-size: 1rem; font-weight: bold; transition: background 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.btn-print:hover { background: #0f172a; }

/* --- EXTRACTED DOSSIER COMPONENTS --- */
.dossier-wrapper h1.fact-sheet-title { font-size: 2.5em; margin-bottom: 10px; }
.dossier-wrapper p.fact-sheet-subtitle { font-size: 1.1em; margin: 0; color: var(--text-muted); }

.metric-desc { font-size: 0.85em; color: var(--text-muted); margin-top: 10px; }

/* Staggered Math Narratives (Keep flex-direction dynamic in JS) */
.staggered-math-block { gap: 40px; margin-bottom: 45px; align-items: center; page-break-inside: avoid; }
.math-narrative h4 { color: var(--print-primary); font-family: 'Georgia', serif; font-size: 1.25rem; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.math-narrative p { color: var(--text-dark); font-size: 1.05rem; line-height: 1.6; }
.math-equation { background: #f8fafc; padding: 25px; border-radius: 6px; text-align: center; font-size: 1.1rem; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }

/* Viability Bar */
.viability-bar { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border: 1px solid var(--border); border-radius: 4px; padding: 15px 25px; margin-top: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.viability-label { display: block; font-size: 0.85em; color: var(--text-muted); text-transform: uppercase; font-weight: bold; letter-spacing: 0.05em; }
.viability-value { font-size: 1.4em; font-family: 'Georgia', serif; font-weight: bold; color: var(--text-dark); }
.viability-badge { display: inline-block; padding: 8px 16px; border-radius: 30px; font-size: 0.9em; font-weight: bold; color: white; }
/* Dynamic colors for the badge should be applied via a class (e.g., .bg-danger or .bg-success) from JS */
.bg-danger { background-color: var(--danger); }
.bg-success { background-color: var(--success); }

/* Split Section Additions */
.col.highlight-col { display: flex; flex-direction: column; justify-content: center; align-items: center; background: #ebf8ff; border: 1px solid #bee3f8; border-radius: 4px; padding: 20px; }
.highlight-number { font-size: 4em; font-weight: bold; color: #3182ce; font-family: 'Georgia', serif; }
.highlight-label { text-transform: uppercase; letter-spacing: 0.1em; color: var(--print-primary); font-size: 12px; font-weight: bold; }
.highlight-sub { margin-top: 10px; font-size: 0.85em; color: var(--text-muted); }

/* Integrity Grids */
.integrity-container { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.integrity-container h4 { display: flex; align-items: center; margin-bottom: 10px; }
.integrity-list { list-style: none; padding: 0; font-size: 12px; margin: 0; }
.integrity-list li { margin-bottom: 5px; }

/* Chart Visualization */
.chart-viz-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 4px; padding: 20px; text-align: center; height: 260px; display: flex; flex-direction: column; justify-content: center; align-items: center; margin-top: 20px; }
.chart-viz-caption { margin-top: 20px; text-align: center; color: var(--text-muted); font-size: 13px; max-width: 85%; margin-left: auto; margin-right: auto; }

/* Matrix Table */
.matrix-table-wrapper { overflow-x: auto; margin-top: 15px; border: 1px solid var(--border); border-radius: 4px; }
.matrix-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.matrix-table tr.header-row { background: #f8fafc; text-align: left; border-bottom: 1px solid var(--border); }
.matrix-table th, .matrix-table td { padding: 10px; }

/* Local Comps Box */
.local-comps-box { background: white; border: 1px solid var(--border); padding: 15px; border-radius: 4px; }
.local-comps-box h4 { margin-bottom: 10px; font-family: sans-serif; color: var(--text-muted); text-transform: uppercase; font-size: 12px; }

/* ==========================================
   6. PRINT OPTIMIZATION
   ========================================== */
@media print {
    body, html, .dashboard-content { 
        height: auto !important; overflow: visible !important; 
        background: white !important; padding: 0 !important; margin: 0 !important; 
    }
    
    /* Hide all dashboard UI */
    .app-header, .toggle-container, .print-btn-container, .btn-print, .bottom-bar { 
        display: none !important; 
    }
    
    /* Optimize Dossier for A4 */
    .dossier-wrapper { 
        box-shadow: none !important; 
        border: none !important; 
        padding: 0 !important; 
        max-width: 100% !important; 
        margin: 0 !important;
    }
    
    /* Ensure colors print correctly */
    * { -webkit-print-color-adjust: exact; color-adjust: exact; print-color-adjust: exact; }
    
    /* Prevent awkward page breaks */
    .dossier-section { page-break-inside: avoid; }
    .hero-metrics { page-break-inside: avoid; }
    .split-section { page-break-inside: avoid; }
    
    table { width: 100%; border-collapse: collapse; page-break-inside: auto; }
    tr { page-break-inside: avoid; page-break-after: auto; }
    thead { display: table-header-group; }
}

/* ==========================================
   AUTHENTICATION OVERLAY
   ========================================== */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.95);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
}

.login-card {
    background: var(--surface); padding: 40px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); width: 100%; max-width: 400px;
}

.login-card h2 { margin-bottom: 24px; text-align: center; color: var(--primary); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9rem; }
.form-group input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 1rem; }

#login-btn {
    width: 100%; padding: 12px; background: var(--secondary); color: white;
    border: none; border-radius: 6px; font-size: 1rem; font-weight: bold;
    cursor: pointer; margin-top: 10px; transition: background 0.2s;
}
#login-btn:hover { background: #2563eb; }
.error-msg { color: var(--danger); text-align: center; margin-top: 12px; font-size: 0.9rem; font-weight: 600; }

/* ==========================================
   UI TRANSITIONS & MOBILE CONSTRAINTS
   ========================================== */

/* Cinematic Stage 1 -> Stage 2 Exit Animations */
.fade-out-left {
    opacity: 0 !important;
    transform: translateX(-50px) scale(0.95) !important;
    pointer-events: none;
}
.shrink-to-ghost {
    opacity: 0.4 !important;
    /* Moves the panel up and right, shrinking it to simulate it becoming the Ghost Panel */
    transform: translate(250px, -50px) scale(0.65) !important; 
    filter: grayscale(50%) !important;
    pointer-events: none;
}

/* Slide in for Stage 2 */
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
.cc-right-col {
    animation: slideInRight 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Mobile Constraints: Disable all layout animations/transitions on phones */
@media (max-width: 768px) {
    .panel, .fade-out-left, .shrink-to-ghost, .stage-2-cc-layout, .stage-1-layout, .cc-right-col {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
    
    /* EXCEPTION: We KEEP the data ingestion row animations */
    .fade-in-row { 
        animation: fadeInRow 0.6s ease-out forwards !important;
    }
}

/* Local OLS invalidation rationale block */
.local-ols-rationale {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    background: #fefce8;
    border-left: 3px solid #f59e0b;
    padding: 8px 10px;
    margin-top: 8px;
    border-radius: 0 4px 4px 0;
    line-height: 1.5;
}

/* Warning annotation variant (insufficient local data) */
.chart-annotation.warning {
    color: #dc2626;
    font-style: italic;
}

/* Appraiser foresight callout — private, never visible to viewer */
.foresight-callout {
    background: #f0f9ff;
    border-left: 3px solid #3b82f6;
    padding: 6px 10px;
    margin: 8px 0;
    font-size: 0.82rem;
    border-radius: 0 4px 4px 0;
}
.foresight-label { color: #64748b; margin-right: 6px; }
.foresight-value { font-weight: 600; color: #1e40af; }

/* Offer log */
.offer-log { margin: 10px 0; font-size: 0.85rem; }
.offer-entry { padding: 4px 8px; border-radius: 4px; margin-bottom: 4px; }
.offer-entry.appraiser { background: #f0fdf4; }
.offer-entry.viewer { background: #eff6ff; }
.offer-entry.engine { background: #fafafa; color: #64748b; }
.offer-ts { float: right; color: #94a3b8; font-size: 0.75rem; }

/* Final decline confirmation dialog */
.confirm-dialog {
    background: #fff7ed;
    border: 1px solid #f97316;
    border-radius: 6px;
    padding: 16px;
    margin: 12px 0;
}
.confirm-dialog p { margin: 0 0 12px; }
.confirm-dialog input { width: 100%; margin-bottom: 10px; }
.price-drop { color: #dc2626; font-weight: 600; }
.price-stable { color: #16a34a; }

/* Mobile — Stage-2 stacks vertically */
@media (max-width: 768px) {
    .stage-2-cc-layout { display: flex; flex-direction: column; overflow: visible; }
    .cc-left-col, .cc-right-col { width: 100%; min-width: unset; height: auto; }
    #stage2-map { height: 250px; }
    .panel, .ghost-panel, .macro-hero-panel, .negotiation-panel { margin-bottom: 16px; }
    body { overflow-y: auto !important; }
}

/* PDF viewer collapsible */
#pdf-viewer-details summary { cursor: pointer; padding: 8px 12px; background: #f1f5f9; border-radius: 6px; font-size: 0.9rem; user-select: none; list-style: none; }
#pdf-viewer-details summary::before { content: '▶ '; font-size: 0.75em; }
#pdf-viewer-details[open] summary { border-radius: 6px 6px 0 0; }
#pdf-viewer-details[open] summary::before { content: '▼ '; }
.pdf-viewer-content { border: 1px solid #e2e8f0; border-top: none; border-radius: 0 0 6px 6px; }
.origins-tooltip { z-index: 9999; }