:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #e6f4f2;
  --live: #e11d48;
  --live-soft: #fff1f3;
  --warn-soft: #fff7e6;
  --warn: #b45309;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 18px rgba(15, 23, 42, .05);
  --nav-h: 70px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(244, 245, 247, .92);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  display: flex; align-items: center; gap: 10px; padding: 12px 16px 10px; min-height: 58px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.topbar h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { border: 0; background: var(--card); width: 38px; height: 38px; border-radius: 12px; box-shadow: var(--shadow); font-size: 20px; cursor: pointer; flex: none; }
main { max-width: 760px; margin: 0 auto; padding: 4px 14px calc(var(--nav-h) + var(--safe-b) + 28px); }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; align-items: center; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 6px 0; }
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a.on { color: var(--primary); }
.bottomnav a.live { color: #fff; }
.bottomnav a.live .dot { width: 54px; height: 54px; border-radius: 18px; background: var(--live); display: grid; place-items: center; margin-top: -26px; box-shadow: 0 6px 18px rgba(225, 29, 72, .35); }
.bottomnav a.live span { color: var(--live); }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
.card h2 { font-size: 17px; margin: 0 0 10px; letter-spacing: -.2px; }
.card h3 { font-size: 15px; margin: 14px 0 6px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin: 20px 4px 8px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0; }
.row:last-child { border-bottom: 0; }
.row:active { background: #f8fafc; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: #cbd5e1; font-size: 20px; flex: none; }
.row .right { text-align: right; flex: none; font-size: 13px; color: var(--muted); }
.row input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--primary); }
.empty { text-align: center; color: var(--muted); padding: 30px 16px; }
.empty .big { font-size: 36px; margin-bottom: 6px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat .n { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 13px; padding: 13px 18px; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; background: var(--primary); color: var(--primary-ink); min-height: 48px; }
.btn:disabled { background: #e2e8f0; color: #94a3b8; box-shadow: none; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.live { background: var(--live); color: #fff; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 14px; border-radius: 10px; }
.btn.huge { font-size: 21px; min-height: 68px; border-radius: 18px; letter-spacing: .3px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }
.icon-btn { border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 12px; height: 38px; padding: 0 12px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--primary); flex: none; }
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.action { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 14px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.action .ic { font-size: 24px; }
.action small { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.action.live-card { background: var(--live); color: #fff; grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; padding: 18px 16px; }
.action.live-card small { color: rgba(255,255,255,.85); }

/* ---------- forms ---------- */
label.f { display: block; font-weight: 650; font-size: 14px; margin: 14px 0 6px; }
label.f:first-child { margin-top: 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 13px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, #94a3b8 50%), linear-gradient(135deg, #94a3b8 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 12px) 52%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 260px; resize: vertical; line-height: 1.5; }
.search { position: relative; margin-bottom: 10px; }
.search input { padding-left: 40px; background: var(--card); border-color: transparent; box-shadow: var(--shadow); }
.search::before { content: "⌕"; position: absolute; left: 14px; top: 50%; transform: translateY(-52%); font-size: 20px; color: var(--muted); }
.check { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.check .grow { flex: 1; min-width: 0; }
.check .sub { font-size: 13px; color: var(--muted); }
.seg { display: flex; background: #e9ebef; border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 10px; border-radius: 10px; font-weight: 650; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 600; background: #eef0f3; color: #334155; border: 0; cursor: pointer; }
.chip.on { background: var(--primary); color: #fff; }
.toolbar { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; -webkit-overflow-scrolling: touch; }
.toolbar button { flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 7px 11px; font-size: 14px; font-weight: 650; cursor: pointer; }

/* ---------- pills ---------- */
.pill { display: inline-block; font-size: 11.5px; font-weight: 750; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.pill.draft { background: #eef0f3; color: #475569; }
.pill.scheduled { background: #eef2ff; color: #4338ca; }
.pill.sending { background: var(--warn-soft); color: var(--warn); }
.pill.paused { background: var(--warn-soft); color: var(--warn); }
.pill.automation { background: #f5f3ff; color: #6d28d9; }
.pill.sent, .pill.subscribed { background: var(--ok-soft); color: var(--ok); }
.pill.unsubscribed, .pill.no_consent { background: #eef0f3; color: #475569; }
.pill.bounced, .pill.complained, .pill.failed { background: var(--bad-soft); color: var(--bad); }
.pill.event { background: #eef2ff; color: #4338ca; }
.pill.referral { background: var(--live-soft); color: var(--live); }
.pill.interest { background: var(--primary-soft); color: var(--primary); }
.pill.custom { background: #eef0f3; color: #475569; }

/* ---------- notices ---------- */
.notice { border-radius: 14px; padding: 13px 14px; font-size: 14.5px; margin-bottom: 14px; }
.notice.warn { background: var(--warn-soft); color: #7c2d12; }
.notice.info { background: var(--primary-soft); color: #134e4a; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: #14532d; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- progress ---------- */
.progress { height: 14px; background: #e9ebef; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s ease; }
.progress.live > div { background: var(--live); }

/* ---------- live send ---------- */
.live-hero { background: var(--live); color: #fff; border-radius: 20px; padding: 18px; margin-bottom: 14px; }
.live-hero h2 { margin: 0 0 4px; font-size: 20px; }
.live-hero p { margin: 0; opacity: .9; font-size: 14px; }
.step { display: flex; align-items: center; gap: 10px; margin: 18px 4px 8px; font-weight: 800; font-size: 16px; }
.step .num { width: 28px; height: 28px; border-radius: 50%; background: var(--text); color: #fff; display: grid; place-items: center; font-size: 14px; flex: none; }
.step.done .num { background: var(--ok); }
.pick { display: flex; align-items: center; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick:last-child { border-bottom: 0; }
.pick .radio { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #cbd5e1; flex: none; display: grid; place-items: center; }
.pick.on { background: var(--live-soft); }
.pick.on .radio { border-color: var(--live); background: var(--live); }
.pick.on .radio::after { content: "✓"; color: #fff; font-size: 14px; font-weight: 900; }
.pick .grow { flex: 1; min-width: 0; }
.pick .title { font-weight: 700; }
.pick .sub { font-size: 13px; color: var(--muted); }
.sendbar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 10; }
.bigdone { text-align: center; padding: 26px 10px; }
.bigdone .icon { font-size: 64px; }
.bigdone h2 { font-size: 24px; margin: 6px 0; }
.say { background: #0f172a; color: #fff; border-radius: 16px; padding: 16px; font-size: 18px; line-height: 1.4; margin: 14px 0; text-align: left; }
.say small { display: block; color: #94a3b8; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; font-weight: 700; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
@media (min-width: 700px) { .modal-bg { align-items: center; } }
.modal { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); animation: up .2s ease; }
@media (min-width: 700px) { .modal { border-radius: 22px; } }
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal .btn-row { margin-top: 16px; }
.modal iframe { width: 100%; height: 62vh; border: 1px solid var(--line); border-radius: 12px; background: #f3f4f6; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 200; background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: 14.5px; max-width: calc(100% - 28px); box-shadow: 0 8px 28px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
#toast.bad { background: var(--bad); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 26px 22px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; background: #f1f5f9; padding: 8px 10px; border-radius: 10px; }
.qr { display: grid; place-items: center; padding: 10px; }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; }
table.simple { width: 100%; border-collapse: collapse; font-size: 14px; }
table.simple th, table.simple td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.simple th { color: var(--muted); font-weight: 650; font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
.scroll-x { overflow-x: auto; }
.selbar { position: fixed; left: 10px; right: 10px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 25; background: #0f172a; color: #fff; border-radius: 16px; padding: 10px 12px; display: flex; gap: 8px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 740px; margin: 0 auto; }
.selbar .grow { flex: 1; font-weight: 700; font-size: 14px; }
.selbar button { border: 0; border-radius: 10px; padding: 9px 11px; font-weight: 700; font-size: 13.5px; cursor: pointer; background: #fff; color: #0f172a; }
.selbar button.x { background: transparent; color: #fff; font-size: 20px; padding: 4px 8px; }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(0,0,0,.12); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.gap { height: 10px; }

.sticky-go { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 10; box-shadow: 0 10px 28px rgba(225, 29, 72, .35); }
