:root {
  color-scheme: dark;
  --bg: #070b12;
  --panel: #0c131e;
  --panel-2: #101a27;
  --line: #213247;
  --line-bright: #38516d;
  --text: #ecf5ff;
  --muted: #8fa4ba;
  --cyan: #5ce1e6;
  --blue: #5d8cff;
  --violet: #aa83ff;
  --amber: #ffbf69;
  --red: #ff7285;
  --green: #72e6a0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 18% -10%, rgba(93, 140, 255, .17), transparent 31rem),
    radial-gradient(circle at 90% 2%, rgba(92, 225, 230, .10), transparent 28rem),
    var(--bg);
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }

.app-shell { max-width: 1600px; margin: 0 auto; padding: 28px; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 20px; }
.eyebrow, .details-kicker { margin: 0 0 6px; color: var(--cyan); font-size: 11px; font-weight: 700; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(30px, 5vw, 52px); line-height: 1; letter-spacing: -.04em; }
.subtitle { margin: 8px 0 0; color: var(--muted); }
.cluster-state { display: flex; align-items: center; gap: 10px; color: var(--muted); white-space: nowrap; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px var(--green); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.stats div { display: flex; align-items: baseline; gap: 8px; padding: 15px 20px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; }
.stats span { color: var(--cyan); font-size: 25px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }

.toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; padding: 18px 0; }
.toolbar label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.search-field { flex: 1 1 260px; }
input, select, .toolbar button, .zoom-controls button, .warning-banner button {
  min-height: 40px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-bright);
  border-radius: 7px;
}
input, select { padding: 8px 11px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.toolbar button { padding: 8px 16px; }
.toolbar button:hover, .zoom-controls button:hover { background: var(--panel-2); border-color: var(--cyan); }

.warning-banner { margin: 0 0 18px; padding: 10px 14px; border: 1px solid rgba(255, 191, 105, .45); border-radius: 8px; background: rgba(255, 191, 105, .08); }
.warning-banner button { min-height: 0; padding: 0; border: 0; background: transparent; color: var(--amber); }
.warning-banner ul { margin: 10px 0 2px; padding-left: 22px; color: var(--muted); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; min-height: 650px; }
.graph-panel, .details { border: 1px solid var(--line); border-radius: 10px; background: rgba(12, 19, 30, .88); box-shadow: 0 18px 60px rgba(0, 0, 0, .28); }
.graph-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2, .details h2 { margin: 0; font-size: 17px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.legend { display: flex; gap: 13px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 11px; height: 11px; }
.legend-service { border-radius: 2px; background: var(--blue); }
.legend-shared { border-radius: 50%; background: var(--cyan); }
.legend-private { border-radius: 50%; background: var(--violet); }
.legend-declared { border: 1px dashed var(--muted); border-radius: 2px; background: transparent; }

.graph-wrap { position: relative; min-height: 590px; overflow: hidden; background-image: radial-gradient(circle, rgba(143, 164, 186, .15) 1px, transparent 1px); background-size: 22px 22px; }
#graph { display: block; width: 100%; height: 100%; min-height: 590px; touch-action: none; user-select: none; }
.edge { stroke: var(--line-bright); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.edge.is-active { stroke: var(--cyan); stroke-width: 2.2; }
.node { transition: opacity .15s ease; }
.node .shape { vector-effect: non-scaling-stroke; stroke-width: 1.4; }
.node text { fill: var(--text); font-size: 11px; pointer-events: none; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.node-service .shape { fill: #182840; stroke: var(--blue); }
.node-network.shared .shape { fill: #10333d; stroke: var(--cyan); }
.node-network.private .shape { fill: #2a2040; stroke: var(--violet); }
.node-network.unresolved .shape { fill: #3d2427; stroke: var(--red); stroke-dasharray: 4 3; }
.node.declared .shape { opacity: .65; stroke-dasharray: 4 3; }
.node.is-muted { opacity: .13; }
.node.is-active .shape { stroke-width: 3; filter: drop-shadow(0 0 7px rgba(92, 225, 230, .6)); }
.zoom-controls { position: absolute; right: 14px; bottom: 14px; display: grid; gap: 6px; }
.zoom-controls button { width: 40px; padding: 0; font-size: 20px; }

.details { padding: 20px; overflow-wrap: anywhere; }
.details-empty { color: var(--muted); line-height: 1.55; }
.details-type { display: inline-block; margin: 10px 0 18px; padding: 4px 8px; border-radius: 99px; color: var(--cyan); background: rgba(92, 225, 230, .1); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.details dl { margin: 0; }
.details dt { margin-top: 15px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
.details dd { margin: 4px 0 0; line-height: 1.45; }
.details code { color: var(--cyan); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.connection-list { margin: 7px 0 0; padding: 0; list-style: none; }
.connection-list button { width: 100%; padding: 7px 0; color: var(--text); text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.connection-list button:hover { color: var(--cyan); }

footer { display: flex; justify-content: space-between; gap: 18px; margin-top: 13px; color: var(--muted); font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .details { min-height: 220px; }
  .graph-wrap, #graph { min-height: 520px; }
}

@media (max-width: 620px) {
  .app-shell { padding: 18px 14px; }
  .masthead { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(2) { border-right: 0; }
  .stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .toolbar label, .toolbar button { flex: 1 1 100%; width: 100%; }
  footer { flex-direction: column; }
}

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