/* ==========================================================================
   1. SYSTEM CORES & DESIGN VARIABLES
   ========================================================================== */
:root {
    --bg-ivory: #f1efe9;
    --surface-white: #ffffff;
    --text-charcoal: #2c2a29;
    --text-muted: #6e6b64;
    --border-line: #d7d3c9;
    
    /* Academic Visualization Spectrum */
    --color-crimson: #b83b2e;
    --color-forest: #3e7d5a;
    --color-cobalt: #3a6186;
    --color-gold: #c29238;
    --color-terminal: #25402a;
    
    /* Advanced Eco-Monetary & Macro-Shocks Expansion Colors */
    --color-debt-amber: #d97706;
    --color-error-red: #dc2626;
    --color-resource-blue: #2563eb;
    --color-velocity-purple: #7c3aed;
}

body {
    background-color: var(--bg-ivory);
    color: var(--text-charcoal);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    letter-spacing: -0.01em;
}

/* ==========================================================================
   2. THREE-COLUMN DASHBOARD MASTER GRID
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 350px 1fr 340px;
    height: 100vh;
    width: 100vw;
    box-sizing: border-box;
}

.panel {
    padding: 1.5rem;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--border-line);
    display: flex;
    flex-direction: column;
}

.panel::-webkit-scrollbar {
    width: 4px;
}
.panel::-webkit-scrollbar-thumb {
    background: var(--border-line);
    border-radius: 2px;
}

/* ==========================================================================
   3. COLUMN 1: INTELLECTUAL SPECIFICATIONS
   ========================================================================== */
.theory-panel {
    background-color: var(--bg-ivory);
}

.brand-header h1 {
    font-family: "Times New Roman", Times, Baskerville, Georgia, serif;
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    margin: 0;
    color: var(--text-charcoal);
}

.classification {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-top: 0.3rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--text-charcoal);
    padding-bottom: 0.5rem;
    text-transform: uppercase;
}

/* Historic Campaign Preset Button Block */
.sub-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.02em;
}

.campaign-presets {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}

.btn-preset {
    background: transparent;
    border: 1px solid var(--border-line);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-charcoal);
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.btn-preset:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--text-charcoal);
}

.btn-preset.active {
    background: var(--text-charcoal);
    color: var(--bg-ivory);
    border-color: var(--text-charcoal);
}

.prose-block h2 {
    font-family: "Times New Roman", Times, Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.prose-block p {
    font-size: 0.8rem;
    line-height: 1.55;
    color: #444240;
    margin-top: 0;
    margin-bottom: 1rem;
    text-align: justify;
}

.prose-block code {
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 4px;
    border-radius: 2px;
    font-family: monospace;
    font-size: 0.75rem;
}

/* Equation Containment System: Avoids Cross-Panel bleeding */
.equation-box {
    background: rgba(0, 0, 0, 0.02);
    border-left: 2px solid var(--text-muted);
    padding: 0.65rem;
    margin: 0.8rem 0;
    color: var(--text-charcoal);
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: normal;
    word-break: break-word;
    box-sizing: border-box;
}

.equation-box .MathJax, 
.prose-block .MathJax {
    display: inline-block !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    text-align: left !important;
    box-sizing: border-box;
}

/* ==========================================================================
   4. COLUMN 2: PRIMARY VISUAL KINETIC FIELD
   ========================================================================== */
.simulation-panel {
    background-color: #faf9f6; /* Clinical bone background */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
}

.oracle-container {
    width: 100%;
    max-width: 620px;
    background: var(--surface-white);
    border: 1px solid var(--border-line);
    padding: 10px 14px;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-radius: 2px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
    margin-bottom: 0.5rem;
}

.oracle-badge {
    font-size: 0.58rem;
    font-weight: 900;
    background: var(--text-charcoal);
    color: var(--bg-ivory);
    padding: 3px 6px;
    letter-spacing: 0.06em;
    border-radius: 1px;
    white-space: nowrap;
    margin-top: 1px;
}

.oracle-text {
    font-size: 0.78rem;
    font-family: Georgia, serif;
    font-style: italic;
    color: #3a3836;
    line-height: 1.4;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: break-word;
}

.canvas-container {
    box-shadow: 0 15px 40px rgba(44, 42, 41, 0.06);
    border: 1px solid var(--border-line);
    background-color: var(--surface-white);
    line-height: 0;
    border-radius: 2px;
    width: 100%;
    max-width: 620px;
    display: flex;
    justify-content: center;
}

.main-sim-container canvas {
    max-width: 100%;
    width: 100%;
    height: auto;
    background: #fdfdfb;
}

/* System Clock Controllers & Velocity Widgets */
.control-bar {
    width: 100%;
    max-width: 620px;
    background: var(--surface-white);
    border: 1px solid var(--border-line);
    padding: 12px 16px;
    box-sizing: border-box;
    border-radius: 2px;
}

.time-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.slider-group input[type="range"] {
    accent-color: var(--text-charcoal);
    cursor: pointer;
    width: 110px;
}

.control-title {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.5rem;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.action-buttons .btn {
    flex: 1;
}

.btn {
    background: var(--surface-white);
    border: 1px solid var(--border-line);
    padding: 8px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:hover {
    background: var(--text-charcoal);
    color: var(--bg-ivory);
}

/* ==========================================================================
   5. COLUMN 3: REAL-TIME TELEMETRY SUITE
   ========================================================================== */
.telemetry-panel {
    border-right: none;
    background-color: #eae7df; /* Deep statistics ivory tone */
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-family: "Times New Roman", Times, Georgia, serif;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}

.status-indicator {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--color-forest);
    background: rgba(62, 125, 94, 0.1);
    padding: 3px 6px;
    border-radius: 2px;
}

.pulses::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    background: var(--color-forest);
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.panel-divider {
    border: none;
    border-top: 1px solid var(--border-line);
    margin: 1rem 0;
    width: 100%;
}

.metric-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.metric-box {
    display: flex;
    flex-direction: column;
}

/* Highlights new endogenous AI Central Bank & Credit Engine readouts */
.metric-box.structural-highlight {
    background: rgba(0, 0, 0, 0.02);
    padding: 4px 6px;
    border-radius: 2px;
    border-left: 2px solid var(--text-muted);
}

.metric-label {
    font-size: 0.58rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    margin-bottom: 0.1rem;
    text-transform: uppercase;
}

.metric-value {
    font-family: monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-charcoal);
}

.metric-value.ESCROW {
    color: #a4761c;
}

.metric-value.ERROR {
    color: var(--color-debt-amber);
}

/* Alert formatting for micro credit crashes */
.metric-value.CRITICAL-SHOCK {
    color: var(--color-error-red);
    animation: flashAlert 1s infinite alternate;
}

@keyframes flashAlert {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

.progress-track {
    width: 100%;
    height: 3px;
    background: var(--border-line);
    margin-top: 3px;
    border-radius: 1px;
}

.progress-fill {
    height: 100%;
    background: var(--text-charcoal);
    width: 0%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dynamic slider fill colors matching adaptive systems */
#barTaxRate {
    background: var(--color-cobalt);
}

/* INTERACTIVE LIVE LEGEND HOVER STATES */
.telemetry-bar-stack {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.demo-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    padding: 6px 8px;
    border-radius: 2px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.01);
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.demo-row:hover {
    background: var(--surface-white);
    border-color: var(--border-line);
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.legend-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.demo-pct {
    font-weight: 700;
}

.micro-status {
    font-size: 0.52rem;
    font-weight: 900;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin-top: 1px;
}

.dot-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}
.dot-indicator.crimson { background-color: var(--color-crimson); }
.dot-indicator.forest { background-color: var(--color-forest); }
.dot-indicator.cobalt { background-color: var(--color-cobalt); }

/* CENTRAL BANK INSTITUTIONAL INTEGRATED MICRO-TERMINAL */
.bank-policy-panel {
    background: #242321; /* Charcoal vintage console block */
    padding: 12px;
    border-radius: 2px;
    border: 1px solid #363431;
}

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

.bank-policy-header h2 {
    color: #9e9b95;
    font-family: monospace;
    font-size: 0.65rem;
    font-weight: bold;
    letter-spacing: 0.06em;
    margin: 0;
    text-transform: uppercase;
}

.bank-sub-telemetry {
    display: flex;
    margin-bottom: 6px;
    border-bottom: 1px solid #363431;
    padding-bottom: 4px;
}

.bank-sub-telemetry small {
    color: #8c8983;
    font-family: monospace;
    font-size: 0.58rem;
}

.bank-sub-telemetry span {
    color: var(--bg-ivory);
}

.policy-toggle-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-label {
    font-family: monospace;
    font-size: 0.58rem;
    color: var(--color-gold);
    font-weight: bold;
}

.btn-toggle {
    background: #3a3835;
    border: 1px solid #4d4a46;
    color: #eae7df;
    font-family: monospace;
    font-size: 0.55rem;
    padding: 2px 5px;
    cursor: pointer;
    border-radius: 1px;
    transition: background 0.1s ease;
}

.btn-toggle:hover {
    background: var(--text-charcoal);
    color: var(--surface-white);
}

.terminal-log {
    font-family: monospace;
    font-size: 0.62rem;
    line-height: 1.4;
    color: #4af626; /* Neo-phosphor amber/green output print */
    height: 56px;
    overflow-y: hidden;
    opacity: 0.88;
    text-shadow: 0 0 2px rgba(74, 246, 38, 0.3);
}

/* DIAGNOSTIC GRAPH SPECIFICATIONS: Stacked column configuration */
.diagnostic-grid-layout {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.canvas-container.diagnostic-container {
    background: var(--surface-white);
    border: 1px solid var(--border-line);
    padding: 0.4rem;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 0.2rem;
    width: 100%; /* Keeps metrics strictly within width profiles */
    height: 110px; /* Locked physical scale constraints */
}

/* Ensures custom engine sub-canvases stretch safely across structural blocks */
.canvas-container.diagnostic-container canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.matrix-mini-map {
    background: #1e1d1c !important; /* Continuous spectrum radar scope vector field */
    border-color: #2c2a29;
}

/* Utility Helpers */
.monospace { font-family: monospace; }
.text-bold { font-weight: bold; }

/* ==========================================================================
   6. MOBILE ARCHITECTURE ENHANCEMENTS & RESPONSIVE BREAKPOINT
   ========================================================================== */

@media (max-width: 1024px) {
    /* 1. Reset root webpage container environments to a standard long fluid text layout */
    html {
        height: auto !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    body {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        position: relative !important;
    }

    /* 2. FORCE LINEAR ARCHITECTURE FROM THE ROOT CONTAINER DOWNWARD */
    .dashboard-grid {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        max-height: none !important;
        min-height: 100vh !important;
        width: 100vw !important;
        overflow: visible !important;
    }

    /* 3. HARD RESET SEMANTIC TAG ARCHITECTURE WITH FLEX FLOW MECHANICS */
    main, 
    aside,
    .panel,
    .theory-panel,
    .simulation-panel,
    .telemetry-panel {
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
        overflow: visible !important;
        
        /* Box model configurations */
        width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-line) !important;
        padding: 1.5rem 1.25rem !important;
        box-sizing: border-box !important;
    }

    /* 4. PHYSICAL LAYOUT REORDER MAPPING COORDINATES (Canvas -> Text Abstract -> Demographics) */
    .simulation-panel {
        order: 1 !important; /* Moves running HTML5 sandbox cleanly to the top position */
        background-color: #faf9f6 !important;
        padding: 1rem 0.75rem !important;
    }
    
    .theory-panel {
        order: 2 !important; /* Plugs structural writeups in the middle row track */
        background-color: var(--bg-ivory) !important;
    }
    
    .telemetry-panel {
        order: 3 !important; /* Anchors sub-canvases and chart diagnostics at the absolute base */
        border-bottom: none !important;
        background-color: #eae7df !important;
    }

    /* 5. INPUT EVENT PASS-THROUGH VALVE */
    .canvas-container,
    .main-sim-container canvas {
        touch-action: pan-y !important; /* Tells mobile viewport: pass vertical swipe patterns to the core browser scroll framework */
    }

    /* 6. FLUID CONTAINER INTERFACE SCALING LAYOUTS */
    .oracle-container,
    .control-bar {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .canvas-container {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin-bottom: 0.75rem !important;
        display: flex !important;
        justify-content: center !important;
    }

    .main-sim-container canvas {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important; /* Keeps the simulation square field layout intact */
    }

    /* 7. ACCESSIBLE SLIDER MECHANICS & EXPANDED BUTTON TOUCH TARGETS */
    .time-controls {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }

    .slider-group {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .slider-group input[type="range"] {
        width: 55% !important;
        height: 24px !important; /* Easier calibration access on phone screens */
    }

    .action-buttons {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
    }

    .btn, .btn-preset, .btn-toggle {
        min-height: 44px !important; /* Standard layout tap metrics rule criteria */
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.78rem !important;
        flex: 1 1 calc(50% - 0.4rem) !important; /* Stacks interactive buttons neatly in grids on small frames */
    }

    /* 8. COMPACT RESPONSIVE VISUAL TYPOGRAPHY PROFILE */
    .brand-header h1 {
        font-size: 1.75rem !important;
        letter-spacing: 0.04em !important;
    }

    .prose-block p {
        text-align: left !important;
    }

    /* 9. SUB-DIAGNOSTIC CHART SCREEN ADAPTATIONS */
    .metric-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; /* Maps telemetry outputs cleanly into two symmetric grid structures */
        gap: 0.6rem !important;
    }

    .diagnostic-grid-layout {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        width: 100% !important;
    }

    .canvas-container.diagnostic-container {
        height: 100px !important;
        width: 100% !important;
        display: flex !important;
    }
}