/* ── Base ──────────────────────────────────────────────────────────── */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.12);
  --radius: 10px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo span { color: var(--accent); }

nav a {
  color: var(--text-muted);
  margin-left: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
}
nav a:hover { color: var(--text); text-decoration: none; }

main { padding: 2rem 0 4rem; }

/* ── Stats Cards ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  transition: border-color 0.15s;
}

.stat-card:hover { border-color: var(--accent); }

.stat-card .label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-card.accepted .value { color: var(--green); }
.stat-card.rejected .value { color: var(--red); }

/* ── Domain Checker ───────────────────────────────────────────────── */
.domain-checker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.domain-checker h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.domain-checker form {
  display: flex;
  gap: 0.75rem;
}

.domain-checker input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.625rem 1rem;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.domain-checker input:focus { border-color: var(--accent); }
.domain-checker input::placeholder { color: var(--text-muted); }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn:hover { background: var(--accent-hover); }

#domain-result {
  margin-top: 1rem;
  font-size: 0.875rem;
  line-height: 1.7;
}

#domain-result .tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ── Filter Bar ───────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { color: var(--text); border-color: var(--text-muted); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

thead th {
  background: rgba(0,0,0,0.2);
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.6875rem;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--surface-hover); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.pass, .badge.accepted {
  background: var(--green-bg);
  color: var(--green);
}

.badge.fail, .badge.rejected {
  background: var(--red-bg);
  color: var(--red);
}

.badge.none, .badge.neutral, .badge.softfail {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}

.pagination a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.pagination .current { background: var(--accent); color: #fff; }

/* ── Detail Page ──────────────────────────────────────────────────── */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.875rem;
}

.detail-grid dt {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-grid dd {
  color: var(--text);
  word-break: break-all;
}

pre.raw-headers {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  overflow-x: auto;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Nav Active / Badge ────────────────────────────────────────────── */
nav a.nav-active { color: var(--text); }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 0.3rem;
  vertical-align: middle;
  line-height: 1;
}

/* ── Inbox List ───────────────────────────────────────────────────── */
.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.inbox-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.inbox-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.inbox-actions {
  display: flex;
  gap: 0.5rem;
}

.inbox-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.inbox-row {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.1s;
  gap: 0.75rem;
  cursor: pointer;
}

.inbox-row:last-child { border-bottom: none; }
.inbox-row:hover { background: var(--surface-hover); text-decoration: none; }

.inbox-row.unread {
  color: var(--text);
  background: rgba(59, 130, 246, 0.04);
}

.inbox-row.unread .sender-name { font-weight: 700; }
.inbox-row.unread .subject-text { font-weight: 600; }

.star-form { display: flex; }

.star-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.star-btn:hover { color: var(--yellow); }
.star-btn.starred { color: var(--yellow); }

.inbox-sender {
  min-width: 200px;
  max-width: 200px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.sender-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.sender-domain {
  font-size: 0.6rem !important;
  flex-shrink: 0;
}

.inbox-subject {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.8125rem;
}

.subject-text { color: var(--text); }

.body-preview {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.inbox-meta {
  flex-shrink: 0;
  margin-left: auto;
}

.inbox-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.inbox-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.inbox-empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ── Message View ─────────────────────────────────────────────────── */
.msg-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.msg-toolbar-right {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); text-decoration: none; }

.btn-danger-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--red);
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger-ghost:hover { background: var(--red-bg); border-color: var(--red); }

.msg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.msg-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.msg-subject {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.msg-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.msg-from-name { font-weight: 600; }
.msg-from-addr { color: var(--text-muted); }
.msg-date { color: var(--text-muted); font-size: 0.75rem; }

.msg-auth-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.msg-body {
  padding: 1.5rem;
}

.msg-text {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
}

.msg-html-frame iframe {
  width: 100%;
  min-height: 200px;
  border: none;
  border-radius: 6px;
  background: #fff;
}

.text-muted { color: var(--text-muted); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr; }
  .domain-checker form { flex-direction: column; }
  .table-wrapper { overflow-x: auto; }
  table { min-width: 640px; }
  .detail-grid { grid-template-columns: 1fr; }
  .inbox-sender { min-width: 120px; max-width: 120px; }
  .msg-toolbar { flex-direction: column; }
}
