:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --pass: #16a34a;
  --pass-bg: #f0fdf4;
  --fail: #dc2626;
  --fail-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', Consolas, monospace;
}

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

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-badge {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--primary);
  background: #eff6ff;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #dbeafe;
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.status-dot.online { background: var(--pass); }

/* ── Main Layout ── */
.main-container {
  max-width: 1040px;
  margin: 36px auto;
  padding: 0 24px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  margin-bottom: 24px;
}

/* ── Hero Generator Section ── */
.hero-card h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.hero-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 24px;
  max-width: 780px;
}

.address-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.input-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  margin-bottom: 8px;
}

.input-action-group {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.code-input {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text-main);
  outline: none;
}

.code-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 0.86rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #fff; color: var(--text-main); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--border-hover); }

.btn-outline { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-outline:hover { color: var(--text-main); background: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.full-width { width: 100%; }

.listening-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pulse-indicator {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.hidden { display: none !important; }

/* ── Dashboard Grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 16px;
  margin-bottom: 28px;
}

.summary-card {
  padding: 22px;
  margin-bottom: 0;
}

.score-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  margin-bottom: 8px;
}

.score-container {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.score-number {
  font-family: var(--mono);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--pass);
}

.score-max { font-size: 0.9rem; color: var(--text-subtle); }
.score-tag { font-size: 0.78rem; font-weight: 500; margin-top: 6px; }

/* ── Meta Card ── */
.meta-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.meta-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
}

.meta-label { color: var(--text-muted); }
.meta-value { font-weight: 500; }
.mono { font-family: var(--mono); font-size: 0.8rem; }

.actions-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

/* ── Accordion System ── */
.accordion-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.acc-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.acc-item:hover {
  border-color: var(--border-hover);
}

.acc-header {
  padding: 18px 24px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.acc-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.acc-badge {
  width: 24px;
  height: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.acc-header-left h3 {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.acc-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chevron {
  color: var(--text-subtle);
  transition: transform 0.2s ease;
}

.acc-item.open .chevron {
  transform: rotate(180deg);
}

.acc-body {
  display: none;
  padding: 24px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.acc-item.open .acc-body {
  display: block;
}

/* ── Pills / Badges ── */
.pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.pill-pass, .pill.pass { background: var(--pass-bg); color: var(--pass); }
.pill-fail, .pill.fail { background: var(--fail-bg); color: var(--fail); }
.pill-warn, .pill.warning { background: var(--warn-bg); color: var(--warn); }
.pill-info, .pill.info { background: var(--info-bg); color: var(--info); }

/* ── Segmented Control (Tabs) ── */
.segmented-control {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
  margin-bottom: 20px;
}

.segmented-btn {
  flex: 1;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font);
}

.segmented-btn:hover { color: var(--text-main); }

.segmented-btn.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.frame-wrapper iframe {
  width: 100%;
  height: 380px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.code-view {
  background: #0f172a;
  color: #f8fafc;
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 16px;
  border-radius: 6px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

.pane-action {
  margin-bottom: 12px;
  display: flex;
  justify-content: flex-end;
}

/* ── Tables ── */
.table-wrapper {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

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

.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.data-table tr:last-child td { border-bottom: none; }

.score-cell { font-family: var(--mono); font-weight: 600; }
.score-cell.pos { color: var(--fail); }
.score-cell.neg { color: var(--pass); }

/* ── Protocol Grid ── */
.section-hint {
  font-size: 0.82rem;
  color: var(--primary);
  margin-bottom: 16px;
}

.protocol-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.proto-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.proto-card:hover {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.proto-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.proto-title { font-size: 0.88rem; font-weight: 600; }
.proto-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }
.proto-link { font-size: 0.74rem; color: var(--primary); font-weight: 500; margin-top: 10px; }

/* ── DNSBL Grid ── */
.dnsbl-matrix {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.dnsbl-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dnsbl-cell-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dnsbl-cell-status {
  font-size: 0.72rem;
  font-weight: 600;
}

.dnsbl-cell-status.clean { color: var(--pass); }
.dnsbl-cell-status.listed { color: var(--fail); }

/* ── Split Grid & AI Container ── */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.box h4 { font-size: 0.88rem; font-weight: 600; margin-bottom: 12px; }

.bullet-list { list-style: none; font-size: 0.84rem; }
.bullet-list li {
  margin-bottom: 8px;
  padding-left: 16px;
  position: relative;
  color: var(--text-muted);
}

.box-warning .bullet-list li::before {
  content: "—"; color: var(--warn); position: absolute; left: 0; font-weight: 700;
}

.box-success .bullet-list li::before {
  content: "✓"; color: var(--pass); position: absolute; left: 0; font-weight: 700;
}

/* ── AI Box ── */
.ai-container {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 22px;
}

.ai-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.ai-headline { font-size: 1rem; font-weight: 700; }
.ai-subheadline { font-size: 0.84rem; color: var(--primary); font-weight: 500; }

.ai-score {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  background: #eff6ff;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #bfdbfe;
}

.ai-group { margin-bottom: 18px; }
.ai-group h5 { font-size: 0.85rem; font-weight: 600; margin-bottom: 10px; }

.ai-bullet-list { list-style: none; font-size: 0.84rem; color: var(--text-muted); }
.ai-bullet-list li { margin-bottom: 8px; padding-left: 16px; position: relative; }
.ai-bullet-list li::before { content: "•"; color: var(--primary); position: absolute; left: 0; font-weight: 700; }

.ai-subject-list { display: flex; flex-direction: column; gap: 8px; }

.ai-subject-item {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: #fff;
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 6px;
}

/* ── Modal Backdrop & Box ── */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 680px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  color: var(--text-subtle);
  cursor: pointer;
}

.modal-content { padding: 24px; max-height: 75vh; overflow-y: auto; }

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

.weight-tag {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.modal-group { margin-bottom: 20px; }
.modal-group h4 { font-size: 0.88rem; font-weight: 600; margin-bottom: 8px; }
.modal-group p { font-size: 0.86rem; color: var(--text-muted); line-height: 1.5; }

.code-banner {
  background: var(--bg);
  padding: 12px 14px;
  border-radius: 6px;
  border-left: 3px solid var(--primary);
  font-size: 0.84rem;
}

/* ── Responsive ── */
@media (max-width: 840px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .protocol-grid { grid-template-columns: 1fr; }
  .dnsbl-matrix { grid-template-columns: repeat(2, 1fr); }
  .split-grid { grid-template-columns: 1fr; }
}
