:root {
  --cream: #FFF9EF; --ink: #243B4A; --ink-soft: #5b6b75; --turmeric: #FBB22B; --coral: #FF6F4C;
  --teal: #2FA88B; --blue: #1E9FD4; --blue-deep: #1577A8; --blue-pale: #E3F4FB;
  --line: #eadfcd; --card: #fff; --danger: #c8412b;
  --serif: 'Fraunces', Georgia, serif; --sans: 'Nunito Sans', system-ui, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--cream); color: var(--ink); font: 15px/1.5 var(--sans); }
.hidden { display: none !important; }
h1, h2, h3 { font-family: var(--serif); margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 28px; } h2 { font-size: 21px; } h3 { font-size: 17px; }
a { color: var(--blue-deep); }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

.brand { font-family: var(--serif); font-weight: 700; font-size: 20px; white-space: nowrap; }
.brand span { color: var(--coral); }
.brand.big { font-size: 28px; text-align: center; margin-bottom: 8px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 24px;
  background: #fff; border-bottom: 4px solid var(--turmeric); flex-wrap: wrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { white-space: nowrap; text-decoration: none; color: var(--ink); font-weight: 700; padding: 6px 12px; border-radius: 999px; }
.topbar nav a.active { background: var(--blue-pale); color: var(--blue-deep); }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }

.card { background: var(--card); border-radius: 14px; padding: 20px; box-shadow: 0 2px 14px rgba(36,59,74,.06); margin-bottom: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--card); border-radius: 14px; padding: 16px 18px; box-shadow: 0 2px 14px rgba(36,59,74,.06); border-left: 5px solid var(--teal); }
.stat b { display: block; font-family: var(--serif); font-size: 28px; }
.stat.warn { border-left-color: var(--coral); } .stat.gold { border-left-color: var(--turmeric); } .stat.blue { border-left-color: var(--blue); }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 13px; margin-bottom: 12px; }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%;
}
textarea { min-height: 320px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: transparent; }

.btn { font: inherit; font-weight: 800; border: 0; border-radius: 999px; padding: 9px 18px; cursor: pointer; background: var(--blue-pale); color: var(--blue-deep); white-space: nowrap; }
.btn.primary { background: var(--coral); color: #fff; }
.btn.teal { background: var(--teal); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn.danger { background: #fde5df; color: var(--danger); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #f1e8da; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: #fffaf0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #eee; white-space: nowrap; }
.pill.subscribed, .pill.sent { background: #dcf3ec; color: #1d7a63; }
.pill.unsubscribed, .pill.skipped, .pill.cancelled { background: #eceff1; color: #5b6b75; }
.pill.never_subscribed, .pill.draft { background: #fff1d1; color: #8a5b00; }
.pill.bounced, .pill.complained, .pill.failed { background: #fde5df; color: var(--danger); }
.pill.sending, .pill.queued, .pill.paused { background: var(--blue-pale); color: var(--blue-deep); }

.progress { height: 10px; background: #f1e8da; border-radius: 999px; overflow: hidden; display: flex; }
.progress i { display: block; height: 100%; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.preview-frame { width: 100%; height: 640px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
.hint { background: var(--blue-pale); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.hint code { background: #fff; padding: 1px 5px; border-radius: 4px; }
.notice { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; background: #fff1d1; }
.notice.bad { background: #fde5df; }
.error { color: var(--danger); font-weight: 700; min-height: 1.2em; margin: 8px 0 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; border-top: 6px solid var(--turmeric); }
.login-card .btn { width: 100%; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
#toast.bad { background: var(--danger); }

dialog { border: 0; border-radius: 16px; padding: 24px; max-width: 460px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(36,59,74,.45); }

@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; }
  .preview-frame { height: 520px; }
  .topbar { padding: 10px 16px 0; gap: 8px; }
  .topbar nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; }
  .topbar #logout { margin-left: auto; }
}
