:root {
    --bg-core: #09090b;
    --bg-panel: #18181b;
    --border-color: #27272a;
    --text-primary: #e4e4e7;
    --text-muted: #71717a;
    --accent: #22d3ee;
    /* Cyan */
    --accent-dim: rgba(34, 211, 238, 0.1);
    --alert: #f43f5e;
    /* Rose */
    --success: #10b981;
    /* Emerald */
    --warning: #f59e0b;
    /* Amber */
    --font-mono: 'JetBrains Mono', monospace;
}

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

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

/* CRT Mesh Overlay */
.monitor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.02) 20%, transparent 80%),
        linear-gradient(rgba(0, 0, 0, 0.1) 50%, transparent 50%);
    background-size: 100% 100%, 10px 10px;
    pointer-events: none;
    z-index: 999;
}

/* HEADER */
header {
    height: 50px;
    background: #000;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 40px;
}

.brand-unit {
    display: flex;
    flex-direction: column;
}

.brand-logo {
    font-weight: 900;
    letter-spacing: 2px;
    color: #fff;
    font-size: 16px;
}

.brand-meta {
    font-size: 10px;
    color: var(--text-muted);
}

.stat-unit-group {
    display: flex;
    gap: 30px;
    margin-left: auto;
}

.stat-unit {
    display: flex;
    flex-direction: column;
    width: 100px;
}

.stat-unit .label {
    font-size: 9px;
    color: var(--text-muted);
}

.stat-unit .value {
    font-weight: bold;
    color: var(--accent);
}

.bar-graph {
    height: 3px;
    background: #333;
    margin-top: 2px;
}

.bar-graph .fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.5s;
}

.time-unit {
    font-weight: bold;
    color: #fff;
    border-left: 1px solid #333;
    padding-left: 20px;
}

/* MAIN GRID */
.main-grid {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR */
.tactical-nav {
    width: 220px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.nav-section {
    color: #555;
    font-size: 10px;
    font-weight: bold;
    margin: 15px 0 5px 5px;
}

.t-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    text-align: left;
    padding: 10px;
    margin-bottom: 2px;
    cursor: pointer;
    font-family: var(--font-mono);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.t-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.t-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

.t-btn.blink-red {
    animation: blinkRed 2s infinite;
    color: var(--alert);
}

@keyframes blinkRed {
    50% {
        opacity: 0.5;
    }
}

.system-log-panel {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    height: 150px;
    display: flex;
    flex-direction: column;
}

.panel-header {
    font-size: 10px;
    color: #555;
    margin-bottom: 5px;
}

.log-feed {
    flex: 1;
    overflow-y: auto;
    font-size: 10px;
    color: var(--text-muted);
}

.log-entry {
    margin-bottom: 3px;
    border-left: 2px solid #333;
    padding-left: 4px;
}

/* VIEWPORT */
.viewport {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #0c0c0e;
    position: relative;
}

.view-layer {
    display: none;
}

.view-layer.active {
    display: block;
}

.layer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.layer-header h2 {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.header-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* AGENT UNITS */
.agents-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.agent-unit {
    width: 200px;
    background: #131316;
    border: 1px solid var(--border-color);
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100px;
}

.unit-status-light {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: absolute;
    top: 10px;
    right: 10px;
    background: #333;
}

.unit-status-light.ok {
    background: var(--success);
    box-shadow: 0 0 5px var(--success);
}

.unit-status-light.idle {
    background: var(--warning);
}

.unit-status-light.wa {
    background: var(--accent);
    animation: pulse 1s infinite;
}

.unit-info h3 {
    font-size: 14px;
    margin-bottom: 2px;
    color: #fff;
}

.unit-info .spec {
    font-size: 10px;
    color: var(--text-muted);
}

.unit-info .status-text {
    font-size: 10px;
    color: var(--accent);
    margin-top: 5px;
}

.unit-graph {
    height: 20px;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMjAiPjxwb2x5bGluZSBwb2ludHM9IjAsMjAgMTAsMTUgMjAsMTggMzAsMTAgNDAsMTUgNTAsNSA2MCwxMiA3MCw4IDgwLDE1IDkwLDEwIDEwMCwxOCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMjJkM2VlIiBzdHJva2Utd2lkdGg9IjEiIG9wYWNpdHk9IjAuMyIvPjwvc3ZnPg==');
    background-size: cover;
    opacity: 0.5;
    margin-top: auto;
}

/* DATA PANELS */
.data-panels {
    display: flex;
    gap: 20px;
}

.data-panel {
    background: #131316;
    border: 1px solid var(--border-color);
    padding: 15px;
    flex: 1;
}

.data-panel.large {
    flex: 2;
}

.panel-title {
    font-size: 11px;
    color: #666;
    margin-bottom: 10px;
    font-weight: bold;
    letter-spacing: 1px;
}

.map-placeholder {
    height: 150px;
    background: #000;
    border: 1px dashed #333;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    font-weight: bold;
}

.resource-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 11px;
}

.progress {
    width: 60%;
    height: 6px;
    background: #222;
}

.progress .bar {
    height: 100%;
    background: var(--accent);
}

/* MODULE GRID */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.t-module {
    background: #131316;
    border: 1px solid var(--border-color);
    padding: 20px;
    cursor: pointer;
    transition: 0.2s;
}

.t-module:hover {
    border-color: var(--accent);
    background: #1a1a20;
}

.t-module.offensive:hover {
    border-color: var(--alert);
}

.t-module h3 {
    font-size: 14px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.t-module p {
    font-size: 11px;
    color: var(--text-muted);
}

/* CHAT TERMINAL */
.chat-terminal {
    background: #000;
    border: 1px solid var(--border-color);
    height: 400px;
    display: flex;
    flex-direction: column;
    font-family: 'Courier New', monospace;
}

.chat-feed {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    color: #aaa;
    font-size: 12px;
}

.chat-feed .Line {
    margin-bottom: 5px;
}

.chat-feed .agent {
    color: var(--accent);
}

.chat-input-line {
    display: flex;
    border-top: 1px solid #333;
    padding: 10px;
    background: #111;
}

.chat-input-line input {
    background: transparent;
    border: none;
    color: #fff;
    flex: 1;
    outline: none;
    font-family: inherit;
}

/* --- NEW MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: #0f0f12;
    border: 1px solid var(--border-color);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    width: 500px;
    max-width: 95%;
}

.modal-header {
    background: #18181b;
    border-bottom: 1px solid var(--border-color);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: #fff;
    font-size: 14px;
    letter-spacing: 1px;
    font-weight: bold;
}

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

.modal-header button:hover {
    color: #fff;
}

.modal-content {
    padding: 20px;
    color: var(--text-primary);
}

.panel-desc {
    font-size: 12px;
    color: #888;
    margin-bottom: 20px;
    line-height: 1.5;
    background: #131316;
    padding: 10px;
    border-left: 3px solid var(--accent);
}

.panel-desc.danger {
    border-color: var(--alert);
    background: rgba(244, 63, 94, 0.05);
}

.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    font-size: 11px;
    color: #aaa;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-input,
.form-select {
    width: 100%;
    background: #000;
    border: 1px solid #333;
    color: #fff;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
}

.t-btn.full-width {
    width: 100%;
    justify-content: center;
    margin-top: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 12px;
}

.t-btn.danger {
    color: var(--alert);
    border-color: rgba(244, 63, 94, 0.3);
}

.t-btn.danger:hover {
    background: rgba(244, 63, 94, 0.1);
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.2);
}

.result-box {
    margin-top: 15px;
    padding: 10px;
    background: #000;
    border: 1px dashed #333;
    font-size: 11px;
    color: #ccc;
    max-height: 150px;
    overflow-y: auto;
    display: none;
}