:root {
  --bg: #0b1017;
  --panel: #121a24;
  --panel-2: #172231;
  --line: #243244;
  --text: #dfe8f3;
  --muted: #8ea1b8;
  --accent: #3fb6ff;
  --accent-2: #f4a534;
  --good: #3ecf8e;
  --bad: #ff6b6b;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.7rem 1.2rem; background: linear-gradient(90deg, #0f1824, #13253a);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 0.78rem; }
.logo { font-size: 1.8rem; color: var(--accent); }
nav { display: flex; gap: 0.3rem; flex-wrap: wrap; align-items: center; }
nav button, nav a {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 0.45rem 0.8rem; border-radius: 6px; cursor: pointer; font-size: 0.85rem; text-decoration: none;
}
nav button:hover, nav a:hover { color: var(--text); border-color: var(--line); }
nav button.active { color: var(--text); background: var(--panel-2); border-color: var(--line); }
nav a.gh { color: var(--accent); }

main { flex: 1; padding: 1rem; }
.tab { display: none; }
.tab.active { display: block; }

.layout { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem; }
.controls { display: flex; flex-direction: column; gap: 0.7rem; align-self: start; }
.controls label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); }
.controls label.inline { flex-direction: row; align-items: center; gap: 0.4rem; }
select, input[type="range"], textarea { width: 100%; }
select, textarea {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem;
}
textarea { min-height: 280px; font-family: "Consolas", monospace; font-size: 0.72rem; }
input[type="range"] { accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.6rem; }
fieldset legend { color: var(--muted); font-size: 0.78rem; padding: 0 0.3rem; }
.slice { display: grid; grid-template-columns: 14px 1fr 1fr; gap: 0.3rem; align-items: center; font-size: 0.75rem; color: var(--muted); }
.value { color: var(--text); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 0.5rem; align-items: center; }
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 0.45rem 0.9rem; cursor: pointer; font-size: 0.85rem;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: #145a86; border-color: #1d7ab5; }
.btn:disabled { opacity: 0.5; cursor: default; }
.muted { color: var(--muted); }
.small { font-size: 0.76rem; }
.hidden { display: none; }

.legend-bar { height: 12px; border-radius: 4px; border: 1px solid var(--line); }
.legend-labels { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }

.stage { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.canvas3d {
  position: relative; height: 58vh; min-height: 380px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: radial-gradient(circle at 50% 30%, #1a2a3e, #080c12);
}
.canvas3d canvas { display: block; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.label3d {
  position: absolute; transform: translate(-50%, -120%); font-size: 0.7rem; padding: 1px 5px; border-radius: 4px;
  background: rgba(10, 16, 24, 0.8); border: 1px solid var(--line); pointer-events: none; white-space: nowrap;
}

.charts { display: grid; gap: 1rem; }
.charts.one { grid-template-columns: 1fr; margin-top: 1rem; }
.charts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.charts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 1rem; }
@media (max-width: 900px) { .charts.two, .charts.three { grid-template-columns: 1fr; } }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem; height: 280px; }
.charts.one .chart-card { height: 340px; }

.stats { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem; line-height: 1.5; }
.stats b { color: var(--text); }
.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.intro h2 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.intro p { margin: 0 0 0.6rem; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.kpis { display: flex; gap: 0.7rem; flex-wrap: wrap; }
.kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.8rem; min-width: 150px; }
.kpi .k { font-size: 0.72rem; color: var(--muted); }
.kpi .v { font-size: 1.15rem; font-weight: 600; }
.kpi .v.good { color: var(--good); }

.grid4, .grid3 { display: grid; gap: 1rem; margin-top: 1rem; }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid4, .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.map-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem; }
.map-card h3 { margin: 0 0 0.4rem; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
.map-card canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 6px; display: block; }

footer {
  display: flex; justify-content: space-between; padding: 0.8rem 1.2rem; color: var(--muted);
  font-size: 0.75rem; border-top: 1px solid var(--line);
}
