:root {
  --bg: #f4f7fc;
  --bg-elev: rgba(255, 255, 255, 0.92);
  --bg-soft: #f1f5f9;
  --bg-subtle: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-dim: #475569;
  --text-muted: #64748b;
  --blue: #2563eb;
  --indigo: #4f46e5;
  --emerald: #059669;
  --amber: #d97706;
  --rose: #e11d48;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow: 0 8px 28px -4px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.03);
  --radius: 18px;
  --radius-sm: 10px;
  --mono: ui-monospace, 'SFMono-Regular', 'JetBrains Mono', Menlo, Monaco, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(960px 520px at 8% -6%, rgba(37, 99, 235, 0.12), transparent 64%),
    radial-gradient(840px 500px at 92% 0%, rgba(16, 185, 129, 0.10), transparent 64%),
    radial-gradient(880px 520px at 50% 106%, rgba(99, 102, 241, 0.08), transparent 64%);
}

.container { max-width: 1240px; margin: 0 auto; padding: 20px 20px 56px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }

/* Header & Suite Nav */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  margin-bottom: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 40px; height: 40px; flex-shrink: 0; filter: drop-shadow(0 4px 10px rgba(37, 99, 235, 0.14)); }
.brand h1 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }

.badge-ver {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.09);
  color: var(--blue);
  border: 1px solid rgba(37, 99, 235, 0.22);
}

.brand-sub { font-size: 0.78rem; color: var(--text-dim); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.suite-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.suite-link {
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.suite-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.75); }
.suite-link.active { background: #ffffff; color: var(--blue); box-shadow: var(--shadow-sm); }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { border-color: #cbd5e1; background: #f8fafc; transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.24);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #1d4ed8, #4338ca);
  color: #ffffff;
}
.btn-sm { padding: 5px 10px; font-size: 0.76rem; border-radius: 8px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.section-gap { margin-bottom: 18px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-title { font-size: 0.85rem; font-weight: 700; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }

/* Mode Switcher */
.mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.mode-tab {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.mode-tab.active { background: #ffffff; color: var(--blue); box-shadow: var(--shadow-sm); }

/* Hero Search */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.input-wrap { position: relative; flex: 1; min-width: 260px; display: flex; align-items: center; }

.input, .select, .textarea {
  padding: 10px 14px;
  border-radius: 11px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.input { width: 100%; padding-right: 36px; min-height: 44px; }
.textarea { width: 100%; min-height: 115px; resize: vertical; font-family: var(--mono); font-size: 0.84rem; }
.input:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }

.clear-btn {
  position: absolute;
  right: 10px;
  width: 26px;
  height: 26px;
  border: none;
  background: #f1f5f9;
  color: var(--text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.chip-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.chip-lbl { font-size: 0.76rem; color: var(--text-muted); font-weight: 600; }

.chip {
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--blue); color: var(--blue); background: #eff6ff; }

.resolved-bar {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.8rem;
}

/* Badges / Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill-ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.pill-warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.pill-bad { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.pill-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.pill-muted { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

/* 4-Column KPI Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}
.kpi-top { display: flex; justify-content: space-between; align-items: center; font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.kpi-main { font-size: 1.25rem; font-weight: 800; color: var(--text); word-break: break-all; }
.kpi-sub { font-size: 0.78rem; color: var(--text-dim); word-break: break-word; }

/* Split Dashboard Grid (Risk + Map) */
.split-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; }

.purity-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
}

.ring-wrap { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.ring-svg { width: 92px; height: 92px; transform: rotate(-90deg); }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font-size: 1.45rem; font-weight: 800; line-height: 1; }
.ring-lbl { font-size: 0.66rem; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

.fraud-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.fraud-src-card {
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 0.8rem;
}
.fraud-src-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 6px; }
.bar-track { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.35s ease; }

#map { height: 345px; width: 100%; border-radius: 12px; border: 1px solid var(--border); background: #f1f5f9; }

/* Detail Tables & RDAP */
.bottom-grid { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 16px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: #ffffff; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th {
  text-align: left;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 10px 13px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px 13px; border-bottom: 1px solid #f1f5f9; font-size: 0.84rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.82rem;
}
.kv-k { color: var(--text-muted); flex-shrink: 0; font-weight: 500; }
.kv-v { color: var(--text); text-align: right; word-break: break-all; font-weight: 600; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #0f172a;
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer { text-align: center; color: var(--text-muted); font-size: 0.78rem; margin-top: 28px; }
footer a { color: var(--blue); text-decoration: none; font-weight: 500; }

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .split-grid, .bottom-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .container { padding: 12px 12px 40px; }
  .kpi-grid, .fraud-grid { grid-template-columns: 1fr; }
}
