/* ══════════════════════════════════════════════════════════════════════
   NERV MAGI SYSTEM — EVA Theme
   ══════════════════════════════════════════════════════════════════════ */

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

:root {
  --bg:        #030d0f;
  --bg-panel:  #040f12;
  --bg-card:   #071419;
  --orange:    #ff6000;
  --orange2:   #ff8c00;
  --orange-lo: rgba(255,96,0,0.12);
  --orange-dim:#7a2e00;
  --teal:      #00b4c8;
  --teal-dim:  #004a52;
  --text:      #b8d4d8;
  --text-dim:  #486870;
  --border:    #0f2830;
  --danger:    #ff2244;
  --warn:      #ffcc00;
  --green:     #00ff88;
  --font:      'Courier New', 'Lucida Console', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  overflow: hidden;
  user-select: none;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── PIN Screen ──────────────────────────────────────────────────────────── */
#pin-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  background-image:
    radial-gradient(ellipse at center, rgba(255,96,0,0.04) 0%, transparent 70%);
}

.pin-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 52px 72px;
  border: 1px solid var(--orange-dim);
  position: relative;
  background: rgba(255,96,0,0.02);
  box-shadow:
    0 0 60px rgba(255,96,0,0.08),
    inset 0 0 60px rgba(255,96,0,0.02);
}

/* Corner accents */
.pin-panel::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 24px; height: 24px;
  border-top: 2px solid var(--orange);
  border-left: 2px solid var(--orange);
}
.pin-panel::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 24px; height: 24px;
  border-bottom: 2px solid var(--orange);
  border-right: 2px solid var(--orange);
}

.nerv-hex-logo { filter: drop-shadow(0 0 8px var(--orange)); }
.pin-logo svg  { filter: drop-shadow(0 0 12px var(--orange)); }

.pin-title {
  font-size: 18px;
  font-weight: bold;
  color: var(--orange);
  letter-spacing: 0.25em;
  text-shadow: 0 0 12px var(--orange);
}

.pin-subtitle {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
}

.pin-alert {
  font-size: 10px;
  color: var(--danger);
  letter-spacing: 0.1em;
  animation: blink 1.2s step-end infinite;
}

.pin-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.pin-label {
  font-size: 10px;
  color: var(--teal);
  letter-spacing: 0.25em;
}

.pin-dots {
  display: flex;
  gap: 18px;
}

.dot {
  width: 18px; height: 18px;
  border: 2px solid var(--orange-dim);
  border-radius: 50%;
  transition: all 0.1s;
}

.dot.on {
  background: var(--orange);
  border-color: var(--orange);
  box-shadow: 0 0 12px var(--orange);
}

#pin-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px; height: 1px;
}

#pin-error {
  height: 16px;
  font-size: 10px;
  color: var(--danger);
  letter-spacing: 0.1em;
  text-align: center;
}

.pin-footer {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.2em;
  margin-top: 10px;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
#app {
  display: none;
  flex-direction: column;
  height: 100vh;
}

#app.up { display: flex; }

/* Header */
#header {
  display: flex;
  align-items: center;
  height: 54px;
  min-height: 54px;
  padding: 0 14px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--orange);
  gap: 12px;
  box-shadow: 0 2px 24px rgba(255,96,0,0.15);
  flex-shrink: 0;
}

.hdr-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.nerv-hex-logo { filter: drop-shadow(0 0 6px var(--orange)); }

.hdr-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hdr-main {
  font-size: 15px;
  font-weight: bold;
  color: var(--orange);
  letter-spacing: 0.2em;
  text-shadow: 0 0 10px var(--orange);
}

.hdr-sub {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
}

.hdr-magi {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.magi-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 16px;
  background: transparent;
  border: 1px solid var(--orange-dim);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.15s;
  transform: skewX(-8deg);
  clip-path: none;
}

.magi-btn > * { transform: skewX(8deg); display: inline-block; }

.magi-btn:hover {
  border-color: var(--orange);
  color: var(--text);
  background: var(--orange-lo);
}

.magi-btn.active {
  background: var(--orange-lo);
  border-color: var(--orange);
  color: var(--orange);
  box-shadow: 0 0 14px rgba(255,96,0,0.3), inset 0 0 14px rgba(255,96,0,0.05);
}

.magi-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--orange-dim);
  flex-shrink: 0;
}

.magi-btn.active .magi-dot {
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange);
  animation: blink 1.5s ease-in-out infinite;
}

.hdr-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex: 0 0 auto;
}

.online-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  color: var(--green);
  letter-spacing: 0.1em;
}

.online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 2s ease-in-out infinite;
}

#hdr-clock {
  font-size: 13px;
  color: var(--teal);
  letter-spacing: 0.15em;
}

/* Main */
#main {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Monitor section */
#monitor {
  display: flex;
  flex-direction: column;
  width: 50%;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.panel-tabs {
  display: flex;
  height: 30px;
  min-height: 30px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ptab {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.12s;
}

.ptab:hover { background: var(--orange-lo); color: var(--text); }

.ptab.active {
  background: var(--orange-lo);
  color: var(--orange);
  border-bottom: 2px solid var(--orange);
}

/* Panels */
.panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel.active { display: flex; }

.viz {
  flex: 0 0 56%;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  min-height: 0;
  overflow: hidden;
}

.tbl {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  overflow: hidden;
  min-height: 0;
}

.sec-title {
  font-size: 8px;
  color: var(--teal);
  letter-spacing: 0.2em;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--teal-dim);
  margin-bottom: 6px;
  flex-shrink: 0;
}

/* Chart */
.chart-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

.chart-wrap canvas {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

/* Cores grid */
.cores-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
  padding-top: 4px;
}

.core-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.core-bar {
  width: 26px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--teal-dim);
  position: relative;
  overflow: hidden;
}

.core-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  transition: height 0.4s;
}

.core-lbl {
  font-size: 7px;
  color: var(--text-dim);
}

/* Memory */
.mem-wrap { flex-shrink: 0; padding-bottom: 8px; }

.mem-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  padding-bottom: 4px;
}

.mem-track {
  height: 10px;
  background: var(--bg-card);
  border: 1px solid var(--teal-dim);
  overflow: hidden;
}

.mem-fill {
  height: 100%;
  background: linear-gradient(to right, var(--teal), var(--orange));
  transition: width 0.5s;
}

/* Data tables */
.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.dt th {
  text-align: left;
  padding: 3px 6px;
  color: var(--teal);
  border-bottom: 1px solid var(--teal-dim);
  font-size: 8px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
}

.dt td {
  padding: 2px 6px;
  border-bottom: 1px solid rgba(15,40,48,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.dt tr:hover td { background: var(--orange-lo); }
.hi  { color: var(--danger) !important; }
.mid { color: var(--warn)   !important; }
.lo  { color: var(--green)  !important; }

/* tbl area scrollable */
.tbl { overflow-y: auto; }

/* Hex grid */
.hex-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
  overflow: hidden;
  flex: 1;
}

.hx {
  width: 52px;
  height: 60px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  text-align: center;
  transition: background 0.4s;
  line-height: 1.4;
}

/* Disk gauges */
.disk-gauges {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-content: flex-start;
  overflow: hidden;
  flex: 1;
}

.dg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.dg svg { filter: drop-shadow(0 0 4px rgba(255,96,0,0.4)); }
.dg-lbl { font-size: 8px; color: var(--text-dim); max-width: 88px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-sz  { font-size: 8px; color: var(--text-dim); }

/* Vertical divider */
.vdivider {
  width: 2px;
  flex-shrink: 0;
  background: linear-gradient(to bottom,
    transparent 0%, var(--orange) 15%,
    var(--orange) 85%, transparent 100%);
}

/* Terminal panel */
#terminal-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  background: #020a0c;
}

.term-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--orange-dim);
  flex-shrink: 0;
}

.term-hdr-left {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  color: var(--orange);
  letter-spacing: 0.12em;
}

.term-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 6px var(--orange);
  flex-shrink: 0;
  animation: blink 1.8s ease-in-out infinite;
}

.term-status-badge {
  font-size: 8px;
  color: var(--green);
  letter-spacing: 0.15em;
}

#term-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.ti {
  position: absolute;
  inset: 6px;
  display: none;
}

.ti.active { display: block; }

/* xterm overrides */
.xterm { height: 100%; }
.xterm-viewport { background: transparent !important; }
.xterm-screen canvas { background: transparent !important; }

/* Footer */
#footer {
  display: flex;
  align-items: center;
  height: 22px;
  min-height: 22px;
  padding: 0 10px;
  background: var(--bg-card);
  border-top: 1px solid var(--orange-dim);
  gap: 6px;
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

#footer b  { color: var(--orange); font-weight: normal; }
.fsep      { color: var(--border); }
.f-brand   { color: var(--teal); margin-left: auto; animation: blink 3s step-end infinite; }

/* Animations */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-8px); }
  40%,80% { transform: translateX(8px); }
}

/* Scrollbar */
::-webkit-scrollbar            { width: 5px; height: 5px; }
::-webkit-scrollbar-track      { background: var(--bg); }
::-webkit-scrollbar-thumb      { background: var(--teal-dim); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover{ background: var(--orange-dim); }
