/* Heroic CRM — the podspun-cloud "Ash" design system, reproduced in plain CSS so
   it runs on a LAMP box with no build step. Neutral, clean, one accent. */

:root {
  --ash-bg: #f3f5f8;
  --ash-surface: #ffffff;
  --ash-surface-2: #eef1f5;
  --ash-border: #e3e6ec;
  --ash-text: #15171c;
  --ash-dim: #6b7280;
  --ash-faint: #9aa1ac;
  --ash-faintest: #bcc2cc;
  --ash-accent: #dd4619;          /* Heroic/Podspun orange — links + active nav */
  --ash-accent-ink: #ffffff;
  --ash-done: #2f6fd0;            /* calm blue for settled/complete states */
  --ash-accent-soft: rgba(221, 70, 25, 0.08);
  --ash-info-soft: rgba(47, 111, 208, 0.08);
  --ash-good: #1a7f52;
  --ash-good-soft: rgba(26, 127, 82, 0.10);
  --ash-warn: #9a6a12;
  --ash-warn-soft: rgba(197, 138, 22, 0.12);
  --ash-danger: #b42318;
  --ash-danger-soft: rgba(180, 35, 24, 0.08);
  --ash-radius: 12px;
  --ash-radius-sm: 8px;
  --ash-card-pad: 24px;
  --ash-sidebar-w: 232px;
  --ash-content-w: 1040px;
  --ash-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.03);
  --ash-shadow-lift: 0 12px 30px rgba(16, 24, 40, 0.14);
  --ash-btn: #eceff3;
  --ash-btn-hover: #e0e4ea;
  --ash-btn-border: #d6dae1;
  --font-body: "Inter";
  --font-heading: "Oswald";
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--ash-bg);
  color: var(--ash-text);
  font-family: var(--font-body), system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

.msym {
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  flex-shrink: 0;
  font-variation-settings: "opsz" 24, "wght" 400, "FILL" 0, "GRAD" 0;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  vertical-align: middle;
}

.link {
  color: var(--ash-accent);
  font-weight: 600;
  transition: opacity 140ms ease;
}
.link:hover { opacity: 0.78; }
.dim { color: var(--ash-dim); }

/* ── Login / bare pages ───────────────────────────────────────────────────── */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login__card {
  width: 100%;
  max-width: 400px;
  background: var(--ash-surface);
  border: 1px solid var(--ash-border);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.06);
  text-align: center;
}
.login__brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-heading), sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  font-size: 15px;
  color: var(--ash-accent);
  margin-bottom: 22px;
}
.login__brand .msym { font-size: 20px; }
.login__title { margin: 0 0 6px; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.login__sub { margin: 0 0 26px; color: var(--ash-dim); font-size: 14px; }
.login__form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.login__input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--ash-border);
  border-radius: var(--ash-radius-sm);
  font-size: 14px;
  background: var(--ash-surface);
  color: var(--ash-text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.login__input::placeholder { color: var(--ash-faintest); }
.login__input:focus {
  outline: none;
  border-color: var(--ash-accent);
  box-shadow: 0 0 0 3px var(--ash-accent-soft);
}
.login__btn {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--ash-btn-border);
  border-radius: var(--ash-radius-sm);
  background: var(--ash-btn);
  color: var(--ash-text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease;
}
.login__btn:hover:not(:disabled) { background: var(--ash-btn-hover); border-color: var(--ash-faint); }
.login__err { margin: 16px 0 0; color: var(--ash-danger); font-size: 14px; }

/* ── App shell ────────────────────────────────────────────────────────────── */

.ash { display: grid; grid-template-columns: var(--ash-sidebar-w) 1fr; min-height: 100vh; }

.ash__side {
  background: var(--ash-surface);
  border-right: 1px solid var(--ash-border);
  padding: 16px 14px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 90;
  display: flex;
  flex-direction: column;
}
.ash__side-top { padding: 0 10px 6px; flex-shrink: 0; }
.ash__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading), sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 17px;
  padding: 4px 0 16px;
}
.ash__brandmark { color: var(--ash-accent); font-size: 22px; }
.ash__brandtext span { color: var(--ash-accent); }

.ash__nav { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.ash__navsec { display: flex; flex-direction: column; gap: 3px; }
.ash__navhead {
  padding: 20px 10px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ash-faint);
}
.ash__navlink {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--ash-radius-sm);
  color: var(--ash-dim);
  font-weight: 500;
  font-size: 14px;
  transition: background 140ms ease, color 140ms ease;
}
.ash__navlink .msym { font-size: 20px; }
.ash__navlink:hover { background: var(--ash-surface-2); color: var(--ash-text); }
.ash__navlink.is-active { background: var(--ash-accent-soft); color: var(--ash-accent); }

.ash__side-bottom { border-top: 1px solid var(--ash-border); padding-top: 10px; margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.ash__account { align-items: center; }
.ash__accountwrap { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ash__accountname { font-weight: 600; color: var(--ash-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ash__accountrole { font-size: 12px; color: var(--ash-faint); }
.ash__signout:hover { background: var(--ash-danger-soft); color: var(--ash-danger); }

.ash__main { min-width: 0; display: flex; flex-direction: column; }
.ash__content { padding: 32px 40px 64px; width: 100%; }
/* No global width cap — pages use the full width. A page can opt into a narrow
   reading column by wrapping its content in .narrow when it wants one. */
.ash__content--cap { max-width: none; }
.narrow { max-width: 900px; }

/* Mobile top bar + off-canvas sidebar */
.ash__mobbar { display: none; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--ash-border); background: var(--ash-surface); position: sticky; top: 0; z-index: 80; }
.ash__mobtoggle { border: 0; background: transparent; color: var(--ash-text); display: inline-flex; padding: 4px; border-radius: var(--ash-radius-sm); transition: background 140ms ease; }
.ash__mobtoggle:hover { background: var(--ash-surface-2); }
.ash__mobbrand { font-family: var(--font-heading), sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.ash__mobbrand span { color: var(--ash-accent); }
.ash__scrim { display: none; }

/* ── Page header ──────────────────────────────────────────────────────────── */

.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page__title { font-family: var(--font-heading), sans-serif; font-weight: 600; font-size: 28px; letter-spacing: 0.005em; margin: 0; display: inline-flex; align-items: center; gap: 10px; }
.infobtn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; background: transparent; color: var(--ash-faint); border-radius: 50%; cursor: pointer; transition: color 140ms ease, background 140ms ease; }
.infobtn:hover { color: var(--ash-accent); background: var(--ash-accent-soft); }
.infobtn .msym { font-size: 20px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cell-trunc { max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.termlist { margin: 0; }
.termlist dt { font-weight: 650; color: var(--ash-text); margin-top: 12px; }
.termlist dt:first-child { margin-top: 0; }
.termlist dd { margin: 2px 0 0; color: var(--ash-dim); font-size: 14px; }
.page__sub { margin: 6px 0 0; color: var(--ash-dim); font-size: 14px; }
.page__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--ash-btn-border);
  border-radius: var(--ash-radius-sm);
  background: var(--ash-btn);
  color: var(--ash-text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.btn .msym { font-size: 18px; }
.btn:hover:not(:disabled) { background: var(--ash-btn-hover); border-color: var(--ash-faint); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--ash-accent); border-color: var(--ash-accent); color: var(--ash-accent-ink); }
.btn--primary:hover:not(:disabled) { background: #c33d13; border-color: #c33d13; }
.btn--danger { background: var(--ash-surface); border-color: #e6ccc9; color: var(--ash-danger); }
.btn--danger:hover:not(:disabled) { background: var(--ash-danger-soft); border-color: var(--ash-danger); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--ash-dim); }
.btn--quiet:hover:not(:disabled) { background: var(--ash-surface-2); color: var(--ash-text); }
.btn--sm { padding: 6px 10px; font-size: 13px; }

/* ── Cards, stats, tables ─────────────────────────────────────────────────── */

.acard {
  background: var(--ash-surface);
  border: 1px solid var(--ash-border);
  border-radius: var(--ash-radius);
  padding: var(--ash-card-pad);
  box-shadow: var(--ash-shadow);
  margin-bottom: 18px;
}
/* Every block spaces itself below; cards inside a grid let the grid gap do it. */
.grid2 > .acard { margin-bottom: 0; }
.acard .statgrid:last-child { margin-bottom: 0; }
.acard__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.acard__title { font-size: 16px; font-weight: 650; margin: 0; }
.acard__actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--ash-surface);
  border: 1px solid var(--ash-border);
  border-radius: var(--ash-radius);
  padding: 18px 20px;
  box-shadow: var(--ash-shadow);
}
.stat__k { color: var(--ash-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat__v { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; line-height: 1.1; }
.stat__sub { color: var(--ash-faint); font-size: 13px; margin-top: 4px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--ash-border); vertical-align: middle; }
.table th { color: var(--ash-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 120ms ease; }
.table tbody tr:hover { background: var(--ash-surface-2); }
.table--flush { margin: 0 -8px; }

.kv { display: flex; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--ash-border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--ash-dim); min-width: 120px; }
.kv__v { flex: 1; }

/* ── Pills / status ───────────────────────────────────────────────────────── */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--ash-surface-2);
  color: var(--ash-dim);
}
.pill--subscribed, .pill--active, .pill--sent { background: var(--ash-good-soft); color: var(--ash-good); }
.pill--pending, .pill--invited, .pill--sending, .pill--draft { background: var(--ash-warn-soft); color: var(--ash-warn); }
.pill--unsubscribed, .pill--bounced, .pill--failed, .pill--disabled { background: var(--ash-danger-soft); color: var(--ash-danger); }
.pill--owner { background: var(--ash-accent-soft); color: var(--ash-accent); }

/* ── Empty states ─────────────────────────────────────────────────────────── */

.empty { text-align: center; padding: 56px 24px; color: var(--ash-dim); }
.empty--inset { padding: 32px 16px; }
.empty__icon { font-size: 40px; color: var(--ash-faintest); }
.empty__title { font-size: 16px; font-weight: 650; color: var(--ash-text); margin: 12px 0 4px; }
.empty__note { font-size: 14px; margin: 0 auto; max-width: 460px; }

/* ── Forms (shared) ───────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--ash-text); }
.field__hint { font-size: 13px; color: var(--ash-dim); }
.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--ash-border);
  border-radius: var(--ash-radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--ash-surface);
  color: var(--ash-text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--ash-accent);
  box-shadow: 0 0 0 3px var(--ash-accent-soft);
}
.formrow { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

/* ── Toast (flash + JS toasts) ────────────────────────────────────────────── */

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 36px 0;
  padding: 11px 15px;
  border-radius: var(--ash-radius-sm);
  font-size: 14px;
  font-weight: 500;
  background: var(--ash-surface);
  border: 1px solid var(--ash-border);
  box-shadow: var(--ash-shadow);
}
.toast--ok { border-color: var(--ash-good); color: var(--ash-good); background: var(--ash-good-soft); }
.toast--err { border-color: var(--ash-danger); color: var(--ash-danger); background: var(--ash-danger-soft); }
.toast--fixed { position: fixed; top: 18px; right: 18px; left: auto; margin: 0; z-index: 120; animation: toastin 160ms ease; }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── Modal (custom confirm/alert from app.js) ─────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade 140ms ease;
}
.modal {
  width: 100%;
  max-width: 460px;
  background: var(--ash-surface);
  border-radius: 14px;
  box-shadow: var(--ash-shadow-lift);
  padding: 24px;
  animation: pop 140ms ease;
}
.modal__title { font-size: 18px; font-weight: 650; margin: 0 0 8px; }
.modal__body { color: var(--ash-dim); font-size: 14px; margin: 0 0 20px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Email preview (desktop / mobile) ─────────────────────────────────────── */
.preview { width: 100%; max-width: 880px; height: 86vh; background: var(--ash-surface); border-radius: 14px; box-shadow: var(--ash-shadow-lift); display: flex; flex-direction: column; overflow: hidden; animation: pop 140ms ease; }
.preview__bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--ash-border); }
.preview__tabs { display: flex; gap: 4px; background: var(--ash-surface-2); border-radius: 999px; padding: 3px; }
.preview__tab { border: 0; background: transparent; padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ash-dim); cursor: pointer; transition: background 140ms ease, color 140ms ease; }
.preview__tab.is-active { background: var(--ash-surface); color: var(--ash-text); box-shadow: var(--ash-shadow); }
.preview__stage { flex: 1; overflow: auto; background: var(--ash-surface-2); display: flex; justify-content: center; padding: 22px; }
.preview__frame { background: #fff; border: 1px solid var(--ash-border); border-radius: 8px; height: 100%; transition: width 160ms ease; }
.preview__frame--desktop { width: 100%; max-width: 700px; }
.preview__frame--mobile { width: 390px; flex: 0 0 390px; }

/* ── Segment tabs (outreach) ──────────────────────────────────────────────── */

.segtabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--ash-border); margin-bottom: 22px; }
.segtab {
  padding: 9px 14px;
  border: 0;
  background: none;
  color: var(--ash-dim);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
}
.segtab:hover { color: var(--ash-text); }
.segtab.is-active { color: var(--ash-accent); border-bottom-color: var(--ash-accent); }
.segtab .n { margin-left: 6px; color: var(--ash-faint); font-size: 12px; }

.statusline { font-size: 13px; color: var(--ash-dim); min-height: 18px; margin-top: 12px; }

.warnbox {
  background: var(--ash-warn-soft);
  border: 1px solid rgba(197, 138, 22, 0.35);
  color: var(--ash-warn);
  border-radius: var(--ash-radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 22px;
}
.warnbox a { color: inherit; text-decoration: underline; }
.warnbox ul { margin: 6px 0 0; padding-left: 18px; }

details.tpl { background: var(--ash-surface); border: 1px solid var(--ash-border); border-radius: var(--ash-radius-sm); padding: 10px 14px; margin-top: 18px; box-shadow: var(--ash-shadow); }
details.tpl summary { cursor: pointer; color: var(--ash-dim); font-size: 14px; }
details.tpl pre { white-space: pre-wrap; font: 13px/1.5 ui-monospace, Menlo, monospace; color: var(--ash-text); margin-top: 10px; }

/* A card that collapses (native <details>), used for the history/sources block. */
.foldcard > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 650; }
.foldcard > summary::-webkit-details-marker { display: none; }
.foldcard > summary .msym { color: var(--ash-faint); transition: transform 160ms ease; }
.foldcard[open] > summary .msym { transform: rotate(180deg); }

.draftrow { background: var(--ash-surface); border: 1px solid var(--ash-border); border-radius: var(--ash-radius); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--ash-shadow); }
.draftrow .who { font-weight: 600; }
.draftrow .subj { color: var(--ash-dim); font-size: 13px; margin: 4px 0 10px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .ash { grid-template-columns: 1fr; }
  .ash__side {
    position: fixed;
    left: 0; top: 0;
    width: 264px;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--ash-shadow-lift);
  }
  .ash.is-side-open .ash__side { transform: none; }
  .ash__mobbar { display: flex; }
  .ash__content { padding: 20px 18px 56px; }
  .toast { margin: 16px 18px 0; }
  .grid2 { grid-template-columns: 1fr; }
  .ash.is-side-open .ash__scrim { display: block; position: fixed; inset: 0; background: rgba(16,24,40,0.4); z-index: 85; }
}
