:root {
  --bg: #07080f; --bg2: #0b0e1a; --panel: rgba(15, 19, 36, .78); --panel2: rgba(22, 27, 50, .8);
  --line: rgba(0, 243, 255, .16); --line2: rgba(163, 91, 255, .22);
  --cyan: #00f3ff; --blue: #3d7bff; --purple: #a35bff; --magenta: #ff2bd6; --green: #31ff9a; --amber: #ffb020; --red: #ff3b5c;
  --text: #e6ecff; --muted: #8a93b8; --dim: #566089;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "SFMono-Regular", monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, -apple-system, Roboto, sans-serif;
  --radius: 12px; --glow: 0 0 18px rgba(0, 243, 255, .18);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: radial-gradient(1200px 700px at 80% -10%, rgba(163, 91, 255, .13), transparent 60%), radial-gradient(900px 600px at -10% 110%, rgba(0, 243, 255, .09), transparent 55%), var(--bg); color: var(--text); font: 14px/1.45 var(--sans); overflow: hidden; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .012) 0 1px, transparent 1px 3px); z-index: 50; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: .02em; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .12em; color: var(--cyan); }
h3 { font-size: 13px; color: var(--text); }
a { color: var(--cyan); }
code, kbd { font-family: var(--mono); font-size: .92em; color: var(--cyan); background: rgba(0, 243, 255, .07); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .xs { font-size: 11.5px; } .sm { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

#app { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
#nav { display: flex; flex-direction: column; gap: 14px; padding: 16px 12px; border-right: 1px solid var(--line); background: linear-gradient(180deg, rgba(10, 13, 26, .96), rgba(8, 10, 20, .96)); overflow-y: auto; z-index: 20; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 10px; border-bottom: 1px solid var(--line); }
.brand b { display: block; font-size: 17px; letter-spacing: .06em; background: linear-gradient(90deg, var(--cyan), var(--purple)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { color: var(--muted); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; }
#navlinks { display: flex; flex-direction: column; gap: 4px; }
.navbtn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font: inherit; text-align: left; transition: .18s; }
.navbtn svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.navbtn:hover { color: var(--text); background: rgba(0, 243, 255, .05); }
.navbtn.active { color: var(--cyan); background: linear-gradient(90deg, rgba(0, 243, 255, .12), rgba(163, 91, 255, .06)); border-color: var(--line); box-shadow: var(--glow); }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
#content { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
#topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: rgba(8, 10, 20, .6); backdrop-filter: blur(8px); }
#topbar h1 { font-size: 18px; letter-spacing: .08em; text-transform: uppercase; }
.top-info { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#navtoggle { display: none; }
#views { flex: 1; overflow-y: auto; padding: 18px 22px 40px; scroll-behavior: smooth; }
.view { display: none; animation: fade .28s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 8px 28px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .03); position: relative; }
.card.tiny { padding: 10px 12px; }
.card > h2:first-child, .card > .card-h { margin-bottom: 10px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-h .sub { color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 14px; align-items: start; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.kpi { padding: 12px 14px; }
.kpi .lab { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.kpi .val { font: 600 26px/1.15 var(--mono); color: var(--text); margin-top: 2px; }
.kpi .val small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.kpi .delta { font-size: 11.5px; margin-top: 2px; }
.kpi canvas { width: 100%; height: 34px; margin-top: 6px; display: block; }
.good { color: var(--green); } .bad { color: var(--red); } .warn { color: var(--amber); }

button, select, input { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: rgba(0, 243, 255, .07); color: var(--text); cursor: pointer; transition: .16s; white-space: nowrap; }
.btn:hover:not(:disabled) { background: rgba(0, 243, 255, .16); border-color: rgba(0, 243, 255, .5); box-shadow: var(--glow); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(90deg, rgba(0, 243, 255, .28), rgba(163, 91, 255, .3)); border-color: rgba(0, 243, 255, .55); font-weight: 600; }
.btn.danger { border-color: rgba(255, 59, 92, .4); background: rgba(255, 59, 92, .08); } .btn.danger:hover:not(:disabled) { background: rgba(255, 59, 92, .2); box-shadow: 0 0 16px rgba(255, 59, 92, .25); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 7px 12px; color: var(--muted); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); background: rgba(0, 243, 255, .06); }
.seg button.on { color: #04121a; background: linear-gradient(90deg, var(--cyan), #6fb7ff); font-weight: 600; }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
select, input[type=text], input[type=number], input[type=url] { background: rgba(5, 8, 18, .8); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; }
select:focus, input:focus { border-color: var(--cyan); box-shadow: var(--glow); }
label.fld { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
input[type=range] { accent-color: var(--cyan); width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: rgba(8, 12, 24, .7); font-size: 12px; color: var(--muted); }
.chip.on { color: var(--green); border-color: rgba(49, 255, 154, .35); } .chip.off { color: var(--amber); border-color: rgba(255, 176, 32, .3); } .chip.err { color: var(--red); }
.chip .dot, i.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; display: inline-block; }
.badge { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line2); color: var(--purple); background: rgba(163, 91, 255, .09); }
.badge.cyan { color: var(--cyan); border-color: var(--line); background: rgba(0, 243, 255, .07); } .badge.sim { color: var(--amber); border-color: rgba(255, 176, 32, .35); background: rgba(255, 176, 32, .07); }
.pbar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.pbar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--purple)); transition: width .25s; }

.stage { position: relative; background: #05060d; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: inset 0 0 60px rgba(0, 0, 0, .6); }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage .hud { z-index: 4; position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.stage .hud .chip { background: rgba(5, 7, 16, .78); backdrop-filter: blur(4px); }
.stage .corner { z-index: 4; position: absolute; right: 10px; bottom: 10px; }
.stage-lg { aspect-ratio: 16 / 10; min-height: 340px; } .stage-md { aspect-ratio: 4 / 3; } .stage-sm { aspect-ratio: 16 / 11; }
canvas.chart { width: 100%; height: 220px; display: block; }
canvas.chart.sm { height: 150px; } canvas.chart.lg { height: 280px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th { text-align: right; color: var(--muted); font-weight: 500; letter-spacing: .06em; font-size: 11px; text-transform: uppercase; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td { text-align: right; padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, .04); font-family: var(--mono); }
table.t td:first-child { font-family: var(--sans); }
table.t tr.hl td { background: rgba(0, 243, 255, .05); }
table.t td.best { color: var(--green); font-weight: 600; }
.scroll-x { overflow-x: auto; }

.phase-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.phase-btn { padding: 8px 6px; border-radius: 9px; border: 1px solid var(--line); background: rgba(8, 12, 24, .7); color: var(--muted); cursor: pointer; text-align: center; font-size: 12px; }
.phase-btn b { display: block; color: var(--text); font-size: 12.5px; }
.phase-btn.cur { border-color: var(--green); color: var(--green); box-shadow: 0 0 14px rgba(49, 255, 154, .2); } .phase-btn.cur b { color: var(--green); }
.phase-btn.pend { border-color: var(--amber); color: var(--amber); }
.phase-btn:disabled { cursor: default; }
.lane-bars { display: grid; gap: 7px; }
.lane { display: grid; grid-template-columns: 78px 1fr 36px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.lane .pbar { height: 8px; }
.lane .pbar > i { background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); background-size: 300px 100%; }
.light { display: inline-flex; flex-direction: column; gap: 3px; padding: 4px; background: #05060d; border-radius: 6px; border: 1px solid var(--line); }
.light i { width: 9px; height: 9px; border-radius: 50%; background: #1a1d2c; } .light i.r.on { background: var(--red); box-shadow: 0 0 8px var(--red); } .light i.a.on { background: var(--amber); box-shadow: 0 0 8px var(--amber); } .light i.g.on { background: var(--green); box-shadow: 0 0 8px var(--green); }

.mission { display: grid; grid-template-columns: 54px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; transition: .18s; }
.mission:hover:not(.locked) { border-color: rgba(0, 243, 255, .5); box-shadow: var(--glow); transform: translateY(-1px); }
.mission.locked { opacity: .5; cursor: not-allowed; }
.mission.sel { border-color: var(--cyan); box-shadow: var(--glow); }
.mission .num { width: 54px; height: 54px; border-radius: 12px; display: grid; place-items: center; font: 700 22px var(--mono); color: var(--cyan); background: radial-gradient(circle, rgba(0, 243, 255, .16), rgba(163, 91, 255, .06)); border: 1px solid var(--line); }
.stars { color: var(--dim); letter-spacing: 3px; font-size: 16px; } .stars .on { color: var(--amber); text-shadow: 0 0 10px rgba(255, 176, 32, .6); }
.mission h3 { font-size: 14.5px; } .mission p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.obj { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 4px 0; } .obj .tick { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--dim); flex: none; margin-top: 2px; display: grid; place-items: center; font-size: 10px; }
.obj.ok .tick { background: var(--green); color: #04140c; border-color: var(--green); }
.drop { border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: .18s; }
.drop:hover, .drop.over { border-color: var(--cyan); background: rgba(0, 243, 255, .05); color: var(--text); }
.callout { border-left: 3px solid var(--purple); background: rgba(163, 91, 255, .07); padding: 9px 12px; border-radius: 0 8px 8px 0; font-size: 12.5px; color: var(--muted); }
.callout.warn { border-color: var(--amber); background: rgba(255, 176, 32, .07); } .callout.good { border-color: var(--green); background: rgba(49, 255, 154, .06); }

.modal { position: fixed; inset: 0; background: rgba(2, 3, 8, .72); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal-card { width: min(780px, 100%); max-height: 92vh; overflow-y: auto; background: linear-gradient(180deg, #10142a, #0a0d1c); border: 1px solid rgba(0, 243, 255, .35); border-radius: 16px; padding: 22px 24px; box-shadow: 0 0 60px rgba(0, 243, 255, .12), 0 30px 80px rgba(0, 0, 0, .6); animation: pop .22s ease; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 120; }
.toast { background: rgba(10, 14, 28, .95); border: 1px solid var(--line); border-left: 3px solid var(--cyan); padding: 10px 14px; border-radius: 9px; max-width: 360px; animation: pop .2s ease; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.toast.err { border-left-color: var(--red); } .toast.good { border-left-color: var(--green); }
.slider-row { display: grid; grid-template-columns: 110px 1fr 38px; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.slider-row output { font-family: var(--mono); color: var(--text); text-align: right; }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--cyan); border-bottom-color: var(--cyan); }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: rgba(0, 243, 255, .18); border-radius: 8px; } ::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1180px) { .split { grid-template-columns: 1fr; } .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  #nav { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; transform: translateX(-102%); transition: transform .22s; box-shadow: 10px 0 40px rgba(0, 0, 0, .6); }
  #nav.open { transform: none; }
  #navtoggle { display: inline-block; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  #views { padding: 14px 12px 40px; } #topbar { padding: 10px 12px; } .stage-lg { min-height: 260px; }
  .mission { grid-template-columns: 44px 1fr; } .mission > :last-child { grid-column: 1 / -1; }
}
