/* Newsletter platform — one stylesheet, no build step. */
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }

:root {
  --ink: #1b2a41;        /* sidebar, headings */
  --ink-2: #2c3e5c;
  --text: #22272e;
  --muted: #5d6673;
  --line: #d9dee5;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --accent: #1f6feb;     /* links, primary actions */
  --accent-ink: #ffffff;
  --stamp: #b3261e;      /* used only for Send and destructive actions */
  --ok: #1a7f37;
  --ok-bg: #e7f5ec;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --err: #b3261e;
  --err-bg: #fdecea;
  --radius: 6px;
  --focus: 0 0 0 3px rgba(31, 111, 235, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.55 "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 3px; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
code, .code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: #dfe6f1; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 2px; text-decoration: none; }
.org-name { color: #9fb0c8; font-size: .9rem; padding: 0 10px 14px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 10px; }
.side a.nav {
  color: #dfe6f1; text-decoration: none; padding: 8px 10px; border-radius: var(--radius); display: block;
}
.side a.nav:hover { background: var(--ink-2); }
.side a.nav[aria-current="page"] { background: #fff; color: var(--ink); font-weight: 700; }
.side .group-label { color: #8496b0; font-size: .82rem; padding: 14px 10px 4px; }
.side .bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 10px; }
.side form button.nav { background: none; border: 0; color: #dfe6f1; font: inherit; padding: 8px 10px; cursor: pointer; width: 100%; text-align: left; border-radius: var(--radius); }
.side form button.nav:hover { background: var(--ink-2); }
.menu-toggle { display: none; }

main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.panel > h2:first-child { margin-top: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; align-items: start; }

.figures { display: flex; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 20px; flex-wrap: wrap; }
.figure { flex: 1 1 160px; padding: 16px 20px; border-right: 1px solid var(--line); }
.figure:last-child { border-right: 0; }
.figure strong { display: block; font-size: 1.6rem; color: var(--ink); line-height: 1.1; }
.figure span { color: var(--muted); font-size: .92rem; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .96rem; }
table.data th { text-align: left; font-weight: 700; color: var(--muted); font-size: .88rem; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #fafcff; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 700; margin: 0 0 4px; color: var(--ink); }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search],
input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid #b9c2ce; border-radius: var(--radius);
  padding: 9px 11px; min-height: 44px;
}
input[type=color] { width: 64px; height: 44px; padding: 2px; border: 1px solid #b9c2ce; border-radius: var(--radius); background: #fff; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--text); margin-bottom: 10px; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.inline-form { display: inline; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 200px; }
.error-text { color: var(--err); font-size: .92rem; margin-top: 4px; }
.is-invalid { border-color: var(--err) !important; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; }
legend { font-weight: 700; color: var(--ink); padding: 0 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  font: inherit; font-weight: 700; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  text-decoration: none; background: var(--accent); color: var(--accent-ink); white-space: nowrap;
}
.btn:hover { filter: brightness(.94); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #b9c2ce; }
.btn.danger { background: #fff; color: var(--err); border-color: #e4b4b0; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .92rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn.danger { color: var(--err); }

/* The one bold element: sending a newsletter is a postage stamp. */
.stamp {
  background: var(--stamp); color: #fff; padding: 22px 24px;
  border: 7px dotted var(--bg); background-clip: border-box; border-radius: 3px;
  outline: 1px solid rgba(255,255,255,.45); outline-offset: -16px;
}
.stamp h2 { color: #fff; }
.stamp p, .stamp label, .stamp .hint { color: #fde8e6; }
.stamp label { color: #fff; }
.stamp .btn { background: #fff; color: var(--stamp); }
.stamp .check { color: #fff; }
.stamp input[type=datetime-local] { border-color: #fff; }
.stamp .problems { background: #fff; color: var(--err); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.stamp .problems li { margin: 2px 0; }

/* ---------- Status badges ---------- */
.badge { display: inline-block; font-size: .82rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.badge.subscribed, .badge.sent, .badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.pending, .badge.scheduled, .badge.sending { background: var(--warn-bg); color: var(--warn); }
.badge.unsubscribed, .badge.cancelled, .badge.draft { background: #eef1f5; color: var(--muted); }
.badge.bounced, .badge.complained, .badge.failed, .badge.suspended { background: var(--err-bg); color: var(--err); }

/* ---------- Messages ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid; }
.flash.success { background: var(--ok-bg); border-color: #b5dfc2; color: #12592a; }
.flash.error { background: var(--err-bg); border-color: #f0bdb8; color: #7d1b15; }
.flash.warning { background: var(--warn-bg); border-color: #ecd391; color: #5f3e00; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--ink); }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist .tick { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid #b9c2ce; margin-top: 2px; }
.checklist li.done .tick { background: var(--ok); border-color: var(--ok); }
.checklist li.done span { color: var(--muted); text-decoration: line-through; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; flex: 1 1 180px; }

.pagination { display: flex; gap: 6px; list-style: none; padding: 14px; margin: 0; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-block; min-width: 38px; text-align: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: #fff; }
.pagination .active span { background: var(--ink); color: #fff; border-color: var(--ink); }
.pagination .disabled span { color: #aab3bf; }

.codebox { background: #f6f8fa; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }
.recovery { columns: 2; font-family: ui-monospace, Menlo, Consolas, monospace; background: #f6f8fa; padding: 12px 16px; border-radius: var(--radius); }
.qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border: 1px solid var(--line); }

/* ---------- Editor ---------- */
.editor-wrap { background: #fff; border: 1px solid #b9c2ce; border-radius: var(--radius); }
.editor-wrap .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; border-radius: var(--radius) var(--radius) 0 0; }
.editor-wrap .ql-container.ql-snow { border: 0; font: 16px/1.6 Georgia, "Times New Roman", serif; }
.editor-wrap .ql-editor { min-height: 420px; max-width: 640px; margin: 0 auto; padding: 24px; }
.merge-tags button { margin: 0 4px 6px 0; }
iframe.preview { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 28px; }
.auth .brand-line { font-weight: 700; color: var(--ink); margin-bottom: 18px; font-size: 1.05rem; border-left: 4px solid var(--stamp); padding-left: 10px; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; }
  .side .org-name, .side .group-label { display: none; }
  .side nav { display: none; width: 100%; }
  .side.open nav { display: block; }
  .menu-toggle { display: inline-flex; margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; min-height: 40px; padding: 0 12px; border-radius: var(--radius); font: inherit; }
  .side .bottom { border: 0; width: 100%; }
  main { padding: 20px 16px 48px; }
  .grid-2, .grid-3, .split { grid-template-columns: 1fr; }
  .figure { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
