/* ==========================================================================
   Reach X — design system
   ========================================================================== */

:root {
  --bg:            #0f1117;
  --card:          #1a1d27;
  --sidebar:       #13161f;
  --accent:        #4f8ef7;
  --accent-dim:    rgba(79, 142, 247, .14);
  --text:          #ffffff;
  /* Lifted from #8892a4: small secondary text on --card was too low-contrast
     to read comfortably at 11-12px. */
  --muted:         #9ba6b9;
  --muted-dim:     #78829a;
  --green:         #22c55e;
  --red:           #ef4444;
  --orange:        #f59e0b;
  --purple:        #a78bfa;
  --border:        #2a2d3a;

  --radius:        10px;
  --radius-lg:     14px;
  --sidebar-w:     220px;
  --topbar-h:      62px;

  --shadow:        0 8px 30px rgba(0, 0, 0, .45);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2f3341; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3c4152; }

/* ── Login ──────────────────────────────────────────────────────────────── */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(79, 142, 247, .13), transparent 70%),
    var(--bg);
}

.login-wrap { width: 100%; max-width: 400px; padding: 24px; }

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 34px 30px;
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; margin-bottom: 26px; }

.login-logo {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7c5cf7);
  display: grid; place-items: center;
  font-size: 21px; color: #fff;
}

.login-brand h1 { font-size: 24px; letter-spacing: -.4px; }
.login-brand p  { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.login-foot     { text-align: center; color: #5b6274; font-size: 12px; margin-top: 18px; }

.field { margin-bottom: 16px; }
.field > label {
  display: block; margin-bottom: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
}

/* ── Form controls ──────────────────────────────────────────────────────── */

/* Match every text-like input, including ones written without a type
   attribute (which default to text but do NOT match input[type=text]).
   Checkboxes, radios, ranges and file pickers are excluded and styled below. */
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=submit]):not([type=button]),
select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: #12141c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder, textarea::placeholder { color: #545c6e; }
input:disabled, select:disabled, textarea:disabled {
  opacity: .6;
  cursor: not-allowed;
  background: #0e1017;
  color: var(--muted);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }

/* Native date/time pickers render a near-black indicator on a dark field.
   Invert it so the calendar/clock affordance is actually visible. */
input[type=time]::-webkit-calendar-picker-indicator,
input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(.55);
  cursor: pointer;
}
input[type=time]::-webkit-calendar-picker-indicator:hover,
input[type=date]::-webkit-calendar-picker-indicator:hover { filter: invert(1) opacity(1); }

/* Checkboxes and radios — bare ones in table cells were invisible on dark. */
input[type=checkbox], input[type=radio] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
  margin: 0;
}
input[type=checkbox]:disabled, input[type=radio]:disabled { cursor: not-allowed; opacity: .5; }

/* File picker — the native button is unreadable on a dark background. */
input[type=file] {
  font-family: inherit; font-size: 13px;
  color: var(--muted);
  max-width: 100%;
}
input[type=file]::file-selector-button {
  padding: 8px 14px;
  margin-right: 12px;
  background: var(--accent);
  border: 0; border-radius: var(--radius);
  color: #fff;
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
input[type=file]::file-selector-button:hover { background: #3f7ce8; }

input[type=range] { accent-color: var(--accent); cursor: pointer; width: 100%; }

/* ── Input with a leading icon ──────────────────────────────────────────────
   Declared AFTER the base control rules: these carry the same specificity, so
   source order decides. Placed earlier, the base padding reset the offset and
   the icon sat on top of the typed text. */
.input-icon { position: relative; display: flex; align-items: center; }
.input-icon > i:first-child {
  position: absolute; left: 13px; z-index: 1;
  color: #616a7d; font-size: 13px; pointer-events: none;
}
.input-icon > input { padding-left: 36px; }
.input-icon > input[type=password],
.input-icon > input[type=text].has-reveal { padding-right: 40px; }
.input-icon .reveal {
  position: absolute; right: 6px; z-index: 1;
  background: none; border: 0; color: #616a7d;
  padding: 7px 9px; cursor: pointer; border-radius: 6px;
  width: auto; height: auto;
}
.input-icon .reveal:hover { color: var(--text); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8.5 2 4.5h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: #232735;
  color: var(--text);
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}

.btn:hover:not(:disabled)  { background: #2c3141; }
.btn:disabled              { opacity: .55; cursor: not-allowed; }
.btn-primary               { background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: #3f7ce8; }
.btn-danger                { background: var(--red); }
.btn-danger:hover:not(:disabled)  { background: #dc2f2f; }
.btn-ghost                 { background: transparent; border-color: var(--border); }
.btn-ghost:hover:not(:disabled)   { background: #1f2330; }
.btn-sm                    { padding: 6px 11px; font-size: 12.5px; }
.btn-block                 { width: 100%; }

/* Spinner: swaps in place of the label so the button never changes size. */
.btn.is-loading           { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > *       { visibility: hidden; }
.btn.is-loading::after {
  content: '';
  position: absolute; inset: 0; margin: auto;
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: #1f2330; }
.icon-btn.plain { border-color: transparent; }

/* ── Shell ──────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0;
  z-index: 40;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15.5px;
}

.sidebar-logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c5cf7);
  display: grid; place-items: center; font-size: 13px;
}

.sidebar-nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 3px; flex: 1; }

.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav a i     { width: 16px; text-align: center; font-size: 14px; }
.sidebar-nav a:hover { background: #1b1f2b; color: var(--text); }
.sidebar-nav a.active { background: var(--accent-dim); color: var(--accent); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

.master-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: #1b1f2b; border-radius: 8px;
  color: var(--muted); font-size: 12px;
}

.sidebar-scrim {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 35;
}

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 30;
  background: rgba(15, 17, 23, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
}

.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 11px 5px 5px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12.5px; color: var(--muted);
}

.avatar {
  width: 25px; height: 25px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c5cf7);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: #fff;
}

.content { padding: 22px; max-width: 1700px; }
.only-mobile { display: none; }

/* ── Cards & layout ─────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-body { padding: 18px; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.section-head h1 { font-size: 20px; letter-spacing: -.3px; }

.row      { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end  { margin-left: auto; }
.grid     { display: grid; gap: 14px; }
.grid-2   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-4   { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5   { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mt-16    { margin-top: 16px; }
.mt-24    { margin-top: 24px; }

/* ── Stat cards ─────────────────────────────────────────────────────────── */

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 17px;
  display: flex; align-items: center; gap: 13px;
  min-width: 0;
}

.stat-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 15px;
  background: var(--accent-dim); color: var(--accent);
}
.stat-icon.green  { background: rgba(34, 197, 94, .14);  color: var(--green); }
.stat-icon.red    { background: rgba(239, 68, 68, .14);  color: var(--red); }
.stat-icon.orange { background: rgba(245, 158, 11, .14); color: var(--orange); }
.stat-icon.purple { background: rgba(167, 139, 250, .14); color: var(--purple); }

.stat-meta { min-width: 0; }
.stat-label {
  font-size: 12px; color: var(--muted);
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value { font-size: 21px; font-weight: 600; margin-top: 2px; letter-spacing: -.4px; }
.stat-value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 5px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }

table.tbl th {
  text-align: left;
  padding: 11px 14px;
  color: var(--muted);
  font-weight: 500; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: #171a23;
  position: sticky; top: 0; z-index: 1;
}

table.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid #21242f;
  vertical-align: middle;
}

table.tbl tbody tr:hover { background: #1e2130; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl .num { font-variant-numeric: tabular-nums; }
table.tbl td.actions { text-align: right; white-space: nowrap; }

.cell-strong { font-weight: 500; }
.cell-sub    { color: var(--muted); font-size: 12px; margin-top: 2px; }
.clickable   { cursor: pointer; }
.clickable:hover .cell-strong { color: var(--accent); }

/* ── Badges & pills ─────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 500;
  background: #262a38; color: var(--muted);
  white-space: nowrap;
}
.badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge.no-dot::before { display: none; }
.badge.green  { background: rgba(34, 197, 94, .14);  color: var(--green); }
.badge.red    { background: rgba(239, 68, 68, .14);  color: var(--red); }
.badge.orange { background: rgba(245, 158, 11, .14); color: var(--orange); }
.badge.blue   { background: var(--accent-dim);       color: var(--accent); }
.badge.purple { background: rgba(167, 139, 250, .14); color: var(--purple); }

.tag-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  border: 1px solid currentColor;
  margin-right: 4px;
}

/* ── Toggle switch ──────────────────────────────────────────────────────── */

.switch {
  display: inline-flex; align-items: center; gap: 9px;
  cursor: pointer; user-select: none;
  position: relative;
}

/* Visually hidden rather than display:none, so the control stays focusable
   and keyboard-operable. Sized to zero so it cannot paint a native checkbox. */
.switch > input[type=checkbox] {
  position: absolute;
  opacity: 0;
  width: 38px; height: 21px;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.switch > .track {
  width: 38px; height: 21px; flex: none;
  background: #343949;
  border: 1px solid #3d4252;
  border-radius: 20px;
  position: relative;
  transition: background .18s, border-color .18s;
}
.switch > .track::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
  transition: transform .18s;
}

.switch > input[type=checkbox]:checked ~ .track {
  background: var(--green);
  border-color: var(--green);
}
.switch > input[type=checkbox]:checked ~ .track::after { transform: translateX(17px); }
.switch > input[type=checkbox]:focus-visible ~ .track { box-shadow: 0 0 0 3px var(--accent-dim); }
.switch > input[type=checkbox]:disabled ~ .track { opacity: .5; cursor: not-allowed; }

.switch .switch-label { font-size: 13px; color: var(--muted); }

/* ── Progress bar ───────────────────────────────────────────────────────── */

.progress { width: 90px; height: 5px; background: #2a2e3c; border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.progress.red   > span { background: var(--red); }
.progress.green > span { background: var(--green); }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tabs button {
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 15px;
  color: var(--muted);
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.tabs button:hover  { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.subtabs { display: inline-flex; gap: 3px; background: #12141c; padding: 3px; border-radius: 9px; }
.subtabs button {
  background: none; border: 0; border-radius: 7px;
  padding: 6px 13px;
  color: var(--muted); font-family: inherit; font-size: 12.5px; font-weight: 500;
  cursor: pointer;
}
.subtabs button.active { background: #272b3a; color: var(--text); }

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast-host {
  position: fixed; right: 20px; bottom: 20px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 9px;
  max-width: 380px;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; line-height: 1.5;
  animation: toast-in .2s ease-out;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warn    { border-left-color: var(--orange); }
.toast i       { margin-top: 2px; }
.toast.success i { color: var(--green); }
.toast.error i   { color: var(--red); }
.toast.warn i    { color: var(--orange); }
.toast .close    { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Modal ──────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 8, 13, .72);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: grid; place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%; max-width: 540px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: modal-in .18s ease-out;
}
.modal.wide  { max-width: 1080px; }
.modal.large { max-width: 800px; }

@keyframes modal-in { from { opacity: 0; transform: translateY(-10px) scale(.99); } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15.5px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ── Drawer (right-side panel) ──────────────────────────────────────────── */

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 8, 13, .6);
  z-index: 200;
  display: flex; justify-content: flex-end;
}

.drawer {
  width: 100%; max-width: 760px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  animation: drawer-in .2s ease-out;
}

@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }

.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }

/* ── States ─────────────────────────────────────────────────────────────── */

.empty, .loading-box {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}
.empty i, .loading-box i { font-size: 26px; margin-bottom: 12px; display: block; opacity: .55; }
.empty h4 { color: var(--text); font-size: 14.5px; margin-bottom: 5px; }
.empty p  { margin: 0; font-size: 13px; }

.spinner {
  width: 17px; height: 17px;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

.skeleton {
  background: linear-gradient(90deg, #1e2130 25%, #262a39 50%, #1e2130 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
  height: 13px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13px; line-height: 1.55;
  margin-bottom: 14px;
  display: flex; gap: 9px; align-items: flex-start;
}
.alert-error { background: rgba(239, 68, 68, .1);  border: 1px solid rgba(239, 68, 68, .3);  color: #fca5a5; }
.alert-warn  { background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .3); color: #fcd34d; }
.alert-info  { background: var(--accent-dim);      border: 1px solid rgba(79, 142, 247, .3); color: #a5c8fb; }
.alert-ok    { background: rgba(34, 197, 94, .1);  border: 1px solid rgba(34, 197, 94, .3);  color: #86efac; }

/* ── Pagination ─────────────────────────────────────────────────────────── */

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted);
}
.pager .row { gap: 6px; }

/* ── Charts ─────────────────────────────────────────────────────────────── */

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }

/* ── Misc utilities ─────────────────────────────────────────────────────── */

.muted      { color: var(--muted); }
.small      { font-size: 12px; line-height: 1.5; }

/* Keeps long campaign names and email bodies from stretching a table cell
   until the row becomes unreadable. Pair with a title attribute. */
.truncate {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mono       { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.nowrap     { white-space: nowrap; }
.text-right { text-align: right; }
.hidden     { display: none !important; }
.divider    { height: 1px; background: var(--border); margin: 18px 0; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.field-help { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

.list-scroll {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px;
}

.kv-list { display: grid; gap: 9px; }
.kv-row  { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.kv-row  > span:first-child { color: var(--muted); }

/* Preference presets (campaign settings) */
.pref-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.pref-opt {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  cursor: pointer;
  background: #12141c;
  transition: border-color .15s, background .15s;
}
.pref-opt:hover    { border-color: #3b4152; }
.pref-opt.selected { border-color: var(--accent); background: var(--accent-dim); }
.pref-opt strong   { display: block; font-size: 13px; margin-bottom: 3px; }
.pref-opt span     { font-size: 11.5px; color: var(--muted); }

/* CSV column mapping */
.map-row {
  display: grid;
  grid-template-columns: 1fr 26px 1fr 1.2fr;
  gap: 10px; align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid #21242f;
}
.map-row:last-child { border-bottom: 0; }
.map-arrow  { text-align: center; color: var(--muted); }
.map-source { font-size: 13px; font-weight: 500; }
.map-preview {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Sequence editor split view */
.seq-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.seq-list   { display: grid; gap: 9px; }
.seq-item {
  border: 1px solid var(--border);
  border-left: 3px solid #343949;
  border-radius: var(--radius);
  padding: 13px 15px;
  background: #12141c;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  overflow: hidden;                    /* long spintax must not widen the card */
}
.seq-item:hover    { border-color: #3b4152; border-left-color: #4a5164; }
.seq-item.selected { border-color: var(--accent); border-left-color: var(--accent); background: var(--accent-dim); }

.seq-item .step-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 7px;
}
.seq-item .step-no {
  font-size: 12px; font-weight: 600; color: var(--text);
}
.seq-item .step-subject {
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seq-item .step-preview {
  font-size: 11.5px; color: var(--muted-dim); margin-top: 5px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.seq-item .step-empty { color: var(--orange); font-style: italic; }

/* Body editor: monospace makes unbalanced [[random|…]] brackets easy to spot. */
#seqBody {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  min-height: 340px;
}

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

@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seq-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .sidebar.open ~ .sidebar-scrim,
  body.nav-open .sidebar-scrim { display: block; }
  .main { margin-left: 0; }
  .only-mobile { display: grid; }
  .grid-2, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .pref-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .user-chip span { display: none; }
  .map-row { grid-template-columns: 1fr; gap: 6px; }
  .map-arrow { display: none; }
}
