:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #dfe3ea;
  --text: #1c2330;
  --muted: #667085;
  --accent: #1f5fd0;
  --accent-dark: #184ba6;
  --ok: #17794a;
  --ok-bg: #e5f5ec;
  --warn: #9a5b00;
  --warn-bg: #fdf1dc;
  --bad: #b3261e;
  --bad-bg: #fce8e6;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.top {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: #16202f;
}
.top .brand { color: #fff; font-weight: 700; font-size: 17px; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a, .top .logout { color: #b9c3d3; padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
.top nav a:hover, .top .logout:hover { color: #fff; text-decoration: none; }
.top nav a.on { color: #fff; background: #2b3a52; }

main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }
h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .grid.two { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; }

label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 5px; }
label.check { font-weight: 400; font-size: 15px; display: flex; gap: 8px; align-items: center; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], select, textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #c5ccd8;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
textarea { min-height: 110px; resize: vertical; }
textarea.code { font-family: Consolas, "Courier New", monospace; font-size: 13px; min-height: 460px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a9c3f3; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }

.btn, button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn:hover, button:hover { background: var(--accent-dark); text-decoration: none; }
.btn.ghost, button.ghost { background: #fff; color: var(--text); border-color: #c5ccd8; }
.btn.ghost:hover, button.ghost:hover { background: #f1f3f6; }
.btn.danger, button.danger { background: #fff; color: var(--bad); border-color: #e3b1ad; }
.btn.danger:hover, button.danger:hover { background: var(--bad-bg); }
.btn.sm, button.sm { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
form.inline { display: inline; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select { width: auto; min-width: 160px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }
.note { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); margin-bottom: 12px; }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.good { background: var(--ok-bg); color: var(--ok); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e9edf3; color: #465166; }
.badge.subscribed, .badge.sent { background: var(--ok-bg); color: var(--ok); }
.badge.sending, .badge.queued, .badge.paused { background: var(--warn-bg); color: var(--warn); }
.badge.bounced, .badge.complained, .badge.failed { background: var(--bad-bg); color: var(--bad); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag { font-family: Consolas, "Courier New", monospace; font-size: 12px; padding: 3px 8px; border-radius: 5px; border: 1px solid #c5ccd8; background: #f6f8fb; color: var(--text); cursor: pointer; font-weight: 400; }
.tag:hover { background: #e7eefb; }
code { font-family: Consolas, "Courier New", monospace; font-size: 13px; background: #eef1f5; padding: 1px 5px; border-radius: 4px; word-break: break-all; }

iframe.preview { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.bar { height: 10px; background: #e5e9f0; border-radius: 999px; overflow: hidden; margin: 10px 0; }
.bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.login { max-width: 380px; margin: 60px auto; }
