:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b2130;
  --line: #2a3040;
  --text: #e8ecf3;
  --muted: #8b93a7;
  --accent: #6ea8fe;
  --accent-2: #7ee2b8;
  --warn: #f5c86b;
  --nav-h: 64px;
  --maxcard: 520px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; }
.brand-mark { font-weight: 800; letter-spacing: 2px; color: var(--accent); }
.brand-sub { font-size: 11px; color: var(--muted); }
.brand-meta { font-size: 11px; color: var(--muted); text-align: right; }

.content {
  padding: 16px 16px calc(var(--nav-h) + 28px);
  max-width: 1120px;
  margin: 0 auto;
}

.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.view-title { font-size: 20px; margin: 4px 0 14px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.tag-modeled { background: rgba(245,200,107,.15); color: var(--warn); border: 1px solid rgba(245,200,107,.4); }
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, var(--maxcard)));
  justify-content: center;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  max-width: var(--maxcard);
  margin: 0 auto;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }
.card-wide { max-width: 1080px; margin: 0 auto 16px; }

.hero { margin-bottom: 16px; }
.hero-head h1 { margin: 0 0 6px; font-size: clamp(22px, 5vw, 34px); }
.hero-head p { margin: 0 0 12px; color: var(--muted); font-size: 14px; max-width: 60ch; }
.chart-box { position: relative; width: 100%; height: 260px; }
.hero-chart { height: clamp(260px, 42vh, 420px); }
.src { margin: 10px 0 0; font-size: 11px; color: var(--muted); }

.kpi { min-height: 120px; display: flex; flex-direction: column; justify-content: center; }
.kpi .k-label { font-size: 12px; color: var(--muted); }
.kpi .k-value { font-size: 30px; font-weight: 800; margin: 6px 0; }
.kpi .k-detail { font-size: 12px; color: var(--muted); }
.kpi .k-value.accent { color: var(--accent); }
.kpi .k-value.green { color: var(--accent-2); }

/* Network */
.net-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.net-legend span { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.net-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.net-box { width: 100%; height: min(58vh, 520px); background: var(--panel-2); border-radius: 12px; overflow: hidden; }
#netSvg { width: 100%; height: 100%; }
.net-node { cursor: pointer; }
.net-node text { font-size: 9px; fill: var(--text); pointer-events: none; }
.net-edge { stroke: var(--line); stroke-width: 1; }
.net-detail { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 40px; }
.net-detail b { color: var(--text); }

/* Bottom / side nav */
.navbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--nav-h);
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(20, 24, 33, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 30;
  transition: transform .3s ease;
}
.navbar.hidden { transform: translateY(100%); }
.nav-btn {
  background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; cursor: pointer; padding: 6px 8px; flex: 1;
  transition: color .2s ease;
}
.nav-btn svg { width: 22px; height: 22px; fill: currentColor; }
.nav-btn.active { color: var(--accent); }

/* Landscape / wide -> left rail (adapts to shorter side of ratio) */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .navbar {
    top: 0; bottom: 0; right: auto;
    width: 92px; height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
    padding-top: 20px;
    border-top: none;
    border-right: 1px solid var(--line);
  }
  .navbar.hidden { transform: none; }
  .nav-btn { flex: 0 0 auto; width: 100%; }
  .content { padding-left: 108px; }
  .topbar { padding-left: 108px; }
}
