:root {
  --bg:        #0E1319;
  --bg-soft:   #141B23;
  --panel:     #171F28;
  --panel-2:   #1D2731;
  --line:      #26313D;
  --line-soft: #1F2933;
  --text:      #E8EDF2;
  --muted:     #8FA0B0;
  --faint:     #64748B;
  --gold:      #C9A961;
  --gold-dim:  #8A7440;
  --green:     #4ADE80;
  --red:       #F87171;
  --amber:     #FBBF24;
  --radius:    10px;
  --serif:     'Fraunces', Georgia, serif;
  --sans:      'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:      'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 12% -8%, #1B2733 0%, transparent 62%),
    radial-gradient(760px 460px at 92% 4%, #1A2230 0%, transparent 58%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font: 12px/1 var(--mono);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--gold);
}

/* ── Top bar ───────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  padding: 16px 28px;
  background: rgba(14, 19, 25, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font: 600 19px/1.2 var(--serif); letter-spacing: .2px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--faint); letter-spacing: .3px; }
.mark {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: linear-gradient(150deg, var(--gold), var(--gold-dim));
  box-shadow: 0 0 0 1px rgba(201,169,97,.28), 0 6px 18px -8px rgba(201,169,97,.7);
  position: relative;
}
.mark::after {
  content: ''; position: absolute; inset: 9px;
  border: 1.5px solid rgba(14,19,25,.75); border-radius: 2px;
}
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font: 500 11.5px/1 var(--sans);
  letter-spacing: .3px;
  padding: 7px 12px; border-radius: 100px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.pill.good { color: var(--green); border-color: rgba(74,222,128,.32); background: rgba(74,222,128,.08); }
.pill.bad  { color: var(--red);   border-color: rgba(248,113,113,.32); background: rgba(248,113,113,.08); }
.pill.warn { color: var(--amber); border-color: rgba(251,191,36,.3); background: rgba(251,191,36,.07); }

/* ── Layout ────────────────────────────────────────────────────────── */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 24px 100px;
  display: flex; flex-direction: column; gap: 22px;
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 18px 40px -30px rgba(0,0,0,.9);
}
.card-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font: 600 16px/1.3 var(--serif); }
.card-head p  { margin: 3px 0 0; font-size: 13px; color: var(--faint); }
.card-head .head-action { margin-left: auto; flex: none; }
.card-body { padding: 22px 24px; }
.card-body.no-pad { padding: 0; }

.step {
  flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 12px/1 var(--sans);
  color: var(--gold);
  background: rgba(201,169,97,.09);
  border: 1px solid rgba(201,169,97,.34);
  margin-top: 1px;
}

.sub {
  margin: 28px 0 14px;
  font: 600 11px/1 var(--sans);
  letter-spacing: 2.4px; text-transform: uppercase; color: var(--gold-dim);
  padding-bottom: 9px; border-bottom: 1px solid var(--line-soft);
}

/* ── Controls ──────────────────────────────────────────────────────── */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 260px; }
.spacer { flex: 1; }

.input {
  font: 14px/1.4 var(--sans);
  color: var(--text);
  background: #10161D;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,169,97,.13);
}
.input::placeholder { color: #4A5867; }
.input.slim { width: auto; min-width: 190px; padding: 8px 11px; font-size: 13px; }
.input.mono { font-family: var(--mono); font-size: 12.5px; }
textarea.input { resize: vertical; line-height: 1.6; }
select.input { cursor: pointer; }

.btn {
  font: 600 13px/1 var(--sans);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #253141; border-color: #35424F; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, var(--gold), #A98C4C);
  border-color: #B69653; color: #16110A;
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #D6B871, #B2944F); }
.btn.danger { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.42); color: #FCA5A5; }
.btn.danger:hover:not(:disabled) { background: rgba(248,113,113,.18); }
.btn.ghost { background: transparent; font-weight: 500; padding: 9px 13px; }
.btn.tiny { padding: 6px 10px; font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font: 600 10.5px/1 var(--sans);
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
}
.field > span em { font-style: normal; text-transform: none; letter-spacing: .2px; color: var(--faint); font-weight: 400; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.span2 { grid-column: 1 / -1; }

.hint { margin: 14px 0 0; font-size: 12.5px; color: var(--faint); }
.hint b { color: var(--muted); font-weight: 600; }

.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--gold); width: 15px; height: 15px; cursor: pointer; }
.opts { display: flex; gap: 26px; flex-wrap: wrap; margin-bottom: 18px; }

/* ── Messages ──────────────────────────────────────────────────────── */
.msg {
  margin-top: 16px; padding: 12px 14px; border-radius: 7px;
  font-size: 13.5px; line-height: 1.6;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
}
.msg.err  { border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.07); color: #FCA5A5; }
.msg.good { border-color: rgba(74,222,128,.3);  background: rgba(74,222,128,.06); color: #86EFAC; }

/* ── Preview ───────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--faint); font: 600 13px/1 var(--sans);
  padding: 10px 14px; cursor: pointer; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--muted); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.preview { background: #0A0E13; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.preview iframe { display: block; width: 100%; height: 640px; border: 0; background: #0A0E13; }

.pdf-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; font-size: 12.5px; color: var(--faint);
  background: var(--panel-2); border-bottom: 1px solid var(--line);
}
.pdf-stage {
  display: grid; place-items: center;
  padding: 26px 16px;
  background:
    repeating-linear-gradient(45deg, #0C1116 0 10px, #0A0E13 10px 20px);
  min-height: 300px;
}
.pdf-stage canvas {
  max-width: 100%; height: auto;
  border-radius: 2px;
  box-shadow: 0 24px 50px -22px rgba(0,0,0,.95), 0 0 0 1px rgba(255,255,255,.05);
}
.mail-subject {
  padding: 11px 16px; font-size: 13px; color: var(--faint);
  border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.mail-subject b { color: var(--text); font-weight: 600; }

/* ── Table ─────────────────────────────────────────────────────────── */
.table-wrap { max-height: 460px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; padding: 11px 14px;
  font: 600 10.5px/1 var(--sans); letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--faint);
  background: #131A22; border-bottom: 1px solid var(--line);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,.018); }
tbody tr.invalid { background: rgba(248,113,113,.05); }
td.tick, th.tick { width: 40px; }
td.tick input { accent-color: var(--gold); cursor: pointer; }
.cell-name { font-weight: 500; }
.cell-mono { font: 12px/1.4 var(--mono); color: var(--muted); max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.problems { display: block; font-size: 11.5px; color: var(--red); margin-top: 3px; }

.tag {
  display: inline-block; padding: 3px 9px; border-radius: 100px;
  font: 600 10.5px/1.5 var(--sans); letter-spacing: .4px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--faint);
}
.tag.sent    { color: var(--green); border-color: rgba(74,222,128,.3); background: rgba(74,222,128,.08); }
.tag.failed  { color: var(--red);   border-color: rgba(248,113,113,.3); background: rgba(248,113,113,.08); }
.tag.dry-run,
.tag.pending { color: var(--amber); border-color: rgba(251,191,36,.28); background: rgba(251,191,36,.07); }
.tag.invalid { color: var(--red);   border-color: rgba(248,113,113,.3); }

.empty { padding: 40px 24px; text-align: center; color: var(--faint); font-size: 14px; }

/* ── Progress + console ────────────────────────────────────────────── */
.progress { margin: 20px 0 4px; }
.bar { height: 6px; border-radius: 100px; background: var(--panel-2); overflow: hidden; }
.fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width .25s ease;
}
.progress-meta {
  display: flex; justify-content: space-between;
  margin-top: 8px; font-size: 12.5px; color: var(--faint);
}

.console {
  margin-top: 16px; max-height: 260px; overflow: auto;
  background: #0A0E13; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px;
  font: 12px/1.75 var(--mono); color: var(--muted);
}
.console .ok   { color: var(--green); }
.console .err  { color: var(--red); }
.console .warn { color: var(--amber); }
.console .dim  { color: var(--faint); }

.send-row { padding-top: 2px; }
.footer-row { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 18px;
  font-size: 13.5px; color: var(--text);
  box-shadow: 0 20px 40px -20px rgba(0,0,0,.95);
  z-index: 60;
}
.toast.err  { border-color: rgba(248,113,113,.45); color: #FCA5A5; }
.toast.good { border-color: rgba(74,222,128,.4);  color: #86EFAC; }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; }
  .card-head .head-action { margin-left: 0; width: 100%; }
  .preview iframe { height: 480px; }
}

.input.needs-you {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(248,113,113,.16);
  animation: nudge .45s ease;
}
@keyframes nudge {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-4px); }
  75%     { transform: translateX(4px); }
}

.tag.multi { color: var(--gold); border-color: rgba(201,169,97,.35); background: rgba(201,169,97,.09); }

/* ── Manual entry + inline editing ─────────────────────────────────── */
.add-row { border-bottom: 1px solid var(--line-soft); padding-bottom: 16px; }
.add-row .row > .input { flex: 1 1 170px; min-width: 0; }
.add-row .hint { margin-top: 10px; }

.cell-email { display: flex; align-items: center; gap: 8px; }
.cell-email .val { font: 12px/1.4 var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.cell-email .val.bad { color: var(--red); }
.edit-btn {
  opacity: 0; flex: none;
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: var(--faint); font-size: 12px; transition: opacity .12s, color .12s;
}
tbody tr:hover .edit-btn { opacity: 1; }
.edit-btn:hover { color: var(--gold); }
tbody tr.invalid .edit-btn { opacity: 1; color: var(--red); }

.edit-input {
  width: 100%; min-width: 150px;
  font: 12px/1.3 var(--mono);
  color: var(--text); background: #0B1016;
  border: 1px solid var(--gold-dim); border-radius: 5px;
  padding: 6px 8px;
}
.edit-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(201,169,97,.14); }
.tag.manual { color: #7DD3FC; border-color: rgba(125,211,252,.3); background: rgba(125,211,252,.08); }
.tag.edited { color: var(--gold); border-color: rgba(201,169,97,.32); background: rgba(201,169,97,.08); }

/* ── Batch selection ───────────────────────────────────────────────── */
.batch-row { border-bottom: 1px solid var(--line-soft); padding-bottom: 16px; }
.batch-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.batch-head > span {
  font: 600 10.5px/1 var(--sans);
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
}
.batches { display: flex; flex-wrap: wrap; gap: 8px; }
.batch {
  font: 600 13px/1 var(--sans);
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  transition: background .15s, border-color .15s, color .15s;
}
.batch:hover { background: #253141; border-color: #35424F; }
.batch.active {
  background: linear-gradient(180deg, var(--gold), #A98C4C);
  border-color: #B69653; color: #16110A;
}
.batch .n { font: 500 11.5px/1 var(--mono); opacity: .72; }
.batch.done { opacity: .5; }
.batch.done:hover { opacity: .8; }
.send-note { margin: 0 0 16px; }
td.num { font: 12px/1.4 var(--mono); color: var(--faint); width: 56px; }
