:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #16191d;
  --muted: #6b7280;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --good: #15803d;
  --good-bg: #dcfce7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --warn: #a16207;
  --warn-bg: #fef3c7;
  --neutral: #4b5563;
  --neutral-bg: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.05);
}
[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #5b8dff;
  --accent-ink: #0b0d11;
  --good: #4ade80;
  --good-bg: #14351f;
  --bad: #f87171;
  --bad-bg: #3b1717;
  --warn: #fbbf24;
  --warn-bg: #3a2c0a;
  --neutral: #c2c8d2;
  --neutral-bg: #262b35;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.01em; }
.logo {
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 15px; font-weight: 700;
}
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-weight: 550;
  padding: 7px 13px; border-radius: 8px;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); }
.ghost {
  background: none; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; border-radius: 8px; padding: 6px 10px; font: inherit;
}
.ghost:hover { color: var(--text); }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 34px 24px 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
h1 { font-size: 25px; margin: 0 0 4px; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: 0 0 24px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13.5px; }

/* ---------- single check ---------- */
.checkbox-row { display: flex; gap: 10px; margin-bottom: 20px; }
input[type=text] {
  flex: 1; padding: 13px 15px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
}
input[type=text]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
button[type=submit], .btn {
  padding: 13px 20px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block;
}
button[type=submit]:disabled { opacity: .55; cursor: progress; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

.result {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 26px;
}
.result-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.result-email { font-weight: 620; font-size: 16px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- pills ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 650; text-transform: lowercase;
  background: var(--neutral-bg); color: var(--neutral); white-space: nowrap;
}
.pill.valid { background: var(--good-bg); color: var(--good); }
.pill.invalid { background: var(--bad-bg); color: var(--bad); }
.pill.catch_all, .pill.unknown, .pill.running, .pill.queued { background: var(--warn-bg); color: var(--warn); }
.pill.done { background: var(--good-bg); color: var(--good); }
.pill.failed { background: var(--bad-bg); color: var(--bad); }
.pill.duplicate, .pill.disposable { background: var(--neutral-bg); color: var(--neutral); }
.pill.likely_valid { background: var(--warn-bg); color: var(--warn); }
.pill.likely_invalid { background: var(--bad-bg); color: var(--bad); }

/* ---------- threshold slider ---------- */
.threshold-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-top: 16px;
}
.threshold-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.threshold-head label { font-weight: 550; font-size: 14px; }
#threshValue {
  font-variant-numeric: tabular-nums; font-weight: 680; color: var(--accent);
  min-width: 44px; text-align: right;
}
#threshold {
  width: 100%; margin: 12px 0 6px; accent-color: var(--accent); cursor: pointer;
}
#threshHelp { margin: 0; }

/* ---------- confidence meter ---------- */
.conf { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.conf-track { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.conf-fill { height: 100%; border-radius: 99px; }
.conf-num { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); min-width: 30px; }

/* ---------- legend ---------- */
.legend { border-top: 1px solid var(--border); padding-top: 20px; }
.legend h3 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.legend-grid { display: grid; gap: 9px; font-size: 14px; }
.legend-grid > div { display: flex; align-items: baseline; gap: 10px; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border); border-radius: 14px;
  padding: 44px 20px; text-align: center; cursor: pointer;
  background: var(--surface); transition: .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--surface-2); }
.dz-inner { display: grid; gap: 5px; justify-items: center; }
.dz-icon { font-size: 30px; color: var(--accent); }
.dz-inner span { color: var(--muted); font-size: 13.5px; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-top: 22px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head strong { word-break: break-all; }
.panel-head .pill { margin-left: auto; }

.progress { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .3s ease; }
#jobStage { margin-top: 9px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 20px; }
.stat {
  background: var(--surface-2); border-radius: var(--radius);
  padding: 14px; text-align: center;
}
.stat span { display: block; font-size: 23px; font-weight: 680; letter-spacing: -.02em; }
.stat label { color: var(--muted); font-size: 12.5px; }
.stat.good span { color: var(--good); }
.stat.warn span { color: var(--warn); }

.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- filters + table ---------- */
.filters { display: flex; gap: 7px; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); border-radius: 999px; padding: 5px 13px;
  font: inherit; font-size: 13.5px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.email { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
td.why { color: var(--muted); max-width: 340px; }
#resultsMore { margin-top: 11px; }

/* ---------- history ---------- */
.history { display: grid; gap: 11px; }
.hist-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 18px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.hist-item .name { font-weight: 600; word-break: break-all; }
.hist-item .meta { color: var(--muted); font-size: 13px; }
.hist-item .spacer { flex: 1; }
.hist-item a { color: var(--accent); text-decoration: none; font-weight: 550; font-size: 13.5px; }
.hist-item a:hover { text-decoration: underline; }
.del { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.del:hover { color: var(--bad); }

footer { padding: 16px 24px; border-top: 1px solid var(--border); text-align: center; }

.err { color: var(--bad); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 34px 30px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow); text-align: center;
}
.login-logo {
  width: 46px; height: 46px; margin: 0 auto 16px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
}
.login-card button { width: 100%; }

@media (max-width: 620px) {
  .topbar { gap: 12px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .checkbox-row { flex-direction: column; }
  main { padding: 24px 16px 48px; }
}
