:root {
  --purple: #6B2D96;
  --purple-dark: #56227A;
  --purple-soft: #F4EDF9;
  --ink: #0D0A14;
  --text: #22202A;
  --muted: #6B6875;
  --line: #E6E2EC;
  --bg: #FAF9FC;
  --card: #FFFFFF;
  --ok: #1B7F3B;
  --ok-soft: #E8F5EC;
  --bad: #B3261E;
  --bad-soft: #FCEBEA;
  --warn: #8A5A00;
  --warn-soft: #FFF4DB;
  --radius: 12px;
  --head: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --body: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--body); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--head); color: var(--ink); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--bad); margin: 8px 0 0; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: 600 14px/1.2 var(--body); cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #cfc6da; background: #fbf9fd; }
.btn:focus-visible, select:focus-visible, input:focus-visible, .link:focus-visible, .tabs button:focus-visible {
  outline: 3px solid rgba(107, 45, 150, .35); outline-offset: 2px;
}
.btn.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #8C1D17; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }
.link { background: none; border: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
select, input {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px;
  font: 15px var(--body); color: var(--text); background: #fff;
}
select:disabled { background: #f3f2f6; color: var(--muted); }

/* ---------- sign in ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.login-card { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 32px 28px; }
.login-card h1 { font-size: 24px; margin: 16px 0 4px; }
.login-card .muted { margin: 0 0 22px; font-size: 14px; }
.login-card input { margin-bottom: 14px; }
.mark {
  width: 44px; height: 44px; border-radius: 10px; background: var(--purple); color: #fff;
  display: grid; place-items: center; font: 800 16px var(--head); letter-spacing: .02em;
}
.mark.small { width: 32px; height: 32px; font-size: 12px; border-radius: 8px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px;
  padding: 10px 24px; background: var(--ink); color: #fff; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 16px var(--head); }
.tabs { display: flex; gap: 4px; background: #1d1726; padding: 4px; border-radius: 10px; }
.tabs button {
  border: 0; border-radius: 7px; padding: 8px 18px; background: transparent; color: #cbb8db;
  font: 600 14px var(--body); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--purple); color: #fff; }
.who { margin-left: auto; display: flex; gap: 14px; align-items: center; font-size: 14px; color: #cbb8db; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 24px 60px; }

/* ---------- workbook bar ---------- */
.workbook-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.workbook-bar .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.wb-info { font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-top: 16px; }
.card h2 { font-size: 17px; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step {
  width: 26px; height: 26px; border-radius: 50%; background: var(--purple-soft); color: var(--purple);
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 800;
}
.card.empty { text-align: center; padding: 40px 24px; }
.card.empty p { max-width: 560px; margin: 10px auto 20px; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.field { min-width: 220px; }
.grow { flex: 1; }
#msg-desc { margin: 10px 0 0; }

.alert { border-radius: 10px; padding: 12px 14px; margin-top: 14px; font-size: 14px; }
.alert.bad { background: var(--bad-soft); color: #7d1a15; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--purple-soft); color: #4a1f68; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert strong { display: block; }

/* ---------- preview ---------- */
.preview-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; margin-top: 16px; }
@media (max-width: 760px) { .preview-grid { grid-template-columns: 1fr; } }
.phone {
  background: #f1f0f4; border-radius: 22px; padding: 18px; max-width: 380px;
}
.phone .sender { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.bubble {
  background: #fff; border-radius: 16px 16px 16px 4px; padding: 10px 14px; white-space: pre-wrap;
  overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(0,0,0,.06); font-size: 15px;
}
.email-shot { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.email-shot .subject { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.email-shot .subject span { color: var(--muted); }
.email-shot iframe { width: 100%; height: 520px; border: 0; display: block; background: #f4f5f7; }
.facts { display: grid; gap: 10px; align-content: start; }
.preview-grid.email { grid-template-columns: 1fr; }
.preview-grid.email .facts { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.email-shot iframe { min-width: 0; }
.fact { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.fact .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fact .v { font: 700 20px var(--head); color: var(--ink); }
.fact .v.small-v { font: 600 14px var(--body); }

.who-list { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.who-list summary { cursor: pointer; font-weight: 600; }
.lists { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 10px; }
@media (max-width: 760px) { .lists { grid-template-columns: 1fr; } }
.lists h3 { font: 600 13px var(--body); color: var(--muted); margin-bottom: 6px; }
.lists ul, .progress-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.lists li, .progress-list li { padding: 6px 0; border-bottom: 1px solid #f0edf3; font-size: 14px; display: flex; gap: 8px; justify-content: space-between; }
.lists li .r, .progress-list li .r { color: var(--muted); text-align: right; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }

.test { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.test label { margin: 0; }
.test input { width: 260px; flex: 0 1 260px; }

/* ---------- sending ---------- */
.bar { height: 10px; background: var(--purple-soft); border-radius: 999px; overflow: hidden; margin-top: 16px; }
#bar-fill { height: 100%; width: 0; background: var(--purple); transition: width .3s; }
#progress-text { margin: 8px 0; font-weight: 600; }
.ok { color: var(--ok); }
.bad-t { color: var(--bad); }
#stop-btn { margin-top: 12px; }

/* ---------- reports ---------- */
.wrap-row { gap: 8px; }
#report { margin-top: 14px; overflow-x: auto; }
table.report { width: 100%; border-collapse: collapse; font-size: 14px; }
table.report th, table.report td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.report th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.wait { background: var(--purple-soft); color: var(--purple); }

/* ---------- dialog & toast ---------- */
dialog { border: 0; border-radius: 16px; padding: 24px; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(13,10,20,.35); }
dialog::backdrop { background: rgba(13, 10, 20, .55); }
dialog h2 { font-size: 20px; margin-bottom: 8px; }
dialog p { margin: 0 0 20px; white-space: pre-line; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); }

@media (max-width: 600px) {
  .top { padding: 10px 16px; gap: 10px; }
  .wrap { padding: 16px 16px 48px; }
  .card { padding: 16px; }
  .test input { flex: 1 1 100%; width: 100%; }
  .who { width: 100%; margin-left: 0; justify-content: space-between; }
}
