:root {
    --bg-color: #121212;
    --panel-bg: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #333;
    
    --status-healthy: #2e7d32; /* Muted Green */
    --status-healthy-bg: #1b5e20;
    
    --status-degraded: #f57f17; /* Muted Orange */
    --status-degraded-bg: #e65100;
    
    --status-critical: #c62828; /* Muted Red */
    --status-critical-bg: #b71c1c;

    --difficulty-easy: #2e7d32;
    --difficulty-medium: #f57f17;
    --difficulty-hard: #c62828;
    --difficulty-very-hard: #7b1fa2; /* Purple */
    --difficulty-ultra-hard: #000000; /* Black */
    --difficulty-random: #1976d2; /* Blue */

    --font-mono: "SF Mono", "Monaco", "Inconsolata", "Fira Mono", "Droid Sans Mono", "Source Code Pro", monospace;
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-ui);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

header h2 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-top: 5px;
}

/* Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    grid-template-rows: 1fr 250px;
    gap: 15px;
    flex: 1;
    min-height: 0; /* Important for scroll */
}

/* Panel Styles */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 10px;
    background: #252525;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 1px;
}

/* System Overview (Topology) */
.system-overview {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topology-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px;
}

.component {
    width: 160px;
    height: 60px;
    border: 2px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #2a2a2a;
    transition: all 0.3s ease;
    cursor: default;
}

.comp-label {
    font-size: 0.9rem;
    font-weight: bold;
}

.comp-status {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    margin-top: 4px;
}

/* Component States */
.component.healthy {
    border-color: #444;
    color: var(--text-primary);
}
.component.healthy .comp-status { color: var(--status-healthy); }

.component.degraded {
    border-color: var(--status-degraded);
    background: rgba(245, 127, 23, 0.1);
}
.component.degraded .comp-status { color: var(--status-degraded); }

.component.critical {
    border-color: var(--status-critical);
    background: rgba(198, 40, 40, 0.1);
    animation: pulse 2s infinite;
}
.component.critical .comp-status { color: var(--status-critical); }

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(198, 40, 40, 0); }
    100% { box-shadow: 0 0 0 0 rgba(198, 40, 40, 0); }
}

.connection-line {
    width: 2px;
    background: #444;
}
.connection-line.vertical {
    height: 40px;
}
.connection-split {
    width: 400px; /* Width between cache, queue, and DB */
    height: 2px;
    background: #444;
}
.topology-row {
    display: flex;
    justify-content: space-between;
    width: 560px; /* Aligns with split */
}
.topology-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Metrics Panel */
.metrics-panel {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: row;
    padding: 10px;
    gap: 20px;
}

.metric-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #151515;
    border: 1px solid #333;
}

.metric-label {
    position: absolute;
    top: 5px;
    left: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

canvas {
    width: 100%;
    height: 100%;
}

/* Alert Feed */
.alert-feed {
    grid-column: 1;
    grid-row: 1;
    overflow: hidden;
}

#alert-list {
    list-style: none;
    padding: 0;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column; /* Newest at bottom visually, or we prepend */
}

.alert-item {
    padding: 8px 12px;
    border-bottom: 1px solid #333;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    border-left: 3px solid transparent;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.alert-item.info { border-left-color: #666; color: #bbb; }
.alert-item.warning { border-left-color: var(--status-degraded); color: #fff; background: rgba(245, 127, 23, 0.05); }
.alert-item.critical { border-left-color: var(--status-critical); color: #fff; background: rgba(198, 40, 40, 0.1); }

.alert-time {
    color: #666;
    margin-right: 8px;
    font-size: 0.7rem;
}

/* Decision Panel */
.decision-panel {
    grid-column: 3;
    grid-row: 1;
}

.actions-grid {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    background: transparent;
    border: 1px solid #555;
    color: var(--text-primary);
    padding: 12px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.action-btn:hover:not(:disabled) {
    background: #333;
    border-color: #777;
}

.action-btn:active:not(:disabled) {
    background: #444;
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #333;
    color: #555;
}

.action-feedback {
    margin-top: auto;
    padding: 15px;
    font-size: 0.8rem;
    font-style: italic;
    color: var(--text-secondary);
    border-top: 1px solid #333;
    min-height: 60px;
}

/* Overlay & Post Mortem */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.overlay.hidden {
    display: none;
}

.post-mortem-modal {
    background: #1e1e1e;
    border: 1px solid #444;
    width: 600px;
    max-width: 90%;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.post-mortem-modal h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.severity-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #333;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    border-radius: 4px;
    margin-bottom: 20px;
}

.pm-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

.pm-section h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.pm-section p {
    font-size: 0.9rem;
    line-height: 1.4;
}

.pm-leadership-note {
    margin-top: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--text-secondary);
    font-style: italic;
    color: var(--text-secondary);
}

.pm-analysis {
    margin-bottom: 25px;
    padding: 15px;
    border-left: 3px solid #1976d2;
    background: rgba(25, 118, 210, 0.1);
}

.pm-analysis h3 {
    font-size: 0.9rem;
    color: #64b5f6;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.pm-analysis p {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #e0e0e0;
}

.pm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.pm-item h4 {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 8px;
    font-family: var(--font-mono);
}

.pm-item p {
    font-size: 0.9rem;
    line-height: 1.4;
}

.restart-btn {
    width: 100%;
    padding: 15px;
    background: #e0e0e0;
    color: #000;
    border: none;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
}
.restart-btn:hover {
    background: #fff;
}

/* Author CTA Toast */
.author-cta {
    position: fixed;
    bottom: 50px;
    right: 20px;
    background: var(--panel-bg);
    border: 1px solid #1976d2;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    z-index: 2001; /* Above overlay (1000) and other UI */
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 15px;
    font-size: 0.85rem;
    animation: slideIn 0.5s ease, glow 3s infinite ease-in-out;
    max-width: 350px;
}

.cta-icon {
    font-size: 2rem;
    line-height: 1;
}

.cta-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.author-cta.hidden {
    display: none;
}

.cta-link {
    color: #64b5f6;
    text-decoration: none;
    font-weight: bold;
    align-self: flex-end;
    transition: color 0.2s;
}

.cta-link:hover {
    color: #90caf9;
    text-decoration: underline;
}

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

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(25, 118, 210, 0.2); border-color: rgba(25, 118, 210, 0.5); }
    50% { box-shadow: 0 0 15px rgba(25, 118, 210, 0.5); border-color: rgba(25, 118, 210, 1); }
    100% { box-shadow: 0 0 5px rgba(25, 118, 210, 0.2); border-color: rgba(25, 118, 210, 0.5); }
}

@media (max-width: 1000px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        overflow-y: auto;
    }
    
    .system-overview { grid-column: 1; grid-row: 1; }
    .alert-feed { grid-column: 1; grid-row: 3; height: 300px; }
    .decision-panel { grid-column: 1; grid-row: 4; }
    .metrics-panel { grid-column: 1; grid-row: 2; height: 300px; flex-direction: column; }
    
    .author-cta {
        left: 20px;
        right: 20px;
        bottom: 10px;
        text-align: center;
        align-items: center;
    }
    .cta-link {
        align-self: center;
    }
}

/* Context Window */
.context-window {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85); /* Slightly transparent to see dashboard behind */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; /* Above everything */
}

.context-window.hidden {
    display: none;
}

.context-content {
    background: #252525;
    border: 1px solid var(--border-color);
    width: 600px; /* ~30% of 1920, but fixed width is safer for text */
    max-width: 90%;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.context-content h2 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-primary);
}

.context-content ul {
    margin-bottom: 20px;
    padding-left: 20px;
    list-style: square;
    color: #ccc;
}

.context-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.context-hint-wrapper {
    margin-bottom: 25px;
    border-left: 2px solid #555;
    padding-left: 10px;
}

.context-hint-wrapper summary {
    cursor: pointer;
    color: #888;
    font-size: 0.8rem;
    margin-bottom: 5px;
    outline: none;
}

.context-hint-wrapper summary:hover {
    color: #bbb;
}

.context-hint {
    font-size: 0.8rem;
    color: #bbb;
    font-style: italic;
    margin-top: 5px;
}

.start-btn {
    width: 100%;
    background: var(--text-primary);
    color: var(--bg-color);
    font-weight: bold;
    border: none;
}
.start-btn:hover {
    background: #fff;
}

/* Scenario Selector */
.selector-content {
    background: #1e1e1e;
    border: 1px solid #444;
    width: 800px;
    max-width: 95%;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.selector-content h1 {
    margin-bottom: 30px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1.5rem;
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    width: 100%;
}

.scenario-card {
    background: #252525;
    border: 1px solid #444;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.scenario-card:hover {
    background: #333;
    border-color: #777;
    transform: translateY(-2px);
}

.site-footer {
    text-align: center;
    padding: 10px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-color);
    position: relative;
    z-index: 3000; /* Ensure it's above overlays if desired, or keep it below */
}

.difficulty-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    background: var(--status-healthy-bg);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: bold;
}

.difficulty-badge.easy { background: var(--difficulty-easy); }
.difficulty-badge.medium { background: var(--difficulty-medium); }
.difficulty-badge.hard { background: var(--difficulty-hard); }
.difficulty-badge.very-hard { background: var(--difficulty-very-hard); }
.difficulty-badge.ultra-hard { background: var(--difficulty-ultra-hard); border: 1px solid #c62828; color: #ff5252; }
.difficulty-badge.random { background: var(--difficulty-random); }

.scenario-title {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-primary);
}
