/* ==========================================================================
   WhatShark — design system
   Calm, precise surfaces. One accent used sparingly. 8px grid. Hairlines.
   ========================================================================== */

:root {
  /* Brand (swap these three to re-skin) */
  --brand-blue: #1E5EFF;
  --brand-orange: #FF7A1A;
  --brand-navy: #0B1B3A;

  /* Derived brand shades (hover / pressed / accessible ink on tints) */
  --blue-hover: #174FE0;
  --blue-press: #1243C4;
  --blue-tint: rgba(30, 94, 255, .08);
  --blue-tint-2: rgba(30, 94, 255, .12);
  --orange-hover: #F06A0A;
  --orange-press: #D95E08;
  --focus-ring: 0 0 0 3px rgba(30, 94, 255, .25);

  /* Neutrals */
  --ink: #0B1B3A;
  --ink-2: #4A5568;
  --ink-3: #6B7588;   /* AA-adjusted from #8A94A6 for 4.5:1 text contrast */
  --ink-4: #8A94A6;   /* icons, placeholders, disabled */
  --line: #E6E9EF;
  --line-2: #F1F3F7;
  --line-3: #D5DAE3;                            /* hover borders */
  --line-4: #C5CBD6;                            /* skipped / sent-not-delivered greys */
  --bg: #FFFFFF;
  --bg-2: #F7F8FA;

  /* Status (base + readable ink on 10% tint) */
  --ok: #1A9E5C;   --ok-ink: #11734A;   --ok-tint: rgba(26, 158, 92, .10);
  --warn: #FF7A1A; --warn-ink: #A64A05; --warn-tint: rgba(255, 122, 26, .12);
  --err: #D93025;  --err-ink: #B3261E;  --err-tint: rgba(217, 48, 37, .10);
  --info: #1E5EFF; --info-ink: #1747C8; --info-tint: rgba(30, 94, 255, .10);
  --mute-ink: #4A5568; --mute-tint: rgba(74, 85, 104, .10);

  /* WhatsApp preview */
  --chat-bg: #EFEAE2;
  --chat-dot: rgba(11, 27, 58, .045);
  --bubble: #FFFFFF;
  --bubble-ink: #111B21;
  --bubble-meta: #667781;
  --bubble-link: #027EB5;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  /* Shape & depth */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-pop: 0 8px 24px rgba(11, 27, 58, .08);
  --shadow-pop-2: 0 16px 48px rgba(11, 27, 58, .12);

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 150ms;

  /* Layout */
  --sidebar-w: 232px;
  --content-max: 1120px;
  --gutter: 32px;
  --control-h: 36px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
table { border-collapse: collapse; border-spacing: 0; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
::selection { background: rgba(30, 94, 255, .18); }
[hidden] { display: none !important; }
.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; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.ink-2 { color: var(--ink-2); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row-12 { display: flex; align-items: center; gap: 12px; }
.stack-4 > * + * { margin-top: 4px; }
.stack-8 > * + * { margin-top: 8px; }
.stack-16 > * + * { margin-top: 16px; }
.stack-24 > * + * { margin-top: 24px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.text-right { text-align: right; }
.small { font-size: 12px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-content: start; min-height: 100vh; }
.app.is-auth { display: block; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 20px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.logo-mark { width: 28px; height: 28px; flex: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav a svg { color: var(--ink-4); transition: color var(--dur) var(--ease); }
.nav a:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.nav a:hover svg { color: var(--ink-2); }
.nav a[aria-current="page"] { background: var(--blue-tint); color: var(--brand-blue); }
.nav a[aria-current="page"] svg { color: var(--brand-blue); }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.acct-chip {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  text-align: left; background: var(--bg);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.acct-chip:hover { background: var(--bg-2); }
.acct-chip .acct-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.acct-chip .acct-dot.is-err { background: var(--err); }
.acct-chip .acct-dot.is-warn { background: var(--warn); }
.acct-chip .acct-dot.is-none { background: var(--ink-4); }
.acct-chip .t1 { font-size: 13px; font-weight: 500; line-height: 1.3; }
.acct-chip .t2 { font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.acct-chip svg { color: var(--ink-4); flex: none; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--line-2); color: var(--ink-2);
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}
.user-row .uname { font-size: 13px; font-weight: 500; }

.topbar { display: none; }

.main { min-width: 0; background: var(--bg); }
.page { max-width: calc(var(--content-max) + var(--gutter) * 2); margin: 0 auto; padding: var(--gutter); padding-bottom: 64px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; min-height: 36px; }
.page-head .titles { flex: 1 1 auto; min-width: 0; }
.page-title { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -.02em; color: var(--brand-navy); }
.page-desc { font-size: 14px; color: var(--ink-3); margin-top: 2px; }
.page-actions { flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.crumb { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-3); margin-bottom: 4px; font-weight: 500; }
.crumb:hover { color: var(--brand-blue); text-decoration: none; }
.section-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.section-desc { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-h); padding: 0 14px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; user-select: none;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand-blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:active { background: var(--blue-press); }
.btn-accent { background: var(--brand-orange); color: #fff; font-weight: 600; }
.btn-accent:hover { background: var(--orange-hover); }
.btn-accent:active { background: var(--orange-press); }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--bg-2); border-color: #DADFE7; }
.btn-danger { background: var(--bg); color: var(--err-ink); border-color: var(--line); }
.btn-danger:hover { background: var(--err-tint); border-color: rgba(217, 48, 37, .25); }
.btn-danger-solid { background: var(--err); color: #fff; }
.btn-danger-solid:hover { background: #C2281E; }
.btn-ghost { background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn-ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn-link { height: auto; padding: 0; color: var(--brand-blue); font-weight: 500; }
.btn-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading > :not(.spinner) { opacity: 0; }
.btn.is-loading { position: relative; }
.btn.is-loading .spinner { position: absolute; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  color: var(--ink-3);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn.is-danger:hover { background: var(--err-tint); color: var(--err-ink); }
.icon-btn.is-accent { color: var(--brand-orange); }
.icon-btn.is-accent:hover { background: var(--warn-tint); color: var(--orange-press); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-sm svg { width: 16px; height: 16px; }
.btn-group { display: inline-flex; align-items: center; gap: 2px; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field, .field + .field-row, .field-row + .field, .field-row + .field-row { margin-top: 16px; }
.field-row > .field + .field { margin-top: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.label { font-size: 13px; font-weight: 500; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.label .opt { font-weight: 400; color: var(--ink-3); }
.help { font-size: 12px; color: var(--ink-3); line-height: 1.45; }
.field-error { font-size: 12px; color: var(--err-ink); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; height: var(--control-h);
  padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg);
  font-size: 15px; line-height: 1.4; color: var(--ink);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-blue); box-shadow: var(--focus-ring); outline: none; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--err); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(217, 48, 37, .18); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-2); color: var(--ink-3); cursor: not-allowed; }
.input-sm, .select-sm { height: 32px; font-size: 13px; padding: 0 10px; }
.select {
  padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A94A6' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  text-overflow: ellipsis;
}
.select-sm { padding-right: 28px; background-position: right 8px center; }
.textarea { height: auto; min-height: 96px; padding: 8px 12px; resize: vertical; line-height: 1.5; }
.textarea.mono, .input.mono { font-family: var(--mono); font-size: 13px; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { flex: 1; }
.input-group .prefix {
  position: absolute; left: 12px; color: var(--ink-3); font-size: 15px; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.input-group.has-prefix .input { padding-left: 28px; }
.input-group.has-prefix-wide .input { padding-left: 44px; }
.input-group .suffix-btn { position: absolute; right: 2px; }
.input-group.has-suffix .input { padding-right: 40px; }
.input-group .suffix-btn.icon-btn { width: 32px; height: 32px; }

.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-4); width: 16px; height: 16px; pointer-events: none; }
.search .input { padding-left: 34px; font-size: 14px; }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--brand-blue); margin: 0; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 36px; height: 20px; border-radius: 999px; flex: none;
  background: var(--line-3); transition: background-color var(--dur) var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(11, 27, 58, .2);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .track { background: var(--brand-blue); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }
.switch .switch-text { display: flex; flex-direction: column; }
.switch .switch-text b { font-weight: 500; font-size: 14px; }
.switch .switch-text span { font-size: 12px; color: var(--ink-3); }

/* Segmented control */
.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--line-2); border-radius: 9px;
  border: 1px solid var(--line);
}
.segmented button {
  height: 30px; padding: 0 14px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] {
  background: var(--bg); color: var(--ink);
  box-shadow: 0 1px 2px rgba(11, 27, 58, .08), 0 0 0 1px rgba(11, 27, 58, .04);
}
.segmented.is-block { display: flex; width: 100%; }
.segmented.is-block button { flex: 1; justify-content: center; }

/* Chips (presets) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg);
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--line-3); color: var(--ink); }
.chip[aria-pressed="true"] { border-color: var(--brand-blue); background: var(--blue-tint); color: var(--brand-blue); }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 28px 16px; border: 1px dashed #CDD3DD; border-radius: var(--r-md);
  background: var(--bg-2); text-align: center; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand-blue); background: var(--blue-tint); }
.dropzone svg { color: var(--ink-4); width: 24px; height: 24px; }
.dropzone b { font-weight: 500; }
.dropzone .file-name { font-weight: 500; color: var(--ink); }

/* ---------- Cards ---------- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); min-height: 60px; }
.card-head .section-title { flex: 1; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--bg); display: flex; align-items: center; gap: 8px; }
.card-sub { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 12px 16px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* Stat tiles */
.stat { padding: 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--ink-3); }
.stat-icon { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--line-2); color: var(--ink-3); }
.stat-icon svg { width: 16px; height: 16px; }
.stat-value { font-size: 28px; line-height: 36px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--brand-navy); margin-top: 4px; }
.stat-delta { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.stat-delta .delta-chip { color: var(--ink-2); font-weight: 500; }
.stat-delta .up { color: var(--ok-ink); font-weight: 500; }
.stat-delta .down { color: var(--err-ink); font-weight: 500; }
.stat-sm .stat-value { font-size: 20px; line-height: 28px; margin-top: 2px; }
.stat-sm { padding: 16px; }

/* Key/value list */
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }

/* ---------- Tables ---------- */
.table-wrap { position: relative; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th {
  height: 40px; padding: 0 16px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3);
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.table td { height: 44px; padding: 8px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--ink); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr:focus-visible { outline: none; box-shadow: none; }
.table tr:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--brand-blue); }
.table tbody tr { transition: background-color var(--dur) var(--ease); }
.table tbody tr:hover td { background: var(--bg-2); }
.table tr.is-clickable { cursor: pointer; }
.table th.num, .table td.num { text-align: right; }
.table td.actions, .table th.actions { text-align: right; width: 1%; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table .cell-title { font-weight: 500; color: var(--ink); font-size: 13.5px; }
.table .cell-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.table tr.is-expanded td { background: var(--bg-2); }
.table tr.expand-row > td { padding: 0; background: var(--bg-2); }
.table tr.expand-row:hover > td { background: var(--bg-2); }
.table-compact td { height: 40px; padding-top: 6px; padding-bottom: 6px; }
.table-inner { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.table-inner .table th { height: 34px; background: var(--bg); }
.table-inner .table td { height: 38px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { width: 280px; }
.toolbar .spacer { flex: 1; }

/* ---------- Pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 7px; border-radius: var(--r-xs);
  font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; line-height: 1;
  white-space: nowrap; background: var(--mute-tint); color: var(--mute-ink);
}
.pill.ok { background: var(--ok-tint); color: var(--ok-ink); }
.pill.warn { background: var(--warn-tint); color: var(--warn-ink); }
.pill.err { background: var(--err-tint); color: var(--err-ink); }
.pill.info { background: var(--info-tint); color: var(--info-ink); }
.pill.mute { background: var(--mute-tint); color: var(--mute-ink); }
.pill.plain { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.pill .pdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.is-live .pdot { animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--r-xs); background: var(--line-2); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.mono { font-family: var(--mono); font-size: 11.5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); flex: none; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.warn { background: var(--warn); } .dot.info { background: var(--info); }

/* ---------- Progress ---------- */
.progress { height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; display: flex; }
.progress span { height: 100%; transition: width 300ms var(--ease); }
.progress .p-ok { background: var(--ok); }
.progress .p-err { background: var(--err); }
.progress .p-skip { background: var(--line-4); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tabs button { height: 40px; font-size: 14px; font-weight: 500; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--brand-blue); }

/* ---------- Empty / error / skeleton ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; gap: 8px; }
.empty-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--line-2); color: var(--ink-3); display: grid; place-items: center; margin-bottom: 8px; }
.empty-icon svg { width: 22px; height: 22px; }
.empty-title { font-size: 15px; font-weight: 600; }
.empty-text { font-size: 14px; color: var(--ink-3); max-width: 360px; }
.empty .btn { margin-top: 12px; }
.empty.is-compact { padding: 32px 16px; }
.empty.is-error .empty-icon { background: var(--err-tint); color: var(--err-ink); }

.skeleton { position: relative; overflow: hidden; background: var(--line-2); border-radius: var(--r-xs); }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; }
.sk-title { height: 28px; width: 220px; border-radius: var(--r-sm); }
.sk-block { height: 120px; border-radius: var(--r-md); }

/* ---------- Callouts ---------- */
.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); font-size: 13px; line-height: 1.5; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2); }
.callout svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.callout b { color: var(--ink); font-weight: 600; }
.callout.info { background: var(--info-tint); border-color: rgba(30, 94, 255, .14); }
.callout.info svg { color: var(--brand-blue); }
.callout.warn { background: var(--warn-tint); border-color: rgba(255, 122, 26, .2); }
.callout.warn svg { color: var(--warn-ink); }
.callout.err { background: var(--err-tint); border-color: rgba(217, 48, 37, .18); }
.callout.err svg { color: var(--err-ink); }
.callout.ok { background: var(--ok-tint); border-color: rgba(26, 158, 92, .18); }
.callout.ok svg { color: var(--ok-ink); }
.callout .callout-body { min-width: 0; flex: 1; }
.callout .callout-body > * + * { margin-top: 4px; }

.meta-error dl { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 4px 12px; margin-top: 8px; font-size: 12px; }
.meta-error dt { color: var(--err-ink); opacity: .8; }
.meta-error dd { color: var(--ink); overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; }

.code {
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 14px; overflow: auto; max-height: 320px; white-space: pre; color: var(--ink-2);
}
.copy-field { display: flex; align-items: center; gap: 8px; height: var(--control-h); padding: 0 4px 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg-2); }
.copy-field code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13px; }

/* ---------- Overlay: drawer & modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(11, 27, 58, .24);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.overlay.is-open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: 480px; max-width: 100vw;
  display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop-2);
  transform: translateX(24px); opacity: 0;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.drawer.is-wide { width: 880px; }
.drawer.is-open { transform: none; opacity: 1; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
.drawer-head .titles { flex: 1; min-width: 0; }
.drawer-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 24px; }
.drawer-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; overscroll-behavior: contain; }
.drawer-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--bg); }
.drawer-foot .left { margin-right: auto; }
.drawer-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line-2); }
.drawer-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.drawer-section > .eyebrow { margin-bottom: 12px; display: block; }
.drawer-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0; height: 100%; }
.drawer-split > .form-col { padding: 24px; overflow-y: auto; }
.drawer-split > .preview-col { border-left: 1px solid var(--line); background: var(--bg-2); padding: 24px; overflow-y: auto; }
.drawer-body.is-split { padding: 0; overflow: hidden; }

.modal-wrap { position: fixed; inset: 0; z-index: 61; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.modal {
  pointer-events: auto;
  width: 420px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--bg); border-radius: var(--r-lg); border: 1px solid var(--line);
  box-shadow: var(--shadow-pop-2);
  transform: translateY(8px) scale(.98); opacity: 0;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.modal.is-wide { width: 520px; }
.modal.is-open { transform: none; opacity: 1; }
.overlay.is-modal { z-index: 60; }
.modal-head { padding: 20px 24px 0; }
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 8px 24px 0; color: var(--ink-2); font-size: 14px; }
.modal-body .field:first-child { margin-top: 8px; }
.modal-body > p + form, .modal-body > p + .field { margin-top: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 24px; }
.modal-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 12px; background: var(--err-tint); color: var(--err-ink); }
.modal-icon.info { background: var(--info-tint); color: var(--info-ink); }

/* ---------- Popover menu ---------- */
.menu {
  position: fixed; z-index: 70; min-width: 200px; max-width: 320px; max-height: 320px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-pop); padding: 4px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.menu.is-open { opacity: 1; transform: none; }
.menu-label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 8px 10px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 32px; padding: 6px 10px; border-radius: 6px;
  font-size: 13px; text-align: left; color: var(--ink);
}
.menu-item svg { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--bg-2); box-shadow: none; }
.menu-item.is-active { color: var(--brand-blue); }
.menu-item.is-active svg { color: var(--brand-blue); }
.menu-item.is-danger { color: var(--err-ink); }
.menu-item.is-danger svg { color: var(--err-ink); }
.menu-item .mi-sub { font-size: 12px; color: var(--ink-3); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 280px; max-width: 400px; padding: 12px 12px 12px 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-pop);
  font-size: 13px; line-height: 1.45;
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.is-open { opacity: 1; transform: none; }
.toast .dot { margin-top: 5px; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 500; color: var(--ink); }
.toast .t-detail { color: var(--ink-3); margin-top: 2px; overflow-wrap: anywhere; }
.toast .icon-btn { width: 24px; height: 24px; margin: -2px -2px 0 0; }
.toast .icon-btn svg { width: 14px; height: 14px; }

/* ---------- Tooltip (single floating element, see ui.js) ---------- */
.tooltip {
  position: fixed; z-index: 90; max-width: 320px; pointer-events: none;
  padding: 7px 10px; border-radius: var(--r-sm);
  background: var(--brand-navy); color: #fff; font-size: 12px; line-height: 1.45;
  box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(2px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.tooltip.is-open { opacity: 1; transform: none; }

/* ---------- WhatsApp preview ---------- */
.wa {
  border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line);
  background-color: var(--chat-bg);
  background-image: radial-gradient(var(--chat-dot) 1px, transparent 1px);
  background-size: 14px 14px;
}
.wa-bar { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; background: #F0F2F5; border-bottom: 1px solid rgba(11, 27, 58, .06); }
.wa-bar .wa-av { width: 32px; height: 32px; border-radius: 50%; background: #D1D7DB; display: grid; place-items: center; color: #fff; flex: none; }
.wa-bar .wa-av svg { width: 18px; height: 18px; }
.wa-bar .wa-name { font-size: 14px; font-weight: 500; color: var(--bubble-ink); line-height: 1.2; }
.wa-bar .wa-status { font-size: 12px; color: var(--bubble-meta); line-height: 1.2; }
.wa-bar .wa-verified { width: 14px; height: 14px; color: #25D366; display: inline-block; vertical-align: -2px; margin-left: 2px; }
.wa-thread { padding: 16px 14px 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 160px; }
.wa-day { align-self: center; font-size: 11.5px; color: var(--bubble-meta); background: #FFFFFF; padding: 4px 10px; border-radius: 8px; margin-bottom: 8px; box-shadow: 0 1px .5px rgba(11, 27, 58, .1); }
.wa-msg { max-width: 300px; width: 100%; }
.wa-bubble {
  position: relative;
  background: var(--bubble); color: var(--bubble-ink);
  border-radius: 0 8px 8px 8px; padding: 4px; font-size: 14px; line-height: 1.42;
  box-shadow: 0 1px .5px rgba(11, 27, 58, .13);
}
.wa-bubble::before {
  content: ""; position: absolute; top: 0; left: -7px; width: 8px; height: 13px;
  background: var(--bubble);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.wa-media { height: 148px; border-radius: 6px; background: #DCE1E6; display: grid; place-items: center; color: #8696A0; overflow: hidden; }
.wa-media img { width: 100%; height: 100%; object-fit: cover; }
.wa-media svg { width: 36px; height: 36px; }
.wa-doc { display: flex; align-items: center; gap: 10px; padding: 10px; background: #F5F6F6; border-radius: 6px; font-size: 13px; }
.wa-doc svg { color: #E35A4F; width: 26px; height: 26px; }
.wa-content { padding: 4px 6px 2px; }
.wa-h { font-weight: 600; font-size: 14.5px; margin-bottom: 2px; }
.wa-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-footer { font-size: 12.5px; color: var(--bubble-meta); margin-top: 4px; }
.wa-time { font-size: 11px; color: var(--bubble-meta); text-align: right; margin-top: 2px; font-variant-numeric: tabular-nums; }
.wa-var { background: rgba(30, 94, 255, .1); color: var(--info-ink); border-radius: 4px; padding: 0 3px; font-family: var(--mono); font-size: 12.5px; }
.wa-var.is-col { background: rgba(255, 122, 26, .14); color: var(--warn-ink); }
.wa-btns { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.wa-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; background: var(--bubble); border-radius: 8px;
  color: var(--bubble-link); font-size: 14px; font-weight: 500;
  box-shadow: 0 1px .5px rgba(11, 27, 58, .13);
}
.wa-btn svg { width: 15px; height: 15px; }
.wa-empty { font-size: 13px; color: var(--bubble-meta); align-self: center; margin: auto; padding: 32px 0; text-align: center; }

/* ---------- Page specifics ---------- */
/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 380px); justify-content: center; align-content: center; background: var(--bg-2); padding: 24px 16px; }
.auth-card { width: 380px; max-width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 40px 32px 32px; }
.auth-card .logo-mark { width: 40px; height: 40px; margin-bottom: 24px; }
.auth-title { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.auth-sub { font-size: 14px; color: var(--ink-3); margin-top: 4px; margin-bottom: 28px; }
.auth-foot { margin-top: 24px; font-size: 12px; color: var(--ink-3); text-align: center; }

/* Upcoming list */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); min-height: 56px; }
.list-item:last-child { border-bottom: 0; }
.list-item .li-icon { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--blue-tint); color: var(--brand-blue); display: grid; place-items: center; flex: none; }
.list-item .li-icon svg { width: 16px; height: 16px; }
.list-item .li-title { font-size: 13.5px; font-weight: 500; }
.list-item .li-sub { font-size: 12px; color: var(--ink-3); }
.list-item .li-right { margin-left: auto; text-align: right; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
a.list-item { color: inherit; }
a.list-item:hover { background: var(--bg-2); text-decoration: none; }

/* Setup checklist */
.setup { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.setup-step { padding: 20px; border-right: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 6px; }
.setup-step:last-child { border-right: 0; }
.setup-step .ss-num { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; font-weight: 600; display: grid; place-items: center; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.setup-step.is-done .ss-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup-step .ss-num svg { width: 14px; height: 14px; }
.setup-step .ss-title { font-weight: 500; margin-top: 6px; }
.setup-step .ss-text { font-size: 12px; color: var(--ink-3); }
.setup-step .btn-link { margin-top: 4px; font-size: 13px; align-self: flex-start; }

/* Data source cards */
.ds-card { display: flex; flex-direction: column; gap: 16px; padding: 20px; cursor: pointer; transition: border-color var(--dur) var(--ease); }
.ds-card:hover { border-color: var(--line-3); }
.ds-head { display: flex; align-items: flex-start; gap: 12px; }
.ds-type { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--line-2); color: var(--ink-2); }
.ds-type svg { width: 20px; height: 20px; }
.ds-type.csv { background: var(--blue-tint); color: var(--brand-blue); }
.ds-type.gsheet { background: var(--ok-tint); color: var(--ok-ink); }
.ds-type.api { background: var(--warn-tint); color: var(--warn-ink); }
.ds-name { font-weight: 600; font-size: 14.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ds-kind { font-size: 12px; color: var(--ink-3); }
.ds-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.ds-stats .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ds-stats .l { font-size: 12px; color: var(--ink-3); }
.ds-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; }

/* Mapping */
.map-row { display: grid; grid-template-columns: 152px minmax(0, 1fr); gap: 12px; align-items: center; }
.map-row + .map-row { margin-top: 8px; }
.map-key { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.map-key .map-sub { font-size: 12px; color: var(--ink-3); max-width: 100%; }
.map-key code { max-width: 100%; }
.map-key code { font-family: var(--mono); font-size: 12px; background: var(--info-tint); color: var(--info-ink); padding: 2px 6px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-input { position: relative; }
.map-input .input { padding-right: 40px; font-size: 14px; }
.map-input .icon-btn { position: absolute; right: 2px; top: 2px; }

/* Sequence editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.form-card .card-head { border-bottom: 0; padding-bottom: 0; min-height: 0; padding-top: 20px; }
.form-card .card-body { padding-top: 16px; }
.step {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg);
}
.step + .step { margin-top: 0; }
.step-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.step-num { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-navy); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; flex: none; }
.step-title { font-weight: 600; font-size: 14px; }
.step-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; padding: 20px 16px; }
.step-connector { display: flex; align-items: center; gap: 12px; padding: 8px 0 8px 27px; color: var(--ink-3); font-size: 13px; }
.step-connector .line { width: 1px; height: 32px; background: var(--line); }
.step-connector .delay { display: inline-flex; align-items: center; gap: 8px; }
.step-connector .delay .input { width: 88px; height: 32px; font-size: 13px; text-align: right; }
.add-step { display: flex; gap: 8px; margin-top: 16px; }

.sticky-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  margin: 24px calc(var(--gutter) * -1) -64px; padding: 16px var(--gutter);
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.sticky-bar .left { margin-right: auto; font-size: 13px; color: var(--ink-3); }

.schedule-human { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.schedule-human svg { width: 16px; height: 16px; color: var(--brand-blue); }

/* Dry run */
.dry-grid { align-items: start; }
.dry-item { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--bg); min-width: 0; }
.dry-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.dry-item .wa { border: 0; border-radius: 0; }
.dry-item .wa-bar { display: none; }
.dry-item .wa-thread { min-height: 0; }
.dry-json { border-top: 1px solid var(--line); }
.dry-json summary { display: flex; align-items: center; gap: 6px; padding: 10px 14px; font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer; list-style: none; }
.dry-json summary::-webkit-details-marker { display: none; }
.dry-json summary:hover { color: var(--ink); background: var(--bg-2); }
.dry-json[open] summary { border-bottom: 1px solid var(--line); }
.dry-json .code { border: 0; border-radius: 0; max-height: 280px; background: var(--bg-2); }

/* Quick send */
.qs { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.qs-preview { position: sticky; top: 32px; }
.phone-frame { border-radius: 20px; border: 1px solid var(--line); padding: 8px; background: var(--bg); }
.phone-frame .wa { border-radius: 14px; border: 0; }
.phone-frame .wa-thread { min-height: 420px; }

/* Run detail */
.run-detail { padding: 16px 20px 20px; }
.run-stats { display: flex; gap: 24px; font-size: 13px; color: var(--ink-3); flex-wrap: wrap; align-items: center; }
.run-stats b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 4px; }

/* Template grid */
.tpl-name { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink); }

/* Error text in tables */
.err-text { color: var(--err-ink); font-size: 12px; max-width: 280px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qs { grid-template-columns: minmax(0, 1fr) 340px; }
  .step-body { grid-template-columns: minmax(0, 1fr); }
  .step-body .step-preview { max-width: 340px; }
  .drawer.is-wide { width: 100vw; }
}
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 30;
    height: 56px; padding: 0 8px 0 16px;
    background: rgba(255, 255, 255, .92); backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; flex: 1; }
  .mobile-nav {
    position: fixed; top: 56px; left: 0; right: 0; z-index: 29;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-pop);
    padding: 8px 12px 12px; max-height: calc(100vh - 56px); overflow-y: auto;
  }
  .mobile-nav .nav-label { padding-top: 8px; }
  .mobile-nav .sidebar-foot { margin-top: 12px; }
  .page { padding-top: 24px; }
  .page-head { flex-wrap: wrap; }
  .page-actions { width: 100%; justify-content: flex-start; }
  .grid-main-side, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .qs { grid-template-columns: minmax(0, 1fr); }
  .qs-preview { position: static; }
  .setup { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .setup-step:nth-child(2) { border-right: 0; }
  .setup-step:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
  .drawer-split { grid-template-columns: minmax(0, 1fr); height: auto; }
  .drawer-body.is-split { overflow-y: auto; }
  .drawer-split > .form-col, .drawer-split > .preview-col { overflow: visible; }
  .drawer-split > .preview-col { border-left: 0; border-top: 1px solid var(--line); }
  .sticky-bar { margin-bottom: -64px; }
}
@media (min-width: 901px) { .mobile-nav { display: none !important; } }
@media (max-width: 600px) {
  .page-title { font-size: 20px; line-height: 28px; }
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 16px; }
  .stat-value { font-size: 24px; line-height: 32px; }
  .field-row, .field-row.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .toolbar .search { width: 100%; }
  .toolbar > .segmented { max-width: 100%; overflow-x: auto; }
  .drawer { width: 100vw; border-left: 0; }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 16px; padding-right: 16px; }
  .drawer-split > .form-col, .drawer-split > .preview-col { padding: 16px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { min-width: 0; max-width: none; }
  .setup { grid-template-columns: minmax(0, 1fr); }
  .setup-step { border-right: 0; border-bottom: 1px solid var(--line-2); }
  .setup-step:last-child { border-bottom: 0; }
  .kv { grid-template-columns: 112px minmax(0, 1fr); }
  .map-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .card { padding: 16px; }
  .card.card-flush, .card.stat { padding: 0; }
  .card.stat { padding: 16px; }
  .table th:first-child, .table td:first-child { padding-left: 16px; }
  .table th:last-child, .table td:last-child { padding-right: 16px; }
  .list-item { padding: 12px 16px; }
  .auth-card { padding: 32px 24px 24px; }
  .step-body { padding: 16px; }
  .sticky-bar { flex-wrap: wrap; }
  .sticky-bar .left { width: 100%; }
  .ds-stats .v { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Page enter */
.page.is-entering { animation: pageIn 180ms var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.icon-btn:disabled { opacity: .35; pointer-events: none; }

/* Settings sections */
.settings-section { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px; padding: 32px 0; border-top: 1px solid var(--line); }
.settings-section:first-of-type { border-top: 0; padding-top: 8px; }
.settings-section .s-title { font-size: 15px; font-weight: 600; }
.settings-section .s-desc { font-size: 13px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
.settings-section .card { max-width: 560px; }
@media (max-width: 900px) { .settings-section { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 24px 0; } }

@media (max-width: 900px) { .page-actions { flex: 1 1 100%; } }
@media (max-width: 1100px) { .dry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .dry-grid { grid-template-columns: minmax(0, 1fr); } }

.page-title .pill { vertical-align: 5px; margin-left: 10px; }
@media (max-width: 600px) {
  .ds-grid { grid-template-columns: minmax(0, 1fr); }
  .segmented button { padding: 0 10px; }
  .sticky-bar { flex-wrap: nowrap; gap: 6px; }
  .sticky-bar .left, .sticky-bar > .btn-ghost { display: none; }
  .sticky-bar .btn { padding: 0 10px; font-size: 13px; }
  .sticky-bar .btn svg { display: none; }
  .sticky-bar > [data-dryrun] { margin-right: auto; }
}

/* Keep toasts clear of open drawers; anchored scrolling clears sticky bars */
html { scroll-padding-top: 72px; scroll-padding-bottom: 96px; }
body:has(.drawer.is-open) .toasts { right: 504px; }
body:has(.drawer.is-wide.is-open) .toasts { right: 904px; }
.auth > div { width: 100%; max-width: 380px; }
@media (max-width: 1100px) { body:has(.drawer.is-wide.is-open) .toasts { right: auto; left: 24px; bottom: 96px; } }
@media (max-width: 600px) {
  body:has(.drawer.is-open) .toasts, body:has(.drawer.is-wide.is-open) .toasts { right: 16px; left: 16px; top: 16px; bottom: auto; }
}
@media (max-width: 900px) {
  .run-detail { position: sticky; left: 0; width: calc(100vw - 34px); }
  .page-actions .btn-accent { order: -1; }
}

/* ==========================================================================
   Inbox, auto-replies, do-not-contact (inbox track)
   ========================================================================== */
.nav a { position: relative; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand-blue); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; line-height: 1; }
.nav a[aria-current="page"] .nav-badge { background: var(--brand-blue); }

.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - var(--gutter) * 2); min-height: 480px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); overflow: hidden; }
.ib-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.ib-list-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.ib-list-head .search .input { font-size: 14px; }
.ib-rows { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.ib-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line-2); background: var(--bg); color: var(--ink); cursor: pointer; transition: background-color var(--dur) var(--ease); }
.ib-row:hover { background: var(--bg-2); }
.ib-row.is-active { background: var(--blue-tint); }
.ib-row:focus-visible { box-shadow: inset var(--focus-ring); }
.ib-av { width: 36px; height: 36px; border-radius: 50%; background: var(--line-2); color: var(--ink-2); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.ib-row-top, .ib-row-bot { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ib-row-top { justify-content: space-between; }
.ib-name { font-size: 14px; font-weight: 500; }
.ib-row.is-unread .ib-name, .ib-row.is-unread .ib-preview { font-weight: 600; color: var(--ink); }
.ib-time { font-size: 12px; color: var(--ink-3); flex: none; }
.ib-preview { font-size: 13px; color: var(--ink-3); flex: 1; min-width: 0; }
.ib-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand-blue); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; flex: none; font-variant-numeric: tabular-nums; }

.ib-thread { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); background-image: radial-gradient(var(--chat-dot) 1px, transparent 1px); background-size: 14px 14px; }
.ib-blank { flex: 1; display: grid; place-items: center; background: var(--bg); }
.ib-thread-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); min-height: 60px; }
.ib-back { display: none; }
.ib-msgs { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; }
.ib-day { align-self: center; margin: 8px 0; }
.ib-day span { font-size: 11.5px; color: var(--bubble-meta); background: #fff; padding: 4px 10px; border-radius: 8px; box-shadow: 0 1px 0 rgba(11, 27, 58, .06); }
.ib-msg { max-width: min(72%, 520px); display: flex; flex-direction: column; }
.ib-msg.in { align-self: flex-start; }
.ib-msg.out { align-self: flex-end; align-items: flex-end; }
.ib-bubble { position: relative; padding: 6px 8px 4px; border-radius: 8px; background: var(--bubble); color: var(--bubble-ink); font-size: 14px; line-height: 1.4; box-shadow: 0 1px 0 rgba(11, 27, 58, .08); min-width: 64px; }
.ib-msg.in .ib-bubble { border-top-left-radius: 2px; }
.ib-msg.out .ib-bubble { background: #D9FDD3; border-top-right-radius: 2px; }
.ib-msg.is-failed .ib-bubble { background: #FDECEA; }
.ib-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.ib-meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; color: var(--bubble-meta); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ib-status { display: inline-flex; align-items: center; color: var(--bubble-meta); }
.ib-status.is-read { color: #53BDEB; }
.ib-status.is-failed { color: var(--err); }
.ib-tick { width: 16px; height: 13px; }
.ib-handled { color: var(--warn-ink); display: inline-flex; }
.ib-err { display: flex; align-items: flex-start; gap: 4px; font-size: 12px; color: var(--err-ink); margin-top: 4px; max-width: 100%; }
.ib-err svg { flex: none; margin-top: 2px; }
.ib-tap { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--bubble-ink); padding: 2px 0; }
.ib-tap svg { color: var(--bubble-meta); }
.ib-tpl-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--bubble-meta); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.ib-tpl-btns { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ib-tpl-btns span { font-size: 12px; color: var(--bubble-link); background: rgba(255, 255, 255, .6); border-radius: 6px; padding: 3px 8px; }
.ib-media { display: block; max-width: 100%; border-radius: 6px; overflow: hidden; margin-bottom: 4px; }
.ib-media img { display: block; max-width: 100%; max-height: 320px; object-fit: cover; border-radius: 6px; background: #DCE1E6; }
video.ib-media { max-height: 320px; width: 100%; background: #000; }
.ib-audio { width: 260px; max-width: 100%; height: 36px; margin: 2px 0; }
.ib-doc { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(11, 27, 58, .05); border-radius: 6px; font-size: 13px; color: var(--bubble-ink); margin: 2px 0 4px; }
.ib-doc:hover { text-decoration: none; background: rgba(11, 27, 58, .08); }
.ib-doc svg { color: #E35A4F; flex: none; }
.ib-composer { background: var(--bg); border-top: 1px solid var(--line); padding: 10px 16px 12px; }
.ib-window { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; min-height: 28px; }
.ib-window svg { flex: none; }
.ib-window.is-open svg { color: var(--ok-ink); }
.ib-window.is-closed { color: var(--warn-ink); background: var(--warn-tint); border-radius: var(--r-sm); padding: 8px 10px; }
.ib-window .spacer { flex: 1; }
.ib-window .segmented { height: 28px; }
.ib-window .segmented button { height: 26px; font-size: 12px; }
.ib-form { display: flex; gap: 8px; align-items: flex-end; }
.ib-form .textarea { flex: 1; min-height: 40px; max-height: 160px; font-size: 14px; }
.ib-form.is-template { align-items: flex-start; }
.ib-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.ib-vars .field + .field { margin-top: 0; }
.ib-vars .label { font-size: 12px; }

/* keyword chips (auto-reply editor) */
.kw-box { display: flex; flex-wrap: wrap; gap: 6px; min-height: var(--control-h); padding: 4px 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); cursor: text; }
.kw-box:focus-within { border-color: var(--brand-blue); box-shadow: var(--focus-ring); }
.kw-chip { display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 4px 0 10px; border-radius: 6px; background: var(--blue-tint); color: var(--info-ink); font-size: 13px; font-weight: 500; }
.kw-chip .icon-btn { width: 20px; height: 20px; color: inherit; }
.kw-chip .icon-btn svg { width: 12px; height: 12px; }
.kw-input { flex: 1; min-width: 120px; height: 26px; border: 0; outline: 0; font-size: 14px; background: transparent; color: var(--ink); }
.ar-prio { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); display: inline-grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.ar-preview { margin-top: 6px; padding: 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; color: var(--ink); font-size: 13px; }
.table tr.is-off td { color: var(--ink-3); }
.table tr.is-off .cell-title { color: var(--ink-2); }

@media (max-width: 1100px) { .ar-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .inbox { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 56px - 32px); border-radius: var(--r-sm); }
  .ib-list { border-right: 0; }
  .inbox.is-thread .ib-list { display: none; }
  .inbox:not(.is-thread) .ib-thread { display: none; }
  .ib-back { display: inline-grid; margin-left: -6px; }
  .ib-msg { max-width: 86%; }
  .ib-msgs { padding: 12px; }
  .ib-composer { padding: 8px 12px 10px; }
  .ib-hide-sm { display: none !important; }
  .ib-window .segmented { margin-left: auto; }
}

/* ==========================================================================
   Track E — dashboard analytics, charts, setup wizard, help, messages
   (additive section; colours reference the tokens above so themes follow)
   ========================================================================== */
:root {
  --chart-1: var(--brand-blue);                 /* read */
  --chart-2: rgba(30, 94, 255, .55);            /* delivered */
  --chart-3: var(--line-4);                           /* sent, not yet delivered */
  --chart-err: var(--err);                      /* failed */
  --chart-line: var(--brand-orange);            /* replies */
  --chart-grid: var(--line-2);
  --chart-tick: var(--ink-3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --chart-3: rgba(138, 148, 166, .5); --chart-grid: rgba(255, 255, 255, .08); }
}
:root[data-theme="dark"] { --chart-3: rgba(138, 148, 166, .5); --chart-grid: rgba(255, 255, 255, .08); }

.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

/* KPI tiles */
.kpi .stat-delta .delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .stat-delta .delta.up { color: var(--ok-ink); }
.kpi .stat-delta .delta.down { color: var(--err-ink); }
.kpi .stat-delta .delta.flat { color: var(--ink-3); }
.kpi.is-err .stat-value { color: var(--err-ink); }

/* Charts */
.chart-host { position: relative; }
.chart-wrap { position: relative; width: 100%; min-height: 220px; }
.chart { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.chart .ch-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .ch-tick, .chart .ch-x { fill: var(--chart-tick); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ch-bar { outline: none; cursor: default; }
.chart .ch-bar:hover rect:not(.ch-hit), .chart .ch-bar:focus-visible rect:not(.ch-hit) { opacity: .85; }
.chart .ch-bar:focus-visible .ch-hit { fill: var(--blue-tint); stroke: var(--brand-blue); stroke-width: 1.5; rx: 4; }
.chart .ch-empty { fill: var(--line); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 160px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-pop);
  padding: 8px 10px; font-size: 12px; line-height: 1.45; color: var(--ink);
}
.chart-tip .ct-title { font-weight: 600; margin-bottom: 4px; }
.chart-tip .ct-row { display: flex; align-items: center; gap: 6px; }
.chart-tip .ct-row b { font-variant-numeric: tabular-nums; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); }
.ch-key { display: inline-flex; align-items: center; gap: 6px; }
.ch-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.ch-swatch.is-line { height: 3px; border-radius: 2px; width: 14px; }
.spark { display: inline-block; vertical-align: middle; }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.fn-row { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 13px; }
.fn-label { color: var(--ink-2); }
.fn-bar { height: 10px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.fn-fill { display: block; height: 100%; background: var(--c); border-radius: 999px; }
.fn-val { white-space: nowrap; font-size: 13px; }
.fn-val .fn-step { font-size: 11px; }
@media (max-width: 600px) { .fn-row { grid-template-columns: 64px minmax(0, 1fr); } .fn-val { grid-column: 2; } .fn-val .fn-step { display: none; } }

/* Needs attention / activity lists */
.att-list { display: flex; flex-direction: column; }
.att-item { border-bottom: 1px solid var(--line-2); }
.att-item:last-child { border-bottom: 0; }
.att-link { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px; color: inherit; font-size: 13px; }
.att-link > svg { flex: none; color: var(--ink-4); margin-top: 2px; }
a.att-link:hover { background: var(--bg-2); text-decoration: none; }
.att-title { display: block; font-weight: 500; color: var(--ink); }
.att-detail { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; line-height: 1.45; }
.att-time { display: block; color: var(--ink-3); font-size: 11px; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sev { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--info-tint); color: var(--info-ink); }
.sev svg { width: 14px; height: 14px; }
.sev-error { background: var(--err-tint); color: var(--err-ink); }
.sev-warn { background: var(--warn-tint); color: var(--warn-ink); }
.fail-list { display: flex; flex-direction: column; }
.fail-item { padding: 12px 20px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.fail-item:last-child { border-bottom: 0; }
.fail-item .fail-fix { color: var(--ink-2); font-size: 12px; margin: 4px 0 2px; line-height: 1.45; }
.fail-item > .row > b { font-size: 15px; min-width: 32px; }

/* Account health strip */
.health-strip { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.health-card { padding: 10px 16px; font-size: 13px; }
.health-card.is-err { border-color: rgba(217, 48, 37, .35); }
.hc-name { font-weight: 600; }
.hc-warn { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-2); color: var(--ink-2); font-size: 12.5px; line-height: 1.45; }
.hc-warn svg { flex: none; color: var(--warn-ink); margin-top: 2px; }
.setup-strip { display: flex; align-items: center; gap: 12px; padding: 10px 16px; margin-bottom: 16px; font-size: 13px; }
a.setup-step { color: inherit; }
a.setup-step:hover { background: var(--bg-2); text-decoration: none; }

/* Setup wizard */
.wizard { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.wiz-steps { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 24px; }
.wiz-step { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 10px; border-radius: var(--r-sm); text-align: left; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.wiz-step:hover { background: var(--bg-2); color: var(--ink); }
.wiz-step.is-active { background: var(--blue-tint); color: var(--brand-blue); }
.wiz-step .ws-num { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); font-size: 12px; font-weight: 600; display: grid; place-items: center; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; background: var(--bg); }
.wiz-step.is-active .ws-num { border-color: var(--brand-blue); color: var(--brand-blue); }
.wiz-step.is-done .ws-num { background: var(--ok); border-color: var(--ok); color: #fff; }
.wiz-step .ws-num svg { width: 14px; height: 14px; }
.wiz-body { max-width: 720px; }
.wiz-head { margin-bottom: 20px; }
.wiz-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; margin-top: 4px; outline: none; }
.wiz-lead { color: var(--ink-2); font-size: 14px; line-height: 1.55; margin-bottom: 16px; }
.wiz-card { margin-bottom: 16px; }
.wiz-form .field + details, .wiz-form details + .field { margin-top: 12px; }
.wiz-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.wiz-foot .help { flex: 1 1 240px; }
.where { font-size: 13px; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--bg-2); padding: 0 12px; }
.where summary { display: flex; align-items: center; gap: 6px; height: 36px; cursor: pointer; font-weight: 500; color: var(--brand-blue); list-style: none; }
.where summary::-webkit-details-marker { display: none; }
.where summary svg { flex: none; }
.where[open] { padding-bottom: 12px; }
.where-list { padding-left: 20px; list-style: decimal; display: flex; flex-direction: column; gap: 6px; line-height: 1.5; }
.fields-list { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.fields-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.fields-list code { font-family: var(--mono); font-size: 12.5px; background: var(--line-2); padding: 2px 6px; border-radius: 5px; }
.live { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px; background: var(--bg-2); }
.live.is-ok { background: var(--ok-tint); border-color: rgba(26, 158, 92, .25); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ink-4); }
.live-dot.ok { background: var(--ok); }
.live-dot.wait { background: var(--warn); animation: pulse 1.4s var(--ease) infinite; }
.next-cards .next-card { display: flex; flex-direction: column; gap: 8px; color: inherit; }
.next-cards .next-card:hover { text-decoration: none; border-color: var(--line-3); }
.next-cards .next-card b { font-size: 14.5px; }
.details-sm { font-size: 12px; margin-top: 6px; }
.details-sm summary { cursor: pointer; color: var(--ink-3); font-weight: 500; }
.details-sm > :not(summary) { margin-top: 8px; }
@media (max-width: 900px) {
  .wizard { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .wiz-steps { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .wiz-step { width: auto; flex: none; height: 36px; padding: 0 10px 0 6px; font-size: 13px; }
}

/* Messages */
.filters-more { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg-2); margin-bottom: 12px; }
.filters-more .field { margin: 0; min-width: 140px; flex: 1 1 140px; }
.filters-more .field + .field { margin-top: 0; }
.ticks { font-size: 12px; letter-spacing: -.12em; color: var(--ink-4); font-weight: 600; }
.ticks.is-read { color: #53BDEB; }
.kind-ic { display: inline-flex; align-items: center; color: var(--ink-4); gap: 0; }
.kind-ic svg:last-child { margin-left: -2px; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-step { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 13px; color: var(--ink-3); position: relative; }
.tl-step + .tl-step::before { content: ""; position: absolute; left: 8px; top: -14px; height: 14px; width: 1px; background: var(--line); }
.tl-step.is-done { color: var(--ink); }
.tl-dot { width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; flex: none; background: var(--bg); color: #fff; }
.tl-step.is-done .tl-dot { background: var(--ok); border-color: var(--ok); }
.tl-step.is-err .tl-dot { background: var(--err); border-color: var(--err); }
.tl-time { font-size: 12px; white-space: nowrap; }

/* Help */
.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
.help-nav { position: sticky; top: 24px; }
.help-nav ul { display: flex; flex-direction: column; gap: 2px; }
.help-nav a { display: block; padding: 7px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.help-nav a:hover { background: var(--bg-2); color: var(--ink); text-decoration: none; }
.help-nav a.is-dim { opacity: .4; }
.help-body { max-width: 760px; min-width: 0; }
.help-section { padding: 0 0 32px; margin-bottom: 32px; border-bottom: 1px solid var(--line); }
.help-section:last-child { border-bottom: 0; }
.help-section > * + * { margin-top: 14px; }
.help-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; outline: none; }
.help-summary { color: var(--ink-3); font-size: 14px; margin-top: 4px !important; }
.help-section p { font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.help-steps { list-style: decimal; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.help-steps li b { display: block; color: var(--ink); }
.help-bullets { list-style: disc; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.help-table td { vertical-align: top; white-space: normal; line-height: 1.45; }
.help-table .cell-title { white-space: nowrap; }
.err-table td:nth-child(2), .err-table td:nth-child(3) { min-width: 200px; }
.err-table tr.is-hl td { background: var(--warn-tint); }
.help-code pre { max-height: none; white-space: pre-wrap; }
.help-links { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.help-links a { display: inline-flex; align-items: center; gap: 4px; }
.faq { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 14px; }
.faq + .faq { margin-top: 8px !important; }
.faq summary { cursor: pointer; font-weight: 500; font-size: 14px; padding: 11px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.faq summary::before { content: "+"; color: var(--ink-3); width: 14px; }
.faq[open] summary::before { content: "–"; }
.faq summary::-webkit-details-marker { display: none; }
.faq p { padding-bottom: 12px; }
@media (max-width: 900px) {
  .help-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .help-nav { position: static; }
  .help-nav ul { flex-direction: row; flex-wrap: wrap; }
}
/* ---------- Hardening (track D): settings tabs, health warnings, activity ---------- */
.settings-tabs { flex-wrap: wrap; gap: 0 20px; margin-bottom: 8px; }
.settings-tabs button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.settings-tabs button svg { width: 15px; height: 15px; }
.settings-panel .settings-section:first-child { border-top: 0; padding-top: 16px; }
.settings-save { justify-content: flex-end; padding: 8px 0 16px; }
.day-picks { flex-wrap: wrap; gap: 6px; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check span { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink-2); background: var(--bg); cursor: pointer; }
.chip-check input:checked + span { background: var(--blue-tint); border-color: rgba(30, 94, 255, .3); color: var(--brand-blue); }
.chip-check input:focus-visible + span { box-shadow: var(--focus-ring); }
.details-card summary { cursor: pointer; font-weight: 500; font-size: 14px; list-style: none; display: flex; align-items: center; gap: 8px; }
.details-card summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(-45deg); transition: transform var(--dur) var(--ease); }
.details-card[open] summary::before { transform: rotate(45deg); }
.code-block { margin: 6px 0 0; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-sm); font-family: var(--mono); font-size: 12px; line-height: 1.55; overflow: auto; white-space: pre; color: var(--ink); }
.activity-list .li-icon { background: var(--mute-tint); color: var(--ink-3); }
.activity-list .li-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.health-warnings .s-title { font-size: 15px; font-weight: 600; }
.hw-link { color: var(--warn-ink); font-weight: 500; }
.hw-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hw-item { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--warn-tint); border: 1px solid rgba(255, 122, 26, .2); font-size: 13px; line-height: 1.5; }
.hw-item.is-error { background: var(--err-tint); border-color: rgba(217, 48, 37, .18); }
.hw-item .hw-icon { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--warn-ink); }
.hw-item.is-error .hw-icon { color: var(--err-ink); }
.hw-item .hw-msg { font-weight: 500; color: var(--ink); }
.hw-item .hw-fix { color: var(--ink-2); margin-top: 2px; }
.hw-item .hw-fix b { color: var(--ink); font-weight: 600; }
@media (max-width: 600px) { .settings-tabs { gap: 0 14px; } .settings-tabs button span { font-size: 13px; } }
/* ---------- Data sources v2 (type picker, chips, rules, manual list) ---------- */
.ds-type.xlsx { background: var(--ok-tint); color: var(--ok-ink); }
.ds-type.manual { background: var(--blue-tint); color: var(--brand-blue); }
.ds-type.segment { background: rgba(124, 58, 237, .10); color: #5B21B6; }
.ds-type.ingest { background: var(--warn-tint); color: var(--warn-ink); }
.ds-sub { font-weight: 400; }
.ds-sub.err { color: var(--err-ink); }
.ds-when { font-size: 14px; line-height: 27px; font-weight: 500; }
.ds-err { padding: 8px 10px; font-size: 12px; align-items: center; }
.ds-err .btn { flex: none; }
.ds-pick { display: grid; gap: 10px; }
.ds-pick-item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.ds-pick-item:hover { border-color: var(--brand-blue); background: var(--blue-tint); }
.ds-pick-item > .grow { display: flex; flex-direction: column; gap: 2px; }
.ds-pick-item b { font-weight: 600; font-size: 14px; }
.ds-pick-item > svg { color: var(--ink-4); flex: none; }
.ds-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ds-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.ds-chip b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.ds-chip.ok { background: var(--ok-tint); color: var(--ok-ink); } .ds-chip.ok b { color: var(--ok-ink); }
.ds-chip.err { background: var(--err-tint); color: var(--err-ink); } .ds-chip.err b { color: var(--err-ink); }
.ds-chip.warn { background: var(--warn-tint); color: var(--warn-ink); } .ds-chip.warn b { color: var(--warn-ink); }
.ds-chip.info { background: var(--info-tint); color: var(--info-ink); } .ds-chip.info b { color: var(--info-ink); }
.ds-invalid summary { cursor: pointer; font-size: 13px; color: var(--err-ink); font-weight: 500; }
.ds-rulebox { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; background: var(--bg-2); }
.rules { display: flex; flex-direction: column; gap: 8px; }
.ds-rule { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) minmax(0, 1.4fr) 28px; gap: 6px; align-items: center; }
.ds-rule .input[disabled] { opacity: .5; }
.ds-addrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
details > summary { cursor: pointer; color: var(--ink-2); }
details > summary::-webkit-details-marker { color: var(--ink-4); }
@media (max-width: 600px) {
  .ds-rule { grid-template-columns: minmax(0, 1fr) 28px; }
  .ds-rule [data-f] { grid-column: 1 / 2; }
  .ds-addrow { grid-template-columns: minmax(0, 1fr); }
  .field-row.cols-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Contacts hub ---------- */
.ct-avatar { width: 32px; height: 32px; font-size: 12px; flex: none; }
.ct-avatar.is-lg { width: 48px; height: 48px; font-size: 16px; }
.ct-head { display: flex; align-items: flex-start; gap: 14px; }
.ct-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ct-tag { gap: 4px; padding-right: 6px; }
.ct-tag-x { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; color: var(--ink-3); }
.ct-tag-x:hover { background: var(--err-tint); color: var(--err-ink); }
.ct-timeline { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ct-timeline li { display: flex; gap: 12px; align-items: flex-start; }
.ct-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-4); margin-top: 6px; flex: none; }
.ct-dot.sent { background: var(--info); } .ct-dot.delivered, .ct-dot.read { background: var(--ok); } .ct-dot.failed { background: var(--err); }
.ct-table .pill { vertical-align: 1px; margin-left: 4px; }
@media (max-width: 900px) {
  .ct-table th:nth-child(3), .ct-table td:nth-child(3), .ct-table th:nth-child(5), .ct-table td:nth-child(5) { display: none; }
  .toolbar .search { width: 100%; }
}

/* ---------- Sequences v2 (schedule cards, sending rules, variables, recipes, run detail) ---------- */
.sched-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sched-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); cursor: pointer;
  font: inherit; color: var(--ink-2); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sched-card:hover { border-color: var(--line-3); color: var(--ink); }
.sched-card[aria-checked="true"] { border-color: var(--brand-blue); background: var(--blue-tint); color: var(--ink); box-shadow: inset 0 0 0 1px var(--brand-blue); }
.sched-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sched-card .sched-icon { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--line-2); color: var(--ink-2); margin-bottom: 4px; }
.sched-card[aria-checked="true"] .sched-icon { background: #fff; color: var(--brand-blue); }
.sched-card .sched-icon svg { width: 16px; height: 16px; }
.sched-card .sched-title { font-weight: 600; font-size: 14px; }
.sched-card .sched-text { font-size: 12px; color: var(--ink-3); }
.next-fires { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.seq-rule { padding: 14px 0; border-top: 1px solid var(--line-2); }
.seq-rule:first-child { padding-top: 0; border-top: 0; }
.rule-body { margin-top: 12px; padding-left: 52px; }
.rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.rule-grid .field + .field { margin-top: 0; }
.var-rows { display: flex; flex-direction: column; gap: 8px; }
.var-row { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) 28px; gap: 8px; align-items: center; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.recipe-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; min-height: 168px;
  padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg); cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.recipe-card:hover { border-color: var(--brand-blue); transform: translateY(-1px); }
.recipe-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.recipe-card .recipe-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-tint); color: var(--brand-blue); margin-bottom: 4px; }
.recipe-card .recipe-icon svg { width: 20px; height: 20px; }
.recipe-card .recipe-name { font-weight: 600; font-size: 15px; }
.recipe-card .recipe-desc { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.recipe-card .recipe-meta { font-size: 12px; color: var(--ink-3); margin-top: auto; }
.recipe-card .recipe-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.recipe-help { border-color: rgba(30, 94, 255, .25); }
.recipe-help .section-title svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--brand-orange); }
.tpl-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.tpl-example { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg-2); }
.tpl-example .tpl-body { font-size: 13px; line-height: 1.5; color: var(--ink-2); white-space: pre-wrap; margin: 0; }
.dry-warnings { margin: 4px 0 0; padding-left: 18px; }
.dry-warnings li + li { margin-top: 2px; }
.progress-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.progress-legend .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; background: var(--ink-3); }
.progress-legend .sw.ok { background: var(--ok); } .progress-legend .sw.err { background: var(--err); } .progress-legend .sw.skip { background: var(--line); }
.run-note { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); }
.run-note.warn { color: var(--warn-ink); }
.run-note svg { width: 14px; height: 14px; }
.reasons { display: flex; flex-direction: column; gap: 8px; }
.reason { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); font-size: 13px; }
.reason .reason-count { min-width: 36px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--err-ink); }
.reason .reason-code { display: block; font-weight: 500; }
.reason .reason-hint { display: block; color: var(--ink-3); font-size: 12px; margin-top: 2px; line-height: 1.45; }
.rules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.rule-item { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.rule-item .li-icon { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--line-2); color: var(--ink-2); display: grid; place-items: center; flex: none; }
.rule-item .li-icon svg { width: 15px; height: 15px; }
.rule-item .rule-label { display: block; font-size: 12px; color: var(--ink-3); }
.rule-item .rule-value { display: block; font-size: 13px; font-weight: 500; }
.rule-vars { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.detail-grid { align-items: start; }
tr.is-muted td { opacity: .6; }
@media (max-width: 900px) {
  .sched-cards { grid-template-columns: minmax(0, 1fr); }
  .rule-grid { grid-template-columns: minmax(0, 1fr); }
  .rule-grid .field + .field { margin-top: 16px; }
  .rule-body { padding-left: 0; }
  .var-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 28px; }
  .rules-grid { grid-template-columns: minmax(0, 1fr); }
  .field-row.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .run-stats { flex-direction: column; align-items: flex-start; gap: 4px; }
}
