/* ── Base ─────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 1rem;
}
/* Hide scrollbars everywhere */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
tt, pre {
  font-family: 'Roboto Mono', monospace;
  font-size: .9em;
  background: #000000bb;
  padding: 0 .25rem .1rem .25rem;
}

p.description {
  font-size: 0.8rem;
  margin-top: 1rem;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header (sticky top) ────────────────────────────────── */
.header {
  flex-shrink: 0;
  padding: 2rem 0 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.brand-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin: 0 0 0 0.3rem;
}
h1 {
  font-size: 1.8rem;
  color: #f8fafc;
}

p.description { color: #aabbccee; }

.subtitle {
  color: #94a3b8;
  margin-bottom: 0.75rem; margin-top: 0.2rem;
  font-size: 0.95rem;
}

.center { text-align: center; }

/* ── Search box ──────────────────────────────────────────── */
.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.input-wrap .badge-cache {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.search-box input {
  flex: 1;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f8fafc;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}
.search-box input:focus { border-color: #3b82f6; }
.search-box input::placeholder { color: #64748b; }
.search-box .scan-btn {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: #3b82f6;
  background: radial-gradient(#3b82f6, #1b62d6);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.search-box .scan-btn:hover { background: #2563eb; }
.search-box .scan-btn:disabled { background: #475569; cursor: wait; }
.search-box .clear-btn {
  display: none;
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #475569;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: bolder;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  transition: background 0.2s;
}
.input-wrap.has-value .clear-btn { display: block; }
.input-wrap.has-value input { padding-left: 2.5rem; }
.search-box .clear-btn:hover { background: #64748b; }

/* ── Scrollable results area ─────────────────────────────── */
.results-wrap {
  flex: 1;
  overflow-y: auto;
  position: relative;
  min-height: 0;
}

/* ── Loading overlay (centered in results area) ──────────── */
.scan-loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #94a3b8;
  font-size: 0.95rem;
  padding-bottom: 20%;
}
.search-box.htmx-request ~ .results-wrap .scan-loading { display: flex; }
.search-box.htmx-request ~ .results-wrap #results { opacity: 0.15; pointer-events: none; }
.search-box.htmx-request + * + .results-wrap .scan-loading { display: flex; }
.search-box.htmx-request + * + .results-wrap #results { opacity: 0.15; pointer-events: none; }
.search-box.htmx-request .scan-btn { display: none; }
.search-box.htmx-request .input-wrap .clear-btn {
  display: block;
  pointer-events: none;
  background: transparent;
  color: transparent;
  overflow: hidden;
}
.search-box.htmx-request .input-wrap .clear-btn::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 2px solid #475569;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.search-box.htmx-request .input-wrap input { padding-left: 2.5rem; }
#results { transition: opacity 0.3s ease; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 18px; height: 18px;
  border: 2px solid #475569;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Results ─────────────────────────────────────────────── */
.error { color: #f87171; padding: 0.5rem 0; }
section { margin-bottom: 2rem; }
section h2 {
  font-size: 1.15rem;
  color: #f8fafc;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #1e293b;
}
.meta {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* ── Tab count styling ────────────────────────────────────── */
.info-card-denom {
  font-size: 0.85rem;
  font-weight: 400;
  color: #64748b;
}

/* ── Subdomain table fixed column widths ─────────────────── */
.subdomain-table th, .email-table th {
  padding-top: 0.6rem;
}
.subdomain-table colgroup .col-subdomain { width: 50%; }
.subdomain-table colgroup .col-records   { width: 35%; }
.subdomain-table colgroup .col-results   { width: 15%; }

/* ── Tables ──────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: fixed;
}
th {
  text-align: left;
  padding: 0.1rem 0.75rem 0.6rem 0.75rem;
  background: #1e293b;
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
}
td {
  padding: 0.6rem 0.75rem;
  text-overflow: ellipsis;
}
tbody tr { border-bottom: 1px solid #1e293b; }
tr:hover td { background: #1e293b40; }

/* ── Tech table fixed column widths ──────────────────────── */
.tech-table colgroup .col-tech   { width: 40%; }
.tech-table colgroup .col-conf   { width: 22.5%; }
.tech-table colgroup .col-source { width: 37.5%; }

/* ── Email security table fixed column widths ────────────── */
.email-table colgroup .col-proto    { width: 20%; }
.email-table colgroup .col-status   { width: 17.5%; }
.email-table colgroup .col-evidence { width: 62.5%; }

/* ── Sorting ─────────────────────────────────────────────── */
.sortable {
  cursor: pointer;
  user-select: none;
}
.sortable:hover { color: #e2e8f0; }
.sortable.active { color: #e2e8f0; }
.sort-arrow {
  font-size: 1.5rem;
  margin-left: 0.2rem;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-high { background: #166534; color: #4ade80; }
.badge-medium { background: #854d0e; color: #fbbf24; }
.badge-detected { background: #166534; color: #4ade80; }
.badge-missing { background: #7f1d1d; color: #f87171; }
.status-icon { font-size: 1.1rem; }
.status-pass { color: #4ade80; }
.status-fail { color: #f87171; }
.status-unknown { color: #60a5fa; }
.badge-cache {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #334155;
  color: #94a3b8;
  vertical-align: middle;
  margin-left: 0.25rem;
}
.badge-category {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #1e3a5f;
  color: #7dd3fc;
  margin-right: 0.25rem;
  margin-bottom: 0.15rem;
  white-space: nowrap;
}
.badge-rt {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  /* font-family: monospace; */
  background: #334155;
  color: #94a3b8;
  margin: 0.1rem 0 0 0.2rem;
}
.badge-rt.grade-a { background: #166534; color: #4ade80; }
.badge-rt.grade-b { background: #1a4d2e; color: #86efac; }
.badge-rt.grade-c { background: #854d0e; color: #fbbf24; }
.badge-rt.grade-d { background: #78350f; color: #fb923c; }
.badge-rt.grade-f { background: #7f1d1d; color: #f87171; }

/* ── Tech rows ───────────────────────────────────────────── */
.tech-name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.tech-name img, .icon-placeholder {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-block;
}
.icon-placeholder {
  background: #334155;
}
.tech-row {
  cursor: pointer;
  user-select: none;
}
.tech-row:hover td { background: #1e293b80; }
.chevron {
  margin-left: auto;
  color: #475569;
  font-size: 2rem;
  transition: transform 0.2s;
}
.tech-row:has(+ .expanded) .chevron {
  transform: rotate(90deg);
}

/* ── Detail rows ─────────────────────────────────────────── */
.detail-row {
  display: none;
}
.detail-row.expanded {
  display: table-row;
}
.detail-row td {
  padding: 0;
  border-bottom: 1px solid #1e293b;
}
.detail-content {
  padding: 0.75rem 0.75rem 0.75rem 2.75rem;
  background: #1e293b60;
  color: #cbd5e1;
  font-size: 0.85rem;
  line-height: 1.5;
}
.detail-content p {
  margin-bottom: 0.5rem;
}
.detail-content a {
  color: #60a5fa;
  text-decoration: none;
  font-size: 0.8rem;
}
.detail-content a:hover { text-decoration: underline; }
.all-evidence {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: #64748b;
}
.all-evidence ul {
  list-style: none;
  padding: 0;
  margin-top: 0.25rem;
}
.all-evidence li {
  font-family: monospace;
  padding: 0.1rem 0;
  overflow-wrap: anywhere;
}


/* ── Tabs ────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #1e293b;
  position: sticky;
  top: 0;
  background: #0f172a;
  z-index: 10;
}
.tab {
  padding: 0.6rem 1.25rem;
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  white-space: nowrap;
}
.tab:hover { color: #94a3b8; }
.tab.active {
  color: #f8fafc;
}
.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #3b82f6;
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ── DMARC details ──────────────────────────────────────── */
.dmarc-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.dmarc-row {
  display: contents;
}
.dmarc-row dt {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1e293b;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 600;
}
.dmarc-row dd {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1e293b;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.dmarc-row dd a {
  color: #60a5fa;
  text-decoration: none;
}
.dmarc-row dd a:hover { text-decoration: underline; }

/* ── DMARC Score ────────────────────────────────────────── */
.dmarc-score {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.dmarc-grade {
  font-size: 1.6rem;
  font-weight: 800;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.dmarc-grade-a { background: #166534; color: #4ade80; }
.dmarc-grade-b { background: #1a4d2e; color: #86efac; }
.dmarc-grade-c { background: #854d0e; color: #fbbf24; }
.dmarc-grade-d { background: #78350f; color: #fb923c; }
.dmarc-grade-f { background: #7f1d1d; color: #f87171; }
.dmarc-score-detail { flex: 1; min-width: 0; }
.dmarc-score-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}
.dmarc-score-value {
  font-size: 1rem;
  font-weight: 700;
  color: #e2e8f0;
}
.dmarc-score-bar {
  height: 6px;
  background: #1e293b;
  border-radius: 3px;
  overflow: hidden;
}
.dmarc-score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.dmarc-score-fill.dmarc-grade-a { background: #4ade80; }
.dmarc-score-fill.dmarc-grade-b { background: #86efac; }
.dmarc-score-fill.dmarc-grade-c { background: #fbbf24; }
.dmarc-score-fill.dmarc-grade-d { background: #fb923c; }
.dmarc-score-fill.dmarc-grade-f { background: #f87171; }

/* ── Email Security Recommendations ─────────────────────── */
.email-rec {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.4rem;
}
.email-rec-cat {
  flex-shrink: 0;
  width: 4.15rem;
  text-align: center;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.1rem;
}
.email-rec-cat-dmarc   { background: #1e3a5f; color: #60a5fa; }
.email-rec-cat-spf     { background: #3b1f6e; color: #c084fc; }
.email-rec-cat-dkim    { background: #134e4a; color: #5eead4; }
.email-rec-cat-mta-sts { background: #1e293b; color: #94a3b8; }
.email-rec-cat-bimi    { background: #1e293b; color: #94a3b8; }
.email-rec-body { min-width: 0; }
.email-rec-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 0.2rem;
}
.email-rec-desc {
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.4;
}
.email-rec-action {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.15rem 0.5rem;
  background: #1e293b;
  border-radius: 3px;
  font-size: 0.75rem;
  color: #7dd3fc;
}

/* ── DMARC Policy Stoplight ─────────────────────────────── */
.policy-stoplight {
  display: inline-flex;
  gap: 0;
  border-radius: 4px;
  overflow: hidden;
}
.policy-light {
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  background: #1e293b;
  color: #475569;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.policy-light-reject.active { background: #166534; color: #4ade80; opacity: 1; }
.policy-light-quarantine.active { background: #854d0e; color: #fbbf24; opacity: 1; }
.policy-light-none.active { background: #7f1d1d; color: #f87171; opacity: 1; }

/* ── SPF Lookup Bar ─────────────────────────────────────── */
.spf-lookup {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}
.spf-lookup-bar {
  flex: 1;
  height: 8px;
  background: #334155;
  border-radius: 4px;
  overflow: hidden;
  max-width: 200px;
}
.spf-lookup-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.spf-bar-ok { background: #4ade80; }
.spf-bar-warn { background: #fbbf24; }
.spf-bar-danger { background: #f87171; }
.spf-lookup-label {
  font-size: 0.85rem;
  color: #94a3b8;
}
.badge-spf-exceeded {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #7f1d1d;
  color: #f87171;
}

/* ── DNS Security ───────────────────────────────────────── */
.dns-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #cbd5e1;
}
.badge-dangling {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #78350f;
  color: #fbbf24;
}

/* ── Evidence ────────────────────────────────────────────── */
.evidence {
  color: #64748b;
  font-size: 0.8rem;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.evidence-clickable { cursor: pointer; }
.evidence-clickable:hover { color: #94a3b8; }

/* ── Evidence Modal ─────────────────────────────────────── */
.ev-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #00000088;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  margin-top: -40vh;
}
.ev-modal.open { display: flex; }
.ev-modal-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ev-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #334155;
  font-size: 0.9rem;
  font-weight: 600;
  color: #f8fafc;
}
.ev-modal-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.ev-btn-copy {
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #334155;
  background: #0f172a;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.ev-btn-copy:hover { background: #334155; color: #e2e8f0; }
.ev-btn-close {
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
}
.ev-btn-close:hover { color: #f8fafc; }
#ev-modal-body {
  margin: 0.75rem 1rem;
  overflow-y: auto;
}
#ev-modal-text {
  margin: 0;
  padding: 0.75rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #cbd5e1;
  font-family: monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Copyright ───────────────────────────────────────────── */
.copyright {
  text-align: center;
  color: #475569;
  font-size: 0.75rem;
  padding: 0.5rem 0;
  flex-shrink: 0;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .header { padding: 1rem 0 0; }
  h1 { font-size: 1.4rem; }
  .brand-logo { width: 28px; height: 28px; }
  .search-box { flex-wrap: nowrap; }
  .results-wrap { overflow-x: hidden; }
  .tab-panel { overflow-x: auto; }
  table { font-size: 0.8rem; min-width: 0; }
  th, td { padding: 0.45rem 0.5rem; overflow: hidden; text-overflow: ellipsis; }
  .tech-name { gap: 0.35rem; overflow: hidden; }
  .chevron { font-size: 1.2rem; }
  .tab-bar { justify-content: center; }
  .tab { padding: 0.6rem 0.75rem; font-size: 0.8rem; }
  .dmarc-details { display: block; }
  .dmarc-row { display: block; margin-bottom: 0.75rem; }
  .dmarc-row dt {
    border-bottom: none;
    padding: 0 0.75rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .dmarc-row dd {
    padding: 0.1rem 0.75rem 0.5rem;
    overflow-wrap: anywhere;
  }
  .spf-lookup { flex-wrap: wrap; }
  .all-evidence li { word-break: break-all; }
}
