:root {
  --line: #cbd5e1;
  --text: #0f172a;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --select: rgba(250, 204, 21, 0.35);
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, Arial, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  color: var(--text);
  display: grid;
  grid-template-columns: 130px 1fr;
  min-height: 100vh;
}
.side-tools {
  background: rgba(255,255,255,.96);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3;
}
.main { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; min-width: 0; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); box-shadow: 0 4px 14px rgba(15,23,42,.05);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-size: 1.25rem; font-weight: 800; margin-right: auto; }
.tool-btn,.action-btn,.tab-btn,button {
  border: 1px solid #cbd5e1; background: #fff; color: var(--text); border-radius: 12px; cursor: pointer;
  transition: .15s ease; box-shadow: 0 2px 8px rgba(15,23,42,.04);
}
.tool-btn:hover,.action-btn:hover,.tab-btn:hover,button:hover { transform: translateY(-1px); border-color: #94a3b8; background: #f8fafc; }
.tool-btn.active,.tab-btn.active { outline: 2px solid var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.tool-btn {
  min-height: 82px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; font-size: .82rem;
}
.tool-btn img { width: 30px; height: 30px; object-fit: contain; pointer-events: none; }
.action-btn { padding: 10px 12px; font-size: .9rem; }
.workspace { position: relative; overflow: hidden; min-height: 0; }
svg#network {
  width: 100%; height: 100%; min-height: 420px; display: block;
  background: radial-gradient(circle at 20px 20px, rgba(148,163,184,.16) 1px, transparent 1px), linear-gradient(180deg, #fff, #f1f5f9);
  background-size: 24px 24px, auto; touch-action: none;
}
.splitter {
  position: absolute; left: 0; right: 0; height: 8px; background: rgba(148,163,184,.25);
  border-top: 1px solid rgba(148,163,184,.45); border-bottom: 1px solid rgba(148,163,184,.45); cursor: ns-resize; z-index: 9;
}
.splitter.hidden { display: none; }
.config-panel {
  display: none; border-top: 1px solid var(--line); background: rgba(255,255,255,.97); padding: 12px 14px 14px;
  height: 35vh; box-shadow: 0 -8px 18px rgba(15,23,42,.06); overflow: auto; position: absolute; left: 0; right: 0; bottom: 0; z-index: 8;
}
.config-panel.visible { display: block; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab-btn { padding: 10px 12px; font-size: .9rem; }
.tab-view { display: none; }
.tab-view.active { display: block; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 12px; }
.field { margin-bottom: 10px; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.92); padding: 12px; box-shadow: var(--shadow); }
input, textarea, select {
  width: 100%; border-radius: 10px; border: 1px solid #cbd5e1; background: #fff; color: var(--text); padding: 10px 12px; margin-top: 6px;
}
textarea { resize: vertical; min-height: 220px; font-family: ui-monospace,SFMono-Regular,Menlo,monospace; }
.terminal {
  background: #0f172a; color: #e2e8f0; border-radius: 16px; padding: 14px; min-height: 260px;
  font-family: ui-monospace,SFMono-Regular,Menlo,monospace; display: grid; grid-template-rows: 1fr auto; gap: 12px;
}
.terminal-output,.browser-source { white-space: pre-wrap; overflow: auto; font-size: .86rem; }
.terminal-input-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.terminal-input { background: #111827; color: #f8fafc; border: 1px solid #334155; margin-top: 0; }
.file-layout { display: grid; grid-template-columns: 240px 1fr; gap: 12px; }
.file-list { display: grid; gap: 8px; align-content: start; }
.file-item { padding: 10px 12px; text-align: left; }
.file-item.active { outline: 2px solid var(--accent); background: var(--accent-soft); }
.browser-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.browser-render { width: 100%; min-height: 260px; border: 1px solid #cbd5e1; border-radius: 12px; background: #fff; }
.install-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.install-item { display: flex; gap: 8px; align-items: center; padding: 10px; border: 1px solid #e2e8f0; border-radius: 12px; }
.node-label { font-size: 12px; fill: #0f172a; text-anchor: middle; pointer-events: none; font-weight: 600; }
.node-sub { font-size: 10px; fill: #475569; text-anchor: middle; pointer-events: none; }
.link { stroke: #64748b; stroke-width: 5; stroke-linecap: round; cursor: pointer; }
.link.selected { stroke: #eab308; stroke-width: 7; }
.link.wifi { stroke-dasharray: 10 8; }
.selection-ring { display: none; }
.node.selected .selection-ring { display: block; stroke: #eab308; stroke-width: 3; fill: var(--select); }
.node-image,.node.selected .selection-ring { pointer-events: none; }
.packet { filter: drop-shadow(0 0 6px rgba(17,24,39,.25)); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.success { background: #16a34a; color: #fff; border-color: #16a34a; }
.warn { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.settings-modal { position: fixed; inset: 0; background: rgba(15,23,42,.35); display: none; align-items: center; justify-content: center; z-index: 30; padding: 20px; }
.settings-modal.open { display: flex; }
.settings-window { width: min(760px,95vw); background: #fff; border-radius: 20px; box-shadow: 0 30px 60px rgba(15,23,42,.28); border: 1px solid #cbd5e1; padding: 18px; }
.pill { display: inline-block; padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc; }
table.traffic-table, table.route-table { width: 100%; border-collapse: collapse; }
.traffic-table th,.traffic-table td,.route-table th,.route-table td { text-align: left; padding: 8px; border-bottom: 1px solid #e2e8f0; font-size: .9rem; vertical-align: top; }
@media (max-width: 980px) {
  body { grid-template-columns: 1fr; }
  .side-tools { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); }
  .grid,.file-layout { grid-template-columns: 1fr; }
}
