:root {
  --bg: #070b14;
  --card: rgba(8, 16, 32, 0.82);
  --line: rgba(0, 240, 255, 0.16);
  --cyan: #00f0ff;
  --emerald: #00ff88;
  --amber: #ffb700;
  --crimson: #ff3366;
  --text: #d5e4f5;
  --muted: #8aa0b8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(0, 140, 255, 0.18), transparent 55%),
    radial-gradient(700px 380px at 90% 10%, rgba(0, 255, 136, 0.06), transparent 50%),
    var(--bg);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 20%, #000 20%, transparent 78%);
  opacity: 0.35;
}
img { max-width: 100%; display: block; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

.wrap { width: min(1240px, calc(100% - 28px)); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(7, 11, 20, 0.82);
  border-bottom: 1px solid rgba(0, 240, 255, 0.12);
}
.topbar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 72px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: white; flex: 0 0 auto; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand strong { display: block; font-size: 14px; letter-spacing: 0.04em; }
.brand small { display: block; color: var(--cyan); font-size: 9px; letter-spacing: 0.14em; margin-top: 2px; }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: white; background: rgba(255,255,255,0.05); }
.top-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.loc-badge, .ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 240, 255, 0.28);
  background: rgba(0, 240, 255, 0.06);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
}
.ghost-btn { color: white; text-decoration: none; }
.ghost-btn:disabled { opacity: 0.5; cursor: wait; }
.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }

.hero { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; padding: 28px 0 18px; }
.hero h1 { margin: 0; font-size: clamp(32px, 4vw, 48px); letter-spacing: -0.03em; color: white; }
.hero h1 span { color: var(--cyan); }
.hero p { margin: 6px 0 0; color: var(--muted); }
.hero-notes { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #b7c7d9;
  font-size: 13px;
}
.ecg-start {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  color: white;
  border-radius: 999px;
  padding: 14px 28px;
  min-height: 74px;
  background: linear-gradient(180deg, #49b2ff 0%, #1d6dff 100%);
  box-shadow: 0 0 0 6px rgba(29, 109, 255, 0.18), 0 10px 40px rgba(29, 109, 255, 0.45);
  animation: glow 2.4s ease-in-out infinite;
}
.ecg-start:disabled { animation: none; filter: saturate(0.8); cursor: wait; }
.ecg-start strong { display: block; letter-spacing: 0.04em; font-size: 16px; }
.ecg-start small { display: block; color: rgba(255,255,255,0.84); font-size: 12px; margin-top: 2px; }
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 6px rgba(29, 109, 255, 0.15), 0 10px 30px rgba(29, 109, 255, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(0, 240, 255, 0.16), 0 10px 40px rgba(0, 240, 255, 0.35); }
}

.board { display: grid; gap: 14px; padding-bottom: 40px; }
.row-1, .row-2, .row-3, .row-4 { display: grid; gap: 14px; }
.row-1 { grid-template-columns: 0.86fr 1.15fr 0.95fr; }
.row-2 { grid-template-columns: 1.35fr 0.9fr; }
.row-3 { grid-template-columns: 1.15fr 1fr; }
.row-4 { grid-template-columns: 1.25fr 0.85fr; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02), 0 10px 30px rgba(0,0,0,0.18);
}
.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #9fb4c9;
}
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.sub { color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; }

.gauge-layout { display: grid; grid-template-columns: 148px 1fr; gap: 8px; align-items: center; }
.gauge { position: relative; width: 148px; height: 148px; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: none;
}
.gauge-center strong { font-size: 40px; line-height: 1; color: white; }
.gauge-center span { color: var(--muted); font-size: 12px; }
.grade-label { margin: 4px 0 0; text-align: center; font-weight: 800; letter-spacing: 0.04em; }
.subscores { display: grid; gap: 7px; }
.subscore { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: #c5d4e4; }
.subscore b { font-weight: 700; }
.summary { margin: 12px 0 0; color: #9fb0c3; font-size: 13px; }

.globe-card { min-height: 360px; }
.globe-stage { position: relative; }
.globe-card canvas, .chart-card canvas, .timeline-card canvas { width: 100%; display: block; }
#globe { height: 340px; }
.globe-labels { position: absolute; inset: 0; pointer-events: none; }
.city-tag {
  position: absolute;
  transform: translate(-50%, -120%);
  pointer-events: auto;
  background: rgba(5, 12, 24, 0.88);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  padding: 4px 7px;
  text-align: left;
  line-height: 1.15;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}
.city-tag strong, .city-tag span { display: block; }
.city-tag strong { font-size: 11px; color: white; }
.city-tag span { font-size: 11px; color: var(--cyan); }
.city-tag.is-selected { box-shadow: 0 0 16px rgba(0, 255, 136, 0.45); }

.legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 5px; }
#live-chart, #timeline { height: 190px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.stat-row div { background: rgba(255,255,255,0.03); border-radius: 10px; padding: 8px; }
.stat-row span { display: block; color: var(--muted); font-size: 11px; }
.stat-row strong { font-size: 16px; color: white; }

.path-nodes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.path-node { text-align: center; padding: 8px 4px; }
.path-ico {
  width: 54px; height: 54px; margin: 0 auto 8px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(0, 240, 255, 0.35);
  background: rgba(0, 240, 255, 0.06);
  color: var(--cyan);
}
.path-node b { display: block; color: white; font-size: 18px; margin-top: 4px; }
.path-node em { font-style: normal; font-size: 12px; font-weight: 700; }
.path-node small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.est-badge[hidden] { display: none !important; }
.est-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(255, 183, 0, 0.5);
  border-radius: 999px;
  padding: 2px 6px;
}
.path-caption { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.linkish { background: none; border: 0; color: var(--cyan); padding: 0; font-weight: 700; }
.path-details {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-size: 12px;
  color: #b7c9da;
}
.path-details p { margin: 0 0 6px; }
.path-line { width: 100%; height: 120px; }
.hop-caption { color: var(--muted); font-size: 12px; margin-top: 4px; }

.service-head { align-items: flex-start; }
.service-head .sub { margin: 4px 0 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: 0 0 auto; }
.seg button { background: transparent; border: 0; padding: 7px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg button.is-on { background: rgba(0, 240, 255, 0.16); color: white; }
.badges { display: grid; gap: 6px; margin-top: 12px; }
.badge { font-size: 12px; font-weight: 600; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); }
.badge.good { color: var(--emerald); border-color: rgba(0, 255, 136, 0.4); }
.badge.fair { color: var(--amber); border-color: rgba(255, 183, 0, 0.4); }
.badge.bad { color: var(--crimson); border-color: rgba(255, 51, 102, 0.4); }
.badge.wait { color: var(--muted); }
.eyeballs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.eyeball {
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 10px;
}
.eyeball-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 12px; margin-bottom: 6px;
}
.eyeball .name { font-size: 13px; color: white; font-weight: 700; }
.eyeball .cat { color: var(--muted); font-size: 10px; line-height: 1.3; min-height: 26px; }
.eyeball .ms { font-size: 18px; color: white; }
.eyeball .grade { font-size: 12px; font-weight: 700; }
.eyeball canvas { width: 100%; height: 36px; margin-top: 6px; }

.targets { display: grid; grid-auto-flow: column; grid-template-rows: repeat(var(--rows, 5), auto); gap: 8px 16px; }
.target {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.target .name { color: white; font-size: 13px; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.bars i { display: block; width: 3px; background: rgba(255,255,255,0.15); border-radius: 1px; }
.bars i:nth-child(1) { height: 5px; }
.bars i:nth-child(2) { height: 8px; }
.bars i:nth-child(3) { height: 11px; }
.bars i:nth-child(4) { height: 14px; }
.bars i.on { background: currentColor; }
select.region-filter {
  background: #0c1526;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}

.report-actions { display: flex; gap: 8px; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.report-grid span { display: block; color: var(--muted); font-size: 12px; }
.report-grid strong { color: white; }
.grade-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  margin-top: 12px;
}
#share-dialog {
  background: #0c1526;
  color: white;
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 14px;
  width: min(420px, calc(100% - 24px));
}
#share-dialog textarea {
  width: 100%;
  margin: 8px 0 12px;
  background: #070b14;
  color: white;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 8px;
  padding: 8px;
}
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #102033;
  border: 1px solid var(--cyan);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  z-index: 30;
}

@media (max-width: 1020px) {
  .hero, .row-1, .row-2, .row-3, .row-4 { grid-template-columns: 1fr; }
  .hero-notes { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .top-tools { margin-left: 0; }
  .topbar-row { flex-wrap: wrap; padding: 8px 0; }
  .eyeballs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .targets { grid-auto-flow: row; grid-template-rows: none; }
}
@media (max-width: 720px) {
  .gauge-layout, .stat-row, .report-grid { grid-template-columns: 1fr 1fr; }
  .path-nodes { display: flex; overflow-x: auto; padding-bottom: 6px; }
  .path-node { min-width: 132px; }
  .eyeballs { grid-template-columns: 1fr; }
  .ecg-start { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ecg-start { animation: none; }
}
