:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent2: #06b6d4;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #1a2332 0%, #0f1419 100%);
  text-align: center;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

header p { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }

header .header-contact {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--accent2);
}

.upload-qrcode {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.upload-qrcode img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.upload-qrcode-tip {
  font-size: 0.9rem;
  color: var(--green);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.wechat-guide {
  text-align: center;
  max-width: 520px;
  margin: 0 auto;
}

.wechat-guide-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.wechat-guide h2 {
  font-size: 1.1rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 0.75rem;
}

.wechat-guide-desc {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 0.5rem;
}

.wechat-guide-url {
  margin-top: 0.75rem;
  color: var(--accent2);
  font-size: 0.85rem;
  word-break: break-all;
}

.wechat-guide-note {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 2rem 3rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

.upload-zone input { display: none; }

.upload-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

.upload-zone .hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }

.file-name {
  margin-top: 0.75rem;
  color: var(--accent2);
  font-size: 0.9rem;
  word-break: break-all;
}

.upload-fields {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  width: 100%;
}

.form-grid label {
  flex: 0 1 240px;
  min-width: 200px;
  max-width: 300px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="text"], select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
}

input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  margin-top: 1.25rem;
  width: auto;
  min-width: 12rem;
  padding-left: 2rem;
  padding-right: 2rem;
}

.btn-primary:not(:disabled):hover { opacity: 0.9; }
.btn-primary:not(:disabled):active { transform: scale(0.99); }

.status {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}

.status.show { display: block; }
.status.error { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--red); color: #fca5a5; }
.status.warn { background: rgba(245, 158, 11, 0.12); border: 1px solid var(--orange); color: #fcd34d; }
.status.loading { background: rgba(59, 130, 246, 0.12); border: 1px solid var(--accent); color: #93c5fd; }

#results { display: none; }
#results.show { display: block; }

.cards {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.cards-4x2 {
  grid-template-columns: repeat(4, 1fr);
}

.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card .label { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.2rem; }
.card .value { font-size: 1.35rem; font-weight: 600; line-height: 1.3; }
.card .value.sm { font-size: 1rem; word-break: break-all; }
.card .value.md { font-size: 1.1rem; }
.card .unit { font-size: 0.85rem; font-weight: 500; }
.card .sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; line-height: 1.4; }
.card.highlight .value { color: var(--accent2); }
.card.green .value { color: var(--green); }
.card.warn .value { color: var(--orange); }
.card.ok .value { color: var(--green); }

.bar-chart { margin-top: 0.5rem; }

.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 72px 52px;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
  font-size: 0.85rem;
}

.bar-row .name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; min-width: 0; }
.bar-row .fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.bar-row .traffic { text-align: right; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-row .pct { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.78rem;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* 列宽 */
#province-table th:nth-child(1), #province-table th:nth-child(2) { width: 12%; }
#province-table th:nth-child(n+3) { width: 11%; }

#city-table th:nth-child(1), #city-table th:nth-child(2) { width: 18%; }
#city-table th:nth-child(n+3) { width: 14%; }

#isp-table th:nth-child(1) { width: 40%; }
#isp-table th:nth-child(n+2) { width: 20%; }

#prov-isp-table th:nth-child(1), #prov-isp-table th:nth-child(2) { width: 22%; }
#prov-isp-table th:nth-child(n+3) { width: 14%; }

#top-ip-table th:nth-child(1) { width: 22%; }
#top-ip-table th:nth-child(2), #top-ip-table th:nth-child(3) { width: 12%; }
#top-ip-table th:nth-child(4) { width: 18%; }
#top-ip-table th:nth-child(n+5) { width: 12%; }

#port-table th:nth-child(1) { width: 16%; }
#port-table th:nth-child(n+2) { width: 21%; }

#rport-table th:nth-child(1) { width: 40%; }
#rport-table th:nth-child(2) { width: 60%; }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.tag-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.badge-ip { color: var(--accent2); font-family: ui-monospace, monospace; font-size: 0.82rem; }

.tip-list { margin-top: 0.5rem; padding-left: 1.25rem; color: var(--muted); font-size: 0.88rem; }
.tip-list li { margin-bottom: 0.35rem; }
.capture-warn { margin-top: 0.5rem; color: var(--orange); font-size: 0.85rem; }

.report-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.btn-copy {
  background: linear-gradient(135deg, #0891b2, var(--accent));
  color: #fff;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-copy:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-copy:not(:disabled):hover { opacity: 0.92; }

.copy-hint { font-size: 0.85rem; color: var(--muted); }

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.detail-sections {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.detail-sections-2 {
  grid-template-columns: repeat(2, 1fr);
}

.detail-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  min-width: 0;
  min-height: 200px;
}

.hidden { display: none !important; }

.server-hosts-section {
  margin: 1rem 0 0.5rem;
  padding: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.server-hosts-section .block-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.hosts-note {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.data-table tr.hosts-summary td {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.info-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  grid-template-rows: auto auto;
  gap: 0.1rem 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(45, 63, 86, 0.5);
  font-size: 0.85rem;
  align-items: center;
}

.info-row:last-child { border-bottom: none; }
.info-label { color: var(--muted); grid-row: 1 / 3; }
.info-val { color: var(--text); font-weight: 600; grid-column: 2; }
.info-sub { color: var(--muted); font-size: 0.82rem; grid-column: 2; }

/* 精简报告（复制图片用） */
.report-sheet {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 680px;
  background: #0f1419;
  color: #e8edf4;
  padding: 24px;
  font-family: var(--font);
  box-sizing: border-box;
}

.rs-header { margin-bottom: 16px; border-bottom: 1px solid #2d3f56; padding-bottom: 12px; }
.rs-title { font-size: 18px; font-weight: 600; color: #06b6d4; margin-bottom: 4px; }
.rs-meta { font-size: 12px; color: #8b9cb3; }

.rs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.rs-item {
  background: #1a2332;
  border: 1px solid #2d3f56;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.rs-item.highlight .rs-val { color: #06b6d4; }
.rs-item.green .rs-val { color: #22c55e; }
.rs-val { font-size: 16px; font-weight: 600; line-height: 1.3; word-break: break-all; }
.rs-lbl { font-size: 11px; color: #8b9cb3; margin-top: 4px; }

.rs-section { margin-bottom: 14px; }
.rs-section-title { font-size: 12px; color: #8b9cb3; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }

.rs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.rs-table th, .rs-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #2d3f56;
  text-align: left;
}

.rs-table th { color: #8b9cb3; font-weight: 500; }
.rs-table td.num, .rs-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.rs-footer {
  font-size: 11px;
  color: #8b9cb3;
  padding-top: 10px;
  border-top: 1px solid #2d3f56;
}

@media (max-width: 960px) {
  .cards-4x2 { grid-template-columns: repeat(2, 1fr); }
  .detail-sections-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .cards-4x2 { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  main { padding: 1rem; }
}

.block-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
}

.sub-label { margin-bottom: 0.4rem; color: var(--muted); font-size: 0.82rem; }
.sub-text { margin-top: 0.5rem; color: var(--muted); font-size: 0.88rem; }

.proto-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.proto-stat {
  background: var(--surface);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  text-align: center;
}

.proto-stat .val { font-size: 1.15rem; font-weight: 600; color: var(--accent2); }
.proto-stat .lbl { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; line-height: 1.35; }

.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.detail-grid p { color: var(--muted); margin: 0; }
.detail-grid strong { color: var(--text); font-variant-numeric: tabular-nums; }

.server-offline {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--red);
  color: #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}
.server-offline.show { display: block; }
