:root {
  --bg: #050b14;
  --panel: #0a1522;
  --panel2: #0d1c2d;
  --line: #16344d;
  --cy: #3de0ff;
  --ok: #3dffa0;
  --warn: #ffb02e;
  --crit: #ff4a5e;
  --tx: #cfe6f5;
  --dim: #6f8da5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--tx);
  font: 13px/1.35 "Segoe UI", Roboto, Arial, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 14px;
  background: linear-gradient(180deg, #0c1d30, #07111d);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; gap: 10px; align-items: center; }
.logo { font-size: 28px; color: var(--cy); text-shadow: 0 0 10px var(--cy); }
h1 { margin: 0; font-size: 15px; letter-spacing: 2px; color: var(--cy); }
.brand p { margin: 0; font-size: 11px; color: var(--dim); }

.top-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

select, .btn, .speed button {
  background: #0e2238;
  color: var(--tx);
  border: 1px solid #1f4a6b;
  border-radius: 5px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}

.btn:hover, .speed button:hover, select:hover {
  border-color: var(--cy);
  background: #12304d;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.speed { display: flex; }
.speed button { border-radius: 0; }
.speed button:first-child { border-radius: 5px 0 0 5px; }
.speed button:last-child { border-radius: 0 5px 5px 0; }
.speed button.active { background: var(--cy); color: #02202c; font-weight: 700; }

#clock { min-width: 210px; text-align: right; }
#clockMain { font: 700 16px Consolas, monospace; color: var(--ok); }
#clockSub { font-size: 11px; color: var(--dim); }

.progress {
  height: 5px;
  background: #10263a;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 3px;
}

.progress > div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1fa6d6, var(--ok));
  transition: width 0.2s;
}

/* Main 3-Column Layout */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 360px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  overflow-y: auto;
  padding: 8px 12px 14px;
  min-height: 0;
}

#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); }

.panel h2 {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--cy);
  margin: 12px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.panel h2:first-child { margin-top: 4px; }
#center { position: relative; min-width: 0; min-height: 0; background: #030810; }
#view { position: absolute; left: 0; top: 0; display: block; }

/* Left Panel Controls */
.ctl {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  margin-bottom: 8px;
}

.ctl-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ctl label { font-weight: 600; font-size: 12px; }
.ctl-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); }
.ctl-val { font: 11px Consolas, monospace; color: var(--cy); min-height: 15px; margin-top: 2px; }
input[type=range] { width: 100%; accent-color: var(--cy); margin: 5px 0 0; }

.help {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--cy);
  background: #0a2438;
  color: var(--cy);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.help:hover { background: var(--cy); color: #02202c; }
.btn.wide { display: block; width: 100%; margin: 6px 0 0; text-align: left; }
.eva-bar { margin: 7px 0 2px; }
.eva-bar > div { background: linear-gradient(90deg, #ff9f1c, #ffd23d); }

.load-row { display: flex; align-items: center; gap: 6px; font: 11px Consolas, monospace; margin: 3px 0; }
.load-row span:first-child { width: 78px; color: var(--dim); }
.load-row span:last-child { width: 44px; text-align: right; }
.load-row .bar { flex: 1; height: 6px; background: #10263a; border-radius: 3px; overflow: hidden; }
.load-row .bar i { display: block; height: 100%; background: #ffd23d; }
.load-row.gen .bar i { background: var(--ok); }

/* Right Panel Telemetry Cards, Stores, Assistant & Log */
#cards { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.card {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  border-radius: 5px;
  padding: 6px 8px;
  min-width: 0;
}

.card.warn { border-left-color: var(--warn); }
.card.crit { border-left-color: var(--crit); animation: pulse 1s infinite; }
@keyframes pulse { 50% { background: #2a1019; } }

.card h4 {
  margin: 0;
  font-size: 10px;
  color: var(--dim);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .val { font: 700 17px Consolas, monospace; color: #fff; }
.card.warn .val { color: var(--warn); }
.card.crit .val { color: var(--crit); }
.card .unit { font-size: 10px; color: var(--dim); margin-left: 4px; }
.card .dbar { height: 4px; background: #10263a; border-radius: 2px; margin: 4px 0; overflow: hidden; }
.card .dbar i { display: block; height: 100%; background: var(--ok); }
.card.warn .dbar i { background: var(--warn); }
.card.crit .dbar i { background: var(--crit); }
.card .rate { font: 10px Consolas, monospace; color: var(--dim); white-space: nowrap; }

#stores { font: 11px Consolas, monospace; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; color: var(--dim); }
#stores b { color: var(--tx); font-weight: 600; }

#assistant { display: flex; flex-direction: column; gap: 6px; }
.adv { padding: 6px 8px; border-radius: 5px; font-size: 12px; border: 1px solid; background: #0c1a2a; }
.adv.info { border-color: #1f6a4a; color: #9fe8c4; }
.adv.warn { border-color: #8a5d10; background: #251a08; color: #ffd48a; }
.adv.crit { border-color: #8a1e2e; background: #2a0d14; color: #ff9aa8; }

#log { font: 11px Consolas, monospace; max-height: 150px; overflow-y: auto; color: var(--dim); }
#log div { padding: 1px 0; }
#log .crit { color: var(--crit); }
#log .warn { color: var(--warn); }
#log .ok { color: var(--ok); }

/* Modal Window */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 12, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#modal.hidden { display: none; }

.modal-box {
  position: relative;
  background: #0a1a2b;
  border: 1px solid var(--cy);
  border-radius: 8px;
  max-width: 600px;
  width: 92%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 18px 22px;
  box-shadow: 0 0 36px rgba(61, 224, 255, 0.25);
}

.modal-box h2 { margin: 0 0 10px; color: var(--cy); font-size: 17px; }
.modal-box p, .modal-box li { font-size: 13px; line-height: 1.5; }
.modal-box .tag { display: inline-block; font-size: 10px; letter-spacing: 1px; color: #02202c; background: var(--cy); border-radius: 3px; padding: 1px 6px; margin-bottom: 6px; }
.modal-box code { background: #10263a; padding: 1px 5px; border-radius: 3px; color: var(--ok); }
#modalClose { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--dim); font-size: 20px; cursor: pointer; }
#modalActions { margin-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }
