:root{
  --bg: #ffffff;
  --panel-bg: #f7f7f9;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --link: #cbd5e1;
  --link-highlight: #eab308;
  --accent: #2563eb;
  --shadow: rgba(0,0,0,0.08);

  --node-root: #2563eb;
  --node-subdomain: #16a34a;
  --node-service: #9333ea;
  --node-server: #f59e0b;
  --node-default: #64748b;

  --label: #0f172a;
  --label-outline: #ffffff;
}

body[data-theme="dark"]{
  --bg: #0b1220;
  --panel-bg: #0e1729;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
  --link: #334155;
  --accent: #60a5fa;
  --shadow: rgba(0,0,0,0.3);

  --label: #e5e7eb;
  --label-outline: #0b1220;
}

*{ box-sizing: border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: "Poppins", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.sr-only{
  position:absolute !important;
  width:1px;height:1px;clip:rect(1px,1px,1px,1px);
  overflow:hidden;white-space:nowrap;border:0;padding:0;margin:-1px;
}

.app-header{
  display:flex; align-items:center; gap:16px;
  padding:10px 14px; border-bottom:1px solid var(--border);
  background: var(--panel-bg);
  position: sticky; top:0; z-index:5;
}

.brand{ display:flex; align-items:center; gap:10px; }
.brand h1{ font-size:18px; margin:0; font-weight:600; }

.controls{ display:flex; gap:12px; align-items:center; flex:1; }
.control-group{ display:flex; gap:8px; align-items:center; }

input[type="search"], select{
  background: var(--bg);
  color: var(--text);
  border:1px solid var(--border);
  padding:8px 10px; border-radius:8px; outline:none;
  min-width: 200px;
}
select{ min-width: 130px; }

.btn{
  border:1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius:8px; padding:8px 10px; cursor:pointer;
  display:inline-flex; align-items:center; gap:6px;
  box-shadow: 0 1px 2px var(--shadow);
}
.btn:hover{ border-color: var(--muted); }
.btn[aria-pressed="true"]{ outline: 2px solid var(--accent); }

.btn-mini{
  padding:6px; border-radius:6px;
}

.stats{ display:flex; gap:12px; font-size:12px; color: var(--muted); }

.app-main{
  display:grid; grid-template-columns: 1fr 320px; gap:0;
  height: calc(100vh - 64px);
}

.graph-section{ position:relative; overflow:hidden; }
.graph-container{ position:relative; width:100%; height:100%; }

#graph{
  width:100%; height:100%;
  cursor: move;
  background: var(--bg);
}

.legend{
  position:absolute; left:12px; bottom:12px; padding:8px 10px; border-radius:8px;
  background: var(--panel-bg); border:1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  font-size:12px; color: var(--muted);
}
.legend .legend-row{ display:flex; align-items:center; gap:8px; margin:4px 0; }
.legend .dot{ width:10px;height:10px;border-radius:50%; display:inline-block; border:1px solid var(--border); }
.legend .dot-root{ background: var(--node-root); }
.legend .dot-subdomain{ background: var(--node-subdomain); }
.legend .dot-service{ background: var(--node-service); }
.legend .dot-server{ background: var(--node-server); }

.side-panel{
  border-left:1px solid var(--border); background: var(--panel-bg);
  display:flex; flex-direction:column; min-width:280px; max-width:400px; overflow:auto;
}

.tabs{ display:flex; border-bottom:1px solid var(--border); }
.tab{
  flex:1; padding:10px; background:transparent; border:0; cursor:pointer;
  color: var(--muted);
}
.tab.active{ color: var(--text); border-bottom:2px solid var(--accent); }

.tab-panels{ padding:12px; overflow:auto; }
.tab-panel{ display:none; }
.tab-panel.active{ display:block; }

.details-header h2{ margin:0 0 6px; font-size:18px; }
.details-summary{ font-size:12px; color: var(--muted); }
.details-section h3{ margin:12px 0 6px; font-size:13px; }
.list{ list-style:none; padding:0; margin:0; }
.list li{ padding:6px 0; border-bottom:1px dashed var(--border); font-size:13px; }
.kv{ width:100%; border-collapse: collapse; font-size:13px; }
.kv td{ border-bottom:1px dashed var(--border); padding:6px 4px; }
.kv td:first-child{ color: var(--muted); width: 40%; }

.settings label{ display:block; margin:8px 0; }

.tooltip{
  position:absolute; padding:8px 10px; background: var(--panel-bg);
  border:1px solid var(--border); border-radius:8px; box-shadow: 0 6px 24px var(--shadow);
  pointer-events:none; font-size:12px; color: var(--text); z-index:10;
}

.context-menu{
  position:absolute; padding:6px; background: var(--panel-bg); border:1px solid var(--border);
  border-radius:8px; box-shadow: 0 8px 24px var(--shadow); z-index:12;
}
.context-menu ul{ list-style:none; margin:0; padding:4px; }
.context-menu li{ margin:0; }
.context-menu button{
  width:100%; text-align:left; padding:8px 10px; border:0; background:transparent; color:var(--text); border-radius:6px; cursor:pointer;
}
.context-menu button:hover{ background: var(--bg); }

.minimap{
  position:absolute; right:12px; bottom:12px; padding:6px; border-radius:8px;
  border:1px solid var(--border); background: var(--panel-bg);
  box-shadow: 0 2px 8px var(--shadow); z-index:3;
}
#minimapSvg{ display:block; background: var(--bg); border-radius:6px; }
.mm-viewport{ fill: transparent; stroke: var(--accent); stroke-width: 1.5; }

.perf-badge{
  position:absolute; top:12px; right:12px; background:#0ea5e9; color:white;
  padding:4px 8px; border-radius:999px; font-size:12px; z-index:2;
}

.link{
  stroke: var(--link);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}
.link.highlighted{
  stroke: var(--link-highlight) !important;
  stroke-width: 2 !important;
}

.node circle{
  stroke: #1f2937;
  stroke-width: 1.5;
}
.node.selected circle{
  stroke: var(--accent);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px rgba(37,99,235,0.5));
}
.node.glow circle{
  filter: drop-shadow(0 0 6px rgba(234,179,8,0.9));
}

.label{
  font-size: 10px;
  fill: var(--label);
  paint-order: stroke;
  stroke: var(--label-outline);
  stroke-width: 2.5px;
  stroke-linejoin: round;
  pointer-events: none;
  user-select: none;
}

.hidden{ display:none !important; }

.node.dragging circle{
  filter: none;
}
