/* ---- Tokens ----
   Type: Inter for UI text and data, Familjen Grotesk for headings.
   Every status gets its OWN hue: ready/researching/writing/sending used to
   share one teal, which made the table's most important distinction — is this
   draft waiting for me, or is the machine still working on it? — invisible.
*/
:root {
  color-scheme: light;

  /* Internix brand — from the logo: navy ink, periwinkle blue, amber. The
     page is a cool near-white; structure comes from hairline borders, not
     from shadows or tinted grounds. */
  --cream: #F5F2E9;
  --navy: #0F1126;
  --navy-2: #1A1D3A;
  --blue: #666EFF;
  --amber: #F4B544;
  --amber-soft: #FFF6E0;
  --amber-ink: #8A5A00;

  --bg: #FCFCFD;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EEF0F4;
  --field: #FFFFFF;
  --border: #DFE2E9;
  --border-soft: #ECEEF2;
  --text: #191C2E;
  --text-2: #3A3F52;
  --text-muted: #6A7082;
  --text-dim: #9AA0AE;

  /* The brand blue, deepened just enough for white text to pass contrast. */
  --accent: #4A56E8;
  --accent-hover: #3A45CC;
  --accent-ink: #FFFFFF;
  --accent-soft: #EEF0FF;
  --grad-brand: linear-gradient(180deg, #6B79FE 0%, #3B4ADB 100%);

  /* One hue per pipeline stage. "Waiting for YOU" (ready) is the brand
     blue; "machine working" is teal; problems are warm reds. */
  --st-pending: #7A7C90;
  --st-research: #0E8A9C;
  --st-write: #0B7285;
  --st-ready: #4A56E8;
  --st-queued: #8B63E6;
  --st-sending: #7447D6;
  --st-sent: #16803C;
  --st-failed: #D0453A;
  --st-retry: #C2610C;
  --st-bounced: #B42318;
  --warn: #A86A06;
  --st-skipped: #A5A7B8;

  /* Inter for everything read, Familjen Grotesk for headings. Data (emails,
     counts, timestamps) stays in the UI face with tabular digits; only logs
     and code use a monospace. */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Familjen Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-code: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 1px rgba(25, 28, 46, .05);
  --shadow: 0 1px 2px rgba(25, 28, 46, .05);
  --shadow-lg: 0 20px 25px -5px rgba(25, 28, 46, .08), 0 8px 10px -6px rgba(25, 28, 46, .05);
}

* { box-sizing: border-box; }

/* An author-level `display` (e.g. .batch-actions{display:flex}) outranks the
   UA stylesheet's [hidden]{display:none}, which would leave JS-toggled
   elements — the batch bar, send toast, modal — permanently on screen. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Respect a reduced-motion preference for the pulse/shake/transition effects. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Wide enough for the 9-column tracker table to breathe — at 1040px every
   column truncated to an ellipsis and the timestamps read "202…". */
.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 48px 32px 96px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cell-mono { font-family: var(--font-mono); font-size: 13px; color: var(--text-2); }

/* Top bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

h1 { font-size: 26px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
.subtitle { margin: 0; color: var(--text-muted); font-size: 14px; }

.live-note {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted); font-family: var(--font-mono);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--st-skipped);
  box-shadow: 0 0 0 3px rgba(152, 162, 179, 0.22);
}
.live-note--active { color: var(--accent); }
.dot--pulse {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.topbar-right { display: flex; align-items: center; gap: 18px; }
.workspace-section, .run-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 24px; margin-bottom: 24px;
}
.section-heading, .run-section { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.section-heading { margin-bottom: 22px; }
.section-heading h2, .run-section h2 { margin: 4px 0 4px; font-size: 18px; }
.section-copy { margin: 0; color: var(--text-muted); font-size: 13px; }
.eyebrow { color: var(--accent); font: 600 11px var(--font-mono); text-transform: uppercase; letter-spacing: .08em; }
.setup-status, .run-label { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font: 12px var(--font-mono); white-space: nowrap; }
.setup-status--ready { color: var(--st-sent); }
.setup-status--ready .dot { background: var(--st-sent); }
.setup-status--partial { color: var(--warn); }
.setup-status--partial .dot { background: var(--warn); }
.flash-stack { display: grid; gap: 8px; margin: -16px 0 24px; }
.flash { padding: 11px 14px; border-radius: 7px; font-size: 13px; border: 1px solid; }
.flash--success { color: var(--st-sent); background: rgba(21,128,61,.08); border-color: rgba(21,128,61,.25); }
.flash--error { color: var(--st-failed); background: rgba(206,58,51,.08); border-color: rgba(206,58,51,.25); }
.setup-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-group { display: grid; gap: 6px; }
.form-group--wide { grid-column: 1 / -1; }
.form-group label { color: var(--text-2); font-size: 12px; font-weight: 600; }
/* Styled by exclusion rather than by listing each type: an input with no
   type attribute (or type=number/url/search) previously fell through every
   selector and rendered as a white browser-default box on this dark page. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font: 13px var(--font-ui);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input[type="file"] { padding: 7px; color: var(--text-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.field-hint { color: var(--text-dim); font-size: 11px; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; margin-top: 3px; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
/* Secondary actions read as outlined, not tinted — on white a filled ghost
   button competes with the primary one. */
.button--ghost { color: var(--accent); background: var(--surface); border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border)); white-space: nowrap; }
.button--ghost:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.validation-result:empty { display: none; }
.validation-result { display: block; margin-top: 2px; font-size: 12px; }
.validation-result--ok { color: var(--st-sent); }
.validation-result--bad { color: var(--st-failed); }
/* One border on every button, so primary/ghost/danger keep the same footprint
   and a row of them lines up on the baseline. */
.button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font: 600 13px var(--font-ui);
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, color .14s ease;
}
.button--primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button--danger { color: var(--st-failed); background: color-mix(in srgb, var(--st-failed) 7%, #fff); border-color: color-mix(in srgb, var(--st-failed) 30%, #fff); }
.button--danger:hover { background: color-mix(in srgb, var(--st-failed) 13%, #fff); border-color: color-mix(in srgb, var(--st-failed) 45%, #fff); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button:disabled:hover { background: inherit; }
.run-section { align-items: center; background: linear-gradient(100deg, var(--accent-soft), var(--surface) 62%); border-color: color-mix(in srgb, var(--accent) 22%, var(--border)); }
.progress-section { padding: 0 2px 24px; }
.progress-heading { display: flex; justify-content: space-between; color: var(--text-muted); font: 12px var(--font-mono); margin-bottom: 8px; }
.progress-heading strong { color: var(--text); font-weight: 500; }
.run-form { display: flex; align-items: center; gap: 18px; }
.check-control { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.check-control input { accent-color: var(--accent); }
.refresh-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none;
}
.refresh-toggle input { accent-color: var(--accent); cursor: pointer; }

/* Daily send cap progress bar */
.cap-bar-section { margin-bottom: 24px; }
.cap-bar-label {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px;
}
.cap-bar-track {
  height: 6px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--border); overflow: hidden;
}
.cap-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }
.cap-bar-fill--full { background: var(--warn); }

/* Table controls: search + status filter */
.table-controls {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.search-box, .status-filter {
  background: var(--field); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 7px 10px; font-size: 13px; font-family: var(--font-ui);
}
.search-box { flex: 1; min-width: 160px; }
.search-box:focus, .status-filter:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.visible-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-family: var(--font-mono); }

/* Undelivered or failed sends: a red edge and tint so they stand out in the list. */
tr.row--problem > td { background: rgba(180,35,24,.07); }
tr.row--problem > td:first-child { box-shadow: inset 3px 0 0 var(--st-bounced); }
tr.row--problem .row-error { color: var(--st-failed); }
.status-pill.status-bounced { font-weight: 600; }

.row-error {
  margin-top: 3px; font-size: 11.5px; color: var(--st-failed);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Funnel: the five pipeline stages, in order, each a link that filters
   the table. Replaces a row of up to 11 identical raw-status cards. ── */
.funnel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 860px) { .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .funnel { grid-template-columns: 1fr; } }

.funnel-card {
  display: block;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, background .15s, transform .15s;
}
.funnel-card:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--stage, var(--accent)) 55%, var(--border));
  background: color-mix(in srgb, var(--stage, var(--accent)) 6%, var(--surface));
}
.funnel-card--active {
  border-color: var(--stage, var(--accent));
  background: color-mix(in srgb, var(--stage, var(--accent)) 10%, var(--surface));
}
.funnel-card__value {
  font-family: var(--font-mono);
  font-size: 26px; font-weight: 600; line-height: 1.1;
  color: var(--stage, var(--text));
}
.funnel-card__label { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.funnel-card__meta { font-size: 11px; color: var(--text-dim); margin-top: 6px; font-family: var(--font-mono); }
.funnel-card__meta--danger { color: var(--st-bounced); font-weight: 600; }
.funnel-card--to_prepare { --stage: var(--st-research); }
.funnel-card--ready      { --stage: var(--st-ready); }
.funnel-card--sending    { --stage: var(--st-sending); }
.funnel-card--sent       { --stage: var(--st-sent); }
.funnel-card--problems   { --stage: var(--st-failed); }

.funnel-mini-track {
  height: 4px; border-radius: 999px; background: var(--surface-3);
  margin-top: 8px; overflow: hidden;
}
.funnel-mini-fill { height: 100%; border-radius: 999px; background: var(--stage, var(--accent)); transition: width .3s ease; }

/* ── Status tabs above the table ── */
.status-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 12px 16px 0;
}
.status-tab {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  text-decoration: none;
  white-space: nowrap;
}
.status-tab:hover { color: var(--text); border-color: var(--text-dim); text-decoration: none; }
.status-tab--active {
  color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600;
}
.status-tab__count { opacity: .75; font-family: var(--font-mono); font-size: 11.5px; }

/* Table */
.table-section { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* The table has 9 columns — without its own scroll container it forced the
   whole page to scroll sideways on a laptop or phone. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Fixed layout so the long free-text columns (subject, email) truncate to
   their share instead of pushing the row-actions column off the right edge —
   the Send button was unreachable at 1440px before this. */
.app-table {
  width: 100%; min-width: 900px;
  border-collapse: collapse; background: var(--surface-2);
  table-layout: fixed;
}
/* All-percentage so the widths always total exactly the table width — mixing
   px and % here overflowed the container and clipped the actions column. */
.app-table th:nth-child(1), .app-table td:nth-child(1) { width: 3%; }    /* checkbox */
.app-table th:nth-child(2), .app-table td:nth-child(2) { width: 4%; }    /* id */
.app-table th:nth-child(3), .app-table td:nth-child(3) { width: 14%; }   /* company */
.app-table th:nth-child(4), .app-table td:nth-child(4) { width: 15%; }   /* email */
.app-table th:nth-child(5), .app-table td:nth-child(5) { width: 13%; }   /* status */
.app-table th:nth-child(6), .app-table td:nth-child(6) { width: 8%; overflow: hidden; } /* extras */
.app-table th:nth-child(7), .app-table td:nth-child(7) { width: 16%; }   /* subject */
.app-table th:nth-child(8), .app-table td:nth-child(8) { width: 10%; padding-left: 8px; padding-right: 8px; } /* updated */
.app-table th:nth-child(9), .app-table td:nth-child(9) { width: 17%; padding-left: 8px; } /* actions */

.app-table th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--surface-3);
  font-size: 14px;
  vertical-align: middle;
}

.app-table tr:last-child td { border-bottom: none; }
.app-table tr:hover td { background: var(--surface-3); }

.cell-company { font-weight: 500; }
/* Truncate rather than wrap, so a long subject or address can't make one row
   three lines tall and push the rest of the table out of view. */
.cell-company, .cell-subject, .app-table .cell-mono {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cell-subject { color: var(--text-2); }
.cell-empty { color: var(--st-skipped); }
.cell-time { white-space: nowrap; }

.detail-link {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.detail-col { min-width: 0; }
.panel-heading-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.email-editor { display: grid; gap: 7px; }
.email-editor label { color: var(--text-muted); font-size: 12px; font-weight: 600; margin-top: 6px; }
.email-editor input, .email-editor textarea {
  width: 100%; background: var(--field); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 10px; font: 13.5px/1.6 var(--font-ui); resize: vertical;
}
.email-editor textarea { font-family: var(--font-mono); font-size: 12px; }

/* Status pills — each status has its own hue (see :root tokens), plus a dot,
   so the pipeline stage is readable at a glance and doesn't rely on color
   alone being distinguishable. */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  color: var(--pill, var(--text-muted));
  background: color-mix(in srgb, var(--pill, var(--text-muted)) 13%, transparent);
  border-color: color-mix(in srgb, var(--pill, var(--text-muted)) 28%, transparent);
}
.status-pill::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--pill, var(--text-muted));
  flex-shrink: 0;
}
.status-pill--lg { padding: 6px 14px; font-size: 13px; }

.status-pending     { --pill: var(--st-pending); }
.status-researching { --pill: var(--st-research); }
.status-researched  { --pill: var(--st-research); }
.status-writing     { --pill: var(--st-write); }
.status-ready       { --pill: var(--st-ready); }
.status-queued      { --pill: var(--st-queued); }
.status-sending     { --pill: var(--st-sending); }
.status-sent        { --pill: var(--st-sent); }
.status-failed      { --pill: var(--st-failed); }
.status-retry_wait  { --pill: var(--st-retry); }
.status-bounced     { --pill: var(--st-bounced); }
.status-skipped     { --pill: var(--st-skipped); }

/* An actively-running stage pulses its dot, so "the machine is working on
   this right now" is distinguishable from "it's parked at this stage". */
.status-researching::before,
.status-writing::before,
.status-sending::before { animation: pulse 1.6s ease-in-out infinite; }

/* Chips */
.chip {
  display: inline-block;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
  margin: 2px 4px 2px 0;
  font-family: var(--font-mono);
}
.chip--accent { background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent); }

/* Empty state */
.empty-state { padding: 56px 24px; text-align: center; color: var(--text-muted); }
.empty-hint { font-size: 13.5px; }
.empty-hint code {
  background: var(--surface-3); padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono); color: var(--text-2);
}

/* Detail page */
.back-link { display: inline-block; margin-bottom: 20px; font-size: 13.5px; color: var(--text-muted); }
.back-link:hover { color: var(--accent); }

.detail-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}

.error-box {
  background: rgba(206, 58, 51,0.08);
  border: 1px solid rgba(206, 58, 51,0.25);
  color: var(--st-failed);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 24px;
}

.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
@media (max-width: 680px) {
  .page { padding: 28px 16px 64px; }
  .topbar, .section-heading, .run-section { display: block; }
  .topbar-right, .setup-status, .run-form { margin-top: 16px; }
  .setup-form { grid-template-columns: 1fr; }
  .form-group--wide, .form-actions { grid-column: auto; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 20px;
}

.panel h2 { font-size: 15px; margin: 0 0 14px; font-weight: 600; }
.panel h3 { font-size: 13px; color: var(--text-muted); margin: 18px 0 8px; font-weight: 500; }

.fact-list { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.fact-list dt { color: var(--text-muted); }
.fact-list dd { margin: 0; color: var(--text); }

.bullet-list { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--text-2); }
.bullet-list li { margin-bottom: 4px; }

.reasoning-list { list-style: none; margin: 0; padding: 0; }
.reasoning-list li { margin-bottom: 12px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.reasoning-text { font-size: 13.5px; color: var(--text-2); }

.email-subject { font-size: 13.5px; color: var(--text-2); margin: 0 0 12px; }
.email-body {
  white-space: pre-wrap;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  max-height: 420px;
  overflow-y: auto;
}

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.timeline-item { position: relative; padding: 0 0 20px 20px; }
.timeline-item::before {
  content: "";
  position: absolute; left: -6px; top: 3px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-stage {
  font-family: var(--font-mono);
  font-size: 11px; text-transform: lowercase;
  color: var(--accent); margin-right: 8px;
}
.timeline-time { font-size: 11.5px; }
.timeline-message { margin: 6px 0 0; font-size: 13.5px; color: var(--text); }

/* ── Google OAuth button ── */
.button-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 10px 18px;
  font: 600 14px var(--font-ui);
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow 0.18s, background 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
  user-select: none;
}
.button-google:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
  text-decoration: none;
  color: #3c4043;
}
.button-google:active { background: #f1f3f4; }
.google-icon { width: 20px; height: 20px; flex-shrink: 0; }
.google-icon-sm { width: 26px; height: 26px; flex-shrink: 0; }

/* ── Google connect card (disconnected state) ── */
.google-connect-card {
  background: var(--field);
  border: 1px dashed color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 10px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.google-connect-desc {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ── Google connected card (connected state) ── */
.google-connected-card {
  background: linear-gradient(100deg, color-mix(in srgb, var(--st-sent) 9%, #fff), var(--surface) 62%);
  border: 1px solid rgba(21, 128, 61,0.3);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.google-connected-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.google-connected-email {
  font-weight: 600;
  font-size: 14px;
  color: var(--st-sent);
}
.google-connected-label {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}
.button--sm { padding: 6px 12px; font-size: 12px; }

/* ── SMTP fallback collapsible ── */
.smtp-fallback {
  margin-top: 12px;
}
.smtp-fallback-toggle {
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  user-select: none;
}
.smtp-fallback-toggle::before {
  content: "▶";
  font-size: 9px;
  transition: transform 0.2s;
}
details[open] .smtp-fallback-toggle::before { transform: rotate(90deg); }
.smtp-fallback-toggle:hover { color: var(--text-2); }
.smtp-fallback-body {
  border-left: 2px solid var(--border);
  padding-left: 16px;
  margin-top: 6px;
}

/* ── Google OAuth one-time setup guide ── */
.oauth-guide { margin-top: 12px; }
.oauth-steps {
  margin: 8px 0 8px;
  padding-left: 20px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  border-left: 2px solid var(--border);
}
.oauth-steps li { margin-bottom: 6px; }
.oauth-steps a { color: var(--accent); }
.oauth-steps code.copyable {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--accent);
  user-select: all;
  word-break: break-all;
}
.oauth-upload { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.oauth-upload input[type=file] { font-size: 12px; color: var(--text-2); max-width: 100%; }
.text-danger { color: var(--st-failed); }

/* ── Error shake animation (applied via JS on bad validation) ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-5px); }
  30%       { transform: translateX(5px); }
  45%       { transform: translateX(-4px); }
  60%       { transform: translateX(4px); }
  75%       { transform: translateX(-2px); }
  90%       { transform: translateX(2px); }
}
.input-error {
  border-color: var(--st-failed) !important;
  box-shadow: 0 0 0 2px rgba(206, 58, 51,0.18) !important;
}
.shake {
  animation: shake 0.45s ease-in-out;
}

/* ── Gmail section label area ── */
.gmail-section > label {
  display: block;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ── Batch action bar ── */
.batch-actions {
  position: sticky; bottom: 0; z-index: 100;
  display: flex; justify-content: center; padding: 12px 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  pointer-events: none;
}
.batch-actions-inner {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 12px;
  padding: 12px 22px;
  box-shadow: var(--shadow-lg), 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent);
  pointer-events: auto;
  font: 13px var(--font-mono); color: var(--text-2);
}

/* ── Row checkboxes ── */
.row-select-cb, #select-all-cb {
  accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer;
}
.app-table th:first-child, .app-table td:first-child {
  width: 36px; text-align: center; padding-left: 12px; padding-right: 4px;
}

/* ── Row actions ── */
/* Not display:flex — a flex <td> stops being a table cell, so it lost the
   row's height and background (visible as a gap in tinted problem rows). */
td.row-actions { white-space: nowrap; }
td.row-actions > * + * { margin-left: 8px; }

/* ── Send toast ── */
.send-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200;
}
.send-toast-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 22px; min-width: 380px;
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text);
}
.send-toast-bar {
  height: 4px; background: var(--surface-3); border-radius: 999px;
  margin-top: 10px; overflow: hidden;
}
.send-toast-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width 0.3s ease; width: 0%;
}

/* ── Collapsible setup + pagination ── */
.setup-collapse { margin-top: 24px; }
.setup-collapse-toggle {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2);
  padding: 12px 0; list-style: none;
}
.setup-collapse-toggle::-webkit-details-marker { display: none; }
.pagination {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  margin-top: 16px; font-size: 13px; color: var(--text-muted);
}
.pagination-label { font-family: var(--font-mono); }
.batch-limit-label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.batch-limit-input { width: 88px; padding: 6px 8px; }

/* ── Setup checklist (shown until the workspace is usable) ── */
.checklist {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px;
}
.checklist--partial { border-color: rgba(169, 98, 8,.35); }
.checklist h2 { margin: 6px 0 4px; font-size: 17px; }
.checklist-items { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.checklist-item { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; }
.checklist-mark {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px;
}
.checklist-item--done .checklist-mark { background: rgba(21,128,61,.16); color: var(--st-sent); }
.checklist-item--todo .checklist-mark { background: var(--surface-3); color: var(--text-dim); border: 1px dashed var(--border); }
.checklist-item--done .checklist-text { color: var(--text-2); }
.checklist-item--todo .checklist-text { color: var(--text-muted); }
.checklist-note { font-size: 11.5px; color: var(--text-dim); display: block; margin-top: 2px; }

/* ── Workspace summary bar (replaces the checklist once ready) ── */
.workspace-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px;
  font-size: 12.5px; color: var(--text-muted);
}
.workspace-bar__facts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.workspace-bar__fact { display: flex; align-items: center; gap: 6px; }
.workspace-bar__fact strong { color: var(--text-2); font-weight: 500; }

/* ── Confirm modal (replaces window.confirm for sends) ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(21, 26, 33, .38);
  backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px 24px;
  width: min(480px, 100%);
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal-copy { margin: 0 0 14px; font-size: 13.5px; color: var(--text-muted); }
.modal-list {
  margin: 0 0 16px; padding: 10px 12px; max-height: 190px; overflow-y: auto;
  background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: 12px var(--font-mono); color: var(--text-2);
  list-style: none;
}
.modal-list li { padding: 2px 0; }
.modal-warn { color: var(--warn); font-size: 12.5px; margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── Activity log panel ── */
.log-panel { margin-top: 12px; }
.log-panel-toggle {
  cursor: pointer; font-size: 12.5px; color: var(--text-muted);
  list-style: none; padding: 6px 0; user-select: none;
}
.log-panel-toggle::-webkit-details-marker { display: none; }
.log-panel-toggle:hover { color: var(--text-2); }
.log-output {
  white-space: pre-wrap; font: 11.5px/1.65 var(--font-mono);
  color: var(--text-2); background: var(--surface-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; max-height: 260px; overflow-y: auto; margin: 8px 0 0;
}

/* ── Detail page: Edit / Preview tabs + rendered email preview ── */
.detail-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.detail-tab {
  padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: transparent; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer;
}
.detail-tab--active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.detail-panel[hidden] { display: none; }

.email-preview {
  background: var(--field); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden;
}
.email-preview__headers {
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-3);
  display: grid; grid-template-columns: 62px 1fr; gap: 4px 10px;
  font-size: 12.5px;
}
.email-preview__key { color: var(--text-dim); font-family: var(--font-mono); font-size: 11.5px; }
.email-preview__val { color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.email-preview__subject { color: var(--text); font-weight: 600; }
/* No max-height: the whole email is the thing being reviewed before an
   irreversible send, so it should never be clipped mid-sentence. */
.email-preview__body {
  padding: 18px 20px 4px; white-space: pre-wrap;
  font-size: 13.5px; line-height: 1.75; color: var(--text);
}
.attachment-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 16px 14px; padding: 7px 12px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-2);
}
.attachment-chip--missing { color: var(--warn); border-color: rgba(169,98,8,.3); }
.word-count { font: 11.5px var(--font-mono); color: var(--text-dim); }
.word-count--warn { color: var(--warn); }

/* Editing a draft in place: the save button, what state the draft is in, and
   a warning on the preview while it is mirroring text that isn't saved. */
.editor-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.editor-actions .editor-hint { margin-left: auto; }
.save-state { font: 11.5px var(--font-mono); color: var(--text-dim); }
.save-state--dirty { color: var(--warn); }
.save-state--ok { color: var(--st-sent); }
.save-state--bad { color: var(--st-failed); }
.preview-dirty {
  margin: 0 0 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: rgba(169, 98, 8,.09);
  border: 1px solid rgba(169, 98, 8,.28);
  color: var(--warn);
  font-size: 12px;
}
@media (max-width: 560px) {
  .editor-actions .editor-hint { margin-left: 0; }
}

.detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-nav { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }

.detail-topline {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.detail-topline .back-link { margin-bottom: 0; }
.timeline-detail { margin-top: 8px; }
.timeline-detail-toggle {
  cursor: pointer; font-size: 11.5px; color: var(--text-dim);
  list-style: none; user-select: none;
}
.timeline-detail-toggle::-webkit-details-marker { display: none; }
.timeline-detail-toggle:hover { color: var(--text-muted); }
.timeline-detail .log-output { max-height: 220px; margin-top: 6px; }

/* Stage-colored timeline dots, matching the status pill hues. */
.timeline-item--research::before { background: var(--st-research); }
.timeline-item--write::before    { background: var(--st-write); }
.timeline-item--send::before     { background: var(--st-sent); }
.timeline-item--bounce_check::before { background: var(--st-bounced); }
.timeline-item--skip::before     { background: var(--st-skipped); }

/* ── Table: drop the lowest-value columns before the layout gets cramped ── */
@media (max-width: 980px) {
  .app-table .col-extras, .app-table .col-updated { display: none; }
}
@media (max-width: 720px) {
  .app-table .col-email { display: none; }
  .app-table th, .app-table td { padding: 11px 12px; }
}

/* ── Undelivered-email alert ── */
.delivery-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(180,35,24,.45);
  background: rgba(180,35,24,.12);
  color: var(--st-failed);
  font-size: 13.5px;
  text-decoration: none;
}
.delivery-alert:hover { background: rgba(180,35,24,.18); }
.delivery-alert__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--st-bounced);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}


/* ---- Settings page ----
   The tracker used to carry every credential, file and pacing field inside
   one collapsed <details> at the bottom of the page — a single 2-column wall
   of ~15 inputs with no grouping. They live here now: one card per concern,
   a sticky index that shows at a glance which concern is still unfinished.
*/
.settings-button { display: inline-flex; align-items: center; gap: 7px; }
.settings-button__icon {
  width: 15px; height: 15px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round;
}
/* Nothing works until a key and a list exist, so the way there is marked. */
.settings-button--attention {
  border-color: rgba(169, 98, 8,.45);
  color: var(--warn);
}

.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.settings-nav {
  position: sticky; top: 24px;
  display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
}
.settings-nav__link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13px; font-weight: 500;
}
.settings-nav__link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.settings-nav__mark {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--st-sent);
  box-shadow: 0 0 0 3px rgba(21, 128, 61,.13);
}
.settings-nav__mark--todo {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(169, 98, 8,.13);
}
.settings-nav__note {
  margin: 10px 8px 4px; padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-dim); font-size: 11px; line-height: 1.5;
}

.settings-main { display: grid; gap: 20px; }

.settings-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  /* So an in-page jump doesn't tuck the heading under the sticky nav. */
  scroll-margin-top: 24px;
}
.settings-card__head { margin-bottom: 20px; }
.settings-card__head h2 { margin: 0 0 6px; font-size: 17px; }

.settings-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px;
}

.settings-actions {
  position: sticky; bottom: 0;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
}
.settings-actions .field-hint { margin-left: auto; }

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-actions .field-hint { margin-left: 0; }
}


/* ---------------------------------------------------------------------------
   Light-ground refinements
   The layout above was drawn for a dark page, where a 1px #262B34 border was
   the only thing separating a panel from the background. On white a border
   that heavy reads as a box inside a box, so the separating moves to a
   hairline plus a shadow and the borders lighten.
   --------------------------------------------------------------------------- */

.panel, .workspace-section, .run-section, .settings-card, .settings-nav {
  box-shadow: var(--shadow-sm);
}

/* Motion: short, and only on things that answer the pointer. */
a, .status-tab, .funnel-card, .detail-tab, .settings-nav__link {
  transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}
@media (prefers-reduced-motion: reduce) {
  a, .status-tab, .funnel-card, .detail-tab, .settings-nav__link, .button { transition: none; }
}

/* The funnel is the page's summary row, so it lifts on hover rather than only
   changing colour. */
.funnel-card { background: var(--surface); box-shadow: var(--shadow-sm); }
.funnel-card:hover { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.funnel-card--active { border-color: var(--accent); box-shadow: var(--shadow); }

/* Table: lighter rules, a quieter header, and digits that line up in columns. */
.app-table th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.app-table td { border-bottom: 1px solid var(--border-soft); }
.app-table td.col-updated, .visible-count, .funnel-card__value, .status-tab__count {
  font-variant-numeric: tabular-nums;
}

/* On white a field needs its own edge, and a soft ring reads better than a
   hard outline that clips against the border radius. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Favorites: a star per row, a toggle on the company page, and the
   favorites tab's own send bar. Gold is used nowhere else, so a starred
   row reads as starred at a glance. */
:root { --star: #9E6C00; }  /* ≥4.5:1 on white, so the active tab label stays legible */
.cell-select { white-space: nowrap; }
.cell-select .row-select-cb { margin-left: 6px; vertical-align: middle; }
.fav-btn {
  background: none; border: 0; padding: 2px 3px; cursor: pointer;
  font-size: 16px; line-height: 1; color: var(--text-dim);
  border-radius: 4px; vertical-align: middle;
  transition: color .12s ease, transform .12s ease;
}
.fav-btn:hover { color: var(--star); transform: scale(1.12); }
.fav-btn--on { color: var(--star); }
.fav-toggle--on { color: var(--star); border-color: color-mix(in srgb, var(--star) 45%, var(--border)); }
.fav-toggle--on:hover { background: color-mix(in srgb, var(--star) 8%, #fff); }
.status-tab--favorites.status-tab--active { color: var(--star); border-color: var(--star); }
.favorites-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--star) 30%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--star) 6%, #fff);
}
.favorites-bar__text { font-size: 13.5px; color: var(--text-2); }
.favorites-bar__text strong { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .fav-btn { transition: none; } }

/* Model pool: one pill per model, coloured by what the live check found. */
.pool-table td { vertical-align: middle; }
.pool-state { display: flex; flex-direction: column; gap: 3px; }
.pool-pill {
  align-self: flex-start;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  --pool: var(--text-muted);
  color: var(--pool);
  background: color-mix(in srgb, var(--pool) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--pool) 26%, transparent);
}
.pool-pill--ok { --pool: var(--st-sent); }
.pool-pill--busy { --pool: var(--warn); }
.pool-pill--inactive, .pool-pill--unavailable { --pool: var(--st-retry); }
.pool-pill--bad_key, .pool-pill--error { --pool: var(--st-failed); }
.pool-detail { font-size: 11.5px; }

/* Timeline: a failed step says why in plain words, and superseded history
   folds into one line above the current attempt. */
.timeline-error {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--st-failed);
}
.timeline-item--failed .timeline-message { color: var(--text-muted); }
.timeline-earlier {
  margin: 4px 0 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.timeline-earlier__toggle {
  cursor: pointer;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  list-style: none;
}
.timeline-earlier__toggle::-webkit-details-marker { display: none; }
.timeline-earlier__toggle::before { content: "▸ "; color: var(--text-dim); }
.timeline-earlier[open] .timeline-earlier__toggle::before { content: "▾ "; }
.timeline-earlier[open] .timeline-earlier__toggle { border-bottom: 1px dashed var(--border); }
.timeline--earlier { padding: 6px 12px 10px; opacity: .85; }

/* Status pills need nothing here: they already tint from a --pill variable
   mixed against transparent, which lands correctly on any ground. Overriding
   them again would only create a cascade collision.

   Optical tightening at display sizes. */
h1 { letter-spacing: -0.018em; }
h2 { letter-spacing: -0.01em; }

/* =====================================================================
   Multi-user additions: navigation, sign-in, admin, profile, imports.
   Same tokens, same voice as everything above.
   ===================================================================== */

.page { padding-top: 32px; }

/* ---- Sign-in pages ---- */
.auth-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 32px; }
.auth-card--center { margin: 64px auto; text-align: center; }
.auth-card h1 { font-size: 22px; margin: 18px 0 6px; }
.auth-brand { display: flex; align-items: center; gap: 9px; color: var(--accent); font-weight: 700; font-size: 17px; }
.auth-brand span { color: var(--text); }
.auth-form { display: grid; gap: 14px; margin-top: 22px; }
.auth-form .flash-stack, .auth-card .flash-stack { margin: 16px 0 0; }
.auth-foot { margin: 20px 0 0; font-size: 13.5px; color: var(--text-muted); text-align: center; }
.button--block { width: 100%; justify-content: center; }

/* ---- Notices, segmented controls, small forms ---- */
.notice { display: block; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
  margin-bottom: 20px; font-size: 13.5px; color: var(--text-2); }
.notice--warn { border-color: rgba(169,98,8,.35); background: rgba(169,98,8,.07); color: var(--warn); }
a.notice:hover { text-decoration: none; background: rgba(169,98,8,.11); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); }
.segmented__item { position: relative; padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.segmented__item:hover { color: var(--text); text-decoration: none; }
.segmented__item--active, .segmented__item:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 500; }
.segmented__item input { position: absolute; opacity: 0; pointer-events: none; }
.segmented--small .segmented__item { padding: 5px 10px; font-size: 12.5px; }
.inline-form { display: inline; margin: 0; }
.stack-form { display: grid; gap: 12px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 13.5px; }
.choice:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); }
.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice .field-hint { display: block; margin-top: 2px; }
.subhead { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
.settings-stack { display: grid; gap: 20px; max-width: 880px; }

/* ---- Admin ---- */
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-table td { vertical-align: top; }
.admin-table th:nth-child(n), .admin-table td:nth-child(n) { width: auto; }
.status-tabs--compact { margin: 0; border: 0; padding: 0; }
.action-menu { position: relative; display: inline-block; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu__panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 290px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: grid; white-space: normal; }
.action-menu__panel form { margin: 0; }
.action-menu__panel button { width: 100%; text-align: left; padding: 8px 10px; font: inherit; font-size: 13px; color: var(--text-2);
  background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer; }
.action-menu__panel button:hover { background: var(--surface-3); }
.danger-zone { border-top: 1px solid var(--border-soft); margin-top: 4px !important; padding: 8px 4px 2px; display: grid; gap: 6px; }
.danger-zone input { font-size: 12px; padding: 6px 8px; }
.credential-box { margin: 20px 0; padding: 14px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius); }
.credential-box__secret { font-size: 15px; font-weight: 600; color: var(--text); user-select: all; }
.audit-detail { max-width: 360px; overflow-wrap: anywhere; font-size: 11.5px; }
.audit-table th:nth-child(n), .audit-table td:nth-child(n) { width: auto; }

/* ---- Settings: files, import, email method ---- */
.file-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border-soft); }
.file-current { margin: 0; font-size: 13.5px; }
.import-box { display: grid; gap: 12px; }
.import-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.import-form input[type=file] { font-size: 12.5px; max-width: 100%; }
.import-report { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2); font-size: 13.5px; }
.import-report--bad { border-color: rgba(206,58,51,.3); background: rgba(206,58,51,.05); }
.import-report--ok { border-color: rgba(21,128,61,.3); background: rgba(21,128,61,.06); }
.import-report__title { margin: 0 0 8px; font-weight: 600; }
.import-stats { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-muted); font-size: 12.5px; }
.import-stats strong { color: var(--text); font-family: var(--font-mono); }
.import-errors { margin: 4px 0 8px; padding-left: 18px; font-size: 12.5px; color: var(--st-failed); max-height: 180px; overflow: auto; }
.format-help__body { padding: 10px 0 4px; font-size: 13px; color: var(--text-2); }
.format-table { border-collapse: collapse; margin: 8px 0; font-size: 12.5px; }
.format-table th, .format-table td { text-align: left; padding: 5px 12px 5px 0; border-bottom: 1px solid var(--border-soft); }
.method-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
@media (max-width: 760px) { .method-picker { grid-template-columns: 1fr; } }
.method-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 13.5px; }
.method-card .field-hint { display: block; margin-top: 2px; }
.method-card input { margin-top: 3px; accent-color: var(--accent); }
.method-card--active { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: var(--accent-soft); }
.method-card:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.method-panel { margin-bottom: 14px; }
.pool-details { margin-top: 18px; border-top: 1px solid var(--border-soft); padding-top: 14px; }

/* ---- Language: chips and the EN | FR switch ---- */
.lang-chip { display: inline-block; font: 600 10.5px/1 var(--font-mono); letter-spacing: .04em; padding: 3px 5px;
  border-radius: 4px; border: 1px solid var(--border); color: var(--text-muted); background: var(--surface-2); vertical-align: 1px; }
.lang-chip--fr { color: #1C4FB0; border-color: rgba(28,79,176,.3); background: rgba(28,79,176,.06); }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.lang-switch__option { font: 600 12px var(--font-mono); padding: 7px 12px; border: 0; background: none; color: var(--text-muted); cursor: pointer; }
.lang-switch__option + .lang-switch__option { border-left: 1px solid var(--border); }
.lang-switch__option:hover { background: var(--surface-3); color: var(--text); }
.lang-switch__option--active { background: var(--accent); color: var(--accent-ink); cursor: default; }
.lang-switch__option--active:hover { background: var(--accent); color: var(--accent-ink); }

/* ---- Profile ---- */
.profile-steps { display: grid; gap: 20px; }
.profile-step__summary { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; list-style: none; margin-bottom: 4px; }
.profile-step__summary::-webkit-details-marker { display: none; }
.profile-step__summary--static { cursor: default; margin-bottom: 18px; }
.profile-step[open] > .profile-step__summary { margin-bottom: 20px; }
.profile-step__summary strong { font-size: 16px; display: block; }
.profile-step__summary .field-hint { display: block; margin-top: 3px; font-size: 12.5px; }
.profile-step__num { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 18px; }
.template-card { position: relative; display: grid; gap: 6px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; background: var(--surface); transition: border-color .15s, background .15s; }
.template-card input { position: absolute; top: 12px; right: 12px; accent-color: var(--accent); }
.template-card strong { font-size: 14px; padding-right: 22px; }
.template-card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.template-card--active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.template-card--disabled { opacity: .5; cursor: not-allowed; }
.preview-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
@media (max-width: 900px) { .preview-pair { grid-template-columns: 1fr; } }
.preview-pair .email-preview__body { font-size: 13px; }

.profile-editor { display: grid; gap: 26px; }
.editor-section { display: grid; gap: 14px; }
.pair { display: grid; gap: 6px; }
.pair__label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.pair__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 760px) { .pair__row { grid-template-columns: 1fr; } }
.pair__cell { display: grid; gap: 4px; }
.pair__lang { font: 600 10.5px var(--font-mono); color: var(--text-dim); letter-spacing: .05em; text-transform: uppercase; }
.pair textarea, .pair input { font-size: 13.5px; line-height: 1.5; resize: vertical; }
.input-flagged { border-color: var(--warn) !important; background: rgba(169,98,8,.05) !important; }
.flag { font-size: 12px; color: var(--warn); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.flag__confirm { display: inline-flex; gap: 5px; align-items: center; color: var(--text-2); cursor: pointer; }
.item-list { display: grid; gap: 12px; }
.item-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; display: grid; gap: 12px; margin: 0; background: var(--surface-2); }
.item-card__title { font-weight: 600; font-size: 13.5px; padding: 0 6px; }
.item-card__actions { display: flex; gap: 8px; justify-content: flex-end; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--surface) 94%, transparent);
  padding: 12px 0; border-top: 1px solid var(--border-soft); margin-top: 18px; }
.code-area { font-family: var(--font-mono); font-size: 12px; }

/* ---- Google on the sign-in pages ---- */
.button-google--block { width: 100%; justify-content: center; margin-top: 22px; }
.auth-note { margin: 8px 0 0; font-size: 12px; color: var(--text-dim); text-align: center; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 0; color: var(--text-dim); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-divider + .auth-form { margin-top: 14px; }
