:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #15181d;
  --muted: #6b7280;
  --line: #e6e8ec;
  --brand: #2f6feb;
  --brand-soft: #e9f0fe;
  --green: #15924a;
  --green-soft: #e4f4ea;
  --amber: #b25e09;
  --amber-soft: #fbeed7;
  --red: #c0392b;
  --red-soft: #fbe6e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }

#app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #0f1622;
  color: #cdd4df;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.brand { font-size: 19px; font-weight: 700; color: #fff; padding: 4px 8px 18px; }
.brand span { color: var(--brand); }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  color: #cdd4df;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 500;
}
#nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
#nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #6b7480; padding: 8px; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar h1 { font-size: 18px; margin: 0; }
.view { padding: 24px 28px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.panel-body { padding: 16px 18px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #fafbfc; }
.row-click { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
input, select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }

/* Buttons */
.btn { font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #2a61cf; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; color: #475467; }
.badge.discovered { background: #eef0f3; color: #475467; }
.badge.enriching { background: var(--brand-soft); color: var(--brand); }
.badge.ready { background: var(--brand-soft); color: var(--brand); }
.badge.contacted { background: var(--amber-soft); color: var(--amber); }
.badge.replied { background: var(--green-soft); color: var(--green); }
.badge.signed_up, .badge.listed { background: var(--green-soft); color: var(--green); }
.badge.bounced, .badge.unsubscribed, .badge.do_not_contact { background: var(--red-soft); color: var(--red); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.error { background: var(--red-soft); color: var(--red); }
.badge.running, .badge.pending { background: var(--amber-soft); color: var(--amber); }

.rating { font-weight: 600; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* Pagination */
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; padding: 12px 0; }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 22, 34, 0.4); }
.drawer-panel { position: absolute; top: 0; right: 0; height: 100%; width: 440px; max-width: 92vw; background: var(--panel); box-shadow: -8px 0 24px rgba(16, 24, 40, 0.12); overflow-y: auto; padding: 22px 24px; overflow-wrap: anywhere; word-break: break-word; }
.drawer-panel h2 { margin: 0 0 2px; font-size: 18px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 16px 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 18px 0 8px; }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #15181d; color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-weight: 500; }
.toast.error { background: var(--red); }

.banner { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.info { background: var(--brand-soft); color: var(--brand); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.spacer { flex: 1; }
.progress { height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--brand); }
