:root {
  --bg: #f6f7fb; --panel: #fff; --text: #1d2130; --muted: #6b7183; --line: #e5e7ef;
  --accent: #4f46e5; --accent-soft: #eef0ff; --green: #16a34a; --amber: #d97706; --red: #dc2626; --blue: #2563eb;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
.nav { width: 210px; background: #151827; color: #c9cbe0; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.nav .brand { color: #fff; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; }
.nav a { color: #c9cbe0; padding: 9px 12px; border-radius: 8px; }
.nav a.active, .nav a:hover { background: #262a40; color: #fff; }
.nav-foot { margin-top: auto; font-size: 12px; padding: 10px; color: #9aa0bd; }
.sandbox-tag { margin: -10px 10px 14px; padding: 4px 8px; border-radius: 6px; background: var(--amber); color: #1d1300; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
main { flex: 1; padding: 28px 32px; max-width: 1300px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
h1 .spacer { flex: 1; }
h2 { font-size: 16px; margin: 0 0 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #fafaff; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f5; color: var(--muted); white-space: nowrap; }
.b-active, .b-replied { background: #dcfce7; color: var(--green); }
.b-paused, .b-pending { background: #fef3c7; color: var(--amber); }
.b-bounced, .b-failed { background: #fee2e2; color: var(--red); }
.b-stopped, .b-manual, .b-unsubscribe, .b-bounce { background: #f1f2f6; color: var(--muted); }
.b-completed { background: #dbeafe; color: var(--blue); }
.b-opened { background: var(--accent-soft); color: var(--accent); }
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--red); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); width: 100%; }
textarea { min-height: 180px; resize: vertical; font-family: inherit; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); font-weight: 400; }
.check input { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); }
.tabs button.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.step { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fcfcfe; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.step-head .delay { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.step-head .delay input { width: 70px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice { background: #fff8e6; border: 1px solid #fde4a6; padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 2px 8px; font-size: 12px; font-family: ui-monospace, monospace; cursor: pointer; border: 0; }
.preview { white-space: pre-wrap; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.bar { height: 6px; background: #eef0f5; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
#toast { position: fixed; bottom: 20px; right: 20px; background: #151827; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; max-width: 420px; }
#toast.show { opacity: 1; }
dialog { border: 0; border-radius: 14px; padding: 22px; width: min(720px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 18, 30, .45); }
.timeline div { padding: 6px 0; border-bottom: 1px dashed var(--line); }
@media (max-width: 760px) {
  body { flex-direction: column; }
  .nav { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .nav .brand { padding-bottom: 4px; width: 100%; }
  .nav-foot { display: none; }
  main { padding: 18px 16px; }
}


/* Sign-in page */
[hidden] { display: none !important; }
body.auth-page { align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 6px; }
.auth-card form label { margin-top: 8px; }
.auth-card form button { margin-top: 14px; }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-brand { font-weight: 700; font-size: 18px; margin-bottom: 18px; }
.auth-msg { color: var(--red); font-size: 13px; min-height: 1em; margin: 12px 0 0; }
.auth-card .notice code { word-break: break-all; }

/* Signed-in user in the sidebar; controls hidden from roles that can't use them (the server refuses them anyway) */
.nav-user { font-size: 12px; color: #c9cbe0; padding: 10px; border-top: 1px solid #262a40; }
.nav-user b { color: #fff; display: block; overflow: hidden; text-overflow: ellipsis; }
.nav-user button { background: transparent; color: #c9cbe0; border-color: #3a3f5c; padding: 3px 8px; font-size: 12px; margin: 6px 6px 0 0; }
body[data-role="viewer"] .needs-member, body[data-role="viewer"] .needs-admin, body[data-role="member"] .needs-admin { display: none !important; }
.linkbox { display: flex; gap: 8px; } .linkbox input { font-family: ui-monospace, monospace; font-size: 12px; }

/* Lead finder */
.steps-row { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 13px; }
.steps-row span { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 3px 8px; }
.steps-row i { color: var(--muted); font-style: normal; }
.score { display: inline-block; min-width: 34px; text-align: center; border-radius: 6px; padding: 2px 6px; font-weight: 700; font-size: 13px; }
.score-hi { background: #dcfce7; color: var(--green); } .score-mid { background: #fef3c7; color: var(--amber); } .score-lo { background: #f1f2f6; color: var(--muted); }
a.btn { display: inline-block; color: var(--text); }
