/* SendPilot design system — Resend-grade.
   Dark-first (Resend: canvas #000, surface #18191C, elevated #212629,
   ink #F0F0F0, ink-muted #8798A6, mint accent #22FF99, Inter).
   Light theme via html[data-theme="light"] (quiet near-white dashboard).
   Font stack has full system fallbacks: if the Inter webfont never loads,
   the page still looks designed. */
:root {
  --bg: #000000;
  --surface: #18191c;
  --surface2: #212629;
  --surface3: #26262b;
  --border: #212629;
  --border-strong: #32363d;
  --text: #f0f0f0;
  --text-strong: #ffffff;
  --muted: #8798a6;
  --muted2: #a1a4a5;
  --accent: #22ff99;
  --accent-soft: rgba(34, 255, 153, .12);
  --accent2: #22ff99;
  --green-soft: rgba(34, 255, 153, .1);
  --danger: #ff8585;
  --danger-soft: rgba(255, 107, 107, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --input: #18191c;
  --primary: #f0f0f0;
  --on-primary: #000000;
  --link: #7dd3fc;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  --ring: 0 0 0 3px rgba(176, 199, 217, .35);
}
html[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface2: #f4f4f5;
  --surface3: #ececee;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-strong: #09090b;
  --muted: #71717a;
  --muted2: #a1a1aa;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, .09);
  --accent2: #16a34a;
  --green-soft: rgba(22, 163, 74, .1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .09);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, .1);
  --input: #ffffff;
  --primary: #111113;
  --on-primary: #ffffff;
  --link: #2563eb;
  --shadow: 0 1px 2px rgba(16, 16, 20, .05), 0 1px 3px rgba(16, 16, 20, .04);
  --shadow-lg: 0 8px 28px rgba(16, 16, 20, .1), 0 2px 8px rgba(16, 16, 20, .06);
  --ring: 0 0 0 3px rgba(37, 99, 235, .18);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
::selection { background: var(--accent-soft); }
/* Safety net: an inline SVG can never blow up if a stylesheet fails to load —
   every SVG also carries explicit width/height attributes in the markup. */
svg { flex-shrink: 0; }

/* ---------- layout (Resend: fixed left sidebar, generous content margins) ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--text-strong); }
.logo-mark {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 9px;
  background: var(--primary); color: var(--on-primary);
  display: inline-flex; align-items: center; justify-content: center;
}
.logo-mark svg { width: 17px; height: 17px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted2); padding: 18px 10px 6px; }
.nav-group:first-of-type { padding-top: 4px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav button {
  display: flex; align-items: center; gap: 12px;
  text-align: left; background: none; border: 0;
  color: var(--muted); padding: 8px 10px; border-radius: 8px;
  font-size: 14px; font-weight: 400; font-family: inherit; cursor: pointer;
  transition: background .12s, color .12s;
}
.sidebar nav button svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.sidebar nav button:hover { background: var(--surface2); color: var(--text); }
.sidebar nav button.active { background: var(--surface2); color: var(--text-strong); font-weight: 600; }
.sidebar nav button:focus-visible { outline: none; box-shadow: var(--ring); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.side-foot .ghost-btn { justify-content: flex-start; }
.main { flex: 1; padding: 0 48px 56px; min-width: 0; max-width: 1120px; margin: 0 auto; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 28px 0 18px; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 28px; font-weight: 500; letter-spacing: -.045em; line-height: 1.2; margin: 0; flex: 1; color: var(--text-strong); }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 10px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent2); box-shadow: 0 0 0 3px var(--green-soft); }
.page { display: none; animation: fadein .18s ease; }
.page.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- cards / panels ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.card .value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; margin-top: 8px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow); }
.panel.narrow { max-width: 660px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 0; color: var(--text-strong); }
.panel-head h3, h3 { font-size: 14px; font-weight: 600; color: var(--text-strong); }

/* ---------- tables (Resend: small-caps headers, hairline row separators) ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface2); }
td strong { font-weight: 600; color: var(--text-strong); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1.6; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--accent2); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.grey { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }

/* ---------- buttons / inputs (Resend: 12px radius, 14px/600 labels) ---------- */
.btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit;
  transition: background .12s, border-color .12s, box-shadow .12s, opacity .12s;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { opacity: .88; background: var(--primary); }
.btn:focus-visible, .ghost-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.block { width: 100%; margin-top: 6px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 0; color: var(--muted); border-radius: 8px;
  padding: 8px 10px; cursor: pointer; font-size: 14px; font-weight: 400; font-family: inherit; text-align: left;
}
.ghost-btn:hover { background: var(--surface2); color: var(--text); }
.ghost-btn svg { width: 16px; height: 16px; }
input, select, textarea {
  width: 100%; background: var(--input); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; margin-top: 6px;
  transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted2); }
textarea { resize: vertical; line-height: 1.55; }
label { display: block; margin-bottom: 16px; font-weight: 600; font-size: 14px; color: var(--text-strong); }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input { width: 280px; margin-top: 0; }
.result { margin-top: 16px; padding: 13px 15px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); word-break: break-word; font-size: 14px; line-height: 1.55; }
.result.ok { border-color: var(--accent2); background: var(--green-soft); }
.result.err { border-color: var(--danger); background: var(--danger-soft); }
.error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }

/* ---------- login (Resend: full-bleed dark canvas, centered form) ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(700px 340px at 50% -90px, rgba(34, 255, 153, .07), transparent 70%),
    var(--bg);
}
html[data-theme="light"] .login-page {
  background:
    radial-gradient(700px 340px at 50% -90px, rgba(37, 99, 235, .08), transparent 70%),
    var(--bg);
}
.login-col { width: 100%; max-width: 400px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 28px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: var(--text-strong); }
.login-brand .logo-mark { width: 40px; height: 40px; border-radius: 11px; }
.login-brand .logo-mark svg { width: 20px; height: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 20px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 4px; color: var(--text-strong); text-align: center; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.login-card label { margin-bottom: 18px; }
.login-foot { text-align: center; color: var(--muted2); font-size: 12.5px; margin-top: 20px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 7px 9px; border-radius: 6px; font-size: 12.5px; font-weight: 600; }
.pw-toggle:hover { color: var(--text); background: var(--surface2); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 9px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.legend { display: flex; gap: 18px; color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.progress { height: 8px; background: var(--surface3); border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress.big { height: 10px; }
.progress div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.clickable-card { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.clickable-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.sent { background: var(--accent); }
.sw.bounced { background: var(--danger); }
.sw.held { background: var(--warn); }
#chart { width: 100%; display: block; }
.empty { color: var(--muted); padding: 32px 16px; text-align: center; font-size: 14px; }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 12px; }

@media (max-width: 860px) {
  .main { padding: 0 16px 40px; }
  .sidebar { width: 68px; padding: 14px 8px 10px; }
  .brand span.brand-name, .nav-group, .sidebar nav button span.nav-label, .side-foot .ghost-btn span { display: none; }
  .brand { justify-content: center; padding: 4px 0 14px; }
  .sidebar nav button { justify-content: center; padding: 10px; }
  .ghost-btn { justify-content: center; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .search-row input { width: 100%; }
  .search-row { flex-wrap: wrap; }
  .topbar h1 { font-size: 22px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
}

/* ---------- domain switcher (Resend-style, topbar) ---------- */
.domain-switcher { position: relative; flex-shrink: 0; }
.domain-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 8px 12px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit;
  transition: background .12s, border-color .12s;
  max-width: 320px;
}
.domain-btn:hover { background: var(--surface2); }
.domain-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.domain-btn svg { flex-shrink: 0; }
.domain-btn .chev { transition: transform .15s; color: var(--muted); }
.domain-switcher.open .domain-btn .chev { transform: rotate(180deg); }
#domainLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 260px;
  background: var(--surface2); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 60;
}
.domain-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; background: none; border: 0; color: var(--text);
  padding: 9px 10px; border-radius: 8px; font-size: 14px; font-family: inherit;
  cursor: pointer; text-align: left;
}
.domain-item:hover { background: var(--surface3); }
.domain-item.active { font-weight: 600; color: var(--text-strong); }
.domain-item .domain-check { color: var(--accent); display: inline-flex; flex-shrink: 0; }
.domain-item .domain-check svg { width: 15px; height: 15px; }
.domain-menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.domain-menu-link {
  display: flex; align-items: center; gap: 8px;
  width: 100%; background: none; border: 0; color: var(--muted);
  padding: 9px 10px; border-radius: 8px; font-size: 14px; font-family: inherit;
  cursor: pointer; text-align: left;
}
.domain-menu-link:hover { background: var(--surface3); color: var(--text); }
.domain-menu-link svg { flex-shrink: 0; }

/* ---------- chart range selector + tooltip ---------- */
.seg { display: inline-flex; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; gap: 2px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 500; padding: 4px 10px; border-radius: 6px; cursor: pointer; font-family: inherit; }
.seg-btn:hover { color: var(--text-strong); }
.seg-btn.active { background: var(--surface3); color: var(--text-strong); }
.chart-tip { position: fixed; z-index: 50; background: var(--surface2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.5; color: var(--text-strong); box-shadow: 0 8px 24px rgba(0,0,0,.35); pointer-events: none; }
.chart-tip strong { font-weight: 600; }

.btn.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(255, 107, 107, .22); }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; padding: 24px; max-width: 440px; width: 100%; box-shadow: var(--shadow-lg); }
.modal-card h3 { margin: 0 0 8px; font-size: 16px; color: var(--text-strong); }
.modal-card p { margin: 0 0 20px; font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* docs code blocks */
#page-docs h3 { margin: 20px 0 6px; }
#page-docs h3:first-of-type { margin-top: 4px; }
#page-docs p { margin: 6px 0; }
pre { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 8px 0 16px; }
pre code { background: none; border: none; padding: 0; font-size: 12.5px; line-height: 1.6; display: block; white-space: pre; }
