/* --- CORE SYSTEM RESET & VARIABLES --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-black: #000000;
    --bg-panel: rgba(2, 5, 8, 0.85); 
    --grid-line: #0f1e2b;
    --text-muted: #4a6b82;
    --text-main: #7aa5c4;
    --text-bright: #e0f2fe;
    
    --cyan: #00e5ff; --cyan-glow: 0 0 10px rgba(0, 229, 255, 0.6);
    --amber: #ffb000; --amber-glow: 0 0 10px rgba(255, 176, 0, 0.6);
    --green: #00ff66;
    --red: #ff003c; --red-glow: 0 0 12px rgba(255, 0, 60, 0.8);
    
    --font-mono: 'Courier New', Courier, monospace;
}

body, html {
    width: 100vw; min-height: 100dvh;
    background-color: var(--bg-black);
    font-family: var(--font-mono);
    color: var(--text-main); font-size: 9px; 
    overflow-x: hidden; line-height: 1.1;
}

/* --- UTILITIES --- */
.cyan-txt { color: var(--cyan); text-shadow: var(--cyan-glow); }
.amber-txt { color: var(--amber); text-shadow: var(--amber-glow); }
.xl { font-size: 11px; }

/* --- CINEMATIC OPTICS --- */
.crt-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 9999;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%);
    background-size: 100% 3px; box-shadow: inset 0 0 100px rgba(0,0,0,0.9);
}

/* --- BOOT SEQUENCE --- */
#pre-boot {
    position: fixed; inset: 0; background: #000; z-index: 10000;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    font-size: 14px; color: var(--cyan); text-shadow: var(--cyan-glow); padding: 15px;
    
    .boot-box { width: 100%; max-width: 550px; display: flex; flex-direction: column; gap: 5px; }
    .boot-line { opacity: 0; animation: typeIn 0.05s forwards; display: flex; gap: 10px; flex-wrap: wrap;}
    .boot-sys { color: var(--text-muted); }
    .boot-msg { color: var(--text-bright); word-break: break-word;}
}
@keyframes typeIn { to { opacity: 1; } }

/* --- LAYOUT GRID --- */
#ops-container {
    display: grid;
    grid-template-columns: 280px 280px 1fr 300px;
    grid-template-rows: auto 1fr;
    width: 100vw; min-height: 100dvh;
    border: 1px solid var(--grid-line);
    opacity: 0; transition: opacity 0.8s ease-out; z-index: 10; position: relative;
}

.sys-panel {
    background: var(--bg-panel); backdrop-filter: blur(4px);
    border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line);
    display: flex; flex-direction: column; overflow: hidden; position: relative;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.8);
}

/* --- HEADER --- */
.header-bar {
    grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
    padding: 8px 15px; background: #010203; border-bottom: 1px solid var(--cyan);
    box-shadow: 0 2px 15px rgba(0, 229, 255, 0.1); flex-wrap: wrap; gap: 10px; min-height: 40px;

    .header-block { display: flex; gap: 15px; align-items: center; flex-wrap: wrap; }
    .ship-id { color: #fff; font-size: 14px; font-weight: bold; letter-spacing: 2px; text-shadow: var(--cyan-glow); }
    .clock-display { color: var(--cyan); font-weight: bold; text-shadow: var(--cyan-glow); }
    .auth-txt { font-size: 10px; white-space: nowrap; span { color: #fff; text-shadow: 0 0 5px #fff; } }
    .status-ind { background: var(--green); color: #000; padding: 2px 12px; font-weight: bold; transition: 0.3s; box-shadow: 0 0 10px var(--green); white-space: nowrap;}
}

/* --- PANEL COMPONENTS --- */
.p-head {
    background: linear-gradient(90deg, #050a10 0%, transparent 100%);
    color: var(--cyan); padding: 5px 12px; text-transform: uppercase; border-bottom: 1px solid var(--grid-line);
    display: flex; justify-content: space-between; font-weight: bold; letter-spacing: 2px; text-shadow: var(--cyan-glow);
    &.no-border { border-bottom: none; }
}

.p-scroll { padding: 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; overflow-x: hidden; }

.section-lbl { color: var(--text-muted); border-bottom: 1px solid var(--grid-line); margin-bottom: 5px; padding-bottom: 2px; font-weight: bold; font-size: 10px; letter-spacing: 1px;}

.data-table {
    width: 100%; border-collapse: collapse; font-size: 9px;
    td { padding: 4px 0; border-bottom: 1px dotted var(--grid-line); }
    tr td:nth-child(1) { color: var(--text-muted); width: 35px; } 
    tr td:nth-child(2) { color: var(--text-main); } 
    tr td:nth-child(3) { text-align: right; color: #fff; font-weight: bold; white-space: nowrap; text-shadow: 0 0 4px rgba(255,255,255,0.4); } 
}

/* Diodes & Buttons */
.diode { display: inline-block; width: 6px; height: 6px; background: var(--green); margin-right: 5px; box-shadow: 0 0 8px var(--green); border-radius: 50%; flex-shrink: 0;}
.diode.off { background: #111; box-shadow: none; }

.button-group { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.cmd-btn {
    background: #020304; border: 1px solid var(--grid-line); color: var(--text-main); font-family: var(--font-mono); font-size: 9.5px; 
    padding: 8px; text-align: left; cursor: pointer; display: flex; justify-content: space-between; text-decoration: none; transition: 0.2s; text-transform: uppercase;
    &:hover { background: var(--cyan); color: #000; border-color: var(--cyan); box-shadow: var(--cyan-glow); font-weight: bold;}
    &.center { justify-content: center; }
    &.cyan-btn { border-color: var(--cyan); color: var(--cyan); }
    &.active-alert { background: var(--red); color: #fff; border-color: var(--red); box-shadow: var(--red-glow); font-weight: bold;}
}

/* --- HARDWARE VISUALIZERS --- */
.reactor-core {
    width: 100%; height: 90px; display: flex; justify-content: center; align-items: center; position: relative; margin-top: 10px;
    .rc-outer { width: 80px; height: 80px; border-radius: 50%; border: 2px dashed var(--cyan); animation: spin 10s linear infinite; box-shadow: var(--cyan-glow); position: absolute; }
    .rc-inner { width: 60px; height: 60px; border-radius: 50%; border: 2px solid rgba(0,229,255,0.3); border-top-color: var(--amber); animation: spin 2s linear infinite reverse; position: absolute; box-shadow: inset 0 0 15px rgba(255,176,0,0.5); }
    .rc-center { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle, var(--cyan) 0%, transparent 80%); box-shadow: 0 0 20px var(--cyan); position: absolute; animation: pulse 1s infinite alternate; }
    .rc-data { position: absolute; left: 5px; font-size: 9px; color: var(--cyan); text-shadow: var(--cyan-glow); span { font-size:12px; color:#fff;} }
    .rc-data-r { position: absolute; right: 5px; text-align: right; font-size: 9px; color: var(--amber); text-shadow: var(--amber-glow); span { font-size:12px; color:#fff;} }
}

.power-graph-wrapper { width: 100%; height: 45px; border: 1px solid var(--grid-line); background: #000; position: relative; margin-top: 5px; }
#power-canvas { width: 100%; height: 100%; display: block; }

.radial-gauge-container { width: 100%; display: flex; justify-content: center; margin-top: 10px; }
.radial-gauge {
    width: 140px; height: 70px; border-radius: 70px 70px 0 0; border: 2px solid var(--grid-line); border-bottom: none; position: relative; background: radial-gradient(circle at bottom, rgba(0,229,255,0.1) 0%, transparent 100%); overflow: hidden;
    .rg-marks { position: absolute; inset: 0; border-radius: 50%; border: 4px dashed var(--text-muted); opacity: 0.3;}
    .rg-redzone { position: absolute; inset: 0; border-radius: 50%; border: 4px solid transparent; border-right-color: var(--red); transform: rotate(-15deg); opacity: 0.6; }
    .rg-needle { position: absolute; bottom: -2px; left: 50%; width: 2px; height: 60px; background: var(--cyan); transform-origin: bottom center; transform: rotate(-80deg) translateX(-50%); transition: transform 0.2s ease-out; box-shadow: var(--cyan-glow); z-index: 5;}
    .rg-pivot { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); width: 12px; height: 12px; background: var(--bg-panel); border: 2px solid var(--cyan); border-radius: 50%; z-index: 6; }
    .rg-lbl { position: absolute; bottom: 5px; width: 100%; text-align: center; font-size: 8px; color: var(--text-bright); span { color: var(--cyan); font-weight: bold; }}
}

.shield-diagram {
    width: 100%; height: 90px; position: relative; border: 1px solid var(--grid-line); background: radial-gradient(circle, #050a10 0%, #000 100%); display: flex; justify-content: center; align-items: center; margin-top: 5px; overflow: hidden;
    .shield-scan { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, transparent 70%, rgba(0,229,255,0.3) 100%); animation: spin 3s linear infinite; z-index: 0;}
    .shield-hull { width: 18px; height: 50px; border: 1px solid var(--text-main); border-radius: 50%; background: #000; z-index: 2; }
    .s-arc { position: absolute; border: 2px solid var(--cyan); border-radius: 50%; transition: 0.3s; box-shadow: inset 0 0 10px rgba(0,229,255,0.2), 0 0 10px rgba(0,229,255,0.5); z-index: 1;}
    .s-fore { top: 10px; left: 50%; transform: translateX(-50%); width: 50px; height: 25px; border-bottom: none; }
    .s-aft { bottom: 10px; left: 50%; transform: translateX(-50%); width: 50px; height: 25px; border-top: none; }
    .s-port { left: 25%; top: 50%; transform: translateY(-50%); width: 25px; height: 50px; border-right: none; }
    .s-stbd { right: 25%; top: 50%; transform: translateY(-50%); width: 25px; height: 50px; border-left: none; }
}

.tank-bay { display: flex; justify-content: space-between; height: 70px; margin-top: 5px; padding: 0 5px; }
.tank-wrapper {
    display: flex; flex-direction: column; align-items: center; gap: 5px; width: 40px;
    .tank-glass { width: 100%; height: 100%; border: 1px solid var(--cyan); border-radius: 3px; background: rgba(0, 229, 255, 0.05); position: relative; display: flex; align-items: flex-end; overflow: hidden; box-shadow: inset 0 0 10px rgba(0,229,255,0.2); }
    .tank-liquid { width: 100%; background: linear-gradient(0deg, var(--cyan) 0%, rgba(0,229,255,0.4) 100%); transition: height 0.5s linear; box-shadow: 0 -2px 10px var(--cyan); &.h2o { background: linear-gradient(0deg, var(--green) 0%, rgba(0,255,102,0.4) 100%); }}
    .tank-lbl { font-size: 8px; color: var(--text-bright); text-shadow: 0 0 3px #000; font-weight: bold; position: absolute; top: 2px; left: 50%; transform: translateX(-50%); z-index: 2;}
    .tank-sub { font-size: 7px; color: var(--text-muted); }
}

.spectrum-container { width: 100%; height: 50px; border: 1px solid var(--grid-line); background: #000; position: relative; margin-top: 5px; box-shadow: inset 0 0 15px rgba(0,229,255,0.1);}
#spectrum-canvas { width: 100%; height: 100%; display: block; }
.spec-overlay { position: absolute; top: 2px; left: 4px; font-size: 7px; color: rgba(255,255,255,0.5); }

/* --- ASTROMETRICS CENTER --- */
.center-column { display: flex; flex-direction: column; height: 100%; background: #000; position: relative;}
.astro-viewport { 
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    background-image: radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.05) 0%, transparent 60%), linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px); 
    background-size: 100% 100%, 40px 40px, 40px 40px; background-position: center center; position: relative; overflow: hidden; 
}

.earth-3d { width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #1b4b5e 0%, #030e14 70%, #000 100%); border: 1px solid rgba(0,229,255,0.4); position: relative; z-index: 2; box-shadow: 0 0 40px rgba(0,229,255,0.2); }
.orbit-ring-3d { position: absolute; width: 450px; height: 150px; border-radius: 50%; border: 1px solid rgba(122, 165, 196, 0.3); transform: rotateX(74deg); transform-style: preserve-3d; animation: revolve 40s linear infinite; }
.ship-blip-3d { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); width: 10px; height: 10px; background: var(--amber); border-radius: 50%; box-shadow: var(--amber-glow); animation: pulse 1.5s infinite; }
.trajectory-line { position: absolute; bottom: 0; left: 50%; width: 1px; height: 50%; background: linear-gradient(to top, transparent, rgba(255,176,0,0.8)); }
.hud-overlay { position: absolute; top: 15px; left: 15px; font-size: 10px; color: var(--cyan); text-shadow: var(--cyan-glow); &.right { left: auto; right: 15px; text-align: right; } }

.astro-data-panel { padding: 12px; border-top: 1px solid var(--cyan); background: #010203; box-shadow: inset 0 20px 20px rgba(0,229,255,0.05); }
.astro-grid { display: flex; gap: 15px; flex-wrap:wrap; }
.astro-col { flex: 1; min-width: 130px; &.center-align { display:flex; flex-direction:column; align-items:center; } }

.gimbal-container { width: 100%; height: 120px; display: flex; justify-content: center; align-items: center; position: relative; perspective: 400px; margin-bottom: 10px; }
.g-outer { width: 100px; height: 100px; border-radius: 50%; border: 1px solid rgba(0,229,255,0.3); position: absolute; box-shadow: inset 0 0 20px rgba(0,229,255,0.1); }
.g-pitch, .g-yaw, .g-roll { width: 100%; height: 100%; position: absolute; transform-style: preserve-3d; transition: transform 0.1s; }
.g-pitch { border-top: 2px solid var(--cyan); border-bottom: 2px solid var(--cyan); border-radius: 50%; }
.g-yaw { border-left: 2px dashed var(--amber); border-right: 2px dashed var(--amber); border-radius: 50%; }
.g-crosshair { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 20px; height: 2px; background: var(--red); box-shadow: var(--red-glow); &::after { content: ''; position: absolute; top: -9px; left: 9px; width: 2px; height: 20px; background: var(--red); } }
.gimbal-readouts { display:flex; width:100%; justify-content:space-between; font-size:8px; color:var(--text-bright); }

/* --- EVENT LOG & ALERTS --- */
.event-log-container { flex: 1; border: 1px solid var(--grid-line); background: #010101; overflow: hidden; display: flex; flex-direction: column; padding: 8px; margin-top: 5px; min-height: 100px; box-shadow: inset 0 0 15px rgba(0,0,0,1);}
.event-line { display: flex; gap: 10px; font-size: 9px; margin-bottom: 3px; font-family: var(--font-mono);}
.e-time { color: var(--text-muted); } .e-tag { color: var(--cyan); } .e-msg { color: #fff; word-break: break-all;}

.panel-warning-overlay { position: absolute; inset: 0; background: rgba(255, 0, 60, 0.15); border: 2px solid var(--red); display: none; justify-content: center; align-items: center; z-index: 10; color: #fff; font-size: 24px; font-weight: bold; letter-spacing: 8px; text-align: center; backdrop-filter: blur(2px); text-shadow: var(--red-glow); span { font-size: 14px; letter-spacing:4px; text-shadow:none;} }

/* --- ANIMATIONS --- */
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes revolve { 0% { transform: rotateX(74deg) rotateZ(0deg); } 100% { transform: rotateX(74deg) rotateZ(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); } 50% { opacity: 0.5; transform: translateX(-50%) scale(1.2); } }

/* Scrollbars */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: var(--text-muted); }

/* --- MOBILE REFLOW --- */
@media (max-width: 1200px) {
    body, html { overflow-y: auto; overflow-x: hidden;}
    #ops-container { display: flex; flex-direction: column; height: auto; min-height: 100dvh; }
    .center-column { min-height: 500px; order: -1; }
    .data-table { font-size: 8px; tr td:nth-child(3) { font-size: 9px; } }
}