/* Admin › Emailer (P563, design/chordlens.pen "P563 · Admin › Emailer"): Templates, the editor, Send, Review and send,
   the send's progress and History. Cards, pills, labels and the tablist come from admin.css and feedback.css. */

.em-admin { display: flex; flex-direction: column; gap: 16px; }
.em-admin > .an-tabs { align-self: flex-start; }
.em-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.em-banner {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 16px;
  border-radius: 12px; outline: 1px solid var(--st-line); outline-offset: -0.5px;
  background: var(--st-surface); color: var(--st-text); font-size: 13px;
}
.em-banner::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--st-warn); }
.em-banner[hidden] { display: none; }
.em-alert { margin: 0; color: var(--st-error-ink); font-size: 13px; }
.em-alert:empty { display: none; }
.em-hint { margin: 2px 0 0; color: var(--st-text-dim); font-size: 12.5px; line-height: 18px; }
.em-empty { margin: 0; padding: 24px 0; color: var(--st-text-dim); font-size: 13px; text-align: center; }

/* ---- Cards and the templates table -------------------------------------------- */

.em-card { display: flex; flex-direction: column; gap: 16px; }
.em-card__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.em-card__title { margin: 0; font: 600 15px/20px var(--st-font); }
.em-scroll { overflow-x: auto; }
.em-table { width: 100%; min-width: 820px; border-collapse: collapse; }
.em-th { padding: 8px 12px; border-bottom: 1px solid var(--st-line); color: var(--st-text-dim); font: 500 11.5px/16px var(--st-font); letter-spacing: 0.04em; text-align: left; text-transform: uppercase; }
.em-th--num, .em-td--num { text-align: right; font-variant-numeric: tabular-nums; }
.em-td { padding: 12px; border-bottom: 1px solid var(--st-line); font-size: 13.5px; vertical-align: middle; }
.em-row:last-child .em-td { border-bottom: 0; }
.em-td--subject { color: var(--st-text-dim); }
.em-td--dim { color: var(--st-text-dim); white-space: nowrap; }
.em-td--end { text-align: right; }
.em-name { margin: 0; font-weight: 500; }
.em-sub { margin: 2px 0 0; color: var(--st-text-faint); font-size: 12px; }
.em-sub--sending { color: var(--st-warn); }
.em-chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px;
  background: var(--st-surface-2); color: var(--st-text-dim); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.em-chip--personal { background: var(--st-accent-soft); color: var(--st-accent-ink); }
/* P579: an automatic template's badge, after its name. */
.em-name .em-chip { gap: 4px; height: 20px; margin-left: 8px; padding: 0 6px; vertical-align: 1px; font-size: 11.5px; }
.em-chip--auto { background: var(--st-accent-soft); color: var(--st-accent-ink); }
/* An automatic template that is switched off sends nothing: a grey chip, not the accent. */
.em-chip--auto.em-chip--off { background: var(--st-surface-2); color: var(--st-text-dim); }
.em-chip--auto .st-icon { width: 12px; height: 12px; }
.em-templates { display: flex; flex-direction: column; gap: 16px; }
.em-note { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 0 4px; color: var(--st-text-dim); font-size: 12px; line-height: 18px; }
.em-note .st-icon { width: 14px; height: 14px; margin-top: 2px; color: var(--st-text-faint); }

/* ---- The editor ----------------------------------------------------------------- */

.em-editor { display: flex; flex-direction: column; gap: 16px; }
.em-actions { display: flex; gap: 8px; }
.em-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 16px; }
@media (width < 1100px) { .em-split { grid-template-columns: minmax(0, 1fr); } }
.em-form { display: flex; flex-direction: column; gap: 18px; padding: 20px; }
.em-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.em-field[hidden] { display: none; }
.em-field .st-seg { align-self: flex-start; }
.em-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.em-input {
  width: 100%; height: 40px; padding: 0 12px; border: 0; border-radius: 10px;
  outline: 1px solid var(--st-line); outline-offset: -0.5px;
  background: var(--st-panel); color: var(--st-text); font: 400 13.5px/20px var(--st-font);
}
.em-input::placeholder { color: var(--st-text-faint); }
.em-input[aria-invalid], .em-body[aria-invalid] { outline-color: var(--st-error); }
.em-select option:disabled { color: var(--st-text-faint); }
.em-body { min-height: 260px; }
.em-body[hidden] { display: none; }
.em-body-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.em-insert { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--st-text-faint); font-size: 12px; }
.em-insert .st-btn__label { font-family: var(--st-font-mono); }
.em-fixed { margin: 0; font-size: 13.5px; }
.em-flag { display: flex; align-items: flex-start; gap: 12px; }
.em-flag .st-switch { flex: none; margin-top: 1px; }
.em-flag__text { display: flex; flex-direction: column; gap: 2px; }
.em-flag__title { font-size: 13.5px; font-weight: 500; }
.em-live { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }

/* ---- The email itself (always light, as a mail app shows it) ---------------------- */

.em-mail { overflow: hidden; border-radius: 12px; background: #fff; color: #16171b; color-scheme: light; }
.em-mail--phone { width: 375px; max-width: 100%; margin: 0 auto; border: 10px solid #1c1c21; border-radius: 32px; }
.em-mail__head { padding: 16px 20px; border-bottom: 1px solid #ececf0; }
.em-mail__subject { margin: 0 0 6px; font: 600 18px/24px var(--st-font); }
.em-mail__from { margin: 0; font-size: 13px; font-weight: 600; }
.em-mail__to { margin: 2px 0 0; color: #6b6f7b; font-size: 12.5px; }
.em-frame { display: block; width: 100%; min-height: 320px; border: 0; background: #fff; }
.em-plain { margin: 0; padding: 20px; color: #16171b; font: 400 13px/1.6 var(--st-font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- Dialogs: full preview, confirm ------------------------------------------------ */

.em-dialog {
  width: min(560px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 16px;
  outline: 1px solid var(--st-line); background: var(--st-surface); color: var(--st-text); font-family: var(--st-font);
}
.em-dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.em-dialog__title { margin: 0; font: 600 18px/24px var(--st-font); }
.em-full { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.em-full__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.em-full__stage { padding: 16px; border-radius: 12px; background: var(--st-panel); }

/* ---- Send (E6/E6b) ------------------------------------------------------------------ */

.em-split--send { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
@media (width < 1100px) { .em-split--send { grid-template-columns: minmax(0, 1fr); } }
.em-from { margin: 0; }
.em-search { display: flex; gap: 8px; }
.em-results, .em-picks { display: flex; flex-direction: column; margin: 0; padding: 0; border-radius: 10px; outline: 1px solid var(--st-line); outline-offset: -0.5px; list-style: none; }
.em-results[hidden] { display: none; }
.em-result, .em-pick { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--st-line); font-size: 13.5px; }
:is(.em-result, .em-pick):last-child { border-bottom: 0; }
.em-result__label { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.em-result--out { color: var(--st-text-faint); }
.em-result--out .em-result__label { cursor: default; }
.em-result__email, .em-pick__email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-result__side { color: var(--st-text-faint); font-size: 12px; white-space: nowrap; }
.em-chips { flex-wrap: wrap; }
.em-all { border-bottom: 0; border-radius: 10px; background: var(--st-surface-2); }
.em-all[hidden] { display: none; }
.em-paste { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 10px; outline: 1px solid var(--st-line); outline-offset: -0.5px; background: var(--st-panel); }
.em-paste[hidden] { display: none; }
.em-paste__result { display: flex; flex-direction: column; gap: 10px; }
.em-resolved { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 10px; outline: 1px solid var(--st-line); outline-offset: -0.5px; }
.em-resolved__head { margin: 0; color: var(--st-text); font-size: 14px; font-weight: 600; }
.em-resolved__chips, .em-resolved__emails { display: flex; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.em-resolved__chips { align-items: center; gap: 6px; }
.em-resolved__chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 28px; padding: 0 4px 0 10px; border-radius: 8px; outline: 1px solid var(--st-line); outline-offset: -0.5px; font-size: 12.5px; }
.em-resolved__email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-resolved__group { display: flex; flex-direction: column; gap: 6px; }
.em-resolved__group .fb-label { margin: 0; }
.em-resolved__emails { gap: 4px 14px; color: var(--st-text-dim); font-size: 12.5px; overflow-wrap: anywhere; }
.em-resolved__group--no_account .em-resolved__emails { color: var(--st-warn); }
.em-paste__actions { display: flex; justify-content: flex-end; gap: 8px; }
.em-selected { display: flex; flex-direction: column; gap: 8px; }
.em-selected__head { display: flex; align-items: center; justify-content: space-between; }
.em-selected__head .fb-label { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.em-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--st-accent); color: var(--st-on-accent); font-size: 11.5px; font-weight: 600; }
.em-pick .em-sub { flex: 1; margin: 0; }
.em-left { display: flex; gap: 8px; margin: 0; color: var(--st-text-dim); font-size: 13px; line-height: 19px; }
.em-left[hidden] { display: none; }
.em-send__foot, .em-summary__send { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 16px; border-top: 1px solid var(--st-line); }
.em-who { display: flex; flex-direction: column; gap: 0; }
.em-who__big { margin: 16px 0 0; font: 600 32px/1 var(--st-font); }
.em-who__row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--st-line); color: var(--st-text-dim); font-size: 13.5px; }
.em-who__row:first-of-type { margin-top: 16px; border-top: 1px solid var(--st-line); }
.em-who__row--strong { color: var(--st-text); font-weight: 600; }
.em-who__time { margin: 16px 0 6px; font-size: 13px; }

/* ---- Review and send (E7) ------------------------------------------------------------ */

.em-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; outline-color: var(--st-accent); }
.em-summary__send { padding-top: 0; border-top: 0; }
.em-sendto, .em-review__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.em-sendto__list { display: flex; flex: 1; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.em-counts strong { color: var(--st-text); font-weight: 600; }
.em-review__as { width: auto; }
.em-review__me { margin-left: auto; color: var(--st-text-dim); font-size: 13px; }
.em-review__preview { max-width: 760px; width: 100%; margin: 0 auto; }

/* ---- Confirm (E7b) ------------------------------------------------------------------- */

.em-confirm__rows { margin: 20px 0 16px; border-radius: 12px; outline: 1px solid var(--st-line); outline-offset: -0.5px; }
.em-confirm__row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--st-line); font-size: 14px; }
.em-confirm__row:last-child { border-bottom: 0; }
.em-confirm__key { color: var(--st-text-faint); }
.em-confirm__warn { display: flex; align-items: center; gap: 8px; margin: 0 0 20px; color: var(--st-text-dim); font-size: 14px; }
.em-confirm__warn::before { content: "!"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; outline: 1.5px solid var(--st-warn); color: var(--st-warn); font-size: 11px; font-weight: 700; }
.em-confirm__actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Progress (E7c/E7d v2): one ring, eased ------------------------------------------- */

.em-ring { position: relative; display: grid; flex: none; place-items: center; width: 140px; height: 140px; }
.em-ring__svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.em-ring__track, .em-ring__arc { fill: none; stroke-width: 4; }
.em-ring__track { stroke: var(--st-surface-2); }
.em-ring__arc { stroke: var(--st-accent); stroke-linecap: round; }
.em-ring__percent { font: 600 26px/1 var(--st-font); font-variant-numeric: tabular-nums; }
.em-ring__check { display: none; width: 36px; height: 36px; color: var(--st-ok); }
.em-ring--done .em-ring__arc { stroke: var(--st-ok); }
.em-ring--done .em-ring__percent { display: none; }
.em-ring--done .em-ring__check { display: block; }
.em-progress__count { margin: 0; font: 700 40px/1.2 var(--st-font); font-variant-numeric: tabular-nums; }

/* ---- Plan badge: the Admin look (surface-2 fill, 11/600 sans), Pro in gold ------------------ */

.em-plan { display: inline-flex; flex: none; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--st-surface-2); color: var(--st-text-dim); font: 600 11px/1 var(--st-font); white-space: nowrap; }
.em-plan[data-plan='pro'] { color: var(--st-chord-ink); }

/* ---- History's Unsubscribes line (E9) ------------------------------------------------------- */

.em-history { display: flex; flex-direction: column; gap: 16px; }
.em-unsubs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; font-size: 13.5px; }
.em-unsubs__icon { flex: none; width: 18px; height: 18px; color: var(--st-text-dim); }
.em-unsubs__title { font-weight: 600; }
.em-unsubs__total { font-weight: 600; font-variant-numeric: tabular-nums; }
.em-unsubs__reasons { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--st-line); color: var(--st-text-dim); list-style: none; }
.em-unsubs__n { font-variant-numeric: tabular-nums; }

/* ---- The queue (E9 History, E9b send detail; D577) ------------------------------------------- */

.em-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (width < 900px) { .em-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.em-kpi__label { margin: 0; color: var(--st-text-dim); font-size: 13px; }
.em-kpi__value { margin: 6px 0 2px; font: 600 28px/1.1 var(--st-font); font-variant-numeric: tabular-nums; }
.em-kill { display: inline-flex; align-items: center; gap: 10px; color: var(--st-text-dim); font-size: 13px; cursor: pointer; }
.em-status { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 12px; background: var(--st-surface-2); color: var(--st-text-dim); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.em-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.em-status--sending, .em-status--failed { background: var(--st-accent-soft); color: var(--st-accent-ink); }
.em-status--paused, .em-status--retrying { color: var(--st-warn); }
.em-status--done, .em-status--sent { color: var(--st-ok); }
.em-bar-cell { display: inline-flex; align-items: center; gap: 12px; }
.em-bar { display: block; width: 160px; height: 4px; overflow: hidden; border-radius: 2px; background: var(--st-surface-2); }
.em-bar__fill { display: block; height: 100%; border-radius: 2px; background: var(--st-text-faint); transition: width 0.4s var(--ease); }
.em-bar--sending .em-bar__fill, .em-bar--queued .em-bar__fill { background: var(--st-accent); }
.em-bar--done .em-bar__fill { background: var(--st-ok); }
.em-row--link { cursor: pointer; }
.em-row--link:hover .em-td { background: var(--st-surface-2); }
.em-row__open { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: none; color: var(--st-text-faint); cursor: pointer; }

.em-detail__title { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.em-overview { display: flex; flex-wrap: wrap; align-items: center; gap: 24px 32px; padding: 24px; }
.em-overview .em-progress__count { margin: 0; }
.em-tiles { display: grid; flex: 1; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; min-width: min(100%, 480px); }
.em-tile { padding: 12px 16px; border-radius: 10px; background: var(--st-surface-2); }
.em-tile__label { margin: 0; color: var(--st-text-dim); font-size: 12.5px; }
.em-tile__value { margin: 4px 0 0; font: 600 22px/1.2 var(--st-font); font-variant-numeric: tabular-nums; }
.em-detail__search { width: min(100%, 280px); margin-left: auto; }
.em-detail__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.em-danger { color: var(--st-accent-ink); }
.em-recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--st-surface-2); font-size: 13px; }
.em-recent[hidden] { display: none; }
.em-recent__toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }

/* Test mode (read-only): quieter than the sending-off banner, no warning dot. */
.em-banner--test { padding: 8px 14px; color: var(--st-text-dim); font-size: 12.5px; }
.em-banner--test::before { background: var(--st-text-faint); }
.em-recent--test { color: var(--st-text-dim); }
