:root {
  --bg: #f4f6f9;
  --card: #fff;
  --border: #dde3eb;
  --text: #1c2833;
  --muted: #6b7785;
  --primary: #2563eb;
  --primary-hover: #1e4fd1;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Cantarell, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin-top: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
.topbar {
  background: #1c2833; color: #fff;
  padding: 0 24px; display: flex; align-items: center;
  height: 56px; box-shadow: var(--shadow);
}
.topbar .brand a { color: #fff; font-weight: 700; font-size: 16px; }
.topbar .mainnav { margin-left: 32px; display: flex; gap: 4px; flex: 1; }
.topbar .mainnav a {
  color: #cfd6df; padding: 8px 12px; border-radius: 6px; font-size: 13px;
}
.topbar .mainnav a:hover { background: #2c3e50; color: #fff; text-decoration: none; }
.topbar .mainnav a.logout { margin-left: auto; }

.container { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; padding-bottom: 12px; border-bottom: 1px solid var(--border); }

.btn {
  display: inline-block; padding: 8px 16px;
  background: var(--primary); color: #fff; border: 0;
  border-radius: 6px; cursor: pointer; font-size: 14px;
  text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; color: #fff; }
.btn.secondary { background: #6b7785; }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.alert-info    { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }
.alert-success { background: #dcfce7; border-color: #86efac; color: #166534; }
.alert-warning { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.alert-danger  { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

table { width: 100%; border-collapse: collapse; background: #fff; }
table th, table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table th { background: #f8fafc; font-weight: 600; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
table tr:hover td { background: #fafbfc; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password],
.form-row input[type=number], .form-row select, .form-row textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; font-family: inherit; background: #fff;
}
.form-row textarea { min-height: 120px; font-family: Menlo, monospace; font-size: 13px; }
.form-row small { color: var(--muted); display: block; margin-top: 4px; }
.form-row .help { color: var(--muted); font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; box-shadow: var(--shadow);
}
.stat .num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.badge.active       { background: #dcfce7; color: #166534; }
.badge.unsubscribed { background: #fee2e2; color: #991b1b; }
.badge.bounced      { background: #fef3c7; color: #92400e; }
.badge.draft        { background: #e2e8f0; color: #475569; }
.badge.queued       { background: #fef3c7; color: #92400e; }
.badge.sending      { background: #dbeafe; color: #1d4ed8; }
.badge.sent         { background: #dcfce7; color: #166534; }
.badge.failed       { background: #fee2e2; color: #991b1b; }
.badge.paused       { background: #e2e8f0; color: #475569; }
.badge.pending      { background: #fef3c7; color: #92400e; }
.badge.skipped      { background: #e2e8f0; color: #475569; }
.badge.complained   { background: #fce7f3; color: #be185d; }

.pagination { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.pagination .info { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

.bottombar { padding: 20px; text-align: center; color: var(--muted); }

.login-box {
  max-width: 380px; margin: 80px auto; background: #fff;
  padding: 32px; border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.login-box h1 { text-align: center; margin-bottom: 24px; }

.progress {
  background: #e2e8f0; border-radius: 999px; height: 10px; overflow: hidden; margin-top: 6px;
}
.progress > div {
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  height: 100%; transition: width .3s;
}

code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* Editor */
.editor-wrap textarea { min-height: 360px; }
.preview-frame { width: 100%; height: 600px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }

.kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
