* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --phosphor: #7cff6b;
  --phosphor-dim: #3a8a30;
  --phosphor-bright: #c8ffbe;
  --bg: #050805;
  --status-green: #7cff6b;
  --status-red: #ff4040;
}

html, body {
  height: 100%;
  background: #000;
  font-family: 'Courier New', 'Lucida Console', monospace;
  color: var(--phosphor);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.crt {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: radial-gradient(ellipse at center, #111 0%, #000 100%);
}

.screen {
  position: relative;
  width: 100%;
  max-width: 1000px;
  height: 100%;
  max-height: 800px;
  background: var(--bg);
  border: 2px solid #222;
  border-radius: 20px / 24px;
  box-shadow:
    inset 0 0 80px rgba(124, 255, 107, 0.1),
    inset 0 0 20px rgba(0,0,0,0.9),
    0 0 30px rgba(124, 255, 107, 0.15);
  overflow: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.2) 0px,
    rgba(0,0,0,0.2) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 10;
}

.screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(124, 255, 107, 0.02);
  pointer-events: none;
  z-index: 11;
  animation: flicker 0.1s infinite;
}

@keyframes flicker {
  0%   { opacity: 0.95; }
  50%  { opacity: 1.0; }
  100% { opacity: 0.97; }
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.7) 100%);
}

header {
  text-align: center;
  padding-bottom: 12px;
  flex-shrink: 0;
  text-shadow: 0 0 6px var(--phosphor);
}
header h1 {
  font-size: clamp(12px, 3vw, 18px);
  letter-spacing: 3px;
  color: var(--phosphor-bright);
}
header .sub {
  font-size: clamp(9px, 2vw, 11px);
  color: var(--phosphor-dim);
  margin-top: 2px;
  letter-spacing: 2px;
}

.top-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor-dim);
  font-family: inherit;
  font-size: clamp(11px, 2.8vw, 15px);
  padding: 12px 8px;
  letter-spacing: 1px;
  cursor: pointer;
  text-shadow: 0 0 2px var(--phosphor-dim);
  transition: all 0.15s ease;
  text-align: center;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  border-color: var(--phosphor);
  color: var(--phosphor);
  background: rgba(124, 255, 107, 0.05);
}

.nav-btn.active {
  border-color: var(--phosphor-bright);
  color: var(--phosphor-bright);
  background: rgba(124, 255, 107, 0.12);
  box-shadow: 0 0 15px rgba(124, 255, 107, 0.3), inset 0 0 15px rgba(124, 255, 107, 0.1);
  text-shadow: 0 0 8px var(--phosphor-bright);
  font-weight: bold;
}

.sub-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.sub-buttons.hidden {
  display: none;
}

.sub-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor-dim);
  font-family: inherit;
  font-size: clamp(10px, 2.5vw, 13px);
  padding: 10px 8px;
  letter-spacing: 1px;
  cursor: pointer;
  text-shadow: 0 0 2px var(--phosphor-dim);
  transition: all 0.15s ease;
  text-align: center;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sub-btn:hover {
  border-color: var(--phosphor);
  color: var(--phosphor);
  background: rgba(124, 255, 107, 0.05);
}

.sub-btn.active {
  border-color: var(--phosphor);
  color: var(--phosphor);
  background: rgba(124, 255, 107, 0.08);
  box-shadow: 0 0 10px rgba(124, 255, 107, 0.2);
  text-shadow: 0 0 6px var(--phosphor);
}

/* Power Distribution rows */
.power-row {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.row-label {
  color: var(--phosphor-dim);
  font-size: clamp(8px, 2vw, 10px);
  letter-spacing: 2px;
  padding-right: 4px;
  min-width: 70px;
  text-shadow: 0 0 2px var(--phosphor-dim);
}

.sub-sub-btn {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor-dim);
  font-family: inherit;
  font-size: clamp(9px, 2.5vw, 12px);
  padding: 6px 2px;
  letter-spacing: 1px;
  cursor: pointer;
  text-shadow: 0 0 2px var(--phosphor-dim);
  transition: all 0.15s ease;
  text-align: center;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sub-sub-btn:hover {
  background: rgba(124, 255, 107, 0.05);
}

.sub-sub-btn.active {
  box-shadow: 0 0 10px rgba(124, 255, 107, 0.2);
}

/* Breaker buttons */
.breaker-btn {
  flex: 0 1 auto;
  min-width: 32px;
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor-dim);
  font-family: inherit;
  font-size: clamp(8px, 2vw, 10px);
  padding: 4px 4px;
  letter-spacing: 0;
  cursor: pointer;
  text-shadow: 0 0 2px var(--phosphor-dim);
  transition: all 0.15s ease;
  text-align: center;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.breaker-btn:hover {
  background: rgba(124, 255, 107, 0.05);
}

.breaker-btn.active {
  box-shadow: 0 0 8px rgba(124, 255, 107, 0.3);
}

/* ============================================================
   STATUS COLOR CLASSES (applied to grid/breaker buttons)
   ============================================================ */

.status-online {
  border-color: var(--status-green) !important;
  color: var(--status-green) !important;
  text-shadow: 0 0 4px var(--status-green) !important;
  background: rgba(124, 255, 107, 0.08);
}

.status-online.active {
  background: rgba(124, 255, 107, 0.2);
  box-shadow: 0 0 12px var(--status-green), inset 0 0 8px rgba(124, 255, 107, 0.15) !important;
}

.status-offline,
.status-tripped {
  border-color: var(--status-red) !important;
  color: var(--status-red) !important;
  text-shadow: 0 0 4px var(--status-red) !important;
  background: rgba(255, 64, 64, 0.08);
}

.status-offline.active,
.status-tripped.active {
  background: rgba(255, 64, 64, 0.2);
  box-shadow: 0 0 12px var(--status-red), inset 0 0 8px rgba(255, 64, 64, 0.15) !important;
}

/* Readout */
.readout-area {
  flex: 1;
  border: 1px solid var(--phosphor-dim);
  padding: 16px;
  font-size: clamp(12px, 2.8vw, 15px);
  line-height: 1.6;
  background: rgba(124, 255, 107, 0.02);
  overflow-y: auto;
  text-shadow: 0 0 4px var(--phosphor);
  position: relative;
}

.readout-area .line {
  white-space: pre-wrap;
  margin-bottom: 2px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.readout-area .header-line {
  color: var(--phosphor-bright);
  font-weight: bold;
  border-bottom: 1px dashed var(--phosphor-dim);
  padding-bottom: 4px;
  margin-bottom: 8px;
  display: block;
}

.readout-area .warn { color: #ffb347; text-shadow: 0 0 4px #ffb347; }

.action-btn {
  background: transparent;
  border: 1px solid var(--phosphor);
  color: var(--phosphor);
  font-family: inherit;
  font-size: clamp(10px, 2.5vw, 12px);
  padding: 2px 10px;
  margin-left: 8px;
  cursor: pointer;
  text-shadow: 0 0 4px var(--phosphor);
  transition: all 0.15s ease;
  letter-spacing: 1px;
}

.action-btn:hover {
  background: rgba(124, 255, 107, 0.2);
  box-shadow: 0 0 8px var(--phosphor);
}

.action-btn:active {
  background: rgba(124, 255, 107, 0.4);
  transform: scale(0.98);
}

.action-btn:disabled {
  border-color: var(--phosphor-dim);
  color: var(--phosphor-dim);
  text-shadow: none;
  cursor: not-allowed;
  background: transparent;
}

footer {
  border-top: 1px solid var(--phosphor-dim);
  padding-top: 8px;
  margin-top: 12px;
  font-size: clamp(9px, 2vw, 11px);
  color: var(--phosphor-dim);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  letter-spacing: 1px;
}

.readout-area::-webkit-scrollbar { width: 6px; }
.readout-area::-webkit-scrollbar-track { background: transparent; }
.readout-area::-webkit-scrollbar-thumb { background: var(--phosphor-dim); border-radius: 3px; }

@media (max-width: 480px) {
  .screen { padding: 12px; border-radius: 12px / 16px; }
  .nav-btn { padding: 10px 4px; font-size: 11px; letter-spacing: 0; min-height: 44px; }
  .sub-btn { padding: 8px 4px; font-size: 10px; min-height: 36px; }
  .sub-sub-btn { padding: 5px 2px; font-size: 10px; min-height: 28px; }
  .breaker-btn { min-width: 26px; padding: 3px 2px; font-size: 9px; min-height: 22px; }
  .row-label { min-width: 55px; font-size: 8px; }
  .readout-area { padding: 12px; font-size: 12px; }
  .action-btn { margin-top: 4px; width: 100%; text-align: center; margin-left: 0; }
}

/* Life Support Status Colors */
.status-ok {
    color: #00ff00; /* Bright green */
}

.status-warn {
    color: #ffaa00; /* Amber/yellow */
}

.status-crit {
    color: #ff0000; /* Red */
    font-weight: bold;
}

/* Optional: Add a pulsing animation for critical states */
.status-crit {
    animation: pulse-critical 1s infinite;
}

@keyframes pulse-critical {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}