main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.card .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}
.card .value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.card .sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
}
.chart-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}
.chart-box h3 {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.chart-box canvas {
  width: 100% !important;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
thead th {
  background: var(--surface);
  padding: 0.65rem 0.9rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
}
thead th:hover {
  color: var(--text);
}
thead th.sorted {
  color: var(--accent);
}
thead th .sort-icon {
  opacity: 0.5;
  margin-left: 3px;
}
thead th.sorted .sort-icon {
  opacity: 1;
}
tbody tr {
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child {
  border-bottom: none;
}
tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
tbody td {
  padding: 0.6rem 0.9rem;
  white-space: nowrap;
}
td.city-name {
  font-weight: 500;
}
.badge-5g {
  display: inline-block;
  background: rgba(0, 204, 153, 0.15);
  color: var(--accent);
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 5px;
  margin-left: 4px;
  vertical-align: middle;
}
.bar {
  display: inline-block;
  height: 8px;
  border-radius: 3px;
  vertical-align: middle;
}
.stack {
  display: flex;
  gap: 2px;
  width: 100%;
  min-width: 90px;
}
.stack span {
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.num {
  text-align: right;
}
.hl {
  color: var(--accent);
  font-weight: 600;
}
.ranking {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 600px) {
  .ranking {
    grid-template-columns: 1fr;
  }
}
.rank-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.rank-box h3 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.rank-box h3 svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.rank-item:last-child {
  border-bottom: none;
}
.rank-item .rank-val {
  color: var(--accent);
  font-weight: 600;
}
footer {
  text-align: center;
  padding: 2rem 1.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ── Scope selector ──────────────────────────── */
#scope-selector {
  position: relative;
  flex: 1;
  max-width: 480px;
}
#scope-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid #333;
  border-radius: 6px;
  background: rgba(15, 15, 15, 0.92);
  min-height: 28px;
  cursor: text;
}
#scope-wrap:focus-within {
  border-color: var(--accent);
}
.scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.scope-chip.state {
  background: rgba(0, 204, 153, 0.15);
  color: var(--accent);
}
.scope-chip.city {
  background: rgba(59, 130, 246, 0.15);
  color: #7bb3f7;
}
.scope-chip button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  opacity: 0.6;
  line-height: 1;
}
.scope-chip button:hover {
  opacity: 1;
}
#scope-input {
  border: none;
  background: transparent;
  color: #e6edf3;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  flex: 1;
  min-width: 100px;
}
#scope-input::placeholder {
  color: #555;
}
#scope-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
}
.scope-group-label {
  padding: 6px 10px 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.scope-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text);
}
.scope-item:hover,
.scope-item.active {
  background: rgba(255, 255, 255, 0.05);
}
.scope-item .hint {
  color: var(--muted);
  font-size: 0.7rem;
  margin-left: 6px;
}

.stats-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 3rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.stats-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #333;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
