:root {
  color-scheme: dark;
  --bg: #08090a;
  --panel: #0f1011;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #f7f8f8;
  --muted: #8a8f98;
  --subtle: #62666d;
  --body: #d0d6e0;
  --accent: #7170ff;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --shadow: 0 20px 80px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.03);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: "cv01", "ss03";
  background:
    radial-gradient(circle at 20% 0%, rgba(113,112,255,.18), transparent 34rem),
    radial-gradient(circle at 80% 10%, rgba(20,184,166,.11), transparent 32rem),
    linear-gradient(180deg, #08090a 0%, #050506 100%);
  color: var(--text);
}

body.nav-open .sidebar { transform: translateX(0); }

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .32;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,.18));
}

.shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: rgba(9, 10, 11, .82);
  border-right: 1px solid var(--border-soft);
  backdrop-filter: blur(18px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
}

.brand:hover { background: rgba(255,255,255,.04); }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5e6ad2, #14b8a6);
  box-shadow: 0 10px 35px rgba(113,112,255,.26);
  color: white;
  font-weight: 600;
  letter-spacing: -.04em;
}

.brand strong { display: block; font-weight: 590; letter-spacing: -.02em; }
.brand small { display: block; color: var(--muted); margin-top: 2px; font-size: 12px; }

.room-nav { display: flex; flex-direction: column; gap: 5px; overflow: auto; padding-right: 2px; }
.room-nav::-webkit-scrollbar { width: 8px; }
.room-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 99px; }

.nav-link {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--body);
  border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.045);
  border-color: rgba(255,255,255,.07);
  color: var(--text);
}

.nav-num {
  width: 30px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--room-accent) 18%, transparent);
  color: color-mix(in srgb, var(--room-accent) 80%, white);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  border: 1px solid color-mix(in srgb, var(--room-accent) 25%, transparent);
}

.nav-title { min-width: 0; }
.nav-title strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 510; }
.nav-title span { display: block; color: var(--subtle); font-size: 11px; margin-top: 1px; }
.nav-progress { width: 8px; height: 8px; border-radius: 50%; background: var(--room-accent); box-shadow: 0 0 15px var(--room-accent); }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}

.status-dot { width: 8px; height: 8px; background: var(--good); border-radius: 99px; box-shadow: 0 0 18px rgba(34,197,94,.6); flex: 0 0 auto; }

.main { min-width: 0; padding: 22px clamp(16px, 3vw, 38px) 56px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 20px;
  background: linear-gradient(180deg, rgba(8,9,10,.96) 0%, rgba(8,9,10,.78) 70%, transparent 100%);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 48px); line-height: 1; letter-spacing: -1.056px; font-weight: 510; }
h2 { font-size: clamp(24px, 3vw, 32px); letter-spacing: -.704px; font-weight: 510; }
h3 { font-size: 18px; letter-spacing: -.24px; font-weight: 590; }
p { color: var(--body); line-height: 1.6; }

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.icon-button, .ghost-button, .primary-button {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.035);
  border-radius: 10px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  transition: .18s ease;
}
.icon-button { display: none; width: 42px; padding: 0; }
.ghost-button:hover, .icon-button:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); }
.primary-button { background: #5e6ad2; border-color: #7170ff; color: #fff; }

.mono-chip {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  color: var(--body);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255,255,255,.025);
}

.app { display: flex; flex-direction: column; gap: 20px; }

.card, .hero, .metric-card, .room-card, .panel, .loading-card {
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.024));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 4vw, 38px);
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
  gap: 28px;
  align-items: center;
}

.hero::before {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  right: -160px;
  top: -260px;
  background: radial-gradient(circle, color-mix(in srgb, var(--hero-accent, #7170ff) 30%, transparent), transparent 60%);
  opacity: .9;
  pointer-events: none;
}

.hero > * { position: relative; }
.hero p { max-width: 760px; color: var(--muted); }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-stat {
  padding: 14px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,.025);
  border-radius: 12px;
}
.mini-stat b { display: block; font-size: 26px; letter-spacing: -.04em; }
.mini-stat span { color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 16px; }
.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr); }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rooms-grid { grid-template-columns: repeat( auto-fit, minmax(290px, 1fr) ); }

.metric-card, .panel, .room-card { padding: 18px; }
.metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.metric-value { font-size: clamp(28px, 5vw, 44px); letter-spacing: -.07em; margin: 12px 0 8px; font-weight: 510; }
.metric-detail { color: var(--muted); font-size: 13px; }

.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin: 8px 0 2px; }
.section-head p { margin: 0; color: var(--muted); font-size: 14px; }

.pipeline {
  display: grid;
  grid-template-columns: repeat(12, minmax(120px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.stage {
  min-height: 150px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,.025);
  padding: 12px;
  position: relative;
  overflow: hidden;
}
.stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: calc(var(--p) * 1%);
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent-stage) 30%, transparent));
  opacity: .85;
}
.stage > * { position: relative; z-index: 1; }
.stage-num { font-family: 'JetBrains Mono', monospace; color: var(--accent-stage); font-size: 12px; }
.stage strong { display: block; margin: 8px 0; font-size: 13px; }
.stage small { color: var(--muted); }

.progress-bar {
  width: 100%; height: 9px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.04);
}
.progress-bar span { display: block; height: 100%; width: calc(var(--value) * 1%); background: linear-gradient(90deg, var(--bar, #7170ff), color-mix(in srgb, var(--bar, #7170ff) 45%, white)); border-radius: inherit; }

.ring {
  --size: 116px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: conic-gradient(var(--ring, #7170ff) calc(var(--value) * 1%), rgba(255,255,255,.07) 0);
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
}
.ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: #101112; border: 1px solid var(--border-soft); }
.ring b { position: relative; z-index: 1; font-size: 24px; letter-spacing: -.06em; }

.room-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 255px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.room-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--room-accent) 38%, rgba(255,255,255,.1)); background: rgba(255,255,255,.045); }
.room-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.room-badge { font-family: 'JetBrains Mono', monospace; color: var(--room-accent); border: 1px solid color-mix(in srgb, var(--room-accent) 28%, transparent); background: color-mix(in srgb, var(--room-accent) 12%, transparent); border-radius: 999px; padding: 6px 10px; font-size: 12px; }
.room-card h3 { margin: 0; }
.room-card p { margin: 0; color: var(--muted); font-size: 14px; }
.card-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: auto; }
.card-meta div { padding: 9px; border-radius: 10px; background: rgba(255,255,255,.025); border: 1px solid var(--border-soft); }
.card-meta b { display: block; font-size: 15px; }
.card-meta span { color: var(--muted); font-size: 11px; }

.room-hero { --hero-accent: var(--room-accent); }
.room-hero .hero-title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.status-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--body);
  background: rgba(255,255,255,.025);
  font-size: 12px;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 99px; background: currentColor; box-shadow: 0 0 12px currentColor; }
.status-good { color: var(--good); }
.status-waiting { color: var(--warn); }
.status-bad { color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 510; }
td { color: var(--body); font-size: 13px; }
code, .mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }

.task-list, .file-list, .focus-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.task-item, .file-item, .focus-item {
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,.022);
  border-radius: 11px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.task-state {
  margin-top: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border);
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.task-state.done { background: rgba(34,197,94,.16); border-color: rgba(34,197,94,.35); color: var(--good); }
.task-state.waiting { background: rgba(245,158,11,.14); border-color: rgba(245,158,11,.35); color: var(--warn); }
.task-state.pending { background: rgba(255,255,255,.04); color: var(--muted); }
.task-item span { color: var(--body); font-size: 14px; }
.task-item small { display: block; color: var(--muted); margin-top: 2px; }

.file-item { justify-content: space-between; align-items: center; }
.file-item strong { font-size: 13px; word-break: break-word; }
.file-item small { color: var(--muted); display: block; margin-top: 2px; }

.artifact-bars { display: flex; flex-direction: column; gap: 11px; }
.artifact-row { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(160px, 2fr) 46px; gap: 10px; align-items: center; font-size: 13px; color: var(--body); }
.artifact-row .dir { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.artifact-row .count { text-align: right; font-family: 'JetBrains Mono', monospace; color: var(--text); }

.heatmap { display: grid; grid-template-columns: repeat(12, minmax(44px, 1fr)); gap: 8px; }
.heat-cell { aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border-soft); display: grid; place-items: center; background: color-mix(in srgb, var(--cell) calc(var(--p) * .55%), rgba(255,255,255,.025)); color: var(--text); font-family: 'JetBrains Mono', monospace; font-size: 12px; }

.dependency-svg { width: 100%; min-height: 250px; border-radius: 14px; background: rgba(255,255,255,.018); border: 1px solid var(--border-soft); }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; top: 6px; bottom: 6px; left: 5px; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 16px 12px; }
.timeline-item::before { content: ""; position: absolute; top: 5px; left: -16px; width: 9px; height: 9px; border-radius: 50%; background: var(--timeline, #7170ff); box-shadow: 0 0 16px var(--timeline, #7170ff); }
.timeline-item strong { display: block; font-size: 14px; }
.timeline-item span { color: var(--muted); font-size: 12px; }

.empty-state { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; background: rgba(255,255,255,.018); }

.loading-card { padding: 54px; text-align: center; margin-top: 32px; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255,255,255,.1); border-top-color: #7170ff; margin: 0 auto 18px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; transform: translateX(-105%); width: min(88vw, 320px); transition: transform .2s ease; box-shadow: 30px 0 80px rgba(0,0,0,.55); }
  .icon-button { display: inline-grid; place-items: center; }
  .main { padding-top: 12px; }
  .topbar { align-items: flex-start; }
  .top-actions { align-items: flex-end; }
  .heatmap { grid-template-columns: repeat(6, minmax(40px, 1fr)); }
}

@media (max-width: 560px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: space-between; }
  .kpi-grid, .three-col, .hero-stats { grid-template-columns: 1fr; }
  .metric-card, .panel, .room-card { padding: 15px; }
  .hero { padding: 20px; }
  .artifact-row { grid-template-columns: 1fr; gap: 6px; }
  .artifact-row .count { text-align: left; }
}
