:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #142033;
  --muted: #6b7788;
  --line: #dbe3ee;
  --line-strong: #c5d1df;
  --blue: #1f78ff;
  --blue-weak: #e8f1ff;
  --green: #13a66b;
  --green-weak: #e7f8ef;
  --amber: #f2a900;
  --amber-weak: #fff6db;
  --red: #e05252;
  --red-weak: #ffecec;
  --shadow: 0 10px 24px rgba(38, 57, 86, 0.08);
  --radius: 0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, #f4f7fb 260px, var(--bg) 100%),
    radial-gradient(circle at 18% 0, rgba(31, 120, 255, 0.12), transparent 26%);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(170px, 220px) 1fr auto;
  gap: 20px;
  align-items: center;
  height: 70px;
  padding: 0 clamp(18px, 4vw, 44px);
  border-bottom: 1px solid rgba(219, 227, 238, 0.82);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 0;
  background: #13243a;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

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

.brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  margin-top: -2px;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  min-width: 0;
}

.nav-tab,
.region-filter,
.quick-row button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: #526071;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-tab:hover,
.region-filter:hover,
.quick-row button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  color: var(--ink);
}

.nav-tab.active,
.region-filter.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 0;
  color: #4f5f71;
  background: #fff;
  white-space: nowrap;
}

.status-light {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-weak);
}

.status-pill.online .status-light {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-weak);
}

.status-pill.offline .status-light {
  background: var(--red);
  box-shadow: 0 0 0 4px var(--red-weak);
}

.workspace {
  width: min(1440px, calc(100vw - 36px));
  margin: 28px auto 54px;
}

.hero-panel {
  display: grid;
  grid-template-columns: 0.86fr 1.14fr;
  gap: 28px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 700;
}

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

h1 {
  max-width: 620px;
  margin-bottom: 12px;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero-subtitle {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
}

.query-card,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.query-card {
  padding: 16px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #516174;
  font-weight: 700;
}

.query-row {
  display: grid;
  grid-template-columns: 1fr 96px 128px;
  gap: 10px;
}

.query-row input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  outline: none;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
}

.query-row input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 120, 255, 0.12);
}

.query-row button {
  border-radius: 0;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.query-row button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.quick-row button {
  min-height: 30px;
  padding: 0 10px;
  background: var(--surface-soft);
}

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

.metric-card {
  min-height: 116px;
  padding: 17px 18px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.metric-card.danger strong {
  color: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.6fr);
  gap: 14px;
  margin-bottom: 14px;
}

.content-grid.lower {
  grid-template-columns: minmax(0, 1.35fr) minmax(350px, 0.65fr);
  align-items: start;
}

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

.panel-heading {
  display: flex;
  gap: 14px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin-bottom: 2px;
  font-size: 18px;
  line-height: 1.2;
}

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

.tool-segment {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.region-filter {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.world-map {
  position: relative;
  min-height: 426px;
  overflow: hidden;
  border: 1px solid #dce6f2;
  border-radius: 0;
  background: linear-gradient(180deg, #f8fbff, #eef5fb);
}

.map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(32, 70, 112, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 70, 112, 0.06) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(180deg, transparent, #000 12%, #000 88%, transparent);
}

.world-map canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.node-pin {
  position: absolute;
  z-index: 3;
  display: block;
  transform: translate(-50%, -50%);
  width: 11px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(19, 166, 107, 0.13), 0 8px 18px rgba(24, 44, 76, 0.16);
}

.node-pin::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid rgba(19, 166, 107, 0.22);
}

.node-pin.warn {
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(242, 169, 0, 0.14), 0 8px 18px rgba(24, 44, 76, 0.16);
}

.node-pin.warn::before {
  border-color: rgba(242, 169, 0, 0.26);
}

.node-pin.bad {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(224, 82, 82, 0.15), 0 8px 18px rgba(24, 44, 76, 0.16);
}

.node-pin.bad::before {
  border-color: rgba(224, 82, 82, 0.28);
}

.node-pin.dimmed {
  opacity: 0.18;
}

.map-tooltip {
  position: absolute;
  z-index: 4;
  display: none;
  min-width: 118px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(38, 57, 86, 0.12);
  color: #26384b;
  font-size: 12px;
  pointer-events: none;
}

.map-tooltip strong,
.map-tooltip span {
  display: block;
}

.map-tooltip span {
  color: var(--muted);
}

.top-list {
  display: grid;
  gap: 10px;
}

.top-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-soft);
}

.rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 0;
  background: var(--blue-weak);
  color: var(--blue);
  font-weight: 800;
}

.top-item strong,
.top-item small {
  display: block;
}

.top-item small {
  color: var(--muted);
}

.latency-value {
  color: var(--green);
  font-weight: 800;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
}

.table-actions label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.result-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0;
}

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

.result-table th,
.result-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.result-table th {
  background: #f6f8fb;
  color: #576579;
  font-size: 12px;
  font-weight: 800;
}

.result-table tr:last-child td {
  border-bottom: 0;
}

.result-table td {
  color: #28384a;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 0;
  background: var(--green-weak);
  color: var(--green);
  font-weight: 800;
}

.status-badge.warn {
  background: var(--amber-weak);
  color: #a66f00;
}

.status-badge.bad {
  background: var(--red-weak);
  color: var(--red);
}

.side-stack {
  display: grid;
  gap: 14px;
}

.latency-bars {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 88px 1fr 56px;
  gap: 9px;
  align-items: center;
  color: #536275;
  font-size: 12px;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 0;
  background: #e9eef5;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2fbf83, #1f78ff);
}

.heat-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 7px;
}

.heat-cell {
  aspect-ratio: 1;
  border-radius: 0;
  background: var(--green);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.heat-cell.warn { background: var(--amber); }
.heat-cell.bad { background: var(--red); }
.heat-cell.empty { background: #e5ebf3; }

.empty-state {
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr auto;
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .nav-tabs {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .hero-panel,
  .content-grid,
  .content-grid.lower {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .workspace {
    width: calc(100vw - 20px);
    margin-top: 18px;
  }

  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 30px;
  }

  .query-row {
    grid-template-columns: 1fr 76px;
  }

  .query-row button {
    grid-column: 1 / -1;
    min-height: 42px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    display: grid;
  }

  .world-map {
    min-height: 330px;
  }

  .node-pin {
    width: 10px;
    height: 10px;
  }

  .node-pin::before {
    inset: -6px;
  }

  .heat-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
