:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #171a20;
  --muted: #6b7280;
  --accent: #2457f5;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark { background: var(--accent); color: var(--accent-ink); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; margin-left: 18px; font-weight: 500; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a.active { color: var(--text); border-color: var(--accent); }

.view { padding: 28px 0 60px; }
.hero { margin-bottom: 24px; max-width: 720px; }
.hero p { color: var(--muted); margin: 0; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.sticky { position: sticky; top: 72px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.step { background: var(--text); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; }
.help { color: var(--muted); font-size: 13.5px; margin: -4px 0 14px; }

label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 12px; }
label > input, label > select, label > textarea { display: block; margin-top: 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; margin: 0; }
label.inline { display: flex; align-items: center; gap: 8px; margin: 0; }
label.inline select { width: auto; margin: 0; }
input, select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
textarea { resize: vertical; font-family: inherit; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: 1 / -1; }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.status { font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }

.btn { font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 16px; cursor: pointer; border: 1px solid var(--border); background: #fff; color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.secondary:hover { background: #f3f4f6; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.actions .primary { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chips button { font: inherit; font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #eef2ff; color: #2b3fa0; border: 1px solid #d7ddfb; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.chips button:hover { background: #e0e7ff; }

.preview { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.preview-subject { padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--border); background: #fafbfc; word-break: break-word; }
.preview-body { padding: 14px; font-size: 14px; max-height: 420px; overflow: auto; word-break: break-word; }
.preview-body p { margin: 0 0 1em; }

.summary { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; }
.summary strong { color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
td.wrap { white-space: normal; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8f9fb; }
.card .table-wrap { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; }
.card table { font-size: 13px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f4; color: var(--muted); }
.pill.sent, .pill.done { background: #dcfce7; color: #166534; }
.pill.sending, .pill.queued { background: #dbeafe; color: #1e40af; }
.pill.failed { background: #fee2e2; color: #991b1b; }
.pill.skipped, .pill.cancelled { background: #fef3c7; color: #92400e; }

.progress { height: 8px; background: #e9ebef; border-radius: 999px; overflow: hidden; margin: 10px 0 16px; }
.progress > div { height: 100%; background: var(--accent); transition: width 0.4s; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.back { display: inline-block; margin-bottom: 14px; text-decoration: none; font-weight: 500; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,0.2); z-index: 50; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
}
