/* BGP Control Panel - Zetrik style (light sidebar, colored icon tiles, rounded controls) */
:root {
  --bg: #f3f5f9; --card: #ffffff; --line: #e3e7ee; --line2: #eef1f5;
  --text: #1d2330; --text2: #3a4252; --muted: #5b6475;
  --blue: #0a66d9; --blue-dark: #0a5cc2; --blue-soft: #e3eefc;
  --ok-bg: #e6f4ea; --ok: #1a7f37; --warn-bg: #fff4dc; --warn: #8a5a00;
  --fail-bg: #fdecea; --fail: #b42318; --info-bg: #eef0f3; --info: #4b5563;
  --switch: #34c759; --term: #1d2330;
  --radius: 14px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }

/* Layout */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 0 0 250px; background: #fbfcfe; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: var(--blue); display: flex; align-items: center; justify-content: center; }
.brand-logo svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; min-height: 40px; border-radius: 10px; color: var(--text); font-weight: 500; }
.nav-item:hover { background: #eef2f8; text-decoration: none; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-icon { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex: none; }
.nav-icon svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { flex: 1; }
.nav-count { background: var(--fail); color: #fff; border-radius: 10px; font-size: 12px; font-weight: 600; padding: 1px 8px; }
.nav-item.active .nav-count { background: #fff; color: var(--fail); }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 20px; font-weight: 700; }
.top .sub { font-size: 13px; color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.poll { display: inline-flex; align-items: center; gap: 8px; border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600; }
.poll .dot { width: 8px; height: 8px; border-radius: 4px; background: currentColor; }
.poll-ok { background: var(--ok-bg); color: var(--ok); }
.poll-bad { background: var(--warn-bg); color: var(--warn); }
.user-chip { width: 36px; height: 36px; border-radius: 18px; background: #dbe7fb; color: var(--blue-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.content { padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 18px; max-width: 1320px; width: 100%; }

/* Cards / grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 28px; font-weight: 700; }
.stat .s { font-size: 13px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.row > .card { flex: 1 1 420px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } .side { flex: 1 1 100%; } .content { padding: 16px; } .top { padding: 14px 16px; } }

/* Badges */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; white-space: nowrap; }
.b-ok, .b-pass { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-fail, .b-critical { background: var(--fail-bg); color: var(--fail); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-blue { background: var(--blue-soft); color: var(--blue-dark); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr:last-child td { border-bottom: 0; }
.name-link { font-weight: 600; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .lbl { font-size: 13px; font-weight: 600; color: var(--text2); }
.field .help { font-size: 12.5px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  height: 42px; border: 1px solid #d5dbe5; border-radius: 21px; padding: 0 16px; font: inherit; font-size: 14px; background: #fff; color: var(--text); width: 100%;
}
textarea { height: auto; border-radius: 14px; padding: 10px 16px; font-family: var(--mono); font-size: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3f5; border-color: var(--blue); }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inline-form .field { flex: 1 1 200px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; }

/* Switch (checkbox) */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line2); }
.switch-row:last-child { border-bottom: 0; }
.switch-list { border: 1px solid var(--line); border-radius: var(--radius); }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; background: #c9cfd8; border-radius: 16px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 13px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
.switch input:checked + span { background: var(--switch); }
.switch input:checked + span::after { left: 23px; }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 21px; padding: 10px 20px; min-height: 42px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; background: var(--blue); color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid #d5dbe5; }
.btn-ghost:hover { background: #f3f6fa; }
.btn-dark { background: var(--text); }
.btn-dark:hover { background: #000; }
.btn-danger { background: var(--fail); }
.btn-danger:hover { background: #8f1c13; }
.btn-sm { padding: 6px 13px; min-height: 32px; font-size: 13px; border-radius: 16px; }
.btn[disabled] { background: #8a94a6; cursor: not-allowed; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.link-btn { border: 0; background: none; color: var(--blue-dark); font: inherit; font-weight: 600; padding: 4px 0; cursor: pointer; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid #d5dbe5; border-radius: 18px; padding: 7px 15px; font-size: 13px; font-weight: 600; background: #fff; color: var(--text); }
.pill.on { background: var(--text); color: #fff; border-color: var(--text); }
.pill:hover { text-decoration: none; }
.seg { display: inline-flex; gap: 4px; background: #eef1f6; padding: 4px; border-radius: 20px; flex-wrap: wrap; }
.seg a, .seg label { border-radius: 16px; padding: 7px 14px; font-size: 13px; font-weight: 600; color: var(--text2); cursor: pointer; }
.seg a.on, .seg input:checked + span { background: #fff; color: var(--blue-dark); }
.seg a:hover { text-decoration: none; }
.seg input { position: absolute; opacity: 0; }
.seg label span { display: inline-block; padding: 7px 14px; border-radius: 16px; margin: -7px -14px; }

/* Terminal */
.term { margin: 0; background: var(--term); color: #e6edf6; border-radius: 12px; padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow: auto; white-space: pre; max-height: 560px; }
.term.tall { min-height: 200px; }
details.raw { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
details.raw summary { cursor: pointer; font-weight: 600; }
details.raw pre { margin-top: 10px; }

/* Checks */
.check-row { display: flex; flex-direction: column; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line2); }
.check-row:last-child { border-bottom: 0; }
.check-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.check-head .badge { min-width: 74px; text-align: center; }
.check-title { font-weight: 600; flex: 1 1 200px; }
.check-detail { color: var(--text2); font-size: 13px; flex: 2 1 320px; }
.fix { margin-left: 86px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 760px) { .fix { margin-left: 0; } }

/* Flash */
.flash { border-radius: 12px; padding: 12px 16px; font-weight: 500; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-fail { background: var(--fail-bg); color: var(--fail); }

/* Chart */
.chart { width: 100%; height: auto; }
.chart-axis { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; color: var(--text2); }
.legend i { display: inline-block; width: 18px; height: 3px; margin-right: 6px; vertical-align: middle; }
.chart-empty { padding: 30px 0; text-align: center; }

/* Steps */
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; }
.step .badge { min-width: 70px; text-align: center; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { width: 400px; max-width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 50px rgba(20, 30, 60, .08); }
.login-card .brand { padding: 0 0 8px; }

/* ---- v2: peers list and shared polish ---- */
.b-teal { background: #e3f6f5; color: #0b6e6e; }
.b-purple { background: #f1ebfd; color: #5b3cc4; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 4px; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: var(--ok); } .dot-fail { background: var(--fail); } .dot-info { background: #8a94a6; }
.stat-link { color: var(--text); transition: border-color .15s, box-shadow .15s; }
.stat-link:hover { text-decoration: none; border-color: #b9c7dc; }
.stat-link.on { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar select { width: auto; min-width: 170px; }
.toolbar .grow { flex: 1 1 220px; width: auto; }
table.t tr:hover td { background: #f8fafd; }
table.t.peers td { padding-top: 12px; padding-bottom: 12px; }
.sub-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.sub-line.r { justify-content: flex-end; }
.sub-line .badge { font-size: 11.5px; padding: 2px 8px; }
.num { font-weight: 600; font-variant-numeric: tabular-nums; }
.limit { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.limit .bar { width: 64px; height: 6px; background: #e9edf3; border-radius: 3px; overflow: hidden; }
.limit .bar i { display: block; height: 100%; border-radius: 3px; }
.row-actions { display: inline-flex; gap: 6px; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }
details.menu { position: relative; }
details.menu > summary { list-style: none; padding: 6px 10px; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary svg { fill: currentColor; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(20, 30, 60, .14); padding: 6px; display: flex; flex-direction: column; text-align: left; }
.menu-pop a, .menu-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: 13.5px; color: var(--text); padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: #f1f4f9; text-decoration: none; }
.menu-pop .danger { color: var(--fail); }
.table-wrap.menu-safe { overflow: visible; }
@media (max-width: 1000px) { .table-wrap.menu-safe { overflow-x: auto; } }

/* ---- Routes popup ---- */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(20, 26, 38, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal[hidden] { display: none; }
.modal-box { width: 1120px; max-width: 100%; background: #fff; border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.25); padding: 22px 24px; }
#routesBody { display: flex; flex-direction: column; gap: 14px; }
.rt-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-start; }
.rt-title { font-size: 18px; font-weight: 700; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 6px; font-size: 13px; color: var(--muted); align-items: center; }
.kv b { color: var(--text); font-weight: 600; }
.rt-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #eef1f6; padding: 4px; border-radius: 22px; }
.tabs button { border: 0; background: none; font: inherit; padding: 8px 16px; border-radius: 18px; font-weight: 600; font-size: 13.5px; color: var(--text2); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--blue-dark); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.tabs .c { margin-left: 6px; font-size: 12px; color: var(--muted); font-weight: 500; }
.rt-body { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.rt-top { flex: 1 1 300px; background: #f7f9fc; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.rt-top h3 { font-size: 15px; margin-bottom: 6px; }
.rt-asn { display: grid; grid-template-columns: 1fr 70px 110px; gap: 10px; align-items: center; border: 0; border-bottom: 1px solid var(--line2); background: none; font: inherit; padding: 9px 4px; text-align: left; cursor: pointer; border-radius: 6px; }
.rt-asn:hover { background: #eef2f8; }
.rt-asn .num { text-align: right; }
.rt-asn .bar { height: 6px; background: #e3e8ef; border-radius: 3px; overflow: hidden; display: block; }
.rt-asn .bar i { display: block; height: 100%; border-radius: 3px; }
.rt-list { flex: 2 1 560px; min-width: 0; }
.rt-path { font-size: 12.5px; color: var(--text2); }
.rt-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; }
.rt-empty { display: flex; flex-direction: column; gap: 6px; padding: 30px; text-align: center; background: #f7f9fc; border-radius: var(--radius); }
.rt-loading { padding: 60px 0; text-align: center; color: var(--muted); font-weight: 500; }
.rt-asn-name { display: flex; flex-direction: column; min-width: 0; }
.rt-asn-name .muted { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-asn { grid-template-columns: minmax(0, 1fr) 64px 90px; }
.desc-line { font-size: 12.5px; color: var(--text2); margin-top: 3px; max-width: 420px; }
.sync-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; font-size: 12.5px; padding: 2px 2px 0; }
/* Looking glass: readable BGP path view */
.lg-path { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.lg-path.is-best { border-color: #9fd3ad; background: #f6fbf7; }
.lg-path-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lg-from { font-weight: 600; }
.lg-aspath { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lg-hop { display: inline-flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: 13px; line-height: 1.3; }
.lg-hop small { color: var(--muted); font-size: 11.5px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lg-us { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; justify-content: center; }
.lg-arrow { color: var(--muted); font-size: 18px; }
/* Interfaces / VLANs */
.optic { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.trunk-pick { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.trunk-pick .check { gap: 10px; font-size: 13px; }
/* Live traffic popup */
.live-box { display: flex; flex-direction: column; gap: 14px; }
.live-stats .v { font-size: 22px; }
.live-chart { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px 0; }
.live-note { font-size: 12.5px; }
.live-btn { padding: 4px 10px; min-height: 28px; font-size: 12.5px; }
