*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #252542;
  --border: #2d2d4a;
  --text: #e0e0f0;
  --text-muted: #8888aa;
  --primary: #6c5ce7;
  --primary-hover: #7c6cf7;
  --green: #00e676;
  --green-bg: rgba(0, 230, 118, 0.1);
  --red: #ff5252;
  --red-bg: rgba(255, 82, 82, 0.1);
  --yellow: #ffd740;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-bottom: 1px solid var(--border);
  padding: 40px 0 30px;
  text-align: center;
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 0.95rem;
}

/* Search */
.search-section {
  margin-top: 30px;
}

.search-box {
  display: flex;
  gap: 10px;
}

.region-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.region-selector label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.region-selector select {
  padding: 14px 28px 14px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888aa' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 80px;
}

.region-selector select:focus {
  border-color: var(--primary);
}

.region-selector select option {
  background: var(--surface);
  color: var(--text);
}

.search-box input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
}

.search-box button {
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.search-box button:hover {
  background: var(--primary-hover);
}

.search-box button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.examples {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.example-tag {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.example-tag:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Loading */
.loading-section {
  text-align: center;
  margin: 60px 0;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  font-size: 1.1rem;
  color: var(--text);
}

.loading-hint {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Results */
.results-section {
  margin: 30px 0;
}

.result-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
}

.diagnosis {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.95rem;
  font-weight: 600;
}

.diagnosis-blocked {
  background: var(--red-bg);
  border: 2px solid var(--red);
  color: var(--red);
}

.diagnosis-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.diagnosis-text {
  line-height: 1.4;
}

.region-badge .label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.region-badge .value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
}

.domain-badge .label,
.timestamp .label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.domain-badge .value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.timestamp .value {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.networks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

.network-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.network-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.network-icon {
  font-size: 1.5rem;
}

.network-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.network-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
}

.stat {
  text-align: center;
}

.stat .stat-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
}

.stat .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-normal .stat-value { color: var(--green); }
.stat-blocked .stat-value { color: var(--red); }
.stat-rate .stat-value { color: var(--primary); }

.progress-bar {
  display: flex;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}

.progress-fill {
  transition: width 0.5s ease;
}

.normal-fill { background: var(--green); }
.blocked-fill { background: var(--red); }

.network-verdict {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
}

.network-verdict.normal {
  color: var(--green);
  background: var(--green-bg);
}

.network-verdict.blocked {
  color: var(--red);
  background: var(--red-bg);
}

.network-verdict.partial {
  color: var(--yellow);
  background: rgba(255, 215, 64, 0.1);
}

/* Detail */
.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 30px;
}

.detail-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.detail-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  border-color: var(--primary);
  background: rgba(108, 92, 231, 0.15);
  color: var(--primary);
}

.tab:hover:not(.active) {
  border-color: var(--text-muted);
  color: var(--text);
}

.detail-content {
  max-height: 400px;
  overflow-y: auto;
}

.detail-content::-webkit-scrollbar {
  width: 6px;
}

.detail-content::-webkit-scrollbar-track {
  background: var(--surface2);
  border-radius: 3px;
}

.detail-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-item .proxy-addr {
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}

.detail-item .location-info {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-right: 8px;
  flex-shrink: 0;
}

.detail-item .location-na {
  color: var(--surface2);
}

.detail-item .status-tag {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-tag.normal {
  background: var(--green-bg);
  color: var(--green);
}

.status-tag.blocked {
  background: var(--red-bg);
  color: var(--red);
}

.status-tag.abnormal {
  background: rgba(255, 215, 64, 0.1);
  color: var(--yellow);
}

.error-badge {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--yellow);
  cursor: pointer;
  margin-right: 8px;
  white-space: nowrap;
  transition: background 0.2s;
  flex-shrink: 0;
}

.error-badge:hover {
  background: rgba(255, 215, 64, 0.2);
}

.retry-popup {
  position: fixed;
  z-index: 1000;
  background: #1e1e30;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 180px;
}

.retry-popup p {
  font-size: 0.8rem;
  color: var(--text);
  padding: 3px 0;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.retry-popup p:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

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

/* Error */
.error-section {
  margin: 30px 0;
}

.error-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--red-bg);
  border: 1px solid rgba(255, 82, 82, 0.3);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.error-icon {
  font-size: 1.2rem;
}

.error-text {
  color: var(--red);
  font-size: 0.9rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 30px 0;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.powered-by {
  margin-top: 8px;
  font-size: 1rem !important;
  font-weight: 700;
  background: linear-gradient(135deg, #6c5ce7, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.5px;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 640px) {
  .networks {
    grid-template-columns: 1fr;
  }

  .search-box {
    flex-direction: column;
  }

  .result-summary {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

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