:root {
  --bg:        #0d1117;
  --panel:     #151b23;
  --panel-2:   #1c242e;
  --line:      #262f3b;
  --text:      #e6edf3;
  --muted:     #8b98a8;
  --dim:       #5c6875;

  --ok:        #3fb950;
  --risk:      #d29922;
  --shift:     #58a6ff;
  --broken:    #f85149;
  --cancel:    #6e40c9;
  --accent:    #2f81f7;

  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
em { font-style: normal; color: var(--text); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 14px 22px;
  background: linear-gradient(180deg, #161d26, #121820);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 14px; }
.mark {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #7d4dff);
  display: grid; place-items: center;
  font-weight: 700; letter-spacing: .5px; font-size: 15px;
}
.topbar h1 { font-size: 19px; letter-spacing: -.2px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.topstats { display: flex; align-items: center; gap: 22px; }

.health { position: relative; width: 76px; text-align: center; }
.dial { width: 76px; height: 76px; transform: rotate(-90deg); }
.dial-track, .dial-fill { fill: none; stroke-width: 7; stroke-linecap: round; }
.dial-track { stroke: #222b36; }
.dial-fill  { stroke: var(--ok); stroke-dasharray: 207; stroke-dashoffset: 207;
              transition: stroke-dashoffset .7s cubic-bezier(.4,0,.2,1), stroke .4s; }
.health-num {
  position: absolute; top: 20px; left: 0; right: 0;
  font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.health-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; }

.statgrid { display: flex; gap: 18px; }
.statgrid .s { text-align: right; }
.statgrid .s b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.statgrid .s span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

/* ---------------------------------------------------------------- layout */
main {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 380px;
  gap: 16px; padding: 16px; align-items: start;
}
.rail { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: #c9d4e0; }
.panel h2 .hint { text-transform: none; letter-spacing: 0; color: var(--dim); font-weight: 400; font-size: 11.5px; margin-left: 6px; }
.panel-note { color: var(--muted); font-size: 12px; margin: 8px 0 12px; }

/* ---------------------------------------------------------------- chaos */
.scenarios { display: flex; flex-direction: column; gap: 7px; }
.scen {
  text-align: left; cursor: pointer; width: 100%;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; color: var(--text);
  transition: border-color .15s, background .15s, transform .1s;
}
.scen:hover { border-color: var(--accent); background: #202b38; }
.scen:active { transform: translateY(1px); }
.scen.active { border-color: var(--accent); background: #1b2735; box-shadow: inset 2px 0 0 var(--accent); }
.scen b { display: block; font-size: 12.8px; font-weight: 600; }
.scen span { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.scen .tag {
  display: inline-block; margin-top: 6px; font-size: 9.5px; letter-spacing: .5px;
  text-transform: uppercase; padding: 2px 6px; border-radius: 4px;
  background: #2a333f; color: var(--muted);
}

/* ---------------------------------------------------------------- rows */
.rows { display: flex; flex-direction: column; gap: 7px; }
.row {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 12.2px;
}
.row .rtop { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row b { font-weight: 600; }
.row small { color: var(--muted); font-size: 11.2px; display: block; margin-top: 3px; }
.pill {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 6px; border-radius: 999px; white-space: nowrap; font-weight: 600;
}
.pill.SATISFIED         { background: #123021; color: var(--ok); }
.pill.SATISFIED_ALTERED { background: #12293f; color: var(--shift); }
.pill.AT_RISK           { background: #3a2c0c; color: var(--risk); }
.pill.LOST              { background: #3d1517; color: var(--broken); }
.pill.CRITICAL          { background: #3d1517; color: #ff8a80; }
.pill.HIGH              { background: #2a333f; color: #b7c3d0; }
.pill.NICE_TO_HAVE      { background: #232a34; color: var(--dim); }

/* ---------------------------------------------------------------- stage */
.stage {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; min-width: 0;
}
.stage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.stage-head h2 { font-size: 16px; }
.sub { color: var(--muted); font-size: 12px; margin: 3px 0 0; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.risk { background: var(--risk); }
.dot.shift { background: var(--shift); } .dot.broken { background: var(--broken); }
.dot.cancel { background: var(--cancel); }

.banner {
  margin: 12px 0 0; padding: 11px 13px; border-radius: 8px;
  border: 1px solid #4a2020; background: #2a1416; font-size: 12.5px;
  animation: slidein .35s ease;
}
.banner b { color: #ff9d97; }
.banner .why { color: var(--muted); margin-top: 5px; display: block; font-size: 12px; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.graphwrap { margin-top: 12px; overflow-x: auto; }
#graph { width: 100%; min-height: 460px; display: block; }

.node-box { rx: 6; transition: fill .45s, stroke .45s; cursor: pointer; }
.node-label { font-size: 10.5px; fill: #dfe7ef; pointer-events: none; }
.node-sub   { font-size: 9px;  fill: #7f8c9b; pointer-events: none; }
.edge { fill: none; stroke-width: 1.4; transition: stroke .45s, stroke-width .45s; }
.lane-label { font-size: 9.5px; fill: #55606d; text-transform: uppercase; letter-spacing: .8px; }
.daytick { font-size: 9.5px; fill: #55606d; }
.daygrid { stroke: #1e2530; stroke-width: 1; }
.nowline { stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 4 3; }
.nowlabel { font-size: 9.5px; fill: var(--accent); }

.tooltip {
  position: fixed; z-index: 90; max-width: 300px; pointer-events: none;
  background: #0a0e13; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-size: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.55);
}
.tooltip b { display: block; margin-bottom: 3px; }
.tooltip .t-meta { color: var(--muted); font-size: 11.3px; }
.tooltip .t-reason { margin-top: 6px; color: #ffbdb8; font-size: 11.5px; }

/* ---------------------------------------------------------------- sliders */
.sticky { position: sticky; top: 84px; }
.personas { display: flex; gap: 6px; margin: 10px 0 12px; flex-wrap: wrap; }
.chip {
  cursor: pointer; background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font-size: 11.5px; transition: .15s;
}
.chip:hover { color: var(--text); border-color: #37414e; }
.chip.active { background: #17324f; border-color: var(--accent); color: #cfe4ff; }

.sliders { display: flex; flex-direction: column; gap: 9px; }
.slider label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.slider input { width: 100%; accent-color: var(--accent); margin-top: 2px; }

/* ---------------------------------------------------------------- plans */
.advice {
  background: #2b220e; border: 1px solid #4d3c12; border-radius: 8px;
  padding: 9px 11px; font-size: 12px; margin-bottom: 11px; color: #f0d99b;
}
.advice div + div { margin-top: 4px; }

.plans { display: flex; flex-direction: column; gap: 11px; }
.empty { color: var(--dim); font-size: 12.5px; text-align: center; padding: 22px 8px; }

.plan {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 12px; animation: slidein .3s ease both;
}
.plan.best { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(47,129,247,.25); }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.plan-label { font-weight: 700; font-size: 13.5px; }
.plan-label .crown { color: var(--accent); font-size: 10px; margin-left: 5px; letter-spacing: .5px; }
.plan-net { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.plan-net.pos { color: #ffb4ae; } .plan-net.neg { color: var(--ok); }
.plan-sum { color: var(--muted); font-size: 11.8px; margin: 5px 0 9px; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-bottom: 9px; }
.metric { background: #141b23; border-radius: 6px; padding: 6px 7px; text-align: center; }
.metric b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }
.metric span { font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; }

.ponr {
  display: flex; align-items: center; gap: 8px;
  background: #101820; border: 1px solid #23303d; border-radius: 6px;
  padding: 7px 9px; font-size: 11.5px; margin-bottom: 9px;
}
.ponr.urgent { border-color: #6b2b26; background: #221114; }
.clock { font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--risk); font-variant-numeric: tabular-nums; }
.ponr.urgent .clock { color: var(--broken); }
.ponr .pr { color: var(--muted); line-height: 1.35; }
.ponr .after { color: #ffb4ae; }
.rev { font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--ok); }

.plan details { margin-top: 8px; }
.plan summary { cursor: pointer; font-size: 11.5px; color: var(--muted); user-select: none; }
.plan summary:hover { color: var(--text); }
.plan details ul { margin: 7px 0 0; padding-left: 16px; font-size: 11.5px; color: #b9c5d2; }
.plan details li { margin-bottom: 3px; }
.costline { display: flex; justify-content: space-between; font-size: 11.5px; padding: 2px 0; }
.costline span:last-child { font-family: var(--mono); }
.costline.total { border-top: 1px solid var(--line); margin-top: 5px; padding-top: 5px; font-weight: 700; }

.scen-outcomes { margin-top: 7px; }
.scen-outcomes div { font-size: 11.2px; padding: 2px 0; color: var(--muted); }
.scen-outcomes .yes::before { content: "PASS "; color: var(--ok); font-family: var(--mono); font-size: 10px; }
.scen-outcomes .no::before  { content: "FAIL "; color: var(--broken); font-family: var(--mono); font-size: 10px; }

.lost { color: #ffb4ae; font-size: 11.5px; margin-top: 7px; }
.saved { color: var(--ok); font-size: 11.5px; margin-top: 4px; }

.btn {
  cursor: pointer; border-radius: 7px; padding: 8px 13px;
  font-size: 12.5px; font-weight: 600; border: 1px solid transparent;
  transition: .15s; width: 100%;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #4a94ff; }
.btn.ghost {
  background: transparent; border-color: var(--line); color: var(--muted); width: auto;
}
.btn.ghost:hover { color: var(--text); border-color: #37414e; }

.hidden { display: none !important; }

@media (max-width: 1250px) {
  main { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
