:root {
  --bg: #07111b;
  --bg-soft: #0b1925;
  --card: rgba(13, 29, 42, 0.9);
  --line: rgba(136, 183, 205, 0.16);
  --line-strong: rgba(136, 183, 205, 0.3);
  --text: #eaf4f8;
  --muted: #8299a8;
  --cyan: #5ed8ff;
  --green: #44dfa3;
  --red: #ff6178;
  --amber: #ffbf5b;
  --blue: #77a8ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    radial-gradient(circle at 78% -10%, rgba(35, 110, 145, 0.28), transparent 38%),
    linear-gradient(145deg, #050c13 0%, #091722 50%, #07111b 100%);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

button { font: inherit; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 76px;
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 13, 20, 0.72);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 38px; height: 38px; position: relative;
  display: grid; place-items: center;
}
.brand-mark::before {
  content: ""; position: absolute; inset: 2px;
  border: 1px solid rgba(94, 216, 255, 0.45);
  border-radius: 11px;
  transform: rotate(45deg);
}
.brand-mark span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan); position: absolute;
}
.brand-mark span:nth-child(1) { left: 10px; }
.brand-mark span:nth-child(2) { left: 17px; top: 12px; }
.brand-mark span:nth-child(3) { right: 10px; bottom: 9px; }
.brand-name { font-size: 22px; font-weight: 720; letter-spacing: -0.5px; }
.brand-subtitle { font-size: 9px; color: var(--muted); letter-spacing: 2.3px; margin-top: 2px; }
.topbar-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 236px minmax(560px, 1fr) 350px;
  gap: 18px;
  padding: 18px;
}

.rail, .inspector {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  overflow: hidden;
}

.rail { padding: 22px 16px; }
.rail-heading, .panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
}
.scenario-list { margin-top: 13px; display: grid; gap: 9px; }
.scenario {
  width: 100%;
  padding: 14px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255,255,255,0.018);
  color: var(--text);
  cursor: pointer;
  transition: 160ms ease;
}
.scenario:hover { background: rgba(94,216,255,0.06); border-color: var(--line); }
.scenario.active {
  border-color: rgba(94,216,255,0.42);
  background: linear-gradient(135deg, rgba(94,216,255,0.14), rgba(94,216,255,0.035));
  box-shadow: inset 3px 0 0 var(--cyan);
}
.scenario .mini-kicker { font-size: 9px; color: var(--cyan); letter-spacing: 1.1px; }
.scenario strong { display: block; margin-top: 5px; font-size: 14px; }
.scenario small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.45; }
.rail-note { margin-top: 26px; padding: 15px; border: 1px dashed var(--line-strong); border-radius: 12px; }
.note-kicker { color: var(--amber); font-size: 10px; font-weight: 700; letter-spacing: 1.4px; }
.rail-note p { margin: 9px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }

.map-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  overflow: hidden;
}
.map-head { padding: 27px 28px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.section-kicker { color: var(--cyan); font-size: 10px; letter-spacing: 1.7px; }
.map-head h1 { margin: 5px 0 7px; font-size: 25px; letter-spacing: -0.7px; font-weight: 720; }
.map-head p { margin: 0; color: var(--muted); font-size: 13px; max-width: 620px; line-height: 1.55; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px 14px; min-width: 210px; font-size: 10px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.powered { background: var(--green); }
.dot.outage { background: var(--red); }
.dot.blind { background: #8192a1; }
.line { width: 18px; height: 3px; border-radius: 2px; }
.line.fault { background: var(--amber); box-shadow: 0 0 8px rgba(255,191,91,0.5); }

.map-stage { position: relative; flex: 1; min-height: 460px; overflow: hidden; }
.map-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(108,164,190,0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108,164,190,0.055) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at center, black 35%, transparent 82%);
}
#network-map { width: 100%; height: 100%; position: relative; z-index: 1; }
.edge { stroke: rgba(119,168,255,0.22); stroke-width: 2; }
.edge.affected { stroke: rgba(255,191,91,0.55); stroke-width: 3; }
.edge.fault { stroke: var(--amber); stroke-width: 6; filter: drop-shadow(0 0 8px rgba(255,191,91,0.55)); }
.edge-pulse { stroke: var(--amber); stroke-width: 2; fill: none; stroke-dasharray: 8 13; animation: dash 1.5s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -42; } }
.node { cursor: pointer; }
.node circle { transition: 160ms ease; }
.node:hover circle { stroke-width: 3; }
.node-label { fill: #dceaf0; font-size: 10px; text-anchor: middle; }
.node-sub { fill: var(--muted); font-size: 8px; text-anchor: middle; letter-spacing: 0.5px; }
.source-halo { fill: rgba(94,216,255,0.08); stroke: rgba(94,216,255,0.25); }

.map-foot {
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  gap: 32px;
  align-items: center;
  color: #bed0d9;
  font-size: 11px;
}
.map-foot > div { display: flex; gap: 8px; align-items: center; }
.meta-label { color: var(--muted); font-size: 9px; letter-spacing: 1.1px; }
.ghost-button {
  margin-left: auto;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
}
.ghost-button:hover { border-color: var(--cyan); color: var(--cyan); }

.inspector { padding: 20px; overflow-y: auto; }
.result-hero { padding: 4px 2px 18px; border-bottom: 1px solid var(--line); }
.result-kicker { color: var(--amber); font-size: 10px; letter-spacing: 1.5px; }
.result-hero h2 { margin: 7px 0 5px; font-size: 22px; }
.result-section { color: var(--muted); font-size: 12px; }
.confidence-row { display: flex; gap: 18px; align-items: center; margin-top: 18px; }
.confidence-ring {
  width: 82px; height: 82px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--cyan) var(--confidence), rgba(255,255,255,0.07) 0);
  position: relative;
}
.confidence-ring::after { content: ""; position: absolute; inset: 7px; background: #0c1b27; border-radius: 50%; }
.confidence-value { position: relative; z-index: 1; font-weight: 750; font-size: 18px; }
.confidence-copy strong { display: block; font-size: 13px; }
.confidence-copy span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 17px; }
.metric { padding: 12px; border-radius: 10px; background: rgba(255,255,255,0.025); border: 1px solid var(--line); }
.metric b { display: block; font-size: 18px; }
.metric span { color: var(--muted); font-size: 10px; }
.panel-title { margin: 22px 0 12px; }
.ranking { display: grid; gap: 9px; }
.rank-row { border: 0; color: var(--text); background: transparent; padding: 0; text-align: left; cursor: pointer; }
.rank-top { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.rank-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-pct { color: var(--muted); }
.rank-track { height: 5px; border-radius: 4px; margin-top: 6px; background: rgba(255,255,255,0.06); overflow: hidden; }
.rank-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.rank-row.selected .rank-fill { background: linear-gradient(90deg, var(--amber), #ffe0a4); }
.restore-status { padding: 15px; border-radius: 12px; border: 1px solid rgba(255,191,91,0.3); background: rgba(255,191,91,0.07); margin-top: 18px; }
.restore-status strong { display: block; color: var(--amber); font-size: 16px; margin-bottom: 5px; }
.restore-status span { color: var(--muted); font-size: 11px; line-height: 1.5; }
.finding-list { display: grid; gap: 8px; }
.finding {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
}
.finding i {
  width: 7px; height: 7px; margin-top: 4px; border-radius: 50%;
  background: var(--blue);
}
.finding.critical i { background: var(--red); box-shadow: 0 0 7px rgba(255,97,120,.65); }
.finding.warning i { background: var(--amber); box-shadow: 0 0 7px rgba(255,191,91,.55); }
.finding.ok i { background: var(--green); }
.finding strong { display: block; font-size: 11px; line-height: 1.45; }
.finding span { display: block; color: var(--muted); font-size: 10px; line-height: 1.5; margin-top: 3px; }
.evidence-panel { border-top: 1px solid var(--line); margin-top: 18px; }
.evidence-list { max-height: 260px; overflow-y: auto; display: grid; gap: 6px; padding-right: 4px; }
.evidence {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 9px; align-items: center;
  padding: 9px; border-radius: 9px; background: rgba(255,255,255,0.018); font-size: 10px;
}
.evidence .state-dot { width: 7px; height: 7px; border-radius: 50%; }
.evidence .node-name { font-weight: 650; }
.evidence .evidence-meta { color: var(--muted); text-align: right; line-height: 1.4; }
.empty { color: var(--muted); font-size: 12px; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 200px minmax(480px, 1fr) 300px; }
  .legend { display: none; }
}
@media (max-width: 860px) {
  .topbar-status { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .rail, .inspector { min-height: auto; }
  .scenario-list { grid-template-columns: repeat(3, 1fr); }
  .rail-note { display: none; }
  .map-stage { min-height: 420px; }
}
