/* ============================================================
   ELECTRA · 电力系统一次设计与潮流分析平台
   Dark engineering workstation theme
   ============================================================ */
:root {
  --bg: #07101d;
  --bg-deep: #050b14;
  --canvas: #081321;
  --panel: #0d1929;
  --panel-2: #111f32;
  --panel-3: #16273d;
  --raised: #1a2c42;
  --line: #20344c;
  --line-soft: rgba(99, 137, 178, 0.16);
  --text: #e8f0fa;
  --text-soft: #c0cfe0;
  --muted: #8ca2ba;
  --dim: #5f7691;
  --accent: #4ce0c3;
  --accent-deep: #15a98f;
  --accent-soft: rgba(76, 224, 195, 0.12);
  --blue: #63b3ff;
  --amber: #ffbd66;
  --amber-soft: rgba(255, 189, 102, 0.13);
  --red: #ff7d8c;
  --red-soft: rgba(255, 125, 140, 0.13);
  --green: #67d89a;
  --purple: #b79bff;
  --shadow-lg: 0 22px 70px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 35px rgba(0, 0, 0, 0.28);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 58px;
  --modebar-h: 47px;
  --font: "Inter", "SF Pro Display", "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
::selection { background: rgba(76, 224, 195, 0.26); color: #fff; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #253b55; border-radius: 20px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #34516f; background-clip: padding-box; }

.icon { display: block; flex: 0 0 auto; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.accent { color: var(--accent); }
.amber { color: var(--amber); }
.red { color: var(--red); }
.green { color: var(--green); }
.blue { color: var(--blue); }

#app { height: 100vh; display: flex; flex-direction: column; min-width: 980px; }

/* ---------------- Top bar ---------------- */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px 0 16px;
  background: linear-gradient(180deg, #0d1a2b 0%, #0a1626 100%);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 30;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(76, 224, 195, 0.26), transparent);
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  color: #06211d;
  background: linear-gradient(145deg, #79f4dd 0%, #37cbae 62%, #1ba58c 100%);
  box-shadow: 0 0 24px rgba(76, 224, 195, 0.22), inset 0 1px rgba(255,255,255,.4);
}
.brand-mark .icon { width: 23px; height: 23px; }
.brand-copy { line-height: 1.1; }
.brand-name { font-size: 15px; font-weight: 760; letter-spacing: .10em; }
.brand-name span { color: var(--accent); }
.brand-sub { font-size: 8.5px; color: var(--dim); letter-spacing: .20em; margin-top: 4px; text-transform: uppercase; font-weight: 600; }

.project-crumbs {
  flex: 1;
  min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding-left: 20px;
  border-left: 1px solid var(--line);
  height: 28px;
}
.crumb-main { min-width: 0; }
.crumb-title { font-size: 12.5px; font-weight: 650; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sub { font-size: 10px; color: var(--dim); letter-spacing: .04em; margin-top: 1px; }
.crumb-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 30px; border: 1px solid var(--line); color: var(--muted); font-size: 9.5px; white-space: nowrap; }
.crumb-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 10.5px; margin-left: auto; padding-right: 6px; }
.save-state .icon { opacity: .7; }
.save-state.is-dirty { color: var(--amber); }

.top-actions { display: flex; align-items: center; gap: 8px; }
.top-divider { width: 1px; height: 22px; background: var(--line); margin: 0 3px; }
.icon-btn {
  width: 34px; height: 34px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted);
  display: grid; place-items: center;
  transition: .16s ease;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); border-color: var(--line); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(76,224,195,.24); }
.icon-btn:disabled { opacity: .28; cursor: default; }
.icon-btn:disabled:hover { background: transparent; border-color: transparent; color: var(--muted); }

.btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-soft);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 11.5px; font-weight: 620; letter-spacing: .01em;
  transition: .16s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-3); border-color: #2f4a68; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn .icon { opacity: .9; }
.btn-primary {
  background: linear-gradient(145deg, #57e8cb 0%, #2cc6a9 100%);
  border-color: rgba(103, 255, 228, 0.42);
  color: #06241f;
  font-weight: 780;
  box-shadow: 0 4px 18px rgba(44, 198, 169, 0.20), inset 0 1px rgba(255,255,255,.36);
}
.btn-primary:hover { background: linear-gradient(145deg, #70f3d8, #37d4b5); border-color: #86ffe6; color: #031d19; }
.btn-blue { background: rgba(99,179,255,.12); border-color: rgba(99,179,255,.32); color: #a9d6ff; }
.btn-blue:hover { background: rgba(99,179,255,.2); }
.btn-danger { background: var(--red-soft); border-color: rgba(255,125,140,.3); color: #ffb2ba; }
.btn-danger:hover { background: rgba(255,125,140,.2); border-color: rgba(255,125,140,.5); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-3); border-color: var(--line); }
.btn-soft { background: var(--panel-3); border-color: var(--line); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 10.5px; border-radius: 7px; gap: 5px; }
.btn-lg { height: 40px; padding: 0 18px; border-radius: 9px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn .kbd { font-family: var(--mono); font-size: 9px; background: rgba(0,0,0,.17); padding: 2px 5px; border-radius: 4px; opacity: .65; }
.btn-primary .kbd { background: rgba(0, 0, 0, .1); }

/* ---------------- Mode bar ---------------- */
.modebar {
  height: var(--modebar-h);
  flex: 0 0 var(--modebar-h);
  display: flex; align-items: stretch;
  padding: 0 20px;
  background: #0a1523;
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.mode-tabs { display: flex; align-items: stretch; gap: 2px; height: 100%; }
.mode-tab {
  position: relative;
  border: 0; background: transparent;
  display: flex; align-items: center; gap: 7px;
  padding: 0 15px;
  color: var(--dim);
  font-size: 11.5px; font-weight: 560;
  transition: .16s ease;
}
.mode-tab:hover { color: var(--text-soft); }
.mode-tab.active { color: var(--text); }
.mode-tab.active::after {
  content: ""; position: absolute; left: 13px; right: 13px; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
}
.mode-tab .icon { width: 16px; height: 16px; opacity: .75; }
.mode-tab.active .icon { opacity: 1; color: var(--accent); filter: drop-shadow(0 0 7px rgba(76,224,195,.35)); }
.mode-tab .tab-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); margin-left: 1px; }
.modebar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 10px; }
.network-pill { display: flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 20px; background: rgba(17,31,50,.5); }
.network-pill b { color: var(--text-soft); font-weight: 620; }
.network-pill .icon { width: 13px; height: 13px; opacity: .65; }
.modebar-right .sep { width: 1px; height: 16px; background: var(--line); }

/* ---------------- Workspace ---------------- */
#view-root { flex: 1; min-height: 0; position: relative; }
.view { height: 100%; min-height: 0; }

.design-shell {
  height: 100%;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr) 338px;
  background: var(--bg);
}

/* ---------------- Palette ---------------- */
.palette {
  background: linear-gradient(180deg, #0c1828 0%, #0b1625 100%);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
  padding: 17px 13px 24px;
}
.panel-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 9px; font-weight: 740; letter-spacing: .16em; color: var(--dim);
  text-transform: uppercase;
  padding: 0 4px;
  margin: 4px 0 10px;
}
.panel-label .count { letter-spacing: 0; font-family: var(--mono); font-size: 9px; color: var(--dim); }
.palette-search {
  position: relative; margin-bottom: 14px;
}
.palette-search .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--dim); }
.palette-search input {
  width: 100%; height: 31px; border-radius: 7px; border: 1px solid var(--line);
  background: #081321; padding: 0 9px 0 30px; font-size: 10.5px; color: var(--text-soft); outline: none;
}
.palette-search input:focus { border-color: rgba(76,224,195,.45); }
.palette-search input::placeholder { color: #4e647d; }

.palette-group { margin-bottom: 19px; }
.palette-items { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.palette-item {
  position: relative;
  min-height: 67px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(165deg, rgba(23, 40, 61, .65), rgba(13, 25, 41, .7));
  color: var(--text-soft);
  padding: 9px 7px 8px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
  transition: .16s ease;
  overflow: hidden;
}
.palette-item::after {
  content: ""; position: absolute; right: -14px; top: -18px; width: 46px; height: 46px;
  background: radial-gradient(circle, rgba(76,224,195,.12), transparent 68%);
  opacity: 0; transition: .2s;
}
.palette-item:hover { border-color: #345370; background: #16283e; transform: translateY(-1px); }
.palette-item:hover::after { opacity: 1; }
.palette-item.armed { border-color: var(--accent); background: rgba(76,224,195,.09); box-shadow: 0 0 0 1px rgba(76,224,195,.10), 0 8px 25px rgba(0,0,0,.18); }
.palette-item .p-icon { width: 25px; height: 25px; display: grid; place-items: center; color: var(--accent); }
.palette-item .p-icon .icon { width: 21px; height: 21px; }
.palette-item[data-palette="transformer"] .p-icon, .palette-item[data-palette="transformer3"] .p-icon, .palette-item[data-palette="generator"] .p-icon { color: var(--amber); }
.palette-item[data-palette="load"] .p-icon { color: var(--red); }
.palette-item[data-palette="cable"] .p-icon { color: #6fe3ff; }
.palette-item[data-palette="seriesReactor"] .p-icon, .palette-item[data-palette="seriesCap"] .p-icon, .palette-item[data-palette="fcl"] .p-icon { color: #ffb37a; }
.palette-item[data-palette="loadSwitch"] .p-icon, .palette-item[data-palette="disconnector"] .p-icon, .palette-item[data-palette="recloser"] .p-icon, .palette-item[data-palette="sectionalizer"] .p-icon, .palette-item[data-palette="fuse"] .p-icon { color: var(--blue); }
.palette-item[data-palette="shunt"] .p-icon { color: var(--purple); }
.palette-item[data-palette="breaker"] .p-icon, .palette-item[data-palette="switch"] .p-icon { color: var(--blue); }
.palette-item .p-label { font-size: 10.5px; font-weight: 610; line-height: 1.2; }
.palette-item .p-sub { font-size: 8px; color: var(--dim); line-height: 1.2; margin-top: -2px; }
.palette-item .p-key { position: absolute; right: 6px; top: 6px; font-family: var(--mono); font-size: 7.5px; color: #516984; border: 1px solid var(--line); padding: 1px 3px; border-radius: 3px; }

.palette-tip {
  border: 1px solid rgba(99,179,255,.14);
  background: rgba(99,179,255,.055);
  border-radius: 10px;
  padding: 11px;
  color: var(--muted);
  font-size: 9.6px;
  line-height: 1.65;
}
.palette-tip .tip-head { display: flex; align-items: center; gap: 6px; color: #b6d8ff; font-weight: 650; font-size: 10px; margin-bottom: 5px; }
.palette-tip .tip-head .icon { width: 13px; height: 13px; }
.palette-tip kbd { font-family: var(--mono); font-size: 8px; border: 1px solid var(--line); border-bottom-width: 2px; background: #0b1624; padding: 0 4px; border-radius: 3px; color: var(--text-soft); }
.palette-footer { margin-top: 14px; display: grid; gap: 6px; }
.palette-footer .mini-action {
  display: flex; align-items: center; gap: 7px;
  height: 30px; border: 1px solid var(--line); background: transparent; border-radius: 7px;
  color: var(--muted); padding: 0 9px; font-size: 10px; text-align: left;
}
.palette-footer .mini-action:hover { color: var(--text); background: var(--panel-2); }
.palette-footer .icon { width: 13px; height: 13px; opacity: .7; }

/* ---------------- Canvas ---------------- */
.canvas-column { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--canvas); }
.canvas-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #07111e;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(111, 148, 186, .22) 1px, transparent 0);
  background-size: 22px 22px;
  touch-action: none;
}
.canvas-stage.no-grid { background-image: none; }
.canvas-stage.is-panning { cursor: grabbing !important; }
.canvas-stage.tool-bus, .canvas-stage.tool-line, .canvas-stage.tool-transformer { cursor: crosshair; }
.canvas-stage.tool-pan { cursor: grab; }
.canvas-stage::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(52, 100, 145, 0.10), transparent 55%),
    linear-gradient(180deg, rgba(4, 9, 16, 0) 60%, rgba(3, 8, 14, 0.42) 100%);
}
.canvas-stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  opacity: .22;
  background-image: linear-gradient(rgba(76, 224, 195, .02) 1px, transparent 1px), linear-gradient(90deg, rgba(76, 224, 195, .02) 1px, transparent 1px);
  background-size: 110px 110px;
}
#schematic { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; user-select: none; }
.canvas-toolbar {
  position: absolute; top: 14px; left: 14px; z-index: 5;
  display: flex; align-items: center; gap: 3px;
  background: rgba(12, 24, 39, .92);
  border: 1px solid rgba(39, 62, 87, .9);
  box-shadow: 0 6px 25px rgba(0,0,0,.25);
  backdrop-filter: blur(14px);
  border-radius: 9px;
  padding: 4px;
}
.canvas-toolbar .icon-btn { width: 30px; height: 30px; border-radius: 6px; }
.canvas-toolbar .icon-btn .icon { width: 16px; height: 16px; }
.canvas-toolbar .tb-sep { width: 1px; height: 17px; background: var(--line); margin: 0 3px; }
.canvas-toolbar .tb-label { font-size: 9px; color: var(--dim); padding: 0 7px 0 4px; letter-spacing: .02em; }
.zoom-chip {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  display: flex; align-items: center; gap: 5px;
  border: 1px solid var(--line); border-radius: 7px;
  background: rgba(12, 24, 39, .9); backdrop-filter: blur(12px);
  padding: 3px 4px;
}
.zoom-chip button { width: 25px; height: 24px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; border-radius: 4px; }
.zoom-chip button:hover { background: var(--panel-3); color: var(--text); }
.zoom-chip .level { min-width: 42px; text-align: center; font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.canvas-hint {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 4;
  display: flex; align-items: center; gap: 7px;
  border: 1px solid rgba(76,224,195,.2);
  background: rgba(11, 31, 40, .88);
  color: #a9e7da; padding: 6px 12px; border-radius: 20px;
  font-size: 10px; backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
  max-width: 55%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.canvas-hint .icon { width: 12px; height: 12px; color: var(--accent); }
.canvas-hint kbd { font-family: var(--mono); font-size: 8px; border: 1px solid rgba(76,224,195,.25); border-radius: 3px; padding: 0 4px; }
.canvas-flow-chip {
  position: absolute; top: 14px; right: 14px; z-index: 5;
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: 7px;
  background: rgba(12,24,39,.9); backdrop-filter: blur(12px);
  height: 31px; padding: 0 9px; color: var(--muted); font-size: 9.5px;
}
.canvas-flow-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.canvas-flow-chip.warn .dot { background: var(--amber); }
.canvas-flow-chip.off .dot { background: var(--dim); }
.canvas-empty {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center;
  pointer-events: none;
}
.empty-card {
  text-align: center; padding: 36px 44px;
  border: 1px dashed rgba(111, 154, 196, .24);
  background: rgba(10, 21, 35, .52);
  border-radius: 18px;
  backdrop-filter: blur(8px);
  max-width: 430px;
}
.empty-card .empty-illustration { width: 120px; height: 72px; margin: 0 auto 18px; opacity: .8; }
.empty-card h3 { margin: 0 0 7px; font-size: 17px; letter-spacing: .01em; font-weight: 620; }
.empty-card p { margin: 0 auto 18px; font-size: 11px; line-height: 1.7; color: var(--muted); max-width: 310px; }
.empty-card .btn { pointer-events: auto; }

.canvas-status {
  flex: 0 0 32px; height: 32px;
  background: #0a1522; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 12px;
  color: var(--dim); font-size: 9px;
}
.canvas-status .item { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.canvas-status .item b { color: var(--muted); font-weight: 600; }
.canvas-status .status-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.canvas-status .status-dot.warn { background: var(--amber); }
.canvas-status .status-dot.err { background: var(--red); }
.canvas-status .spacer { flex: 1; }
.canvas-status .coord { font-family: var(--mono); color: #66809b; min-width: 100px; text-align: right; }
.canvas-status .help-link { color: var(--dim); background: none; border: 0; display: flex; align-items: center; gap: 4px; padding: 0; font-size: 9px; }
.canvas-status .help-link:hover { color: var(--text); }

/* ---------------- SVG schematic ---------------- */
.schematic-svg text { font-family: var(--font); user-select: none; pointer-events: none; }
.schematic-svg .world { will-change: transform; }
.bus-g { cursor: pointer; }
.bus-g .bus-bar { transition: filter .15s; }
.bus-g:hover .bus-bar { filter: drop-shadow(0 0 7px currentColor); }
.bus-g.is-selected .bus-bar { filter: drop-shadow(0 0 8px currentColor); }
.bus-g .bus-label-tag { font-weight: 750; letter-spacing: .03em; }
.bus-g .bus-label-name { font-weight: 500; fill: #aabdd0; }
.bus-g .bus-label-kv { font-family: var(--mono); font-weight: 600; }
.bus-g .bus-sel-ring { fill: none; stroke: #d9fff8; stroke-width: 1.4; stroke-dasharray: 4 5; opacity: .75; }
.bus-g .bus-type-badge-text { font-size: 14px; font-weight: 700; letter-spacing: .06em; }
.bus-g .bus-type-badge-bg { rx: 4; }
.branch-g { cursor: pointer; }
.branch-g .branch-hit { stroke: transparent; stroke-width: 22; fill: none; pointer-events: stroke; }
.branch-g .branch-line { transition: filter .15s, stroke .15s; }
.branch-g:hover .branch-line { filter: drop-shadow(0 0 5px rgba(166, 220, 255, .45)); }
.branch-g:hover .branch-hit + .branch-line { stroke: #c8e3ff; }
.branch-g.is-selected .branch-line { filter: drop-shadow(0 0 7px rgba(118, 227, 255, .45)); }
.branch-g .branch-label-bg { fill: rgba(8, 18, 31, .88); stroke: rgba(47, 73, 100, .75); stroke-width: 1; }
.branch-g .branch-tag { font-size: 17px; font-weight: 730; fill: #dce9f7; letter-spacing: .03em; }
.branch-g .branch-meta { font-size: 12.8px; fill: #6e8aa6; }
.branch-g .branch-flow { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.branch-g .branch-open-label { fill: #ff8e9b; font-size: 11px; font-weight: 650; }
.injection-g { cursor: pointer; }
.injection-g .inj-hit { fill: transparent; }
.injection-g:hover .inj-body { filter: drop-shadow(0 0 6px rgba(255, 209, 138, .42)); }
.injection-g.is-selected .inj-body { filter: drop-shadow(0 0 8px rgba(128, 245, 224, .55)); }
.injection-g .inj-label { font-size: 14.5px; font-weight: 620; fill: #ccd9e7; }
.injection-g .inj-meta { font-size: 11.5px; fill: #7992aa; font-family: var(--mono); }
.injection-g .inj-tag { font-size: 15px; font-weight: 750; fill: #f0d19a; }
.injection-g .inj-tag.load { fill: #ff9da8; }
.injection-g .inj-tag.shunt { fill: #bfa8ff; }
.flow-badge { rx: 4; }
.flow-badge-text { font-family: var(--mono); font-size: 10.5px; font-weight: 600; }
.pending-pulse { fill: none; stroke: #6effe2; stroke-width: 1.4; opacity: .8; }
.branch-endpoint { fill: #0b1928; stroke: #8eb3d6; stroke-width: 1.5; }
.terminal-dot { fill: #08131f; stroke: #97b2cb; stroke-width: 1.2; }
.line-open-gap { stroke: #08131f; stroke-width: 10; }
.annotation-text { font-size: 15px; fill: #9cb2c8; }

/* ---------------- Inspector ---------------- */
.inspector {
  background: linear-gradient(180deg, #0d1a2a 0%, #0b1625 100%);
  border-left: 1px solid var(--line);
  overflow-y: auto; min-height: 0;
  padding: 17px 15px 30px;
}
.inspector-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.inspector-icon {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(76,224,195,.18);
}
.inspector-icon .icon { width: 19px; height: 19px; }
.inspector-head-copy { flex: 1; min-width: 0; }
.inspector-kicker { font-size: 8.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .15em; font-weight: 700; }
.inspector-title { font-size: 14px; font-weight: 680; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inspector-head-actions { display: flex; gap: 3px; margin-top: -3px; }
.inspector-head-actions .icon-btn { width: 27px; height: 27px; border-radius: 6px; }
.inspector-head-actions .icon-btn .icon { width: 14px; height: 14px; }
.inspector-section { border-top: 1px solid var(--line-soft); padding: 14px 0 2px; }
.inspector-section:first-of-type { border-top: 0; }
.section-title { font-size: 9px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-bottom: 10px; display: flex; align-items: center; gap: 7px; }
.section-title::after { content: ""; height: 1px; flex: 1; background: linear-gradient(90deg, var(--line-soft), transparent); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field .field-label { font-size: 9.5px; color: var(--muted); font-weight: 540; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.field .unit { font-family: var(--mono); font-size: 8px; color: var(--dim); font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%; height: 31px; border: 1px solid var(--line); border-radius: 6px;
  background: #091421; color: var(--text-soft); padding: 0 8px; font-size: 10.5px; outline: none;
  transition: .15s;
}
.field textarea { height: 58px; resize: vertical; padding: 7px 8px; line-height: 1.5; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #2d4560; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(76,224,195,.6); box-shadow: 0 0 0 2px rgba(76,224,195,.08); }
.field input[type="number"] { font-family: var(--mono); }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237f97b0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 22px; cursor: pointer; }
.field .hint { font-size: 8.5px; color: var(--dim); line-height: 1.4; }
.field .input-wrap { position: relative; }
.field .input-wrap .suffix { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 8px; color: var(--dim); pointer-events: none; }
.field .input-wrap input { padding-right: 30px; }
.range-line { display: flex; align-items: center; gap: 8px; }
.range-line input[type="range"] { flex: 1; height: 4px; padding: 0; accent-color: var(--accent); background: var(--line); border: 0; }
.range-line output { font-family: var(--mono); font-size: 9px; color: var(--muted); min-width: 40px; text-align: right; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #08131f; border: 1px solid var(--line); border-radius: 6px; padding: 2px; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--dim); height: 25px; border-radius: 4px; font-size: 9.5px; font-weight: 600; }
.segmented button:hover { color: var(--text-soft); }
.segmented button.active { background: var(--panel-3); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(76,224,195,.12); }
.switch-row { display: flex; align-items: center; justify-content: space-between; background: #091421; border: 1px solid var(--line); border-radius: 6px; padding: 8px 9px; min-height: 33px; }
.switch-row .switch-label { font-size: 10px; color: var(--text-soft); display: flex; align-items: center; gap: 7px; }
.switch-row .switch-label .icon { width: 13px; height: 13px; color: var(--dim); }
.toggle { position: relative; width: 28px; height: 16px; border-radius: 20px; background: #263a50; border: 1px solid #304961; padding: 0; transition: .16s; flex: 0 0 auto; }
.toggle::after { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: #8195a9; top: 2px; left: 2px; transition: .16s; }
.toggle.on { background: rgba(76,224,195,.23); border-color: rgba(76,224,195,.5); }
.toggle.on::after { background: var(--accent); transform: translateX(12px); box-shadow: 0 0 8px rgba(76,224,195,.5); }
.toggle:disabled { opacity: .4; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 20px; padding: 3px 8px; font-size: 8.5px; color: var(--muted); background: rgba(17,31,50,.45); white-space: nowrap; }
.chip .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.chip.ok { color: #9de8cf; border-color: rgba(76,224,195,.24); background: rgba(76,224,195,.06); }
.chip.warn { color: #ffd298; border-color: rgba(255,189,102,.24); background: rgba(255,189,102,.06); }
.chip.error { color: #ffb1ba; border-color: rgba(255,125,140,.26); background: rgba(255,125,140,.06); }
.chip.purple { color: #d4c4ff; border-color: rgba(183,155,255,.25); background: rgba(183,155,255,.07); }
.derived-card {
  border: 1px solid var(--line-soft);
  background: linear-gradient(155deg, rgba(17,31,50,.76), rgba(9,20,33,.68));
  border-radius: 8px; padding: 9px 10px; margin-top: 9px;
}
.derived-card .d-head { font-size: 8px; letter-spacing: .12em; color: var(--dim); text-transform: uppercase; font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.derived-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.derived-grid .d-item { min-width: 0; }
.derived-grid .d-label { font-size: 8.5px; color: var(--dim); }
.derived-grid .d-val { font-family: var(--mono); font-size: 9.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.derived-grid .d-val.accent { color: var(--accent); }
.inspector-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 14px; }
.inspector-actions .btn { width: 100%; height: 31px; font-size: 10px; }
.issue-list { display: grid; gap: 5px; }
.issue-item { display: flex; gap: 7px; align-items: flex-start; border: 1px solid var(--line-soft); background: rgba(9,20,33,.55); padding: 7px 8px; border-radius: 6px; font-size: 9px; color: var(--muted); line-height: 1.5; }
.issue-item .icon { width: 12px; height: 12px; margin-top: 1px; flex: 0 0 auto; }
.issue-item.warning { border-color: rgba(255,189,102,.17); background: rgba(255,189,102,.04); color: #d8b98b; }
.issue-item.error { border-color: rgba(255,125,140,.2); background: rgba(255,125,140,.05); color: #e9a3aa; }
.issue-item.ok { border-color: rgba(76,224,195,.14); background: rgba(76,224,195,.035); color: #91cdbd; }
.overview-hero {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(150deg, #112942 0%, #0e1d30 57%, #102238 100%);
  padding: 15px 13px 12px; margin-bottom: 14px;
}
.overview-hero::after { content: ""; position: absolute; width: 130px; height: 130px; right: -50px; top: -75px; border-radius: 50%; background: radial-gradient(circle, rgba(76,224,195,.2), transparent 70%); }
.overview-hero .ov-kicker { font-size: 8px; color: var(--accent); text-transform: uppercase; letter-spacing: .17em; font-weight: 700; }
.overview-hero .ov-name { font-size: 14px; font-weight: 650; margin-top: 4px; line-height: 1.35; position: relative; z-index: 1; }
.overview-hero .ov-meta { font-size: 9px; color: var(--dim); margin-top: 3px; }
.overview-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 12px; border-top: 1px solid rgba(79,112,145,.19); padding-top: 10px; }
.overview-stats .ov-stat .v { font-family: var(--mono); font-size: 15px; color: var(--text); font-weight: 600; }
.overview-stats .ov-stat .l { font-size: 8px; color: var(--dim); margin-top: 1px; }
.inspector-empty-note { border-radius: 8px; border: 1px dashed var(--line); color: var(--dim); font-size: 9px; padding: 11px; line-height: 1.6; }
.quick-checks { display: grid; gap: 6px; margin-top: 8px; }
.quick-check { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 9.5px; color: var(--muted); border-bottom: 1px dashed rgba(66,95,126,.2); padding-bottom: 6px; }
.quick-check:last-child { border: 0; }
.quick-check .qv { font-family: var(--mono); color: var(--text-soft); }

/* ---------------- Shared page scaffolding ---------------- */
.page-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.page-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.page-head { padding: 25px 28px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-head-copy .eyebrow { font-size: 8.5px; letter-spacing: .17em; text-transform: uppercase; color: var(--accent); font-weight: 750; }
.page-head-copy h1 { margin: 4px 0 3px; font-size: 21px; font-weight: 680; letter-spacing: -.015em; }
.page-head-copy p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.6; max-width: 720px; }
.page-head-actions { display: flex; align-items: center; gap: 7px; padding-top: 3px; flex: 0 0 auto; }
.breadcrumb-mini { display: flex; align-items: center; gap: 6px; font-size: 9px; color: var(--dim); margin-bottom: 6px; }
.breadcrumb-mini .icon { width: 10px; height: 10px; }
.main-pad { padding: 0 28px 34px; }
.content-max { max-width: 1460px; margin: 0 auto; }
.card {
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(17,31,50,.82), rgba(11,22,37,.82));
  border-radius: var(--radius);
  box-shadow: 0 5px 24px rgba(0,0,0,.09);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.card-title { font-size: 11.5px; font-weight: 650; display: flex; align-items: center; gap: 7px; }
.card-title .icon { width: 15px; height: 15px; color: var(--accent); opacity: .9; }
.card-sub { font-size: 9px; color: var(--dim); margin-top: 2px; }
.card-body { padding: 15px 16px; }
.card-actions { display: flex; align-items: center; gap: 6px; }
.empty-state { text-align: center; padding: 70px 30px; max-width: 550px; margin: 0 auto; }
.empty-state .es-icon { width: 70px; height: 70px; margin: 0 auto 16px; border-radius: 18px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); }
.empty-state .es-icon .icon { width: 32px; height: 32px; }
.empty-state h2 { font-size: 17px; margin: 0 0 7px; }
.empty-state p { font-size: 10.5px; color: var(--muted); line-height: 1.7; margin: 0 auto 18px; max-width: 430px; }

/* ---------------- Analysis ---------------- */
.analysis-shell { height: 100%; display: grid; grid-template-columns: 292px minmax(0,1fr); min-height: 0; }
.analysis-side {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0d1929, #0b1625);
  overflow-y: auto; padding: 18px 15px 26px;
}
.side-section { margin-bottom: 16px; }
.side-label { font-size: 8.5px; font-weight: 750; letter-spacing: .15em; text-transform: uppercase; color: var(--dim); display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.side-label::after { content: ""; height: 1px; flex: 1; background: linear-gradient(90deg, var(--line-soft), transparent); }
.algo-list { display: grid; gap: 4px; }
.algo-item { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 8px; text-align: left; padding: 9px 9px; display: flex; align-items: center; gap: 9px; transition: .15s; }
.algo-item:hover { background: var(--panel-2); border-color: var(--line); }
.algo-item.active { background: rgba(76,224,195,.075); border-color: rgba(76,224,195,.24); box-shadow: inset 0 0 0 1px rgba(76,224,195,.04); }
.algo-radio { width: 13px; height: 13px; border: 1px solid #42617f; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.algo-item.active .algo-radio { border-color: var(--accent); }
.algo-item.active .algo-radio::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 5px var(--accent); }
.algo-copy { flex: 1; min-width: 0; }
.algo-name { font-size: 10.8px; font-weight: 620; color: var(--text-soft); display: flex; align-items: center; gap: 5px; }
.algo-desc { font-size: 8.5px; color: var(--dim); margin-top: 1px; }
.algo-badge { font-size: 7px; color: #0c2a24; background: var(--accent); border-radius: 3px; padding: 1px 4px; font-weight: 750; }
.param-panel { display: grid; gap: 8px; }
.param-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.param-row .pl { font-size: 9.5px; color: var(--muted); }
.param-row .pv { display: flex; align-items: center; gap: 4px; }
.mini-input { width: 72px; height: 27px; border: 1px solid var(--line); border-radius: 5px; background: #091421; padding: 0 6px; font-family: var(--mono); font-size: 9.5px; color: var(--text-soft); outline: none; text-align: right; }
.mini-input:focus { border-color: rgba(76,224,195,.5); }
.mini-unit { font-size: 8px; color: var(--dim); width: 24px; }
.analysis-cta { display: grid; gap: 6px; margin-top: 16px; }
.analysis-cta .btn { width: 100%; justify-content: flex-start; height: 34px; }
.analysis-cta .btn-primary { justify-content: center; }
.side-note { font-size: 8.5px; color: var(--dim); line-height: 1.65; border-top: 1px solid var(--line-soft); padding-top: 10px; margin-top: 12px; }
.analysis-main { overflow-y: auto; min-height: 0; background: radial-gradient(ellipse at 65% 0%, rgba(35,82,111,.12), transparent 42%), var(--bg); }
.analysis-inner { max-width: 1500px; margin: 0 auto; padding: 22px 25px 40px; }
.analysis-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.analysis-title .eyebrow { font-size: 8.5px; color: var(--accent); letter-spacing: .16em; font-weight: 750; text-transform: uppercase; }
.analysis-title h1 { font-size: 20px; margin: 3px 0 3px; font-weight: 680; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.analysis-title p { margin: 0; font-size: 10px; color: var(--muted); }
.analysis-top-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.result-badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; border: 1px solid rgba(76,224,195,.26); background: rgba(76,224,195,.08); color: #9aecd9; font-size: 8.5px; padding: 4px 9px; font-weight: 650; }
.result-badge.fail { border-color: rgba(255,125,140,.25); background: var(--red-soft); color: #ffb5bd; }
.result-badge.neutral { border-color: var(--line); background: var(--panel-2); color: var(--muted); }
.result-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-bottom: 13px; }
.metric {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(155deg, rgba(20,37,58,.9), rgba(11,22,37,.86));
  padding: 12px 13px 11px;
}
.metric::after { content: ""; position: absolute; right: -22px; bottom: -34px; width: 80px; height: 80px; border-radius: 50%; background: radial-gradient(circle, currentColor, transparent 68%); opacity: .06; }
.metric .m-label { display: flex; align-items: center; gap: 5px; font-size: 8.5px; color: var(--dim); letter-spacing: .01em; }
.metric .m-label .icon { width: 11px; height: 11px; opacity: .7; }
.metric .m-value { font-size: 22px; font-family: var(--mono); font-weight: 600; letter-spacing: -.03em; margin-top: 5px; color: var(--text); line-height: 1.1; }
.metric .m-value small { font-size: 10px; color: var(--muted); font-weight: 500; margin-left: 2px; letter-spacing: 0; }
.metric .m-foot { font-size: 8.5px; color: var(--dim); margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.metric.good .m-value { color: #b7f4e6; }
.metric.warn .m-value { color: #ffd79d; }
.metric.bad .m-value { color: #ffadb6; }
.metric.accent-metric { border-color: rgba(76,224,195,.22); background: linear-gradient(155deg, rgba(20,54,57,.5), rgba(11,28,35,.85)); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.section-gap { margin-top: 11px; }
.chart-wrap { width: 100%; height: 190px; position: relative; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--dim); font-size: 9px; }
.legend-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 8.5px; color: var(--dim); }
.legend-row .lg { display: flex; align-items: center; gap: 5px; }
.legend-row .sw { width: 9px; height: 2px; border-radius: 2px; }
.legend-row .sw.dot { width: 6px; height: 6px; border-radius: 50%; }
.table-wrap { overflow: auto; max-height: 340px; }
.table-wrap.tall { max-height: 470px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 9.5px; white-space: nowrap; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #0c1929;
  color: var(--dim); font-size: 8px; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 700; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line);
}
.data-table tbody td { padding: 8px 10px; border-bottom: 1px solid rgba(35,58,82,.42); color: var(--text-soft); vertical-align: middle; }
.data-table tbody tr:hover td { background: rgba(76,224,195,.035); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { font-family: var(--mono); text-align: right; font-size: 9px; }
.data-table .name-cell { color: var(--text); font-weight: 600; }
.data-table .tag-cell { color: var(--dim); font-family: var(--mono); font-size: 8.5px; }
.data-table .row-warn td { background: rgba(255,189,102,.035); }
.data-table .row-bad td { background: rgba(255,125,140,.045); }
.data-table .cell-sub { color: var(--dim); font-size: 8px; margin-top: 1px; }
.value-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: 8.5px; }
.value-pill.ok { color: #9be9d5; background: rgba(76,224,195,.08); }
.value-pill.warn { color: #ffd198; background: rgba(255,189,102,.1); }
.value-pill.bad { color: #ffadb6; background: rgba(255,125,140,.1); }
.value-pill.neutral { color: var(--muted); background: var(--panel-2); }
.load-bar { display: flex; align-items: center; gap: 7px; }
.load-bar .bar { width: 45px; height: 3px; background: var(--line); border-radius: 4px; overflow: hidden; }
.load-bar .bar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.load-bar .bar span.warn { background: var(--amber); }
.load-bar .bar span.bad { background: var(--red); }
.method-note { display: flex; align-items: flex-start; gap: 7px; padding: 9px 10px; border-radius: 7px; background: rgba(99,179,255,.045); border: 1px solid rgba(99,179,255,.12); color: #91b5d3; font-size: 8.7px; line-height: 1.6; }
.method-note .icon { color: var(--blue); width: 12px; height: 12px; margin-top: 1px; }
.check-list { display: grid; gap: 6px; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line-soft); background: rgba(9,20,33,.4); border-radius: 6px; font-size: 9px; color: var(--muted); }
.check-row .icon { width: 13px; height: 13px; flex: 0 0 auto; }
.check-row.ok { color: #9ccec1; border-color: rgba(76,224,195,.12); }
.check-row.warn { color: #d9b98b; border-color: rgba(255,189,102,.16); }
.check-row.bad { color: #e4a2a9; border-color: rgba(255,125,140,.18); }
.check-row .check-main { flex: 1; }
.check-row .check-val { font-family: var(--mono); font-size: 8.5px; }
.tabs-row { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 4px; overflow-x: auto; }
.tab-btn { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--dim); font-size: 9.5px; padding: 8px 10px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text-soft); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.matrix-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.matrix-quick .btn { font-size: 9px; height: 29px; }
.notice-strip { display: flex; align-items: center; gap: 7px; border: 1px solid rgba(255,189,102,.16); background: rgba(255,189,102,.04); color: #c9ad86; border-radius: 7px; padding: 8px 10px; font-size: 9px; }
.notice-strip .icon { width: 13px; height: 13px; flex: 0 0 auto; color: var(--amber); }

/* ---------------- Protection ---------------- */
.protection-shell { height: 100%; display: grid; grid-template-columns: 288px minmax(0,1fr) 390px; min-height: 0; }
.relay-side { border-right: 1px solid var(--line); background: linear-gradient(180deg, #0d1929, #0b1625); overflow-y: auto; padding: 17px 13px 28px; }
.relay-side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.relay-side-head .count-badge { font-family: var(--mono); font-size: 8.5px; color: var(--dim); border: 1px solid var(--line); padding: 2px 5px; border-radius: 4px; }
.relay-filter { display: flex; gap: 4px; margin-bottom: 9px; }
.relay-filter button { flex: 1; height: 25px; border: 1px solid var(--line); background: transparent; color: var(--dim); border-radius: 5px; font-size: 8.5px; }
.relay-filter button.active { border-color: rgba(76,224,195,.27); background: var(--accent-soft); color: var(--accent); }
.relay-list { display: grid; gap: 5px; }
.relay-item {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(13,27,44,.55); padding: 9px; display: flex; gap: 8px; text-align: left;
  transition: .15s;
}
.relay-item:hover { background: var(--panel-2); border-color: #2d455f; }
.relay-item.active { border-color: rgba(76,224,195,.42); background: rgba(76,224,195,.065); box-shadow: inset 0 0 0 1px rgba(76,224,195,.04); }
.relay-status-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 5px; background: var(--green); box-shadow: 0 0 7px var(--green); flex: 0 0 auto; }
.relay-status-dot.off { background: var(--dim); box-shadow: none; }
.relay-status-dot.warn { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.relay-item-body { flex: 1; min-width: 0; }
.relay-item-top { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.relay-item-name { font-size: 10px; font-weight: 630; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.relay-item-type { font-size: 7px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; flex: 0 0 auto; }
.relay-item-meta { display: flex; gap: 7px; margin-top: 3px; font-size: 8px; color: var(--dim); font-family: var(--mono); }
.relay-item-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relay-type-icon { width: 22px; height: 22px; border-radius: 6px; background: var(--panel-3); display: grid; place-items: center; color: var(--amber); flex: 0 0 auto; }
.relay-type-icon .icon { width: 13px; height: 13px; }
.protection-main { overflow-y: auto; min-height: 0; background: radial-gradient(ellipse at 35% 0%, rgba(62,75,118,.12), transparent 44%), var(--bg); }
.protection-inner { max-width: 1100px; margin: 0 auto; padding: 21px 23px 40px; }
.protection-right { border-left: 1px solid var(--line); background: #0b1727; overflow-y: auto; padding: 18px 15px 30px; }
.protection-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.protection-header h1 { margin: 3px 0 3px; font-size: 19px; font-weight: 680; }
.protection-header p { margin: 0; color: var(--muted); font-size: 9.7px; }
.protection-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.protection-card { margin-bottom: 10px; }
.relay-hero { border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(150deg, #122a42, #0e1d30); padding: 14px 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.relay-hero .rh-icon { width: 42px; height: 42px; border-radius: 11px; background: rgba(255,189,102,.1); border: 1px solid rgba(255,189,102,.18); display: grid; place-items: center; color: var(--amber); }
.relay-hero .rh-copy { flex: 1; }
.relay-hero h2 { font-size: 15px; margin: 0; font-weight: 680; }
.relay-hero .rh-sub { color: var(--dim); font-size: 9px; margin-top: 3px; }
.relay-hero .rh-status { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.function-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); }
.function-title { display: flex; align-items: center; gap: 7px; font-size: 10.5px; font-weight: 650; }
.function-title .icon { width: 15px; height: 15px; color: var(--accent); }
.function-title .sub { font-size: 8.5px; color: var(--dim); font-weight: 400; }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; padding: 13px; }
.settings-grid.two { grid-template-columns: 1fr 1fr; }
.setting-field label { font-size: 8.5px; color: var(--dim); display: flex; justify-content: space-between; }
.setting-field input, .setting-field select { width: 100%; height: 30px; border: 1px solid var(--line); background: #091421; border-radius: 5px; padding: 0 7px; color: var(--text-soft); font-family: var(--mono); font-size: 9.5px; outline: none; margin-top: 4px; }
.setting-field input:focus, .setting-field select:focus { border-color: rgba(76,224,195,.55); }
.setting-field .unit { color: var(--dim); font-size: 8px; }
.settings-foot { grid-column: 1/-1; display: flex; align-items: center; gap: 6px; font-size: 8.3px; color: var(--dim); border-top: 1px dashed var(--line-soft); padding-top: 8px; margin-top: 2px; }
.switch-row.compact { min-height: 28px; padding: 4px 8px; }
.function-toggle-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.function-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 8.5px; border: 1px solid var(--line); padding: 3px 7px; border-radius: 5px; color: var(--dim); }
.function-pill.on { border-color: rgba(76,224,195,.24); background: var(--accent-soft); color: var(--accent); }
.curve-card { padding: 13px 15px; }
.curve-toolbar { display: flex; gap: 4px; flex-wrap: wrap; }
.curve-svg { width: 100%; height: 180px; }
.curve-svg text { font-family: var(--mono); font-size: 7.5px; fill: var(--dim); }
.curve-svg .grid-line { stroke: rgba(73,101,130,.2); stroke-width: .8; }
.curve-svg .axis-line { stroke: rgba(97,128,158,.42); stroke-width: 1; }
.curve-svg .relay-curve { fill: none; stroke: var(--amber); stroke-width: 2.2; filter: drop-shadow(0 0 4px rgba(255,189,102,.25)); }
.curve-svg .relay-curve.secondary { stroke: var(--blue); stroke-width: 1.4; opacity: .7; }
.curve-svg .fault-line { stroke: var(--red); stroke-width: 1; stroke-dasharray: 4 3; opacity: .8; }
.curve-svg .fault-label { fill: #ff9aa6; font-size: 7.5px; }
.curve-svg .trip-marker { fill: #0b1727; stroke: var(--amber); stroke-width: 1.5; }
.curve-svg .axis-label { fill: #7088a1; font-size: 7.5px; }
.curve-caption { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; font-size: 8px; color: var(--dim); }
.issue-panel { margin-top: 10px; }
.issue-panel .issue-list { margin-top: 2px; }
.check-matrix { display: grid; gap: 5px; padding: 12px 14px; }
.coord-row { border: 1px solid var(--line-soft); border-radius: 6px; padding: 7px 8px; display: flex; align-items: center; gap: 7px; font-size: 8.5px; }
.coord-row .coord-names { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.coord-row .coord-time { font-family: var(--mono); color: var(--dim); font-size: 7.5px; }
.coord-row .coord-icon { width: 13px; height: 13px; }
.coord-row.ok .coord-icon { color: var(--green); }
.coord-row.warning .coord-icon { color: var(--amber); }
.formula-box { border: 1px solid var(--line-soft); background: rgba(8,18,30,.5); border-radius: 6px; padding: 8px 9px; font-family: var(--mono); font-size: 8.5px; color: #93afc9; line-height: 1.7; }
.formula-box b { color: var(--accent); font-weight: 500; }
.profile-list { display: grid; gap: 7px; }
.profile-row { display: flex; align-items: center; gap: 7px; }
.profile-row .pr-name { font-size: 8.5px; color: var(--muted); width: 60px; flex: 0 0 auto; }
.profile-row .pr-track { flex: 1; height: 4px; background: var(--line); border-radius: 3px; overflow: hidden; }
.profile-row .pr-fill { height: 100%; background: linear-gradient(90deg, var(--accent-deep), var(--accent)); border-radius: 3px; }
.profile-row .pr-val { font-family: var(--mono); font-size: 8px; color: var(--text-soft); width: 36px; text-align: right; }

/* ---------------- Short circuit ---------------- */
.sc-shell { height: 100%; display: grid; grid-template-columns: 310px minmax(0,1fr); min-height: 0; }
.sc-side { border-right: 1px solid var(--line); background: linear-gradient(180deg, #0d1929, #0b1625); overflow-y: auto; padding: 18px 15px 30px; }
.sc-side .card { margin-bottom: 9px; }
.sc-main { overflow-y: auto; min-height: 0; background: radial-gradient(ellipse at 60% 0%, rgba(57,101,130,.11), transparent 42%), var(--bg); }
.sc-inner { max-width: 1450px; margin: 0 auto; padding: 21px 25px 40px; }
.sc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 14px; }
.sc-head h1 { margin: 3px 0; font-size: 20px; font-weight: 680; }
.sc-head p { margin: 0; font-size: 9.7px; color: var(--muted); }
.sc-actions { display: flex; gap: 6px; }
.sc-form { display: grid; gap: 9px; }
.sc-bus-pick { display: grid; gap: 5px; max-height: 300px; overflow-y: auto; }
.sc-bus-option { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: rgba(9,20,33,.55); padding: 6px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; }
.sc-bus-option:hover { border-color: #34506d; background: var(--panel-2); }
.sc-bus-option.active { border-color: rgba(76,224,195,.35); background: rgba(76,224,195,.06); }
.sc-bus-option .bo-name { font-size: 9.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-bus-option .bo-kv { font-family: var(--mono); font-size: 8px; color: var(--dim); flex: 0 0 auto; }
.sc-summary { display: grid; grid-template-columns: 1.4fr 1fr; gap: 11px; margin-bottom: 11px; }
.fault-hero { position: relative; overflow: hidden; border-radius: 12px; border: 1px solid rgba(255,125,140,.2); background: linear-gradient(140deg, rgba(84,34,50,.45), rgba(30,20,35,.8) 55%, rgba(15,24,38,.9)); padding: 17px 18px; }
.fault-hero::after { content: ""; position: absolute; width: 170px; height: 170px; right: -55px; top: -65px; border-radius: 50%; background: radial-gradient(circle, rgba(255,125,140,.2), transparent 68%); }
.fault-hero .fh-kicker { font-size: 8px; color: #ff9ba8; letter-spacing: .16em; font-weight: 750; text-transform: uppercase; }
.fault-hero .fh-value { font-family: var(--mono); font-size: 39px; letter-spacing: -.05em; line-height: 1.1; margin-top: 5px; color: #ffe3e5; }
.fault-hero .fh-value small { font-size: 14px; color: #db9ca3; margin-left: 5px; letter-spacing: 0; }
.fault-hero .fh-sub { font-size: 9px; color: #bb8b92; margin-top: 4px; }
.fault-hero .fh-meta { display: flex; gap: 14px; margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(255,125,140,.15); }
.fault-hero .fh-meta .item .l { font-size: 7.5px; color: #9c767d; }
.fault-hero .fh-meta .item .v { font-family: var(--mono); font-size: 11px; color: #f0c9cd; margin-top: 1px; }
.sc-meta-card { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-soft); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sc-meta-item { background: #0d1929; padding: 12px; }
.sc-meta-item .l { font-size: 8px; color: var(--dim); }
.sc-meta-item .v { font-family: var(--mono); font-size: 14px; color: var(--text-soft); margin-top: 3px; }
.sc-meta-item .v small { font-size: 8px; color: var(--dim); margin-left: 2px; }
.voltage-dip-bar { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 64px; }
.voltage-dip-bar span { height: 100%; display: block; background: var(--amber); border-radius: 3px; }
.contrib-rank { display: grid; gap: 6px; }
.contrib-rank .cr-row { display: flex; align-items: center; gap: 8px; font-size: 8.5px; }
.contrib-rank .cr-name { width: 100px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.contrib-rank .cr-bar { height: 5px; flex: 1; background: var(--line); border-radius: 4px; overflow: hidden; }
.contrib-rank .cr-bar span { height: 100%; display: block; background: linear-gradient(90deg, #d75e6c, #ff9aa5); }
.contrib-rank .cr-val { width: 50px; text-align: right; font-family: var(--mono); color: var(--text-soft); }
.sc-note { display: flex; gap: 7px; align-items: flex-start; font-size: 8.6px; color: #879db4; line-height: 1.65; padding: 10px 12px; border: 1px solid rgba(99,179,255,.12); background: rgba(99,179,255,.035); border-radius: 7px; margin-top: 10px; }
.sc-note .icon { width: 13px; height: 13px; flex: 0 0 auto; color: var(--blue); margin-top: 1px; }

/* ---------------- Report ---------------- */
.report-shell { height: 100%; overflow-y: auto; background: radial-gradient(ellipse at 50% -10%, rgba(67,97,127,.15), transparent 50%), #060e18; }
.report-toolbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 12px 25px; border-bottom: 1px solid var(--line); background: rgba(8,17,29,.9); backdrop-filter: blur(16px); }
.report-toolbar .rt-left { display: flex; align-items: center; gap: 10px; }
.report-toolbar .rt-title { font-size: 12px; font-weight: 650; }
.report-toolbar .rt-sub { font-size: 8.5px; color: var(--dim); }
.report-toolbar .rt-actions { display: flex; gap: 6px; }
.report-paper-wrap { padding: 28px 25px 60px; display: flex; justify-content: center; }
.report-paper { width: 862px; max-width: 100%; background: #f7f8fb; color: #1b2734; border-radius: 3px; box-shadow: 0 30px 80px rgba(0,0,0,.5); padding: 46px 54px 48px; position: relative; }
.report-paper::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, #159f87, #43cdb1 55%, #285b84); }
.report-paper .rp-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid #193548; padding-bottom: 18px; margin-bottom: 24px; }
.report-paper .rp-brand { font-size: 9px; letter-spacing: .18em; text-transform: uppercase; color: #55758d; font-weight: 700; }
.report-paper .rp-title { font-size: 26px; font-weight: 760; letter-spacing: -.02em; margin: 6px 0 4px; color: #112635; }
.report-paper .rp-subtitle { font-size: 11px; color: #607a8c; }
.report-paper .rp-doc { text-align: right; font-family: var(--mono); font-size: 8.5px; color: #647d8e; line-height: 1.7; }
.report-paper .rp-doc b { color: #1c3e51; font-weight: 650; }
.report-paper h2 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #18394c; border-bottom: 1px solid #cbd8e1; padding-bottom: 6px; margin: 25px 0 11px; display: flex; align-items: center; gap: 7px; }
.report-paper h2 .num { font-family: var(--mono); font-size: 9px; color: #218d7c; background: #e3f4f0; border-radius: 3px; padding: 1px 4px; }
.report-paper h3 { font-size: 10px; color: #2a485c; margin: 13px 0 6px; }
.report-paper p { font-size: 9.5px; line-height: 1.75; color: #405a6c; margin: 0 0 8px; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.report-kv { display: grid; grid-template-columns: 90px 1fr; gap: 5px 8px; font-size: 9px; }
.report-kv .k { color: #6a8293; }
.report-kv .v { color: #203c4d; font-weight: 600; }
.report-table { width: 100%; border-collapse: collapse; font-size: 8.3px; margin: 7px 0 10px; }
.report-table th { text-align: left; background: #e9eff4; color: #385668; padding: 5px 6px; border: 1px solid #d3dee6; font-weight: 650; }
.report-table td { padding: 4px 6px; border: 1px solid #dce5eb; color: #354f61; }
.report-table td.num { font-family: var(--mono); text-align: right; }
.report-table tr.total td { background: #f0f5f7; font-weight: 650; color: #1f3d50; }
.report-subtitle { margin: 12px 0 6px; font-size: 10px; font-weight: 700; color: var(--text-soft); }
.report-callout { border-left: 3px solid #28a58e; background: #edf7f4; padding: 9px 11px; font-size: 9px; line-height: 1.7; color: #3a605b; margin: 10px 0; }
.report-callout.warn { border-color: #d39536; background: #fbf5e9; color: #6f5c3b; }
.report-callout b { color: #1a5a4f; }
.report-signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 36px; padding-top: 18px; border-top: 1px solid #d3dee6; }
.report-signatures .sig .line { border-bottom: 1px solid #91a6b4; height: 25px; }
.report-signatures .sig .cap { font-size: 8px; color: #6d8291; margin-top: 5px; }
.report-footer { margin-top: 28px; padding-top: 9px; border-top: 1px solid #dbe4ea; display: flex; justify-content: space-between; font-size: 7.5px; color: #8a9daa; font-family: var(--mono); }
.report-watermark { position: absolute; right: 38px; top: 154px; font-size: 78px; font-weight: 800; color: rgba(27, 63, 80, .028); letter-spacing: .05em; transform: rotate(-8deg); pointer-events: none; }
.report-empty .empty-state { color: #304a5d; }
.report-empty .empty-state h2 { color: #1e3b4d; }
.report-empty .empty-state p { color: #6b8291; }
.report-paper .report-mini-chart { width: 100%; height: 120px; border: 1px solid #dce5eb; background: #fbfcfd; padding: 6px; margin: 6px 0 10px; }

/* ---------------- Modal ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 7, 12, .72); backdrop-filter: blur(6px); opacity: 0; transition: .2s; pointer-events: none; }
.modal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -48%) scale(.985); opacity: 0; pointer-events: none; transition: .2s ease; background: #0c1929; border: 1px solid #29425d; border-radius: 13px; box-shadow: 0 36px 90px rgba(0,0,0,.6); display: flex; flex-direction: column; max-height: 90vh; min-height: 220px; }
.modal-root.open { pointer-events: auto; }
.modal-root.open .modal-backdrop { opacity: 1; pointer-events: auto; }
.modal-root.open .modal { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-sm { width: 440px; }
.modal-md { width: 610px; }
.modal-lg { width: 900px; }
.modal-matrix { width: min(1250px, 94vw); height: min(840px, 89vh); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 17px 19px 14px; border-bottom: 1px solid var(--line); }
.modal-head .mh-kicker { font-size: 8px; color: var(--accent); letter-spacing: .16em; text-transform: uppercase; font-weight: 750; }
.modal-head h2 { font-size: 16px; font-weight: 680; margin: 3px 0 2px; }
.modal-head p { font-size: 9px; color: var(--muted); margin: 0; line-height: 1.55; }
.modal-close { width: 29px; height: 29px; border: 1px solid transparent; background: transparent; color: var(--dim); border-radius: 6px; display: grid; place-items: center; }
.modal-close:hover { background: var(--panel-3); color: var(--text); }
.modal-body { padding: 17px 19px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 7px; padding: 12px 19px; border-top: 1px solid var(--line); background: #0a1523; border-radius: 0 0 13px 13px; }
.modal-foot .left { margin-right: auto; color: var(--dim); font-size: 8.5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-grid .full { grid-column: 1/-1; }
.modal-field label { display: block; font-size: 9px; color: var(--muted); margin-bottom: 5px; }
.modal-field input, .modal-field select, .modal-field textarea { width: 100%; height: 34px; border: 1px solid var(--line); background: #081421; border-radius: 6px; padding: 0 9px; font-size: 10.5px; color: var(--text-soft); outline: none; }
.modal-field textarea { height: 75px; padding: 8px 9px; resize: vertical; line-height: 1.5; }
.modal-field input:focus, .modal-field select:focus, .modal-field textarea:focus { border-color: rgba(76,224,195,.5); }
.modal-field .hint { font-size: 8px; color: var(--dim); margin-top: 3px; line-height: 1.4; }
.modal-help { background: rgba(99,179,255,.04); border: 1px solid rgba(99,179,255,.1); border-radius: 7px; padding: 9px 10px; font-size: 8.5px; line-height: 1.65; color: #8ca6be; margin-top: 12px; }
.modal-tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: 0 0 auto; }
.modal-tab { border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--dim); padding: 9px 10px; font-size: 9.5px; white-space: nowrap; margin-bottom: -1px; }
.modal-tab:hover { color: var(--text-soft); }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.matrix-toolbar { display: flex; align-items: center; gap: 7px; padding: 10px 18px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.matrix-toolbar .spacer { flex: 1; }
.matrix-mode { display: flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.matrix-mode button { border: 0; background: transparent; color: var(--dim); height: 25px; padding: 0 8px; font-size: 8.5px; border-right: 1px solid var(--line); }
.matrix-mode button:last-child { border: 0; }
.matrix-mode button.active { background: var(--accent-soft); color: var(--accent); }
.matrix-content { flex: 1; overflow: auto; padding: 14px 18px 22px; min-height: 0; }
.matrix-table { border-collapse: separate; border-spacing: 0; font-family: var(--mono); font-size: 8.3px; white-space: nowrap; }
.matrix-table th { position: sticky; top: 0; z-index: 2; background: #0c1929; color: var(--dim); font-weight: 600; padding: 5px 7px; border-bottom: 1px solid var(--line); text-align: right; font-size: 7.5px; }
.matrix-table th.rowhead { position: sticky; left: 0; z-index: 1; background: #0c1929; text-align: left; color: var(--muted); border-right: 1px solid var(--line); min-width: 98px; }
.matrix-table th.corner { left: 0; z-index: 3; text-align: left; color: var(--dim); }
.matrix-table td { padding: 4px 7px; text-align: right; border-bottom: 1px solid rgba(36,58,81,.32); color: #b7c8d8; }
.matrix-table td.rowhead { position: sticky; left: 0; background: #0b1727; color: var(--muted); text-align: left; border-right: 1px solid var(--line); }
.matrix-table td.zero { color: #3f566d; }
.matrix-table td.diag { color: #a7eadc; background: rgba(76,224,195,.035); }
.matrix-table tr:hover td { background: rgba(99,179,255,.04); }
.matrix-table tr:hover td.rowhead { background: #122237; }
.matrix-table td.partition { background: rgba(255,189,102,.06); }
.matrix-legend { display: flex; align-items: center; gap: 12px; font-size: 8px; color: var(--dim); margin-bottom: 9px; flex-wrap: wrap; }
.matrix-legend .sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.matrix-info { font-size: 8.5px; color: var(--dim); line-height: 1.6; }
.matrix-empty { display: grid; place-items: center; height: 100%; color: var(--dim); font-size: 10px; }
.matrix-badge { font-size: 8px; color: var(--muted); border: 1px solid var(--line); padding: 2px 5px; border-radius: 4px; }
.kbd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 18px; }
.kbd-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 9.5px; color: var(--muted); border-bottom: 1px dashed var(--line-soft); padding-bottom: 6px; }
.kbd-row kbd, .shortcut { font-family: var(--mono); font-size: 8px; border: 1px solid var(--line); border-bottom-width: 2px; background: #091421; border-radius: 4px; padding: 2px 5px; color: var(--text-soft); display: inline-block; }
.confirm-icon { width: 39px; height: 39px; border-radius: 10px; background: var(--red-soft); border: 1px solid rgba(255,125,140,.2); color: var(--red); display: grid; place-items: center; margin-bottom: 10px; }
.confirm-icon .icon { width: 19px; height: 19px; }
.confirm-title { font-size: 14px; font-weight: 650; margin-bottom: 5px; }
.confirm-text { font-size: 10px; color: var(--muted); line-height: 1.65; }

/* ---------------- Toasts / misc ---------------- */
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 7px; pointer-events: none; }
.toast { min-width: 250px; max-width: 370px; display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(14,28,45,.96); box-shadow: var(--shadow-md); backdrop-filter: blur(14px); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: auto; }
.toast.show { opacity: 1; transform: none; }
.toast .toast-icon { width: 20px; height: 20px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: 0 0 auto; margin-top: 1px; }
.toast .toast-icon .icon { width: 12px; height: 12px; }
.toast .toast-copy { flex: 1; min-width: 0; }
.toast .toast-title { font-size: 10px; font-weight: 650; color: var(--text); }
.toast .toast-msg { font-size: 8.8px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.toast.warning { border-color: rgba(255,189,102,.25); }
.toast.warning .toast-icon { background: var(--amber-soft); color: var(--amber); }
.toast.error { border-color: rgba(255,125,140,.28); }
.toast.error .toast-icon { background: var(--red-soft); color: var(--red); }
.toast .toast-close { border: 0; background: transparent; color: var(--dim); padding: 0; width: 18px; height: 18px; display: grid; place-items: center; }
.loading-overlay { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; background: rgba(3,8,14,.55); backdrop-filter: blur(4px); }
.loading-card { display: flex; align-items: center; gap: 12px; padding: 17px 21px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow-lg); font-size: 10.5px; color: var(--text-soft); }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(76,224,195,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fade-in { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.danger-note { color: #ffb0b8; }
.status-pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 20px; padding: 2px 7px; font-size: 8px; font-weight: 600; }
.status-pill.ok { background: rgba(76,224,195,.08); color: #9fe8d9; }
.status-pill.warn { background: var(--amber-soft); color: #f4ca8c; }
.status-pill.bad { background: var(--red-soft); color: #ffb3bb; }
.status-pill.neutral { background: var(--panel-2); color: var(--dim); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1460px) {
  .design-shell { grid-template-columns: 214px minmax(0,1fr) 320px; }
  .analysis-shell { grid-template-columns: 278px minmax(0,1fr); }
  .protection-shell { grid-template-columns: 268px minmax(0,1fr) 354px; }
  .metrics { gap: 7px; }
  .metric { padding: 11px; }
  .metric .m-value { font-size: 20px; }
}
@media (max-width: 1270px) {
  .design-shell { grid-template-columns: 200px minmax(0,1fr) 310px; }
  .palette { padding: 14px 10px 22px; }
  .palette-items { gap: 5px; }
  .protection-shell { grid-template-columns: 245px minmax(0,1fr) 325px; }
  .analysis-shell { grid-template-columns: 263px minmax(0,1fr); }
  .analysis-inner { padding: 18px 20px 35px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .page-head { padding: 21px 22px 13px; }
  .main-pad { padding: 0 22px 30px; }
}
@media (max-width: 1080px) {
  .design-shell { grid-template-columns: 178px minmax(0,1fr) 290px; }
  .brand { min-width: 195px; }
  .brand-sub { letter-spacing: .11em; }
  .project-crumbs { padding-left: 12px; }
  .mode-tab { padding: 0 10px; }
  .protection-shell { grid-template-columns: 220px minmax(0,1fr); }
  .protection-right { display: none; }
  .sc-shell { grid-template-columns: 270px minmax(0,1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media print {
  body { overflow: visible; background: white; }
  .topbar, .modebar, .report-toolbar, .toast-stack, .modal-root { display: none !important; }
  #view-root, .view, .report-shell { overflow: visible; height: auto; background: white; }
  .report-paper-wrap { padding: 0; }
  .report-paper { width: 100%; box-shadow: none; border-radius: 0; padding: 28px 34px; }
  .report-paper::before { display: none; }
  .report-paper h2 { break-after: avoid; }
  .report-table, .report-callout { break-inside: avoid; }
  @page { size: A4; margin: 14mm; }
}

/* Polish: keep labels legible when branch routes pass behind them */
.bus-g .bus-label-tag, .bus-g .bus-label-name, .bus-g .bus-label-kv {
  paint-order: stroke fill;
  stroke: #07111e;
  stroke-width: 3.5px;
  stroke-linejoin: round;
}
.branch-g .branch-open-label { paint-order: stroke fill; stroke: #07111e; stroke-width: 2.5px; }
.injection-g .inj-tag, .injection-g .inj-label, .injection-g .inj-meta {
  paint-order: stroke fill;
  stroke: #07111e;
  stroke-width: 3px;
  stroke-linejoin: round;
}
.report-diagram svg { max-width: 100%; height: auto; display: block; }
.report-diagram { break-inside: avoid; }
.canvas-stage.is-armed { cursor: crosshair; }
.palette-item .p-key { pointer-events: none; }
.inspector textarea:focus { border-color: rgba(76,224,195,.5) !important; }
.modal .modal-close { flex: 0 0 auto; }
.matrix-content:focus { outline: none; }

.branch-g .branch-flow {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
}

@media (max-width: 1460px) {
  .canvas-hint { display: none; }
}

/* Example network library */
.examples-intro { display:flex; align-items:flex-start; gap:7px; padding:9px 11px; margin-bottom:12px; border:1px solid rgba(99,179,255,.12); border-radius:7px; background:rgba(99,179,255,.04); color:#8ca6be; font-size:8.8px; line-height:1.6; }
.examples-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:11px; }
.example-card { position:relative; display:flex; flex-direction:column; gap:8px; padding:13px; border:1px solid var(--line); border-radius:9px; background:linear-gradient(160deg,rgba(19,36,53,.9),rgba(8,19,31,.94)); overflow:hidden; }
.example-card::before { content:''; position:absolute; inset:0 0 auto 0; height:2px; background:var(--ex-accent); opacity:.75; }
.example-top { display:flex; align-items:center; justify-content:space-between; gap:7px; }
.example-glyph { width:36px; height:36px; display:grid; place-items:center; border-radius:9px; border:1px solid color-mix(in srgb,var(--ex-accent) 35%,transparent); background:color-mix(in srgb,var(--ex-accent) 9%,transparent); color:var(--ex-accent); font-size:21px; font-weight:700; }
.example-card h3 { margin:0; font-size:13px; color:var(--text-soft); letter-spacing:.01em; }
.example-card p { margin:0; min-height:48px; color:var(--muted); font-size:9px; line-height:1.6; }
.example-tags { display:flex; flex-wrap:wrap; gap:4px; }
.example-tags span { padding:2px 6px; border:1px solid rgba(95,226,201,.18); border-radius:4px; color:#8fcfc3; background:rgba(95,226,201,.04); font-size:7.8px; }
.example-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:5px; margin-top:auto; }
.example-stats div { display:flex; align-items:baseline; gap:4px; padding:5px 6px; border:1px solid var(--line); border-radius:5px; background:rgba(5,14,24,.45); }
.example-stats b { color:var(--text-soft); font-size:15px; font-family:var(--mono); }
.example-stats small { color:var(--dim); font-size:7.5px; }
.example-load { margin-top:2px; width:100%; justify-content:center; }
@media (max-width:1200px) { .examples-grid { grid-template-columns:1fr 1fr; } }
@media (max-width:760px) { .examples-grid { grid-template-columns:1fr; } }

/* protection function library */
.protection-fn-group { margin-top: 10px; }
.protection-fn-group-title { display:flex; justify-content:space-between; align-items:center; font-size:8px; letter-spacing:.12em; text-transform:uppercase; color:var(--dim); margin:0 0 5px; }
.protection-fn-group-title span { font-family:var(--mono); letter-spacing:0; color:#69839a; }
.protection-fn-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; }
.protection-fn { display:flex; align-items:center; gap:5px; min-height:27px; padding:4px 6px; border:1px solid rgba(80,110,140,.18); border-radius:5px; background:rgba(10,22,36,.45); color:var(--muted); text-align:left; font-family:inherit; cursor:pointer; transition:.15s; overflow:hidden; }
.protection-fn:hover { border-color:rgba(99,179,255,.35); background:rgba(20,38,58,.7); }
.protection-fn.on { color:var(--text-soft); border-color:rgba(76,224,195,.18); }
.protection-fn.active { border-color:rgba(76,224,195,.65); background:rgba(76,224,195,.08); box-shadow:0 0 0 1px rgba(76,224,195,.1); }
.protection-fn.off { opacity:.62; }
.protection-fn-dot { width:4px; height:4px; border-radius:50%; background:#516984; flex:none; }
.protection-fn.on .protection-fn-dot { background:var(--green); box-shadow:0 0 6px rgba(76,224,195,.5); }
.protection-fn-code { font-family:var(--mono); font-size:7px; color:#6c8aa4; flex:none; }
.protection-fn-name { font-size:8.5px; line-height:1.15; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.protection-fn-detail .settings-grid { grid-template-columns:1fr 1fr 1fr; }
@media (max-width:1180px){ .protection-fn-grid{grid-template-columns:repeat(3,minmax(0,1fr));} }

.protection-catalog { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.catalog-column { min-width:0; border:1px solid rgba(80,110,140,.16); border-radius:8px; overflow:hidden; background:rgba(8,19,33,.4); }
.catalog-head { display:flex; align-items:center; gap:6px; padding:8px 10px; font-size:9px; font-weight:650; color:var(--text-soft); background:rgba(20,38,58,.55); border-bottom:1px solid rgba(80,110,140,.16); }
.catalog-head span { margin-left:auto; font-family:var(--mono); font-size:7.5px; color:var(--dim); }
.catalog-row { display:grid; grid-template-columns:34px 1fr auto; gap:2px 6px; padding:6px 8px; border-bottom:1px solid rgba(80,110,140,.09); }
.catalog-row:last-child { border-bottom:0; }
.catalog-code { font-family:var(--mono); font-size:7px; color:#6c8aa4; padding-top:1px; }
.catalog-name { font-size:8.5px; font-weight:600; color:var(--text-soft); line-height:1.2; }
.catalog-name em { font-style:normal; font-size:6.5px; color:var(--amber); border:1px solid rgba(255,196,110,.3); border-radius:3px; padding:0 3px; margin-left:4px; }
.catalog-state { font-size:6.5px; color:var(--dim); white-space:nowrap; padding-top:1px; }
.catalog-state.on { color:var(--green); }
.catalog-state.off { color:#6f7c88; }
.catalog-desc { grid-column:2 / -1; font-size:7px; line-height:1.4; color:#617a91; }
@media (max-width:1050px){ .protection-catalog{grid-template-columns:1fr;} }
