/* VERSION: 2024-COUNTRY */
body { font-family: -apple-system, "Segoe UI", sans-serif; background: #f4f5f7; margin: 0; padding: 20px; color: #333; }
.container { max-width: 1400px; margin: 0 auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
h1 { text-align: center; font-size: 18px; margin: 0 0 20px; }
h2 { font-size: 15px; margin: 24px 0 12px; }
h2 .hint { font-size: 12px; font-weight: normal; color: #9ca3af; margin-left: 6px; }

.input-row { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-start; }
.input-row input, .input-row textarea { flex: 1; padding: 8px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px; }
.input-row textarea { min-height: 100px; font-family: monospace; resize: vertical; }
button { padding: 8px 16px; background: #3b82f6; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
button:hover { background: #2563eb; }
button.secondary { background: #6b7280; }
button.secondary:hover { background: #4b5563; }

#status { min-height: 20px; font-size: 13px; color: #666; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 24px; table-layout: fixed; border: 1px solid #eef1f5; border-radius: 8px; overflow: hidden; }
th, td { border-bottom: 1px solid #e1e4e8; padding: 8px 10px; text-align: left; vertical-align: top; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th { background: #f3f5f9; color: #4b5563; font-weight: 600; font-size: 12px; }
#resultTable tbody tr:hover { background: #f8fafc; }
#resultTable tbody tr:nth-child(even) { background: #fcfcfd; }
#resultTable tbody tr:nth-child(even):hover { background: #f1f5f9; }
#resultTable td:nth-child(1) { text-align: center; color: #9ca3af; font-size: 12px; }

.proto { display: inline-block; padding: 2px 8px; border-radius: 4px; background: #eef2ff; color: #4338ca; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.stack-4 { color: #3b82f6; font-weight: bold; }
.stack-6 { color: #f59e0b; font-weight: bold; }

td:nth-child(8) { white-space: nowrap; overflow: hidden; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: #1f2937; }
.ipv4-text { letter-spacing: 0.2px; }
.ipv6-chip { display: inline-block; max-width: 100%; padding: 2px 8px; border-radius: 6px; background: #f3f4f6; color: #6b7280; cursor: pointer; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.ipv6-chip:hover { background: #e5e7eb; color: #111827; }

.ip-popover { position: fixed; z-index: 9999; padding: 10px 14px; background: rgba(17,24,39,.95); color: #f9fafb; border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.6; max-width: 440px; word-break: break-all; box-shadow: 0 8px 24px rgba(0,0,0,.18); pointer-events: none; opacity: 0; transition: opacity .15s; }
.ip-popover.show { opacity: 1; }

/* 个人画像 */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tag { background: #eef2ff; color: #4338ca; border-radius: 999px; padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.charts-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.chart { flex: 1 1 300px; height: 260px; background: #fafafa; border-radius: 8px; min-width: 260px; }

/* ---------- 国家 / 地区分布 ---------- */
.country-stats { margin-bottom: 24px; }

.country-summary {
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 12px;
}
.country-summary b { color: #111827; font-weight: 600; }

.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.country-card {
  background: #fafbfd;
  border: 1px solid #eef1f5;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  cursor: default;
}

.country-card:hover {
  transform: translateY(-2px);
  border-color: #dbeafe;
  background: #f8fbff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, .1);
}

.country-flag {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 6px;
  user-select: none;
}

.country-name {
  font-size: 12px;
  color: #374151;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-count {
  font-size: 11px;
  color: #6b7280;
}
.country-count b {
  color: #3b82f6;
  font-weight: 600;
  font-size: 13px;
}

.country-empty {
  font-size: 13px;
  color: #9ca3af;
  padding: 12px 0;
}

/* 拓扑图 */
.topo { width: 100%; min-height: 200px; background: linear-gradient(180deg, #fafbfd 0%, #f5f7fa 100%); border: 1px solid #eef1f5; border-radius: 10px; box-sizing: border-box; padding: 4px; transition: height .25s ease; }

/* 查询结果 */
.query-result { margin-bottom: 20px; }
.query-card { background: #fafbfd; border: 1px solid #eef1f5; border-radius: 8px; padding: 14px 18px; }

/* BGP 抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.35); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; z-index: 1000; }
.drawer-mask.show { opacity: 1; visibility: visible; }
.drawer { position: fixed; top: 0; right: 0; width: 440px; max-width: 92vw; height: 100vh; background: #fff; box-shadow: -8px 0 24px rgba(0,0,0,.08); transform: translateX(100%); transition: transform .25s ease; z-index: 1001; display: flex; flex-direction: column; }
.drawer.show { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 14px; border-bottom: 1px solid #eef1f5; }
.drawer-title { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; font-weight: 600; color: #111827; }
.drawer-sub { font-size: 12px; color: #6b7280; margin-top: 4px; }
.drawer-close { background: transparent; color: #6b7280; padding: 4px 8px; font-size: 16px; }
.drawer-close:hover { background: #f3f4f6; color: #111827; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 32px; }
.bgp-section { margin-bottom: 22px; }
.bgp-title { font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 10px; }
.bgp-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px dashed #eef1f5; font-size: 13px; }
.bgp-row:last-child { border-bottom: none; }
.bgp-row > span { color: #6b7280; flex: 0 0 84px; }
.bgp-row > b { color: #111827; font-weight: 500; text-align: right; flex: 1; word-break: break-all; }
.bgp-row .chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.bgp-row .chip { display: inline-block; padding: 2px 8px; border-radius: 4px; background: #eef2ff; color: #4338ca; font-size: 11px; font-weight: 500; }
.ok { color: #059669; } .no { color: #dc2626; }
.bgp-loading { color: #9ca3af; font-size: 13px; padding: 8px 0; }
.bgp-error { color: #dc2626; font-size: 13px; padding: 8px 0; }
.bgp-empty { color: #9ca3af; font-size: 13px; padding: 4px 0; }
.bgp-foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid #eef1f5; font-size: 11px; color: #9ca3af; text-align: center; }

/* 诊断 */
.diag-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.diag-result { margin-bottom: 24px; }
.diag-card { background: #fafbfd; border: 1px solid #eef1f5; border-radius: 8px; padding: 16px 20px; }
.diag-title { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 10px; }
.diag-row-item { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13px; }
.diag-row-item > span { color: #6b7280; }
.diag-row-item > b { color: #111827; font-weight: 500; word-break: break-all; text-align: right; }
.diag-note { margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: #f3f4f6; font-size: 12px; color: #4b5563; line-height: 1.7; }
.diag-note.ok { background: #ecfdf5; color: #065f46; }
.diag-note.warn { background: #fef3c7; color: #92400e; }