:root {
  --bg: #0f1216;
  --panel: #161b21;
  --panel2: #1c232b;
  --line: #2a333d;
  --text: #dfe6ee;
  --dim: #8b98a6;
  --accent: #f5a623;
  --ok: #3ddc84;
  --warn: #f5c542;
  --bad: #ef5350;
  --off: #5b6673;
  --up: #4fc3f7;
  --down: #f5a623;
  --smb: #b388ff;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", Roboto, Ubuntu, sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #1a1205; border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.small { padding: 3px 8px; font-size: 12px; }
input, select, textarea { background: #0c0f13; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { width: auto; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.dim { color: var(--dim); }

/* layout */
.shell { display: grid; grid-template-columns: 210px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.top { grid-column: 1 / 3; display: flex; align-items: center; gap: 18px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .5px; display: flex; align-items: center; gap: 9px; min-width: 178px; }
.brand .logo { width: 22px; height: 22px; border: 2px solid var(--accent); border-radius: 4px; position: relative; }
.brand .logo::after { content: ""; position: absolute; inset: 5px; background: var(--accent); border-radius: 1px; }
.stats { display: flex; gap: 18px; flex: 1; overflow: hidden; }
.stat { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 13px; }
.stat b { font-family: var(--mono); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--off); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.nav { background: var(--panel); border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; }
.nav a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--panel2); }
.nav a.active { background: var(--panel2); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 4px; }
.main { overflow: auto; position: relative; }
.page { padding: 20px 24px; max-width: 1400px; }
.page h1 { font-size: 20px; margin: 0 0 4px; }
.page .sub { color: var(--dim); margin-bottom: 18px; }
.bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.bar .grow { flex: 1; }

/* cards & tables */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #20272f; vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
td .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; border: 1px solid var(--line); color: var(--dim); white-space: nowrap; }
.tag.ok { color: var(--ok); border-color: #2c5a40; }
.tag.bad { color: var(--bad); border-color: #5e2d2c; }
.tag.warn { color: var(--warn); border-color: #5d5129; }
.tag.acc { color: var(--accent); border-color: #6a4d1b; }
.empty { color: var(--dim); padding: 18px; text-align: center; }

/* map */
.mapwrap { position: absolute; inset: 0; display: flex; }
.mapcanvas { flex: 1; position: relative; overflow: hidden; background:
  radial-gradient(circle at 50% 50%, #151b22 0, #0f1216 70%); }
.mapcanvas svg { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
.mapcanvas svg.drag { cursor: grabbing; }
.maptools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 2; }
.maptools label { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 12.5px; cursor: pointer; }
.legend { position: absolute; bottom: 12px; left: 12px; background: rgba(22,27,33,.92); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; display: grid; grid-template-columns: auto auto; gap: 4px 14px; z-index: 2; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 3px; display: inline-block; border-radius: 2px; }
.detail { width: 360px; background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; flex: none; }
.detail h2 { margin: 0 0 2px; font-size: 17px; }
.detail .kv { display: grid; grid-template-columns: 120px 1fr; gap: 5px 10px; font-size: 13px; margin: 12px 0; }
.detail .kv div:nth-child(odd) { color: var(--dim); }
.detail .kv div:nth-child(even) { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.detail .btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.detail h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--dim); margin: 18px 0 6px; }
.rates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.rates div { background: var(--panel2); border-radius: 6px; padding: 8px 10px; }
.rates small { color: var(--dim); display: block; font-size: 11px; text-transform: uppercase; }
.rates b { font-family: var(--mono); font-size: 15px; }

svg .edge { fill: none; stroke-linecap: round; pointer-events: none; }
svg .edge.base { stroke: #2b3540; }
svg .edge.base.ok { stroke: #2f5f45; }
svg .edge.base.warn { stroke: #6a5b2b; }
svg .edge.base.bad { stroke: #5a2f2f; stroke-dasharray: 4 6; }
svg .edge.lan { stroke: #34404c; stroke-width: 1.4; }
svg .flow { pointer-events: none; fill: none; stroke-linecap: round; stroke-dasharray: 2 12; animation: flow linear infinite; }
svg .flow.up { stroke: var(--up); }
svg .flow.down { stroke: var(--down); }
svg .flow.smb { stroke: var(--smb); stroke-dasharray: 6 10; }
@keyframes flow { to { stroke-dashoffset: -28; } }
svg .node { cursor: pointer; }
svg .node .ring { fill: #12171c; stroke-width: 2.5; }
svg .node.sel .ring { stroke-width: 4; filter: drop-shadow(0 0 6px var(--accent)); }
svg .node text { fill: var(--text); font-size: 12px; pointer-events: none; }
svg .node text.small { fill: var(--dim); font-size: 10.5px; font-family: var(--mono); }
svg .node text.icon { font-size: 13px; font-weight: 700; fill: var(--dim); font-family: var(--mono); }
svg .elabel { font-size: 10.5px; fill: var(--dim); font-family: var(--mono); pointer-events: none; }
svg .elabel.route { fill: var(--accent); }
svg .elabel.bg { stroke: #0f1216; stroke-width: 4; stroke-linejoin: round; }
svg .pulse { fill: none; stroke: var(--ok); stroke-width: 2; opacity: 0; animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { opacity: .6; r: 30; } 100% { opacity: 0; r: 60; } }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: 520px; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 18px 20px; }
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 4px; }
.field.check label { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .err { color: var(--bad); min-height: 18px; font-size: 13px; }
pre.code { background: #0b0e11; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: var(--mono); font-size: 12px; overflow: auto; max-height: 340px; white-space: pre; margin: 0; }
#toast { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
#toast div { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 9px 14px; border-radius: 6px; max-width: 420px; }
#toast div.err { border-left-color: var(--bad); }

/* login */
.login { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login .box { width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 26px; }
.login h1 { margin: 0 0 4px; font-size: 22px; }

/* charts */
.chart svg { width: 100%; height: 220px; display: block; }
.chart .axis { fill: var(--dim); font-size: 10px; font-family: var(--mono); }
.chart .gridl { stroke: #232b34; }
.meter { height: 8px; background: #0b0e11; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; background: var(--accent); }
.switch { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.switch button { border: 0; border-radius: 0; background: transparent; }
.switch button.on { background: var(--accent); color: #1a1205; }
