:root {
  --bg: #0e1117;
  --surface: #151922;
  --surface-2: #1c212c;
  --border: #2a303c;
  --text: #eef2f7;
  --muted: #9ca8b8;
  --green: #a8d63f;
  --purple: #77539b;
  --cyan: #08a9c9;
  --cyan-2: #07d2e6;
  --warn: #f6b84a;
  --danger: #ff5d6c;
  --ok: #42d392;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
select,
input {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 38px;
}

button {
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--green);
}

select {
  padding: 0 38px 0 12px;
}

input {
  min-width: 260px;
  padding: 0 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: #0a0d12;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 78px;
  height: 38px;
  object-fit: contain;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  text-align: left;
  background: transparent;
  color: var(--muted);
}

.nav button.active {
  color: var(--text);
  border-color: rgba(168, 214, 63, 0.55);
  background: rgba(168, 214, 63, 0.09);
}

.license {
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.license span,
.license small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.license strong {
  display: block;
  margin: 4px 0;
}

.main {
  padding: 26px 30px 42px;
}

.topbar,
.panel-title,
.top-title,
.header-actions,
.filters,
.prefix-status,
.decision-meta,
.button-row {
  display: flex;
  align-items: center;
}

.top-title {
  gap: 14px;
}

.top-logo {
  width: 94px;
  height: 42px;
  object-fit: contain;
  opacity: 0.95;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

h3 {
  margin-bottom: 6px;
  font-size: 13px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.header-actions {
  gap: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.metric {
  padding: 14px 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.metric.warn strong {
  color: var(--warn);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-title {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.group-list,
.card-list {
  display: grid;
  gap: 10px;
}

.group-item,
.data-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111620;
}

.group-item strong,
.data-card strong {
  display: block;
}

.group-item span,
.data-card span {
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.ok {
  color: #062414;
  background: var(--ok);
}

.status.warn {
  color: #2f1f00;
  background: var(--warn);
}

.decision-card {
  border: 1px solid rgba(168, 214, 63, 0.28);
  border-radius: 8px;
  padding: 14px;
  background: rgba(168, 214, 63, 0.06);
}

.decision-meta {
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.decision-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 12px;
}

.button-row {
  flex-wrap: wrap;
  gap: 8px;
}

button.danger {
  border-color: rgba(255, 93, 108, 0.45);
  background: rgba(255, 93, 108, 0.12);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 11px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

td {
  font-size: 13px;
}

.tag-ok,
.tag-warn,
.tag-risk {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.tag-ok {
  color: #062414;
  background: var(--ok);
}

.tag-warn {
  color: #332200;
  background: var(--warn);
}

.tag-risk {
  color: #fff1f3;
  background: rgba(255, 93, 108, 0.28);
}

.propagation-title {
  align-items: flex-start;
}

.asn-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  background: #111620;
}

.asn-title-row,
.asn-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.asn-title-row h2 {
  font-size: 21px;
}

.asn-hero p {
  margin: 6px 0 0;
  color: var(--text);
  font-weight: 700;
}

.country-chip {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 22px;
  border: 1px solid rgba(168, 214, 63, 0.4);
  border-radius: 4px;
  color: var(--green);
  background: rgba(168, 214, 63, 0.1);
  font-size: 11px;
  font-weight: 900;
}

.asn-links span {
  color: var(--muted);
  font-size: 12px;
}

.radar-grid {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.radar-card {
  min-height: 72px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: #111620;
}

.radar-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.radar-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.radar-card.warn strong {
  color: var(--warn);
}

.gauge-card {
  background:
    radial-gradient(circle at 50% 120%, rgba(168, 214, 63, 0.18), transparent 48%),
    #111620;
}

.filters {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.prefix-status {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.prefix-status > div {
  min-width: 150px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #111620;
}

.prefix-status span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.prefix-status strong {
  display: block;
  margin-top: 4px;
}

.graph-shell {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px),
    #161b24;
  background-size: 86px 72px;
}

.graph-axis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
}

.graph-axis span {
  padding: 14px;
  color: var(--text);
  font-weight: 700;
  text-align: center;
}

.graph-axis span:first-child {
  text-align: left;
}

#propagationGraph {
  width: 100%;
  min-height: 440px;
  display: block;
  transform-origin: 0 0;
  transition: transform 140ms ease;
}

.node rect {
  fill: var(--cyan);
  stroke: rgba(7, 210, 230, 0.65);
  stroke-width: 1.5;
}

.node {
  cursor: pointer;
}

.node:hover rect {
  stroke: var(--green);
  filter: brightness(1.08);
}

.node text {
  fill: #fff;
  font-weight: 800;
  text-anchor: middle;
  font-size: 16px;
}

.node .sub {
  font-size: 10px;
  font-weight: 700;
}

.node .owner {
  font-size: 8px;
  font-weight: 700;
  opacity: 0.9;
}

.edge {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 3;
  opacity: 0.9;
}

.edge.primary {
  stroke: var(--green);
}

.graph-tools {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  display: grid;
  gap: 6px;
}

.graph-tools button {
  width: 34px;
  min-height: 30px;
  padding: 0;
  font-weight: 800;
}

.graph-legend {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(42, 48, 60, 0.75);
  border-radius: 8px;
  background: rgba(17, 22, 32, 0.78);
}

.graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.graph-legend i {
  width: 18px;
  height: 2px;
  display: inline-block;
}

.legend-provider {
  background: var(--cyan);
}

.legend-peer {
  background: var(--green);
}

.legend-origin {
  background: var(--purple);
}

.asn-section {
  margin-top: 16px;
}

.panel-title.compact {
  margin-bottom: 8px;
}

.compact-table {
  min-width: 640px;
}

.compact-table th,
.compact-table td {
  padding: 9px 10px;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
}

.modal {
  width: min(860px, 100%);
  max-height: min(760px, 90vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111620;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #111620;
}

.modal-body {
  padding: 16px;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-weight: 800;
}

pre {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #0a0d12;
  color: var(--text);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.status-grid > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #0f141d;
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 5px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  border: 1px solid rgba(168, 214, 63, 0.4);
  border-radius: 8px;
  padding: 10px 12px;
  background: #111620;
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.32);
}

.analysis p {
  margin-bottom: 16px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .metric-grid,
  .grid.two,
  .radar-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .asn-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .graph-legend {
    position: static;
    margin: 0 12px 12px;
  }
}
