/* Zipreach - design system.
   Warm paper neutrals, one deep "postmark" green used sparingly, hairline borders instead of shadows,
   Inter for everything (one simple font). Every colour is a token below and
   is redefined for dark mode at the end of the file. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  /* surfaces */
  --bg: #f6f5f1;
  --card: #ffffff;
  --surface-2: #f1efea;
  --line: #e5e2da;
  --line-2: #eeebe5;
  --line-strong: #d3cfc5;
  /* text */
  --ink: #1b1a17;
  --ink-2: #44413b;
  --muted: #6b675f;
  --placeholder: #a7a297;
  --faint: #c8c3b7;
  /* brand: deep postmark green */
  --brand: #1d5a46;
  --brand-hover: #164a39;
  --brand-600: #174a39;
  --brand-50: #e8f0ec;
  --brand-100: #cfe1d7;
  --on-brand: #ffffff;
  --chip-line: #d3cfc5;
  /* states */
  --ok: #2e7d4f;
  --ok-50: #eaf3ed;
  --ok-line: #c8e0d0;
  --ok-ink: #1f5a37;
  --warn: #a35a00;
  --warn-50: #faf1e2;
  --warn-line: #ecd3a6;
  --warn-ink: #6b3c02;
  --bad: #b4321f;
  --bad-50: #f9ebe7;
  --bad-line: #eec3b9;
  --bad-ink: #7c2214;
  --danger-line: #eec3b9;
  --info-ink: #47443d;
  /* shape, depth */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(27, 26, 23, .06);
  --shadow-lg: 0 18px 44px rgba(27, 26, 23, .16), 0 2px 6px rgba(27, 26, 23, .06);
  --overlay: rgba(20, 19, 16, .42);
  --toast-bg: #1b1a17;
  --nav-bg: rgba(246, 245, 241, .88);
  --glow-1: transparent;
  --glow-2: transparent;
  /* type */
  --sans: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: var(--sans);   /* one font everywhere: kept as an alias so older rules stay plain */
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--brand-100); color: var(--ink); }
a { color: var(--brand); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); }
h1 { font-weight: 700; font-size: 26px; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.55; }
.mono { font-family: var(--mono); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.grow { flex: 1; min-width: 0; }
.mt-10 { margin-top: 10px; }
.ml-6 { margin-left: 6px; }
.mt-12 { margin-top: 12px; }
.mb-20 { margin-bottom: 20px; }
.center { text-align: center; }
.label-text { font-weight: 500; color: var(--ink-2); font-size: 13px; }
.search-input { max-width: 320px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
table, .stat .value, .summary-line, .usage-row, .nav-count, .pill { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; }
.brand img, .brand-mini img { height: 26px; width: 26px; }
.brand-name { font-weight: 700; font-size: 17px; line-height: 1; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; }
.brand-mini { display: inline-flex; align-items: center; gap: 8px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label { font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase;
  letter-spacing: .08em; padding: 18px 10px 6px; }
.nav button {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; font-size: 14px;
  border: 1px solid transparent;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button.active { background: var(--card); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.nav button.active svg { color: var(--brand); }
.nav button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.nav svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 6px 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .btn-block { justify-content: flex-start; padding: 0 8px; height: 30px; font-weight: 500; color: var(--ink-2); }

.main { min-width: 0; padding: 36px 44px 72px; max-width: 1320px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-head p { color: var(--muted); margin-top: 8px; max-width: 760px; font-size: 14px; }
.mobile-bar { display: none; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 24px; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.card-body { padding: 20px; }
.step-num {
  width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--ink); color: var(--card); font: 500 12px var(--mono);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); }

/* ------------------------------------------------------------------ stats: one joined strip, hairline dividers */
.stat { padding: 18px 20px 20px; min-width: 0; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 28px; line-height: 1; font-weight: 700; margin-top: 10px; letter-spacing: -0.02em; color: var(--ink); }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 8px; }
#dash-stats, #sent-stats, #analytics-stats {
  gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
#dash-stats > .card, #sent-stats > .card, #analytics-stats > .card { border: 0; border-radius: 0; }
.meter { height: 4px; background: var(--line-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s; }
.meter.warn > span { background: var(--warn); }

/* ------------------------------------------------------------------ forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--ink-2); font-size: 13px; }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; line-height: 1.5; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=datetime-local], select, textarea {
  font: inherit; color: var(--ink); background: var(--card); width: 100%; min-height: 36px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 7px 11px;
  transition: border-color .15s, box-shadow .15s;
}
select { padding-right: 28px; }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
textarea.body-editor { min-height: 260px; font-size: 14px; }
input:hover:not(:disabled), select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--brand); }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button {
  all: unset; cursor: pointer; padding: 5px 12px; border-radius: 6px; font-weight: 500; color: var(--muted); font-size: 13px;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.segmented button:focus-visible { outline: 2px solid var(--brand); }

/* ------------------------------------------------------------------ buttons */
.btn {
  font: inherit; font-weight: 500; font-size: 14px; cursor: pointer; height: 34px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { color: var(--bad); border-color: var(--danger-line); background: var(--card); }
.btn-danger:hover { background: var(--bad-50); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ chips, status */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 12px var(--mono); cursor: pointer; border: 1px solid var(--line); color: var(--ink-2);
  background: var(--surface-2); padding: 2px 8px; border-radius: 5px;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
/* Status: a coloured dot and quiet text, not a filled lozenge */
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500;
  padding: 0; background: none; color: var(--ink-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.pill.ok::before { background: var(--ok); }
.pill.warn::before { background: var(--warn); }
.pill.bad { color: var(--bad-ink); }
.pill.bad::before { background: var(--bad); }
.pill.info::before { background: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.pill.plain::before { display: none; }

/* ------------------------------------------------------------------ notices */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm);
  font-size: 13px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  box-shadow: inset 3px 0 0 var(--faint); }
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--muted); }
.alert.info { box-shadow: inset 3px 0 0 var(--brand); }
.alert.info svg { color: var(--brand); }
.alert.warn { background: var(--warn-50); border-color: var(--warn-line); color: var(--warn-ink); box-shadow: inset 3px 0 0 var(--warn); }
.alert.warn svg { color: var(--warn); }
.alert.bad { background: var(--bad-50); border-color: var(--bad-line); color: var(--bad-ink); box-shadow: inset 3px 0 0 var(--bad); }
.alert.bad svg { color: var(--bad); }
.alert.ok { background: var(--ok-50); border-color: var(--ok-line); color: var(--ok-ink); box-shadow: inset 3px 0 0 var(--ok); }
.alert.ok svg { color: var(--ok); }
#dash-warnings { display: flex; flex-direction: column; gap: 8px; }
#dash-warnings:not(:empty) { margin-bottom: 20px; }

/* ------------------------------------------------------------------ dropzone */
.dropzone {
  display: block;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 28px; text-align: center;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; color: var(--muted);
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-50); }
.dropzone svg { width: 24px; height: 24px; color: var(--ink-2); }
.dropzone b { display: block; margin-top: 8px; font-weight: 500; color: var(--ink); }
.file-list { display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--card); font-size: 13px; }
.file-chip button { all: unset; cursor: pointer; color: var(--muted); padding: 0 4px; font-size: 15px; line-height: 1; }
.file-chip button:hover { color: var(--bad); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 360px; }
.card > .table-wrap { border: none; border-radius: 0 0 var(--radius) var(--radius); max-height: none; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { position: sticky; top: 0; background: var(--card); text-align: left; font-weight: 500; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--ink); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
td.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.dim td { color: var(--placeholder); text-decoration: line-through; }
.progress-cell { min-width: 140px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); font-size: 13px; }
.empty svg { width: 26px; height: 26px; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; font-weight: 600; font-size: 16px; }

/* ------------------------------------------------------------------ preview */
.email-preview { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--card); }
.email-preview .meta { padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 13px; }
.email-preview .meta div { display: flex; gap: 8px; }
.email-preview .meta span:first-child { color: var(--muted); width: 56px; flex: none; }
.email-preview pre { margin: 0; padding: 16px; white-space: pre-wrap; word-break: break-word;
  font: 14px/1.65 var(--sans); color: var(--ink); max-height: 420px; overflow: auto; }

.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.summary-line:last-of-type { border-bottom: none; }
.summary-line span:first-child { color: var(--muted); }
.summary-line span:last-child { font-weight: 500; text-align: right; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center;
  z-index: 50; padding: 16px; animation: fade .15s; backdrop-filter: blur(2px); }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.modal .card-head h2 { font-weight: 600; font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); background: var(--surface-2); }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--toast-bg); color: #f6f5f1; padding: 11px 14px; border-radius: 8px; box-shadow: var(--shadow-lg);
  font-size: 13px; max-width: 380px; animation: slide .2s; display: flex; gap: 10px; align-items: flex-start; }
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #a7a297; flex: none; margin-top: 6px; }
.toast.ok::before { background: #6fcf97; }
.toast.bad { background: var(--toast-bg); box-shadow: var(--shadow-lg), inset 3px 0 0 #ec7562; }
.toast.bad::before { content: "!"; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; background: #ec7562; color: #1b1a17;
  font-size: 11px; font-weight: 700; display: grid; place-items: center; }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }

/* ------------------------------------------------------------------ public pages (login, unsubscribe) */
.public-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background-color: var(--bg);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 22px 22px; }
.public-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 34px 32px 30px; display: flex; flex-direction: column; gap: 16px; }
.public-card h1 { font-size: 34px; }
.public-card p { color: var(--ink-2); }
.public-card .logo { height: 36px; width: auto; align-self: flex-start; margin-bottom: 6px; }
.public-card form { display: flex; flex-direction: column; gap: 14px; }
.public-card .brand-link .muted { font-size: 13px; letter-spacing: .02em; }

/* ------------------------------------------------------------------ send page */
.password-wrap { position: relative; display: block; }
.password-wrap input { width: 100%; padding-right: 78px; }
.pw-toggle { all: unset; box-sizing: border-box; cursor: pointer; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border-radius: 6px;
  font-size: 12px; font-weight: 500; color: var(--muted); }
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.pw-toggle svg { width: 15px; height: 15px; flex: none; }
.pw-toggle[aria-pressed="true"] { color: var(--ink-2); }

/* Label text and its hint stay on one line, so side-by-side boxes line up. */
.field-label { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; row-gap: 2px; }
.field-label .hint { font-size: 12px; }

.warn-text { color: var(--warn-ink); font-weight: 500; }
.table-wrap.short { max-height: none; }
.table-more { padding: 8px; border-top: 1px solid var(--line-2); }
.status-card { box-shadow: inset 3px 0 0 var(--brand); }
.nowrap { white-space: nowrap; }
.detail-row td { background: var(--surface-2); }
.message-body { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; font: 13.5px/1.65 var(--sans);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; max-height: 360px; overflow: auto; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .builder { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky { position: static; }
  .main { padding: 32px 28px 64px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; width: 248px; transform: translateX(-100%);
    transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px;
    background: var(--nav-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .mobile-bar img { height: 24px; width: 24px; }
  .mobile-bar .brand-name { font-size: 17px; }
  .main { padding: 22px 16px 48px; }
  h1 { font-size: 22px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; align-items: flex-start; margin-bottom: 22px; }
  .stat .value { font-size: 24px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}

.builder > *, .stack > *, .grid > * { min-width: 0; }

/* ------------------------------------------------------------------ accounts */
.logo-sm { height: 28px; width: 28px; }
.auth-tabs { display: flex; }
.auth-tabs button { flex: 1; text-align: center; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 4px 8px; }
.user-chip .stack-0 { display: flex; flex-direction: column; min-width: 0; }
.user-chip b { font-weight: 500; font-size: 13px; }
.user-chip .trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--ink); color: var(--card); font: 600 14px var(--sans); }

/* ------------------------------------------------------------------ formatted email editor */
.rich { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); overflow: hidden; position: relative; }
.rich:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 5px; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.toolbar button { all: unset; cursor: pointer; min-width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 5px; color: var(--ink-2); font-size: 14px; }
.toolbar button:hover { background: var(--card); color: var(--ink); }
.toolbar button:focus-visible { outline: 2px solid var(--brand); }
.toolbar svg { width: 16px; height: 16px; }
.toolbar-sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.rich-editor { min-height: 260px; max-height: 560px; overflow: auto; padding: 12px 14px; outline: none; line-height: 1.65; font-size: 14px; }
.rich-editor.is-empty::before { content: attr(data-placeholder); color: var(--placeholder); position: absolute; pointer-events: none; }
.rich-editor p, .pv-html p { margin: 0 0 12px; }
.rich-editor ul, .rich-editor ol, .pv-html ul, .pv-html ol { margin: 0 0 12px; padding-left: 22px; }
.pv-html { padding: 16px; font-size: 14px; line-height: 1.65; max-height: 420px; overflow: auto; }

/* ------------------------------------------------------------------ dashboard & settings */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.settings-grid > * { min-width: 0; }
@media (max-width: 860px) {
  .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  td.trunc { max-width: 150px; }
  .progress-cell { min-width: 110px; }
}
.setup-step { padding: 10px 0; border-top: 1px solid var(--line-2); }
.setup-step:first-of-type { border-top: none; }

/* ------------------------------------------------------------------ SaaS pages */
.brand-link { color: inherit; gap: 9px; }
.brand-link:hover { text-decoration: none; }
.dash-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.usage-row { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.usage-row .meter { margin-top: 2px; }
.link-btn { all: unset; cursor: pointer; color: var(--ink); font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.link-btn:hover { color: var(--brand); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--brand); }
.toast-action { all: unset; cursor: pointer; font-weight: 600; text-decoration: underline; white-space: nowrap; }
.select-sm { width: auto; min-height: 32px; padding: 4px 28px 4px 10px; font-size: 13px; }
.template-pick { max-width: 420px; }
.settings-wide { grid-column: 1 / -1; }
.sender-form { border-top: 1px solid var(--line-2); padding-top: 18px; }
.actions-cell { gap: 4px; justify-content: flex-end; }
.danger-card { border-color: var(--danger-line); }
.danger-card .card-head h2 { color: var(--bad); }
.checkbox span { font-weight: 400; }
.checkbox.small { align-items: flex-start; font-size: 13px; line-height: 1.5; }
.checkbox.small input { margin-top: 2px; flex: none; }
.plans-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.plan-card.current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.plan-card .card-body { height: 100%; }
.plan-price { font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.plan-list { list-style: none; padding: 0; margin: 4px 0 12px; display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--ink-2); flex: 1; }
.plan-list li::before { content: "—"; color: var(--brand); margin-right: 8px; }
.modal-wide { width: min(720px, 100%); }
label.field.contacts-list-name { flex-direction: row; align-items: center; gap: 8px; white-space: nowrap; }
.contacts-list-name input { width: 200px; }
#auth-notice { margin-top: -4px; }
@media (max-width: 1100px) {
  .dash-top { grid-template-columns: minmax(0, 1fr); }
  .plans-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------------ dark theme
   No saved choice: follow the system. A saved choice (theme.js) sets data-theme on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --card: #1a1a18; --surface-2: #20201d; --line: #2c2b27; --line-2: #242421; --line-strong: #3b3934;
    --ink: #efede8; --ink-2: #d3d0c8; --muted: #a29f97; --placeholder: #6e6a61; --faint: #4c4943;
    --brand: #7cc4a3; --brand-hover: #92d1b4; --brand-600: #a6dcc2; --brand-50: #17271f; --brand-100: #213a2e;
    --on-brand: #0e1a14; --chip-line: #3b3934;
    --ok: #63c08b; --ok-50: #15231a; --ok-line: #26402e; --ok-ink: #a7dcbb;
    --warn: #e2a853; --warn-50: #261d0f; --warn-line: #4a3517; --warn-ink: #f1cb8d;
    --bad: #ec7562; --bad-50: #2a1613; --bad-line: #57261f; --bad-ink: #ffb6a8; --danger-line: #57261f;
    --info-ink: #c9c6bd;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
    --overlay: rgba(0, 0, 0, .6); --toast-bg: #2c2b27; --nav-bg: rgba(18, 18, 17, .88);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --card: #1a1a18; --surface-2: #20201d; --line: #2c2b27; --line-2: #242421; --line-strong: #3b3934;
  --ink: #efede8; --ink-2: #d3d0c8; --muted: #a29f97; --placeholder: #6e6a61; --faint: #4c4943;
  --brand: #7cc4a3; --brand-hover: #92d1b4; --brand-600: #a6dcc2; --brand-50: #17271f; --brand-100: #213a2e;
  --on-brand: #0e1a14; --chip-line: #3b3934;
  --ok: #63c08b; --ok-50: #15231a; --ok-line: #26402e; --ok-ink: #a7dcbb;
  --warn: #e2a853; --warn-50: #261d0f; --warn-line: #4a3517; --warn-ink: #f1cb8d;
  --bad: #ec7562; --bad-50: #2a1613; --bad-line: #57261f; --bad-ink: #ffb6a8; --danger-line: #57261f;
  --info-ink: #c9c6bd;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
  --overlay: rgba(0, 0, 0, .6); --toast-bg: #2c2b27; --nav-bg: rgba(18, 18, 17, .88);
  color-scheme: dark;
}

/* theme toggle: moon + "Dark mode" in light, sun + "Light mode" in dark */
.theme-toggle .i-sun, .theme-toggle .l-light { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon, :root[data-theme="dark"] .theme-toggle .l-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun, :root[data-theme="dark"] .theme-toggle .l-light { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-moon, :root:not([data-theme="light"]) .theme-toggle .l-dark { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-sun, :root:not([data-theme="light"]) .theme-toggle .l-light { display: inline; }
}
.theme-toggle svg { width: 15px; height: 15px; }
.icon-toggle { all: unset; cursor: pointer; display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 7px; color: var(--ink-2); }
.icon-toggle:hover { background: var(--surface-2); color: var(--ink); }
.icon-toggle:focus-visible { outline: 2px solid var(--brand); }
.public-card { position: relative; }
.corner-toggle { position: absolute; top: 16px; right: 16px; }

/* ------------------------------------------------------------------ deliverability */
.sender-health { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sender-health:has(.notice) { display: block; }

/* Gentle status notice: tinted box, icon, short title, one line of help, one action. */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.notice-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); color: var(--muted); border: 1px solid var(--line); }
.notice-icon svg { width: 13px; height: 13px; }
.notice-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notice-title { font-weight: 600; color: var(--ink); }
.notice-text { color: var(--muted); font-size: 13px; line-height: 1.45; }
.notice-action { flex: none; align-self: center; }
.notice.bad { background: var(--bad-50); border-color: var(--bad-line); }
.notice.bad .notice-icon { background: var(--bad); border-color: var(--bad); color: #fff; }
.notice.bad .notice-title { color: var(--bad-ink); }
.notice.warn { background: var(--warn-50); border-color: var(--warn-line); }
.notice.warn .notice-icon { background: var(--warn); border-color: var(--warn); color: #fff; }
.notice.warn .notice-title { color: var(--warn-ink); }
.notice.ok { background: var(--ok-50); border-color: var(--ok-line); }
.notice.ok .notice-icon { background: var(--ok); border-color: var(--ok); color: #fff; }
.notice.ok .notice-title { color: var(--ok-ink); }
.notice .extra { color: var(--muted); font-size: 13px; }
@media (max-width: 640px) {
  .notice { flex-wrap: wrap; }
  .notice-body { flex-basis: calc(100% - 34px); }
  .notice-action { margin-left: 34px; align-self: flex-start; }
}
.spam-check { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2);
  display: flex; flex-direction: column; gap: 8px; }
.spam-issues { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.spam-issues .lvl-fail { color: var(--bad); }
.spam-issues .lvl-fail span:first-child { font-weight: 600; }
.spam-issues .lvl-warn span:first-child { color: var(--warn-ink); }
.spam-issues .lvl-info span:first-child { color: var(--ink-2); }
.health-check { border-top: 1px solid var(--line-2); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.health-check .fix { color: var(--ink); overflow-wrap: anywhere; }

/* ---------- replies, analytics, follow-ups */
.nav-count { margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--ink); color: var(--card);
  font-size: 11px; font-weight: 500; line-height: 18px; text-align: center; }
input.input-xs { width: 72px; flex: none; min-height: 30px; padding: 3px 8px; text-align: center; }
input:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--ink-2); }
.checkbox-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.row.align-end { align-items: flex-end; }
details.divided { border-top: 1px solid var(--line-2); padding-top: 12px; margin-top: 4px; }
td.actions, th.actions { text-align: right; white-space: nowrap; }
td:last-child:has(> .btn:only-child) { text-align: right; }
.fu-step { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: var(--surface-2); }
.fu-step textarea { min-height: 70px; }
.reply-snippet { max-width: 520px; white-space: normal; color: var(--muted); }
.cat-select { min-height: 28px; padding: 2px 26px 2px 8px; font-size: 13px; }
.bar-row { display: grid; grid-template-columns: 44px 1fr 96px; gap: 12px; align-items: center; margin: 8px 0; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.bar > span.w0 { width: 0; }
details > summary { cursor: pointer; }
.btn-link { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 500; cursor: pointer; font: inherit; text-align: left;
  text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.btn-link:hover { color: var(--brand); text-decoration-color: currentColor; }
.row-done td { opacity: .55; }
#replies-filter { flex-wrap: wrap; }

/* ---------- phones: tables that turn into stacked cards */
@media (max-width: 640px) {
  table.stack-table thead { display: none; }
  table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
  table.stack-table td { border: 0; padding: 3px 0; }
  table.stack-table td.reply-snippet { max-width: none; }
  table.stack-table td[data-label="Category"], table.stack-table td[data-label="Received"] { display: inline-block; width: auto; margin-right: 10px; }
  table.stack-table td.actions { display: inline-block; width: auto; float: right; }
  table.stack-table .cat-select { width: auto; }
  table.senders-table td { display: inline-block; width: auto; margin-right: 8px; vertical-align: middle; }
  table.senders-table td:first-child, table.senders-table td.actions-cell { display: block; width: 100%; }
  table.senders-table td.actions-cell { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
}

/* ---------- two-factor */
.setup-key { font-family: var(--mono); font-size: 14px; letter-spacing: .06em; word-break: break-all; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.recovery-codes code { font-family: var(--mono); font-size: 14px; padding: 7px 10px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* ---------- onboarding checklist */
.onboarding .setup-step { padding: 11px 0; border-bottom: 1px solid var(--line-2); border-top: 0; }
.onboarding .setup-step:last-child { border-bottom: 0; }
.onboarding .setup-step.done > .row > div > div:first-child { color: var(--muted); }
.step-check { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-strong); display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: var(--on-brand); }
.step-check.on { background: var(--brand); border-color: var(--brand); }
.mailbox-help summary { cursor: pointer; font-weight: 500; font-size: 13px; color: var(--ink); }
.mailbox-help ol { margin: 6px 0 0 18px; padding: 0; font-size: 13px; color: var(--ink-2); }
.mailbox-help li { margin: 3px 0; }
.card-inset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); margin-bottom: 14px; }
.oauth-connect { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--card); }

/* The logo mark is near-black: give it a hairline edge where the background is dark too. */
:root[data-theme="dark"] .brand img, :root[data-theme="dark"] .brand-mini img, :root[data-theme="dark"] .logo-sm,
:root[data-theme="dark"] .logo img { border-radius: 7px; box-shadow: 0 0 0 1px var(--line-strong); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand img, :root:not([data-theme="light"]) .brand-mini img,
  :root:not([data-theme="light"]) .logo-sm, :root:not([data-theme="light"]) .logo img { border-radius: 7px; box-shadow: 0 0 0 1px var(--line-strong); }
}

/* ------------------------------------------------------------------ mailbox picker */
#sender-picker-field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; color: var(--ink-2); font-size: 13px; }
.mailbox-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mailbox-chip { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  font-size: 13px; font-weight: 500; color: var(--ink-2); }
.mailbox-chip:hover { border-color: var(--faint); color: var(--ink); }
.mailbox-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mailbox-chip.active { border-color: var(--brand); color: var(--ink); box-shadow: 0 0 0 1px var(--brand) inset; }
.mailbox-chip.new { border-style: dashed; color: var(--muted); }
.mailbox-chip.new.active { color: var(--ink); }
.mailbox-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.mailbox-chip .dot.on { background: var(--ok); }
.mailbox-chip .trunc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#remember-wrap { margin-top: -4px; }

/* ------------------------------------------------------------------ recipient rows: edit / remove */
.leads-table .actions-col { width: 1%; white-space: nowrap; text-align: right; padding-left: 4px; }
.row-actions { display: inline-flex; gap: 2px; }
.row-btn { all: unset; box-sizing: border-box; cursor: pointer; width: 30px; height: 30px; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted); }
.row-btn:hover { color: var(--ink); background: var(--surface-2); }
.row-btn.danger:hover { color: var(--bad); background: var(--bad-50); }
.row-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.row-btn svg { width: 15px; height: 15px; }
.lead-edit { display: flex; gap: 8px; align-items: center; }
.lead-edit input { flex: 1; min-width: 0; height: 32px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
  .lead-edit { flex-wrap: wrap; }
  .lead-edit input { flex-basis: 100%; }
}

/* ------------------------------------------------------------------ sending speed */
.speed-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.speed-field .strong { font-weight: 600; color: var(--ink); }
#speed-switch button:disabled { opacity: .45; cursor: not-allowed; }
#speed-hint { margin-top: -4px; }
hr.soft { border: 0; border-top: 1px solid var(--line-2); margin: 4px 0; }

/* ------------------------------------------------------------------ inbox status line (Replies) */
.inbox-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.inbox-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none;
  box-shadow: 0 0 0 3px var(--ok-50); }
.inbox-status b { color: var(--ink-2); font-weight: 600; }

/* ------------------------------------------------------------------ contacts: auto-save, samples */
.auto-save-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.switch-line { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; max-width: 640px; }
.switch-line .block { display: block; margin-top: 2px; font-weight: 400; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 36px; height: 20px; margin-top: 1px; border-radius: 999px;
  background: var(--faint); position: relative; cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sample-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: flex; flex-direction: column;
  gap: 10px; background: var(--surface-2); min-width: 0; }
.sample-top { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sample-top .trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-body { color: var(--muted); margin: 0; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sample-full { white-space: pre-wrap; font-family: var(--sans); font-size: 14px; line-height: 1.6; margin: 4px 0 0;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); max-height: 320px; overflow: auto; }

/* ------------------------------------------------------------------ sidebar: theme + sign out on one line */
.sidebar-actions { display: flex; gap: 6px; margin-top: 8px; }
.sidebar-actions .btn { flex: 1 1 0; min-width: 0; justify-content: center; height: 32px; padding: 0 8px; font-weight: 500;
  color: var(--ink-2); border: 1px solid var(--line); gap: 6px; white-space: nowrap; }
.sidebar-actions .btn:hover { color: var(--ink); background: var(--surface-2); }
.sidebar-actions .btn svg { width: 15px; height: 15px; flex: none; }
