:root {
  --bg0: #060b14;
  --bg1: #0a1424;
  --card: rgba(13, 24, 42, 0.84);
  --line: #233a5f;
  --line-soft: #1a2c48;
  --text: #e6f0ff;
  --muted: #8ca4c8;
  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --blue: #2e72ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "JetBrains Mono", "IBM Plex Sans", "Source Han Sans SC", "Microsoft YaHei", monospace;
  background:
    radial-gradient(1200px 500px at 8% -6%, #17345f 0%, transparent 60%),
    radial-gradient(900px 400px at 92% 0%, #0f2b52 0%, transparent 58%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 100%);
}

.wrap {
  width: min(1240px, calc(100% - 28px));
  margin: 16px auto 24px;
}

.panel {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(16, 31, 54, 0.92), var(--card));
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 30px rgba(0, 10, 28, 0.42);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 0 12px;
}

.top h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.03em;
  font-weight: 800;
  line-height: 1.05;
}

.top p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.global-progress {
  margin-bottom: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.global-progress .bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  border: 1px solid #264365;
  background: #0a1526;
  overflow: hidden;
}

.global-progress .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2f74ff 0%, #45b8ff 55%, #1ad16a 100%);
}

.global-progress span {
  color: #9eb6dc;
  font-size: 12px;
  min-width: 82px;
  text-align: right;
}

.query-bar {
  display: grid;
  grid-template-columns: minmax(320px, 520px) 1fr;
  gap: 10px 14px;
  padding: 12px;
  align-items: end;
}

.target {
  max-width: 520px;
}

.target span,
.mini-controls span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.target-head {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
}

.mobile-only {
  display: none;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #2a456b;
  border-radius: 10px;
  background: #0b1628;
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus,
input:focus,
select:focus {
  border-color: #4b78c8;
  box-shadow: 0 0 0 3px rgba(46, 114, 255, 0.18);
}

textarea {
  min-height: 98px;
  max-height: 180px;
  resize: vertical;
}

.mini-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: end;
}

.mini-controls label {
  width: 88px;
}

.mini-controls label.switch {
  width: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 9px;
}

.switch input {
  width: 14px;
  height: 14px;
}

.mini-controls #runButton {
  min-width: 88px;
  padding: 8px 12px;
}

.mini-controls #exportButton {
  min-width: 58px;
  padding: 8px 10px;
}

.hidden {
  display: none !important;
}

.captcha-wrap {
  min-width: 270px;
}

.captcha-wrap small {
  color: var(--muted);
  font-size: 11px;
}

.btn {
  border: 1px solid #2c4267;
  border-radius: 10px;
  background: #13233a;
  color: #deebff;
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #183050;
  border-color: #426391;
}

.btn.primary {
  background: linear-gradient(180deg, #3f81ff 0%, #2e6be3 100%);
  border-color: #4f88f0;
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4a8bff 0%, #3374ef 100%);
  border-color: #5a93ff;
}

.btn.tiny {
  padding: 5px 8px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.nodes {
  margin-top: 12px;
  padding: 10px 12px;
}

.nodes-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.nodes-head strong {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.nodes-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.node-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px 12px;
}

.node-item {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 5px 0;
}

.node-item input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.node-item strong {
  font-size: 13px;
}

.node-item em {
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
}

.meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.meta b {
  color: var(--text);
}

.meta .ok b {
  color: var(--ok);
}

.meta .bad b {
  color: var(--bad);
}

.results {
  margin-top: 12px;
  overflow: auto;
}

.mobile-collapsible .collapse-body {
  display: block;
}

.mobile-collapsible .collapse-toggle::after {
  content: " v";
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #1c304d;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  color: #9db4d7;
  font-size: 12px;
  background: #101e33;
  z-index: 1;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover {
  color: #d3e3ff;
}

th.sortable.active {
  color: #e5efff;
}

th.sortable.active.asc::after {
  content: " ^";
  font-size: 10px;
}

th.sortable.active.desc::after {
  content: " v";
  font-size: 10px;
}

tbody tr:hover {
  background: rgba(22, 40, 65, 0.7);
}

.empty td {
  text-align: center;
  color: var(--muted);
  padding: 24px 8px;
}

.loss-ok {
  color: var(--ok);
}

.loss-bad {
  color: var(--warn);
}

.loss-dead {
  color: var(--bad);
}

.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.9);
  margin-right: 6px;
}

.packet-chart {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 130px;
}

.chart-percent {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 130px;
}

.chart-percent .pct-bar {
  width: 88px;
  height: 8px;
  border-radius: 999px;
  background: #0b1629;
  border: 1px solid #203754;
  overflow: hidden;
}

.chart-percent .pct-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2f74ff, #4ebaff, #1ad16a);
}

.chart-percent span {
  color: #9fb6d9;
  font-size: 12px;
}

.pkt {
  width: 8px;
  height: 18px;
  border-radius: 2px;
  border: 1px solid #223753;
  background: #0a1528;
}

.pkt.ok {
  background: #1acd58;
  border-color: #12a948;
}

.pkt.fail {
  background: #ff3535;
  border-color: #b62323;
}

.pkt.empty {
  opacity: 0.44;
}

.mtr-row td {
  background: #081911;
  padding-top: 4px;
  padding-bottom: 10px;
}

.mtr-inline {
  border: 1px solid #1f6a37;
  border-radius: 10px;
  padding: 8px 10px;
}

.mtr-title {
  color: #8ef7ab;
  font-weight: 700;
  margin-bottom: 6px;
}

.mtr-hops {
  display: grid;
  gap: 3px;
}

.mtr-hop {
  color: #74ec97;
  font-size: 12px;
  border-bottom: 1px dashed #1f5130;
  padding-bottom: 3px;
}

.mtr-hop:last-child {
  border-bottom: none;
}

.bgp-link {
  text-decoration: none;
  color: #86cfff;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.bgp-link:hover {
  color: #d0ebff;
  text-shadow: 0 0 7px rgba(134, 207, 255, 0.35);
}

.bgp-link.as-link {
  color: #6de6bf;
}

.bgp-link.as-link:hover {
  color: #b0f6df;
  text-shadow: 0 0 7px rgba(109, 230, 191, 0.35);
}

dialog {
  width: min(900px, calc(100% - 24px));
  border: 1px solid #315181;
  border-radius: 12px;
  background: #091627;
  color: #d8ff9a;
}

dialog::backdrop {
  background: rgba(2, 8, 14, 0.65);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.trace-content {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
}

.trace-hop {
  display: flex;
  gap: 14px;
  border-bottom: 1px dashed #2f6038;
  padding: 4px 0;
}

.trace-raw {
  margin-top: 10px;
  border: 1px solid #25613c;
  border-radius: 8px;
  background: #04160f;
  padding: 8px;
  white-space: pre-wrap;
  color: #7bfc9c;
}

@media (max-width: 1000px) {
  .query-bar {
    grid-template-columns: 1fr;
  }

  .target {
    max-width: 100%;
  }

  .mini-controls label {
    width: 92px;
  }
}

@media (max-width: 768px) {
  .wrap {
    width: calc(100% - 12px);
    margin: 8px auto 14px;
  }

  .top {
    margin: 2px 0 6px;
  }

  .top h1 {
    font-size: 18px;
  }

  .top p {
    font-size: 12px;
  }

  .global-progress {
    margin-bottom: 6px;
    padding: 7px 8px;
    gap: 8px;
  }

  .global-progress .bar {
    height: 7px;
  }

  .query-bar {
    gap: 6px;
    padding: 8px;
  }

  .mobile-only {
    display: inline-flex;
  }

  .target span,
  .mini-controls span {
    margin-bottom: 4px;
    font-size: 11px;
  }

  textarea {
    min-height: 62px;
    max-height: 94px;
    padding: 7px 8px;
  }

  input,
  select {
    padding: 6px 8px;
  }

  .query-bar.mobile-advanced-collapsed .mini-controls {
    display: flex;
    justify-content: flex-end;
    gap: 0;
  }

  .query-bar.mobile-advanced-collapsed .mini-controls > * {
    display: none;
  }

  .query-bar.mobile-advanced-collapsed .mini-controls #runButton {
    display: inline-flex;
    width: auto;
    min-width: 84px;
  }

  .mini-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    align-items: end;
  }

  .mini-controls label,
  .mini-controls label.switch {
    width: auto;
    padding-bottom: 0;
  }

  .mini-controls #runButton,
  .mini-controls #exportButton {
    width: 100%;
    min-width: 0;
    padding: 7px 10px;
  }

  .nodes {
    padding: 7px;
  }

  .nodes-head {
    margin-bottom: 6px;
  }

  .nodes-head strong {
    font-size: 14px;
  }

  .node-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 8px;
  }

  .node-item strong {
    font-size: 12px;
  }

  .node-item em {
    font-size: 10px;
  }

  .meta {
    gap: 10px;
    font-size: 11px;
  }

  .mobile-collapsible.collapsed-mobile .collapse-body {
    display: none;
  }

  .mobile-collapsible.collapsed-mobile .collapse-toggle::after {
    content: " v";
  }

  .mobile-collapsible:not(.collapsed-mobile) .collapse-toggle::after {
    content: " ^";
  }

  .mobile-collapsible.collapsed-mobile .nodes-head {
    margin-bottom: 0;
  }

  .results {
    overflow: hidden;
  }

  .results table {
    table-layout: fixed;
    width: 100%;
  }

  th,
  td {
    padding: 7px 6px;
    font-size: 12px;
    white-space: normal;
    word-break: break-word;
  }

  th {
    font-size: 11px;
  }

  .results thead th:nth-child(1),
  .results thead th:nth-child(6),
  .results thead th:nth-child(7),
  .results thead th:nth-child(9),
  .results thead th:nth-child(10),
  .results thead th:nth-child(11),
  .results tbody tr:not(.mtr-row) td:nth-child(1),
  .results tbody tr:not(.mtr-row) td:nth-child(6),
  .results tbody tr:not(.mtr-row) td:nth-child(7),
  .results tbody tr:not(.mtr-row) td:nth-child(9),
  .results tbody tr:not(.mtr-row) td:nth-child(10),
  .results tbody tr:not(.mtr-row) td:nth-child(11) {
    display: none;
  }

  .results thead th:nth-child(2) {
    width: 28%;
  }

  .results thead th:nth-child(3) {
    width: 20%;
  }

  .results thead th:nth-child(4) {
    width: 12%;
  }

  .results thead th:nth-child(5) {
    width: 10%;
  }

  .results thead th:nth-child(8) {
    width: 15%;
  }

  .results thead th:nth-child(12) {
    width: 15%;
  }

  .results thead th:nth-child(8),
  .results tbody tr:not(.mtr-row) td:nth-child(8) {
    display: table-cell;
  }

  .results td:nth-child(12) .btn.tiny {
    padding: 4px 6px;
    font-size: 11px;
    min-width: 34px;
  }

  .mtr-inline {
    padding: 7px 8px;
  }

  .mtr-title,
  .mtr-hop {
    white-space: normal;
    word-break: break-word;
  }
}
