:root {
  --bg: #f4f5f8;
  --canvas: #f8f9fb;
  --dot: #d9dde4;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-3: #e8ebf0;
  --border: #dfe3e9;
  --border-strong: #c9ced8;
  --text: #171a21;
  --muted: #667085;
  --accent: #5b4bdb;
  --accent-soft: #eeecfd;
  --create: #16a34a;
  --update: #c47f0a;
  --replace: #e0620d;
  --delete: #dc2626;
  --read: #2f7bd8;
  --applying: #2f7bd8;
  --complete: #16a34a;
  --errored: #dc2626;
  --grants: #c08410;
  --edge: #a7aebb;
  --edge-hot: #5b4bdb;
  --high: #dc2626;
  --medium: #c47f0a;
  --low: #6b7280;
  --c-compute: #e8833a;
  --c-database: #3b82f6;
  --c-storage: #16a34a;
  --c-network: #8b5cf6;
  --c-identity: #d6409f;
  --c-secret: #ca8a04;
  --c-api: #0891b2;
  --c-messaging: #e11d48;
  --c-workflow: #0d9488;
  --c-observability: #64748b;
  --c-other: #8a8f98;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --radius: 8px;
  --radius-lg: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14;
    --canvas: #101319;
    --dot: #1e232d;
    --surface: #161a22;
    --surface-2: #1d222c;
    --surface-3: #252b37;
    --border: #272d39;
    --border-strong: #353c4b;
    --text: #e7e9ef;
    --muted: #9198a8;
    --accent: #8f82ff;
    --accent-soft: #24203f;
    --create: #3ecf7f;
    --update: #e5a73d;
    --replace: #f28c4d;
    --delete: #f26b6b;
    --read: #61a5f2;
    --applying: #61a5f2;
    --complete: #3ecf7f;
    --errored: #f26b6b;
    --grants: #e5a73d;
    --edge: #485062;
    --edge-hot: #8f82ff;
    --c-compute: #f39a55;
    --c-database: #60a5fa;
    --c-storage: #4ade80;
    --c-network: #a78bfa;
    --c-identity: #f472b6;
    --c-secret: #facc15;
    --c-api: #22d3ee;
    --c-messaging: #fb7185;
    --c-workflow: #2dd4bf;
    --c-observability: #94a3b8;
    --c-other: #9aa0aa;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 2px 8px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
svg { stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 4px; text-align: center;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface-2);
  font: 11px/16px var(--mono); color: var(--muted);
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; letter-spacing: -.015em; }
.source { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; overflow: hidden; color: var(--muted); white-space: nowrap; }
.source > * { flex: none; }
.source .label { flex: 0 1 auto; min-width: 40px; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 26vw; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.tag.plan { color: var(--update); border-color: color-mix(in srgb, var(--update) 40%, var(--border)); }
.tag.state { color: var(--create); border-color: color-mix(in srgb, var(--create) 40%, var(--border)); }
.tag.static { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.tag.masked { text-transform: none; letter-spacing: 0; font-weight: 500; }
.spacer { flex: 1; }
.search {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 0 8px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2);
}
.search:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { fill: none; stroke: var(--muted); stroke-width: 1.6; flex: none; }
.search input { width: 220px; padding: 5px 0; border: 0; background: none; outline: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:focus-visible, .seg button:focus-visible, .tabs button:focus-visible, .side-row:focus-visible, .node:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.icon { width: 30px; height: 30px; padding: 0; font-size: 15px; }
.btn.icon svg { fill: none; stroke: currentColor; stroke-width: 1.6; }
.btn.ghost { border-color: transparent; background: none; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); filter: brightness(1.08); }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.notes { padding: 7px 14px; background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.notes p { margin: 0; }

/* ---------- layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; position: relative; }
main { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; }
.view { flex: 1; position: relative; min-width: 0; min-height: 0; overflow: hidden; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 272px; flex: none; overflow-y: auto; padding: 12px 10px 24px;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar.collapsed { display: none; }
.card { padding: 4px 4px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.card:last-child { border-bottom: 0; }
.card h3 {
  display: flex; justify-content: space-between; align-items: center;
  margin: 6px 4px 8px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
}
.card h3 .muted { text-transform: none; letter-spacing: 0; font-weight: 500; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { padding: 8px 10px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.stat .n { display: block; font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 11.5px; }
.side-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 6px; border: 0; border-radius: 6px;
  background: none; cursor: pointer; text-align: left;
}
.side-row:hover { background: var(--surface-2); }
.side-row.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row .count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.side-row .meter { width: 54px; height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; flex: none; }
.side-row .meter span { display: block; height: 100%; border-radius: 999px; }
.side-icon { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.side-icon svg { width: 14px; height: 14px; fill: none; stroke-width: 1.5; }
.dotmark { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.finding-row { align-items: flex-start; }
.finding-row .name { white-space: normal; }
.finding-row .addr { display: block; color: var(--muted); font: 11px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ok { display: flex; gap: 8px; align-items: center; padding: 4px 6px; color: var(--create); }
.toggle { display: flex; align-items: center; gap: 8px; padding: 4px 6px; cursor: pointer; border-radius: 6px; }
.toggle:hover { background: var(--surface-2); }
.toggle input { accent-color: var(--accent); margin: 0; }
.legend-line { width: 22px; height: 0; border-top: 2px solid var(--edge); flex: none; }
.legend-line.value { border-top-style: dotted; }
.legend-line.grants { border-top: 2px dashed var(--grants); }

/* ---------- filters bar ---------- */
.filters {
  position: absolute; top: 10px; left: 12px; right: 12px; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none;
}
.filters > * { pointer-events: auto; }
.fchip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 12px;
}
.fchip button { border: 0; background: var(--surface-2); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; line-height: 1; padding: 0; }
.fchip.clear { padding-right: 10px; cursor: pointer; color: var(--accent); }

/* ---------- graph ---------- */
#graph-view {
  background-color: var(--canvas);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
}
#graph { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; touch-action: none; }
#graph.panning { cursor: grabbing; }
.zoom { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.zoom .btn { box-shadow: var(--shadow); }
#minimap {
  position: absolute; left: 14px; bottom: 14px; width: 200px; height: 130px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
}
#minimap .mm-node { opacity: .85; }
#minimap .mm-view { fill: var(--accent); fill-opacity: .08; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.empty-card { max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px 26px; box-shadow: var(--shadow); text-align: left; }
.empty-card h3 { margin: 0 0 6px; color: var(--text); font-size: 15px; }
.empty-card pre { margin: 10px 0 0; background: var(--surface-2); border: 1px solid var(--border); padding: 10px 12px; border-radius: var(--radius); font: 12px/1.6 var(--mono); color: var(--text); overflow-x: auto; }

.node { cursor: pointer; transition: opacity .15s ease; }
.node rect.box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.2; rx: 10; filter: drop-shadow(0 1px 1.5px rgba(16, 24, 40, .08)); }
.node:hover rect.box { stroke: var(--accent); }
.node text { fill: var(--text); font-family: var(--sans); }
.node text.kind { fill: var(--muted); font-size: 10.5px; }
.node text.name { font-size: 13px; font-weight: 650; }
.node text.badge { font-size: 13px; font-weight: 800; }
.node .icon-bg { fill-opacity: .14; }
.node .icon path, .node .icon circle, .node .icon rect, .node .icon ellipse { fill: none; stroke-width: 1.5; }
#graph.lod-far .node text.kind { display: none; }
#graph.lod-far .node text.name { font-size: 19px; transform: translateY(-5px); }
#graph.lod-far .node .phase-icon { font-size: 17px; }
.node.impact-down rect.box { stroke: var(--delete); stroke-width: 2.4; }
.node.impact-up rect.box { stroke: var(--read); stroke-width: 2.2; stroke-dasharray: 6 3; }
.node.impact-origin rect.box { stroke: var(--accent); stroke-width: 3; }
.node.drifted rect.box { stroke: var(--update); stroke-dasharray: 2 2; stroke-width: 2.2; }
.node.selected rect.box { stroke: var(--accent); stroke-width: 2.5; }
.node.match rect.box { stroke: var(--accent); stroke-width: 2.2; }
.node.dim { opacity: .22; }
.node.data rect.box { stroke-dasharray: 5 3; }
.node.ghost rect.box { stroke-dasharray: 2 3; fill: var(--surface-2); }
.node.action-create rect.box { stroke: var(--create); stroke-width: 1.8; }
.node.action-update rect.box { stroke: var(--update); stroke-width: 1.8; }
.node.action-replace rect.box { stroke: var(--replace); stroke-width: 1.8; }
.node.action-delete rect.box { stroke: var(--delete); stroke-width: 1.8; }
.node.action-delete text.name { text-decoration: line-through; }
.badge.create { fill: var(--create); } .badge.update { fill: var(--update); } .badge.replace { fill: var(--replace); }
.badge.delete { fill: var(--delete); } .badge.read { fill: var(--read); } .badge.forget { fill: var(--muted); }
.finding-dot.high { fill: var(--high); } .finding-dot.medium { fill: var(--medium); } .finding-dot.low { fill: var(--low); }
.finding-text { fill: #fff !important; font-size: 10px; font-weight: 800; }
.node.phase-pending rect.box { stroke-dasharray: 3 3; stroke: var(--applying); }
.node.phase-refreshing rect.box { stroke: var(--applying); stroke-dasharray: 3 3; }
.node.phase-applying rect.box { stroke: var(--applying); stroke-width: 2.6; stroke-dasharray: 10 6; animation: march 1s linear infinite; }
.node.phase-complete rect.box { stroke: var(--complete); stroke-width: 2.2; stroke-dasharray: none; }
.node.phase-errored rect.box { stroke: var(--errored); stroke-width: 2.8; stroke-dasharray: none; fill: color-mix(in srgb, var(--errored) 9%, var(--surface)); }
.node .phase-icon { font-size: 12px; font-weight: 700; }
.phase-icon.complete { fill: var(--complete); } .phase-icon.errored { fill: var(--errored); } .phase-icon.applying, .phase-icon.refreshing, .phase-icon.pending { fill: var(--applying); }
@keyframes march { to { stroke-dashoffset: -32; } }

.edge { fill: none; stroke: var(--edge); stroke-width: 1.4; transition: opacity .15s ease; }
.edge.value { stroke-dasharray: 1 4; stroke-width: 2; }
.edge.grants { stroke: var(--grants); stroke-dasharray: 6 4; stroke-width: 1.6; }
.edge.hot { stroke: var(--edge-hot); stroke-width: 2.4; }
.edge.grants.hot { stroke: var(--grants); stroke-width: 2.6; }
.edge.dim { opacity: .1; }
.arrow { fill: var(--edge); } .arrow.grants { fill: var(--grants); } .arrow.hot { fill: var(--edge-hot); }

/* ---------- table ---------- */
#table-view { overflow: auto; background: var(--surface); }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid th { position: sticky; top: 0; background: var(--surface-2); cursor: pointer; font-weight: 600; z-index: 1; font-size: 12px; color: var(--muted); }
.grid th.sorted { color: var(--text); }
.grid th.sorted::after { content: " ↓"; }
.grid th.sorted.asc::after { content: " ↑"; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid tbody tr.selected { background: var(--accent-soft); }
.grid td.addr { font-family: var(--mono); font-size: 12px; }
.svc { display: inline-flex; align-items: center; gap: 6px; }
.pill { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.pill.create { color: var(--create); } .pill.update { color: var(--update); } .pill.replace { color: var(--replace); }
.pill.delete { color: var(--delete); } .pill.read { color: var(--read); } .pill.no-op { color: var(--muted); }
.pill.applying, .pill.pending, .pill.refreshing { color: var(--applying); } .pill.complete { color: var(--complete); } .pill.errored { color: var(--errored); }
.pill.high { color: var(--high); } .pill.medium { color: var(--medium); } .pill.low { color: var(--low); }

/* ---------- timeline ---------- */
#timeline-view { overflow: auto; background: var(--surface); }
.tl-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.tl-head h2 { margin: 0; font-size: 15px; }
.tl-head .stat-inline { color: var(--muted); }
.tl-head .stat-inline strong { color: var(--text); font-variant-numeric: tabular-nums; }
.tl { padding: 8px 18px 24px; }
.tl-row { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 14px; align-items: center; min-height: 30px; border-radius: 6px; cursor: pointer; padding: 0 6px; }
.tl-row:hover { background: var(--surface-2); }
.tl-row.selected { background: var(--accent-soft); }
.tl-label { display: flex; align-items: center; gap: 8px; min-width: 0; font: 12px var(--mono); }
.tl-label span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 18px; }
.tl-axis { position: sticky; top: 0; z-index: 1; background: var(--surface); display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 14px; padding: 6px 24px 6px 24px; border-bottom: 1px solid var(--border); }
.tl-ticks { position: relative; height: 16px; font-size: 11px; color: var(--muted); }
.tl-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-grid { position: absolute; inset: 0; pointer-events: none; }
.tl-grid i { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--border); }
.tl-bar {
  position: absolute; top: 2px; height: 14px; min-width: 4px; border-radius: 4px; background: var(--complete);
  display: flex; align-items: center; justify-content: flex-end; padding: 0 5px; color: #fff; font-size: 10px; font-weight: 700; overflow: hidden;
}
.tl-bar.applying, .tl-bar.refreshing {
  background: repeating-linear-gradient(-45deg, var(--applying) 0 8px, color-mix(in srgb, var(--applying) 70%, #fff) 8px 16px);
  background-size: 22px 22px; animation: stripes 1s linear infinite;
}
.tl-bar.errored { background: var(--errored); }
.tl-bar.pending { background: none; border: 1.5px dashed var(--applying); }
.tl-bar.delete { background: var(--delete); }
.tl-dur { position: absolute; top: 1px; font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@keyframes stripes { to { background-position: 22px 0; } }

/* ---------- panel ---------- */
.panel {
  width: min(520px, 44vw); flex: none; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px 10px 14px; }
.panel-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.panel-icon svg { width: 20px; height: 20px; fill: none; stroke-width: 1.5; }
.panel-titles { flex: 1; min-width: 0; }
.panel-type { color: var(--muted); font: 12px var(--mono); }
.panel h2 { margin: 2px 0 0; font: 650 14px/1.3 var(--mono); word-break: break-all; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; padding: 8px 10px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { font-size: 11px; margin-left: 5px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); }
.tabs .count.high { background: var(--high); color: #fff; }
.panel-body { overflow: auto; padding: 14px 16px 28px; flex: 1; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-all; }
.section-title { margin: 18px 0 6px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.links { list-style: none; padding: 0; margin: 0; }
.links li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.links li:last-child { border-bottom: 0; }
.linkish { color: var(--accent); cursor: pointer; text-decoration: none; font-family: var(--mono); font-size: 12px; word-break: break-all; background: none; border: 0; padding: 0; text-align: left; }
.linkish:hover { text-decoration: underline; }
.links .kind { color: var(--muted); font-size: 11px; margin-left: auto; text-align: right; }
.external { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-weight: 600; }
.external:hover { text-decoration: underline; }
.tree { font: 12px/1.65 var(--mono); }
.tree details { margin-left: 14px; }
.tree summary { cursor: pointer; margin-left: -14px; list-style: none; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸ "; color: var(--muted); }
.tree details[open] > summary::before { content: "▾ "; }
.tree .row { white-space: pre-wrap; word-break: break-all; }
.tree .k { color: var(--muted); }
.tree .s { color: var(--create); } .tree .n { color: var(--read); } .tree .b { color: var(--replace); } .tree .z { color: var(--muted); font-style: italic; }
.tree .ph { color: var(--update); font-style: italic; }
.tree mark { background: var(--accent-soft); color: inherit; border-radius: 2px; }
.row-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.filter { flex: 1; padding: 5px 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); outline: none; }
.filter:focus { border-color: var(--accent); }
.policy { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 12px; overflow: hidden; }
.policy-head { padding: 7px 10px; background: var(--surface-2); display: flex; justify-content: space-between; gap: 10px; font: 12px var(--mono); }
.not-evaluated { padding: 8px 10px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--update) 8%, transparent); font-size: 12px; }
.not-evaluated ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); }
.stmt { padding: 9px 10px; border-top: 1px solid var(--border); }
.stmt:first-of-type { border-top: 0; }
.stmt .effect { font-weight: 700; }
.stmt .effect.Allow { color: var(--create); } .stmt .effect.Deny { color: var(--delete); }
.stmt dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 5px 0 0; font: 12px var(--mono); }
.stmt dt { color: var(--muted); }
.stmt dd { margin: 0; word-break: break-all; white-space: pre-wrap; }
.finding { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.finding .where { grid-column: 2; color: var(--muted); font-size: 11.5px; }
.log-lines { font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; }
.log-lines .error { color: var(--errored); }
.log-lines .warn { color: var(--update); }

.changes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.change { border: 1px solid var(--border); border-left: 3px solid var(--update); border-radius: 6px; padding: 6px 9px; }
.change.add { border-left-color: var(--create); } .change.remove { border-left-color: var(--delete); }
.change-path { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 12px var(--mono); color: var(--muted); }
.change-values { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-top: 2px; font: 12px var(--mono); word-break: break-all; white-space: pre-wrap; }
.change-values .before { color: var(--delete); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--delete) 60%, transparent); }
.change-values .after { color: var(--create); }
.change-values .arrow-sep { color: var(--muted); }

/* ---------- live footer ---------- */
.live {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px;
  background: var(--surface); border-top: 1px solid var(--border);
}
.live-status { display: flex; align-items: center; gap: 8px; min-width: 220px; max-width: 45%; overflow: hidden; white-space: nowrap; }
.live-status #live-sub { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.running { background: var(--applying); box-shadow: 0 0 0 0 var(--applying); animation: pulse 1.4s ease-out infinite; }
.dot.succeeded { background: var(--complete); } .dot.failed { background: var(--errored); } .dot.planned { background: var(--update); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--applying) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }
.live.idle .progress, .live.idle .live-counts, .live.idle .runs, .live.idle #log-toggle { display: none; }
.live.idle .live-status { max-width: none; }
.runs-empty { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 48px 24px; }
.progress { flex: 1; height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--complete); transition: width .4s ease; border-radius: 999px; }
.progress.failed .bar { background: var(--errored); }
.live-counts { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.runs select { padding: 4px 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); max-width: 280px; }
.log { height: 30vh; overflow: auto; padding: 8px 14px; background: var(--surface); border-top: 1px solid var(--border); }

/* ---------- toasts and dialog ---------- */
.toasts { position: fixed; top: 60px; right: 16px; z-index: 20; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: slide .2s ease-out;
}
.toast { cursor: pointer; }
.toast .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.toast .count:empty { display: none; }
.toast.succeeded { border-left-color: var(--complete); }
.toast.failed { border-left-color: var(--errored); }
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } }
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(10, 12, 18, .45); }
.dialog { width: min(420px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow-lg); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog h3 { margin: 0; font-size: 15px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 14px 0; }
.keys dd { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .node.phase-applying rect.box, .tl-bar.applying, .dot.running { animation: none; }
}

@media (max-width: 1280px) {
  .source .tfv, .source .masked { display: none; }
}
@media (max-width: 1100px) {
  .sidebar { position: absolute; inset: 0 auto 0 0; z-index: 4; box-shadow: var(--shadow-lg); }
  .source .label { max-width: 18vw; }
}
@media (max-width: 860px) {
  .source, #export, .brand span { display: none; }
  .search input { width: 120px; }
  .panel { position: absolute; inset: 0 0 0 auto; width: 100%; z-index: 5; }
  #minimap { display: none; }
}

/* ---------- runs view ---------- */
#runs-view { display: flex; background: var(--surface); }
.runs-list { width: 300px; flex: none; border-right: 1px solid var(--border); overflow-y: auto; padding: 8px; }
.runs-list-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px 10px; }
.run-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius); background: none; cursor: pointer; text-align: left; margin-bottom: 4px; }
.run-row:hover { background: var(--surface-2); }
.run-row.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.run-row.follow { justify-content: center; color: var(--accent); font-weight: 600; }
.run-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.run-sum { font: 12px var(--mono); color: var(--muted); }
.runs-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.runs-body { flex: 1; overflow: auto; position: relative; }
.pad { padding: 12px 16px; }
.log-tools { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.log-tools .filter { flex: 1 1 220px; margin: 0; }
.log-tools select { padding: 5px 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); max-width: 260px; }
.log-table { font: 12px/1.5 var(--mono); }
.log-row { display: grid; grid-template-columns: 96px 56px minmax(0, 240px) 1fr; gap: 10px; align-items: baseline; padding: 4px 14px; border-bottom: 1px solid var(--border); }
.log-row:hover { background: var(--surface-2); }
.log-row.error { background: color-mix(in srgb, var(--errored) 7%, transparent); }
.log-row .log-time { color: var(--muted); white-space: nowrap; }
.log-row .pill { justify-self: start; }
.log-row .linkish { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-text { white-space: pre-wrap; word-break: break-word; }
.outcome-sum { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 16px; }
.empty-card.inline { margin: 24px; max-width: 640px; }

/* ---------- explorers ---------- */
#explore-view { display: flex; flex-direction: column; background: var(--bg); }
.explore-tabs { background: var(--surface); padding: 0 16px; }
.explore-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.xcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.xcard-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.xcard-head .spacer { flex: 1; }
.gw { display: inline-flex; align-items: center; gap: 4px; }
.chip-link { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 3px; margin: 2px 4px 2px 0; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); cursor: pointer; font: 12px var(--mono); color: var(--text); max-width: 100%; }
.chip-link:hover { border-color: var(--accent); }
.chip-link span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-block; padding: 1px 8px; margin: 2px 4px 2px 0; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font: 12px var(--mono); }
.subnets { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.subnet { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--surface-2); }
.subnet.public { border-top: 3px solid var(--update); }
.subnet.private { border-top: 3px solid var(--complete); }
.subnet-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.subnet p { margin: 6px 0; }
.placed { display: flex; flex-wrap: wrap; }
.grid.compact th, .grid.compact td { padding: 6px 10px; white-space: normal; vertical-align: top; }
.rule { font: 12px var(--mono); }
.note { padding: 10px 14px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--update) 40%, var(--border)); background: color-mix(in srgb, var(--update) 8%, var(--surface)); font-size: 13px; }
details.role { border-top: 1px solid var(--border); padding: 8px 0; }
details.role > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; flex-wrap: wrap; }
details.role > summary::-webkit-details-marker { display: none; }
details.role > summary .spacer { flex: 1; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 6px 0 6px 4px; }
.kv .k { color: var(--muted); font-size: 12px; }
.kv ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.policy-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0; }
.policy-line code { font: 11.5px var(--mono); color: var(--muted); }
.keys { display: flex; gap: 28px; padding: 6px 0 4px; }
.keys .k { display: block; color: var(--muted); font-size: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } .runs-list { width: 220px; } .kv { grid-template-columns: 1fr; } }

/* ---------- guide ---------- */
.tour { position: fixed; inset: 0; z-index: 40; }
.tour-spot {
  position: fixed; border-radius: var(--radius-lg); pointer-events: none;
  box-shadow: 0 0 0 3px var(--accent), 0 0 0 9999px rgba(8, 10, 16, .55);
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-spot.none { box-shadow: 0 0 0 9999px rgba(8, 10, 16, .55); }
.tour-card {
  position: fixed; width: min(400px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px 14px; box-shadow: var(--shadow-lg);
  transition: top .25s ease, left .25s ease;
}
.tour-step { color: var(--muted); font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.tour-card h3 { margin: 4px 0 6px; font-size: 15px; }
.tour-card .tour-text { margin: 0 0 12px; line-height: 1.5; color: var(--text-2, var(--text)); }
.tour-card pre.tour-cmd { margin: 8px 0; padding: 8px 10px; font: 12px/1.5 var(--mono); background: var(--surface-2); border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tour-card code { font: 12px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-actions .spacer { flex: 1; }
.tour-hint {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 25; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 16px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); animation: slide .2s ease-out;
  flex-wrap: wrap; width: max-content; max-width: min(620px, calc(100vw - 24px));
}
.tour-hint > span { flex: 1 1 260px; line-height: 1.45; }
