/* ==========================================================================
   Saleslights Emailer — console design system
   Dark, dense SaaS console. Tokens first, then primitives, then layout.
   No build step, no CDN, no inline style soup.
   ========================================================================== */

:root {
  /* palette */
  --bg:            #0b0f16;
  --bg-raised:     #111722;
  --bg-card:       #141b27;
  --bg-input:      #0d131d;
  --bg-hover:      #1b2432;
  --bg-active:     #1f2a3a;
  --border:        #232e3f;
  --border-strong: #32415a;

  --text:          #e6ecf5;
  --text-dim:      #9fb0c7;
  /* WCAG: label/meta text is 11.5–12.5px, so it must clear 4.5:1 on every
     surface it sits on. #93a6bf measures 7.2:1 on --bg-raised. */
  --text-faint:    #93a6bf;

  --accent:        #4f8dfd;
  --accent-hover:  #6ea0ff;
  --accent-dim:    #1d3a6b;
  --accent-soft:   rgba(79, 141, 253, .14);

  --ok:            #37c58b;
  --ok-soft:       rgba(55, 197, 139, .14);
  --warn:          #e3a33a;
  --warn-soft:     rgba(227, 163, 58, .14);
  --danger:        #f26a6a;
  --danger-soft:   rgba(242, 106, 106, .14);
  --neutral-soft:  rgba(159, 176, 199, .12);

  /* Chip foregrounds: the saturated --ok/--warn/--danger hues only reach ~4.1–5.9:1
     on their own tinted pills, so chips use these paler tints (>= 7:1) and carry a
     glyph as well as colour. */
  --chip-ok-text:      #9df0cb;
  --chip-warn-text:    #ffd79a;
  --chip-danger-text:  #ffc0c0;
  --chip-info-text:    #b9d0ff;
  --chip-neutral-text: #c8d4e4;

  /* spacing scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;

  /* type ramp */
  --f-micro: 11.5px;
  --f-sm:    12.5px;
  --f-base:  14px;
  --f-lg:    16px;
  --f-h3:    15px;
  --f-h2:    20px;
  --f-h1:    22px;

  --radius:    10px;
  --radius-sm: 6px;
  --radius-pill: 999px;

  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win. Author `display` declarations (chips
   are inline-flex, alerts are block, toolbars are flex) override the UA
   stylesheet's `[hidden] { display: none }`, so a hidden element keeps
   rendering — which is why the sequence builder showed "Unsaved changes" and
   "Saved" at the same time, permanently. One rule closes the whole class. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--f-base)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code { font-family: var(--mono); font-size: .92em; color: var(--text-dim); }

:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
  border-radius: 3px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------- type primitives */
.h1 { font-size: var(--f-h1); font-weight: 600; margin: 0; letter-spacing: -.01em; }
.h2 { font-size: var(--f-h2); font-weight: 600; margin: 0 0 var(--s2); letter-spacing: -.01em; }
.h3 { font-size: var(--f-h3); font-weight: 600; margin: 0; }
.muted { color: var(--text-dim); }
.micro { font-size: var(--f-micro); line-height: 1.45; }
.mono-note {
  font-family: var(--mono); font-size: var(--f-sm); color: var(--text-dim);
  margin: var(--s2) 0; white-space: pre-wrap; word-break: break-word;
}

/* ------------------------------------------------------------------ brand */
.brand { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.brand-mark {
  flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--accent), #2b5fc4);
  color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  display: grid; place-items: center;
}
.brand-text {
  font-size: var(--f-sm); color: var(--text-dim); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.brand-text strong { color: var(--text); font-weight: 600; }
.brand-lg { margin-bottom: var(--s5); }
.brand-lg .brand-mark { width: 34px; height: 34px; font-size: 13px; }
.brand-lg .brand-text { font-size: var(--f-lg); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font: 500 var(--f-base)/1 var(--sans);
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #07101f; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: var(--f-sm); }
.btn-block { width: 100%; }
.btn-link {
  background: none; border: 0; padding: 0; color: var(--accent);
  font: 500 var(--f-base)/1.4 var(--sans); cursor: pointer; text-align: left;
}
.btn-link:hover { color: var(--accent-hover); text-decoration: underline; }
.icon-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  width: 32px; height: 32px; min-width: 32px; min-height: 32px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 15px; line-height: 1; display: grid; place-items: center;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.icon-btn:focus-visible { border-color: var(--accent); }
.icon-btn.remove:hover { color: var(--danger); border-color: rgba(242,106,106,.5); }

/* ------------------------------------------------------------------ inputs */
.field { display: block; min-width: 0; }
.field + .field { margin-top: var(--s3); }
.field-label {
  display: block; font-size: var(--f-micro); font-weight: 600;
  letter-spacing: .03em; text-transform: uppercase; color: var(--text-faint);
  margin-bottom: var(--s1);
}
input, textarea, select {
  width: 100%;
  font: var(--f-base)/1.4 var(--sans);
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, textarea:disabled, select:disabled { opacity: .5; cursor: not-allowed; }
textarea { min-height: 64px; resize: vertical; font-family: var(--mono); font-size: var(--f-sm); }
select { appearance: none; background-image: none; cursor: pointer; }
input[type=file] { padding: 7px 10px; font-size: var(--f-sm); }
input[type=checkbox] { width: auto; }
.field-check { display: flex; align-items: center; gap: var(--s2); align-self: end; }
.field-check .field-label { margin: 0; text-transform: none; font-size: var(--f-base); letter-spacing: 0; color: var(--text); font-weight: 400; }
.field-inline { min-width: 150px; }
.field-inline .field-label { margin-bottom: 2px; }

.stack > * + * { margin-top: var(--s3); }
.row-tight { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: flex-end; margin-top: var(--s3); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3); }
.grid-2 > .field + .field { margin-top: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: var(--s4); align-items: start; }

fieldset.subform {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s3) var(--s4) var(--s4); margin: 0;
}
fieldset.subform legend {
  font-size: var(--f-micro); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-faint); padding: 0 var(--s2);
}

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
}
.card + .card, .tiles + .card, .card + .cols, .cols + .card, .tabpanel > * + * { margin-top: var(--s4); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3);
}
.card-head .row-tight { margin-top: 0; }

/* ------------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: var(--s1);
  font-size: var(--f-micro); font-weight: 600; letter-spacing: .02em;
  padding: 3px 9px; border-radius: var(--radius-pill);
  border: 1px solid transparent; white-space: nowrap;
}
/* Every tone also carries a leading glyph, so state is never colour-only. The
   glyph is CSS content: it is announced by neither innerText nor a screen
   reader, which read the chip's own word ("verified", "held", ...). */
.chip::before { font-size: 10px; line-height: 1; opacity: .9; }
.chip-ok      { background: rgba(55,197,139,.18);   color: var(--chip-ok-text);      border-color: rgba(55,197,139,.45); }
.chip-ok::before      { content: "\2713\00a0"; }
.chip-warn    { background: rgba(227,163,58,.18);   color: var(--chip-warn-text);    border-color: rgba(227,163,58,.45); }
.chip-warn::before    { content: "\0021\00a0"; font-weight: 800; }
.chip-danger  { background: rgba(242,106,106,.18);  color: var(--chip-danger-text);  border-color: rgba(242,106,106,.5); }
.chip-danger::before  { content: "\2715\00a0"; }
.chip-info    { background: rgba(79,141,253,.18);   color: var(--chip-info-text);    border-color: rgba(79,141,253,.45); }
.chip-info::before    { content: "\25CF\00a0"; font-size: 8px; }
.chip-neutral { background: var(--neutral-soft);    color: var(--chip-neutral-text); border-color: var(--border-strong); }
.chip-neutral::before { content: "\2013\00a0"; }
.chip-block { display: block; text-align: center; white-space: normal; line-height: 1.35; padding: 6px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0; }

/* ------------------------------------------------------------------ alerts */
.alert {
  display: block; font-size: var(--f-sm); line-height: 1.5;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-raised);
  color: var(--text-dim); margin: 0;
}
.alert:empty { display: none; }
.alert-error { background: var(--danger-soft); border-color: rgba(242,106,106,.4); color: #ffc9c9; }
.alert-warn  { background: var(--warn-soft);  border-color: rgba(227,163,58,.4);  color: #ffe0ad; }
.alert-info  { background: var(--accent-soft); border-color: rgba(79,141,253,.35); color: #cfe0ff; }
.alerts { display: grid; gap: var(--s2); padding: 0 var(--s5); }
.alerts:empty { display: none; }
.alerts .alert { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.alert-dismiss {
  background: none; border: 0; color: inherit; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px; opacity: .7;
}
.alert-dismiss:hover { opacity: 1; }

/* ------------------------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.shell[hidden] { display: none; }

.sidebar {
  display: flex; flex-direction: column; gap: var(--s4);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  padding: var(--s4) var(--s3);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.ws-switcher { display: grid; gap: var(--s2); }
.ws-new summary {
  font-size: var(--f-micro); color: var(--text-faint); cursor: pointer;
  padding: 2px 0; list-style: none;
}
.ws-new summary::marker, .ws-new summary::-webkit-details-marker { display: none; }
.ws-new summary::before { content: "+ "; }
.ws-new summary:hover { color: var(--text); }
.ws-new .row-tight { margin-top: var(--s2); }

.nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--s3);
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: var(--f-base); font-weight: 500;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item[aria-current="page"] {
  background: var(--accent-soft); color: var(--text);
  border-color: rgba(79,141,253,.3);
}
.nav-ico { width: 14px; text-align: center; font-size: 11px; color: var(--text-faint); }
.nav-item[aria-current="page"] .nav-ico { color: var(--accent-hover); }

.sidebar-foot { margin-top: auto; display: grid; gap: var(--s2); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); flex-wrap: wrap;
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-raised), var(--bg));
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { min-width: 0; }
.topbar-title p { margin: 2px 0 0; }
.topbar-actions { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.identity {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--f-sm); color: var(--text-dim);
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: var(--radius-pill);
}
.identity-name { color: var(--text); font-weight: 600; }
.identity-sep { color: var(--text-faint); }
.identity-role { color: var(--text-dim); }
.identity-source { color: var(--text-faint); }
.version-label {
  font-size: var(--f-micro); color: var(--text-faint); letter-spacing: .04em;
  text-align: center; font-variant-numeric: tabular-nums; opacity: .85;
}
.state-line { font-size: var(--f-sm); color: var(--text); margin: 0 0 var(--s2); }
.views { padding: var(--s5); display: block; }
.view[hidden] { display: none; }

/* sidebar collapsed */
.shell.collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
.shell.collapsed .brand-text,
.shell.collapsed .ws-switcher,
.shell.collapsed .sidebar-foot .chip,
.shell.collapsed .sidebar-foot .micro,
.shell.collapsed .nav-item span:not(.nav-ico) { display: none; }
.shell.collapsed .nav-item { justify-content: center; }

/* ------------------------------------------------------------------- tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s3); }
.tiles-sm { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s4);
}
.tile-label {
  display: block; font-size: var(--f-micro); font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint);
}
.tile-value {
  display: block; font-size: 26px; font-weight: 600; margin-top: var(--s1);
  letter-spacing: -.02em; font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.tile-value.unknown { font-size: var(--f-lg); color: var(--text-faint); font-weight: 500; }
.tile-note { display: block; font-size: var(--f-micro); color: var(--text-dim); margin-top: var(--s1); }
.tile-breakdown { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); margin-top: var(--s2); }

/* ------------------------------------------------------------------- table */
.toolbar {
  display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end;
  margin-bottom: var(--s3);
}
.toolbar .field-inline:first-child { flex: 1 1 240px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: var(--f-sm); }
.table thead th {
  text-align: left; font-size: var(--f-micro); font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; color: var(--text-faint);
  background: var(--bg-raised); padding: 9px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
.table th.num, .table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.table tbody td {
  padding: 0 12px; height: 44px; border-bottom: 1px solid var(--border);
  color: var(--text-dim); vertical-align: middle;
}
.table tbody td.empty { height: auto; padding: var(--s5) var(--s4); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; transition: background .1s ease; }
.table tbody tr.clickable:hover { background: var(--bg-hover); }
.table tbody tr.clickable:hover .cell-strong a { color: var(--accent-hover); }
.table tbody tr.clickable:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: -2px; }

/* Six scannable columns, sized so neither 1280 nor 1440 needs a scrollbar. */
.table-campaigns { table-layout: fixed; }
.table-campaigns th:nth-child(1) { width: auto; }
.table-campaigns th:nth-child(2) { width: 8.5rem; }
.table-campaigns th:nth-child(3),
.table-campaigns th:nth-child(4),
.table-campaigns th:nth-child(5) { width: 5.5rem; }
.table-campaigns th:nth-child(6) { width: 10.5rem; }
.table-campaigns .cell-strong a {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.cell-activity { white-space: nowrap; }
.activity-when { font-variant-numeric: tabular-nums; color: var(--text); }
.activity-source {
  display: block; font-size: var(--f-micro); color: var(--text-faint);
  letter-spacing: .02em;
}
.dash { color: var(--text-faint); }
.list-note {
  margin: var(--s3) 0 0; color: var(--text-dim);
  border-left: 2px solid var(--border-strong); padding-left: var(--s3);
}
.table .cell-strong { color: var(--text); font-weight: 600; }
.table .cell-reason { color: var(--warn); max-width: 34rem; white-space: normal; }
.table .cell-reason .muted { color: var(--text-dim); margin-top: 3px; }
.th-sort {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
}
.th-sort:hover { color: var(--text); }
.th-sort[data-dir]::after { content: " \25B2"; font-size: 8px; }
.th-sort[data-dir="desc"]::after { content: " \25BC"; }

/* ----------------------------------------------------------------- pagers */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; margin-top: var(--s3);
}
.pager:empty { display: none; }
.pager-range { font-size: var(--f-sm); color: var(--text-dim); }
.pager-controls { display: flex; align-items: center; gap: var(--s2); }
.pager-page { font-size: var(--f-sm); color: var(--text-dim); min-width: 90px; text-align: center; }

/* ------------------------------------------------- empty / loading / error */
.empty, .notice {
  text-align: center; padding: var(--s6) var(--s4); color: var(--text-dim);
}
.empty .h3 { color: var(--text); margin-bottom: var(--s2); }
.state-block {
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: var(--s4); margin-bottom: var(--s3);
  font-size: var(--f-sm); color: var(--text-dim); background: var(--bg-raised);
}
.state-block strong { color: var(--text); display: block; margin-bottom: var(--s1); }
.state-block code { color: var(--warn); }
.state-unavailable { border-color: rgba(227,163,58,.45); background: var(--warn-soft); }
.state-degraded { border-color: rgba(79,141,253,.4); background: var(--accent-soft); }
/* Request path and status code: a diagnostics line, shown to admins only. */
.state-admin-detail {
  font-family: var(--mono); font-size: var(--f-micro); color: var(--text-faint);
  margin-top: var(--s2); word-break: break-word;
}
.state-admin-detail::before { content: "admin: "; letter-spacing: .04em; }
.spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; margin-right: var(--s2);
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  height: 12px; border-radius: 4px; margin: 10px 12px;
  background: linear-gradient(90deg, var(--bg-hover), var(--bg-active), var(--bg-hover));
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* -------------------------------------------------------------- detail head */
.detail-head { display: flex; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.detail-head-main { min-width: 0; }
.detail-head-main .chips { margin-bottom: var(--s1); }
.detail-head-side { font-size: var(--f-sm); color: var(--text-dim); text-align: right; }

.tabs {
  display: flex; gap: var(--s1); flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin: var(--s4) 0 var(--s4);
}
.tab {
  padding: 10px 16px; font-size: var(--f-base); font-weight: 500;
  color: var(--text-dim); border-bottom: 3px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; margin-bottom: -1px;
}
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab[aria-selected="true"] {
  color: var(--text); font-weight: 600;
  background: var(--accent-soft); border-bottom-color: var(--accent-hover);
}
.tabpanel[hidden] { display: none; }

.blockers { list-style: none; margin: var(--s2) 0; padding: 0; display: grid; gap: var(--s1); }
.blockers:empty { display: none; }
.blockers li {
  font-size: var(--f-sm); color: #ffd7d7;
  background: var(--danger-soft); border-left: 3px solid var(--danger);
  padding: 7px 10px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --------------------------------------------------------------- checklist */
.checklist { display: grid; gap: var(--s2); }
.check-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--s3);
  align-items: start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-raised);
}
.check-mark { font-size: 13px; font-weight: 700; line-height: 1.4; }
.check-row.pass .check-mark { color: var(--ok); }
.check-row.fail .check-mark { color: var(--danger); }
.check-row.unknown .check-mark { color: var(--text-faint); }
.check-label { font-weight: 600; font-size: var(--f-base); }
.check-detail { font-size: var(--f-sm); color: var(--text-dim); margin-top: 2px; word-break: break-word; }
.check-admin {
  font-family: var(--mono); font-size: var(--f-micro); color: var(--text-faint);
  margin-top: var(--s1); word-break: break-word;
}
.check-admin::before { content: "admin: "; letter-spacing: .04em; }

/* ------------------------------------------------------- sequence builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: var(--s4); align-items: start; }
.builder-main, .builder-side { min-width: 0; }
.builder-side { display: grid; gap: var(--s4); position: sticky; top: calc(var(--s5) + 44px); }

.steps { display: grid; gap: 0; margin: var(--s3) 0; }

/* The wait connector is deliberately NOT a card: no border, no raised
   background, a visible rail running between the two step cards it joins. */
.step-wait {
  display: flex; align-items: flex-end; gap: var(--s3);
  padding: var(--s3) 0 var(--s3) 40px; position: relative;
  background: none; border: 0;
}
.step-wait-rail {
  position: absolute; left: 19px; top: 0; bottom: 0;
  border-left: 2px dashed var(--border-strong);
}
.step-wait::after {
  content: ""; position: absolute; left: 15px; top: 50%; margin-top: -4px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong);
}
.step-wait .field-label { margin: 0 0 2px; }
.step-wait-field { flex: 0 0 auto; }
.step-wait-text { font-size: var(--f-sm); color: var(--text-dim); padding-bottom: 9px; }

/* number + unit as one control, so "days" is always visible */
.input-unit {
  display: inline-flex; align-items: stretch; width: 128px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); overflow: hidden;
}
.input-unit:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-unit input {
  width: 72px; border: 0; border-radius: 0; background: transparent;
  font-variant-numeric: tabular-nums; text-align: right;
}
.input-unit input:focus { box-shadow: none; }
.input-unit-suffix {
  display: grid; place-items: center; padding: 0 10px;
  font-size: var(--f-sm); color: var(--text-faint);
  background: var(--bg-raised); border-left: 1px solid var(--border);
}

.step {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg-card); padding: var(--s4); margin: 0; min-width: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.step > .field + .field, .step > .token-strip + .field { margin-top: var(--s3); }
.step.arming { border-color: rgba(242,106,106,.55); }
.step legend { padding: 0; }
.step-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3);
  padding-bottom: var(--s3); border-bottom: 1px solid var(--border);
}
.step-confirm {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  margin-bottom: var(--s3); padding: var(--s2) var(--s3);
  background: var(--danger-soft); border: 1px solid rgba(242,106,106,.45);
  border-radius: var(--radius-sm);
}
.step-confirm[hidden] { display: none; }
.step-confirm-text { font-size: var(--f-sm); color: #ffc0c0; margin-right: auto; }

/* merge fields */
.token-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1) var(--s2);
  margin-top: var(--s2);
}
.token-strip[hidden] { display: none; }
.token-strip-label {
  font-size: var(--f-micro); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-faint);
}
.token {
  font-family: var(--mono); font-size: var(--f-micro); font-weight: 600;
  padding: 2px 7px; border-radius: var(--radius-sm);
  background: rgba(79,141,253,.18); color: var(--chip-info-text);
  border: 1px solid rgba(79,141,253,.45);
}
.token-unresolved {
  background: rgba(227,163,58,.18); color: var(--chip-warn-text);
  border-color: rgba(227,163,58,.5); border-style: dashed;
}
.token-unresolved::after { content: " !"; font-weight: 800; }
.step-badge {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--f-sm); font-weight: 600; color: var(--text);
}
.step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-hover);
  display: grid; place-items: center; font-size: var(--f-micro); font-weight: 700;
  border: 1px solid rgba(79,141,253,.35);
}
.step-tools { display: flex; gap: var(--s1); }
.step-thread-note { font-size: var(--f-micro); color: var(--text-faint); margin: var(--s1) 0 0; }
.body-head {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  margin-bottom: var(--s2);
}
/* Segmented control: the active mode is a filled segment with a tick, and the
   label beside it spells out which editor you are in. */
.body-modes {
  display: inline-flex; gap: 0; padding: 2px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.body-mode {
  font-size: var(--f-micro); font-weight: 600; padding: 5px 12px; min-height: 26px;
  border-radius: var(--radius-pill); border: 1px solid transparent;
  background: transparent; color: var(--text-faint); cursor: pointer;
}
.body-mode:hover { color: var(--text); }
.body-mode[aria-pressed="true"] {
  background: var(--accent); color: #07101f; border-color: var(--accent);
}
.body-mode[aria-pressed="true"]::before { content: "\2713\00a0"; }
.body-mode-note { font-size: var(--f-micro); color: var(--text-faint); }
.step .html[hidden], .step .body[hidden] { display: none; }

/* Bounded, scrollable preview: the full rendered message is always present in
   the DOM — the panel scrolls rather than clipping a sentence. */
.preview-panel {
  margin: var(--s3) 0 0; max-height: 300px; overflow: auto;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); scrollbar-width: thin;
}
.preview-panel:has(.preview-out:empty) { display: none; }
.preview-panel:focus-visible { border-color: var(--accent); }
.preview-out {
  font-family: var(--mono); font-size: var(--f-sm); white-space: pre-wrap;
  overflow-wrap: anywhere; padding: var(--s3); margin: 0;
  color: var(--text-dim); background: none; border: 0; max-height: none;
}

/* ------------------------------------------------------------ mapping rows */
.mapping { display: grid; gap: var(--s2); }
.mapping:empty::before {
  content: "Choose a CSV above to map its columns.";
  color: var(--text-faint); font-size: var(--f-sm);
}
.mapping-row {
  display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,1.2fr) minmax(0,1fr) minmax(0,1fr);
  gap: var(--s2); align-items: center;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-raised);
}
.mapping-row strong { font-size: var(--f-sm); color: var(--text); word-break: break-word; }
.mapping-row .sample { font-size: var(--f-micro); color: var(--text-faint); font-family: var(--mono); word-break: break-all; }
.mapping-row select, .mapping-row input { font-size: var(--f-sm); padding: 6px 8px; }
.mapping-row [hidden] { display: none; }

/* ------------------------------------------------------------ lists, kv */
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.plain-list li {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; min-height: 40px;
  font-size: var(--f-sm); color: var(--text-dim);
  padding: 8px 12px; background: var(--bg-raised); border: 1px solid var(--border);
}
.plain-list li .chips { margin: 0; }
.plain-list li strong { color: var(--text); font-weight: 600; }
.plain-list li:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.plain-list li:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }

.mailbox-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.mailbox-card {
  display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--s3);
  align-items: center; width: 100%; text-align: left;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--s3) var(--s4); cursor: pointer; color: var(--text);
  font: inherit;
}
.mailbox-card:hover { background: var(--bg-hover); border-color: var(--accent); }
.mailbox-card:focus-visible { border-color: var(--accent); }
.mailbox-card .mb-label { font-weight: 600; font-size: var(--f-base); }
.mailbox-card .mb-meta { font-size: var(--f-micro); color: var(--text-dim); font-family: var(--mono); margin-top: 2px; }
.mailbox-card[aria-pressed="true"] { border-color: var(--accent); background: var(--bg-active); }

.kv { display: grid; gap: var(--s1); }
.kv-row {
  display: grid; grid-template-columns: minmax(140px, 32%) minmax(0, 1fr); gap: var(--s3);
  font-size: var(--f-sm); padding: 6px 0; border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: 0; }
.kv-key { color: var(--text-faint); }
.kv-val { color: var(--text-dim); font-family: var(--mono); word-break: break-word; }

.drawer { margin-top: var(--s4); border-left: 3px solid var(--accent); }

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed; right: var(--s4); bottom: var(--s4); z-index: 50;
  display: grid; gap: var(--s2); max-width: 420px;
}
.toast {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 10px 14px;
  font-size: var(--f-sm); color: var(--text); box-shadow: var(--shadow);
}
.toast-ok { border-left: 3px solid var(--ok); }
.toast-error { border-left: 3px solid var(--danger); }

/* ------------------------------------------------------------------- auth */
.auth { display: grid; place-items: center; min-height: 100vh; padding: var(--s5); }
.auth[hidden] { display: none; }
.auth-card { width: 100%; max-width: 400px; padding: var(--s6); box-shadow: var(--shadow); }
.auth-card .alert { margin-top: var(--s3); }
.auth-card #loginBreakGlass { margin: var(--s3) 0 0; }

/* --------------------------------------------- change history & versions */
/* The live editor and a read-only past version sit in one column stack, so a
   narrow main column can never force horizontal scrolling. On a very wide
   screen they sit side by side for a direct comparison. */
.compare { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
.compare > * { min-width: 0; }

.card-live { border-left: 3px solid var(--ok); }
.card-snapshot { border-left: 3px solid var(--warn); }

.live-banner, .snapshot-banner {
  margin: 0 0 var(--s3); padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: var(--f-sm); font-weight: 600;
}
.live-banner { background: var(--ok-soft); color: var(--chip-ok-text); }
.snapshot-banner { background: var(--warn-soft); color: var(--chip-warn-text); }

.history-list { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: var(--s2); }
.history-row { margin: 0; }
.history-open {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text);
  font: inherit;
}
.history-open:hover { background: var(--bg-hover); border-color: var(--accent); }
.history-row.is-current .history-open { border-left-color: var(--ok); }
.history-row.selected .history-open {
  border-color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent);
}
.history-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.history-rev { font-weight: 600; }
.history-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2);
  margin-top: var(--s1); font-size: var(--f-micro); color: var(--text-faint);
}
.history-sep { color: var(--border-strong); }
.history-when { border-bottom: 1px dotted var(--border-strong); cursor: help; }
.history-actor-self { color: var(--chip-ok-text); font-weight: 600; }
.history-actor-other { color: var(--text-dim); font-family: var(--mono); }
.history-actor-unknown { color: var(--chip-warn-text); font-style: italic; cursor: help; }
.history-summary {
  margin: var(--s2) 0 0; font-size: var(--f-sm); color: var(--text-dim);
  word-break: break-word;
}
#historyPager { margin-top: var(--s3); }

.ro-steps { display: grid; gap: var(--s2); margin-top: var(--s3); }
.ro-step {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--s3);
}
.ro-step-head { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.ro-wait { margin: 0; font-size: var(--f-micro); color: var(--text-faint); padding-left: 40px; }
.ro-label {
  display: block; font-size: var(--f-micro); font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-faint); margin-top: var(--s2);
}
.ro-subject { margin: 2px 0 0; font-size: var(--f-sm); color: var(--text); word-break: break-word; }
.ro-body {
  margin: 2px 0 0; font-family: var(--mono); font-size: var(--f-sm); color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto;
}
#restoreRefusal .btn { margin-top: var(--s2); }
#restoreConfirm .row-tight { margin-top: var(--s3); }

/* -------------------------------------------------------------- responsive */
@media (min-width: 1700px) {
  .compare.comparing { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 1400px) {
  .builder { grid-template-columns: minmax(0, 1fr) minmax(0, 300px); }
}
@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .builder-side { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .views, .alerts { padding: var(--s4); }
  .topbar { padding: var(--s4); }
  .mapping-row { grid-template-columns: minmax(0, 1fr); }
}
