/* Панель рассылок — один системный шрифт, спокойная палитра, акцент только на действии и состоянии. */
:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --sunk: #f7f8fa;
  --ink: #1b1f27;
  --muted: #5f6673;
  --line: #e1e4ea;
  --accent: #2647b8;
  --accent-hover: #1f3c9c;
  --accent-soft: #e9eeff;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --danger-soft: #fbeae8;
  --ok: #1a7f4b;
  --ok-soft: #e6f4ec;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --radius: 10px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131519; --card: #1c1f25; --sunk: #171a1f; --ink: #e7e9ee; --muted: #9aa1ad; --line: #2b2f37;
    --accent: #7b93ef; --accent-hover: #93a7f5; --accent-soft: #232a45; --accent-ink: #0f1220;
    --danger: #f28b82; --danger-soft: #3a2320; --ok: #6fcf97; --ok-soft: #1f3328; --warn: #e3b341; --warn-soft: #3a3120;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
main, .login { max-width: 1080px; margin: 0 auto; padding: 20px 16px 72px; }
.login { max-width: 400px; margin-top: 12vh; }
.hidden { display: none !important; }
a { color: var(--accent); }
h1 { font-size: 20px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 650; margin: 0 0 6px; letter-spacing: -.005em; }
h3 { font-size: 15px; font-weight: 650; margin: 18px 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 6px; font-weight: 400; }
.hint b { color: var(--ink); }
small { color: var(--muted); font-size: 13px; }
code { font: 12.5px/1.4 var(--mono); background: var(--sunk); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }

/* шапка */
header { margin-bottom: 18px; }
.brandline { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 0 12px; }
.statusline { color: var(--muted); font-size: 13px; white-space: nowrap; }
nav { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); }
nav a { padding: 9px 12px; color: var(--muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color .15s; }
nav a:hover { color: var(--ink); }
nav a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* карточки и сетки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px 18px; }
@media (max-width: 760px) { .two, .grid, .grid3 { grid-template-columns: 1fr; } .brandline { flex-wrap: wrap; } }
.row { display: flex; gap: 10px; align-items: center; }
.row.gap { gap: 16px; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; margin-top: 4px; }
.wrap { flex-wrap: wrap; }
.seg { margin-bottom: 8px; }

/* формы */
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 14px; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--sunk); border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; transition: border-color .15s, background .15s; }
label > input, label > textarea, label > select, #aud-list > select, #aud-paste > textarea, #ai-brief, #tpl-html, #list-import-text { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
form > input, .row > input { flex: 1 1 240px; min-width: 0; }
textarea { resize: vertical; min-height: 80px; }
textarea[name="html"], #tpl-html { font: 13px/1.45 var(--mono); }
input:hover, textarea:hover, select:hover { border-color: #c9cdd6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; background: var(--card); }
input::placeholder, textarea::placeholder { color: #8a909b; }
input:disabled { opacity: .55; }
select { min-width: 220px; }
label.inline { display: flex; align-items: center; gap: 10px; margin: 0; }
label.inline > input, label.inline > select { margin: 0; width: auto; }
label.inline.test > input { width: 240px; }
label.radio { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 0 6px 6px 0; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--sunk); cursor: pointer; transition: border-color .15s, background .15s; }
label.radio:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
label.radio input { width: auto; margin: 0; accent-color: var(--accent); }
.file { display: inline-block; font-weight: 600; font-size: 13px; color: var(--accent); cursor: pointer; margin: 0; padding: 6px 0; }
.file:hover { text-decoration: underline; }
.file input { display: none; }
details.more { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--accent); list-style: none; padding: 4px 0 10px; }
details.more summary::before { content: "▸ "; display: inline-block; transition: transform .15s; }
details.more[open] summary::before { transform: rotate(90deg); }
details.more summary::-webkit-details-marker { display: none; }

/* кнопки */
button { font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active { transform: translateY(1px); }
button.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--card); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
button.small { padding: 6px 12px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; transform: none; }
button.busy { position: relative; color: transparent !important; }
button.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border: 2px solid var(--accent-ink); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
button.ghost.busy::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 500; font-size: 12px; cursor: pointer; }
.link-btn { font-weight: 600; text-decoration: none; font-size: 13.5px; }

/* сообщения */
.msg, .err { margin: 8px 0 0; min-height: 1.5em; font-size: 14px; color: var(--danger); }
.msg.ok, .err.ok { color: var(--ok); }
.msg.info { color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 11px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 8px 28px -8px rgb(0 0 0 / .35); max-width: 90vw; z-index: 10; animation: rise .2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.wait { color: var(--warn); margin: 6px 0 0; font-size: 13px; }
.empty { padding: 14px 0 2px; }
.empty a { font-weight: 600; text-decoration: none; }

/* шаги отправки */
.step h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step .n { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; flex: none; }
.tpl-row { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.summary { margin-top: 14px; padding: 16px 18px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent-soft); }
.summary h3 { margin: 0 0 10px; }
.summary dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; font-size: 14px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 500; }
#preflight-out { margin: 12px 0 0; padding: 12px 14px; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
#preflight-out ul { margin: 6px 0 0; padding-left: 0; list-style: none; }
#preflight-out li { margin: 4px 0; padding-left: 22px; position: relative; }
#preflight-out li::before { position: absolute; left: 0; top: 0; }
.pf-error { color: var(--danger); } .pf-error::before { content: "⨯"; font-weight: 700; }
.pf-warn { color: var(--warn); } .pf-warn::before { content: "!"; font-weight: 700; }
.pf-info { color: var(--muted); } .pf-info::before { content: "·"; }
.pf-ok { color: var(--ok); } .pf-ok::before { content: "✓"; font-weight: 700; }

/* готовность и справка */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.checklist .ok .mark { background: var(--ok-soft); color: var(--ok); }
.checklist .bad .mark { background: var(--warn-soft); color: var(--warn); }
.checklist .opt .mark { background: var(--sunk); color: var(--muted); }
.checklist a { font-weight: 600; text-decoration: none; }
.steps-help { margin: 0; padding-left: 22px; }
.steps-help li { margin-bottom: 8px; }

/* активная рассылка */
.active { border-color: var(--accent); }
.progress { height: 8px; background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin: 12px 0 8px; }
.progress div { height: 100%; background: var(--accent); width: 100%; transform: scaleX(0); transform-origin: left; transition: transform .4s ease-out; }
.counts { margin: 0; }

/* таблицы */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
tbody tr[data-id], tbody tr[data-tid] { cursor: pointer; }
tbody tr[data-id]:hover, tbody tr[data-tid]:hover { background: var(--sunk); }
td.mono { font: 12.5px/1.4 var(--mono); word-break: break-all; }
td.copy { cursor: copy; }
td .row { gap: 6px; }
.st { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--sunk); border: 1px solid var(--line); }
.st-SENT, .st-DONE { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.st-FAILED, .st-STOPPED { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.st-RUNNING, .st-SENDING { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.st-PAUSED, .st-SKIPPED, .st-PENDING, .st-SCHEDULED { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.rec-ok td:first-child { color: var(--ok); font-weight: 700; }
.rec-bad td:first-child { color: var(--danger); font-weight: 700; }
.ab { padding: 10px 12px; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; font-size: 14px; }
#senders-table td:last-child { text-align: right; }

/* доставляемость и предпросмотр */
.deliv span { display: inline-block; margin-right: 10px; font-weight: 600; }
.deliv .ok { color: var(--ok); }
.deliv .bad { color: var(--danger); }
#html-preview, #tpl-preview { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: 14px; }
#inbound-raw { white-space: pre-wrap; font: 12px/1.45 var(--mono); background: var(--sunk); border: 1px solid var(--line); padding: 12px; border-radius: 8px; max-height: 480px; overflow: auto; }
.dim { opacity: .45; pointer-events: none; }
