:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --text: #1a1d23;
  --muted: #555c66;
  --muted-soft: #656d78;
  --accent: #7a1a2e;
  --accent-hover: #611321;
  --accent-soft: #fbeaed;
  --accent-gradient: linear-gradient(135deg, #8f2238, #5c1220);
  --sidebar-bg: #faf4f5;
  --green: #157a4a;
  --green-soft: #e6f6ee;
  --amber: #92620a;
  --amber-soft: #fdf3dd;
  --red: #b3261e;
  --red-soft: #fbeaea;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 4px 10px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Chart categorical palette — fixed order, validated for CVD-safe adjacent
     pairs (see the dataviz skill's palette reference). Never cycle/reorder
     per-chart; a series beyond slot 8 folds into "Other" instead. */
  --chart-1: #2a78d6; /* blue */
  --chart-2: #eb6834; /* orange */
  --chart-3: #1baf7a; /* aqua */
  --chart-4: #eda100; /* yellow */
  --chart-5: #e87ba4; /* magenta */
  --chart-6: #008300; /* green */
  --chart-7: #4a3aa7; /* violet */
  --chart-8: #e34948; /* red */
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --chart-ink-muted: #898781;
}

* { box-sizing: border-box; }

/* Form controls (button/input/textarea/select) don't inherit font-family
   from the page by default — only properties a rule sets *explicitly* on
   them override the browser's own UA font. `.btn` only ever set
   font-size/font-weight, so every plain <button> site-wide was silently
   rendering in the browser's native control font (e.g. Arial) instead of
   Poppins — and that font's own line-height metrics, not any size/padding
   bug, is what made some buttons render dramatically taller than their
   siblings despite identical CSS. input/textarea/select already had their
   own `font-family: inherit` below; this covers plain buttons too. */
button { font-family: inherit; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* Explicit rather than left to the browser default (~16px): without
     this, any element that doesn't set its own font-size (or that resets
     one via a `font: inherit` shorthand — which, on a button/input,
     inherits from its DOM parent rather than picking up a sibling class's
     size) renders noticeably larger than the rest of the app's ~13.5px
     baseline instead of matching it. */
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app { min-height: 100vh; }
.app-shell { display: flex; width: 100%; align-items: stretch; }

/* ---------- Sidebar ---------- */

.sidebar {
  width: 224px;
  background: var(--accent-gradient);
  border-right: none;
  padding: 22px 0 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  color: rgba(255, 255, 255, 0.92);
}

.sidebar-header { display: flex; align-items: center; justify-content: space-between; }

.sidebar h1 {
  font-size: 13.5px;
  font-weight: 700;
  padding: 0 20px 20px;
  color: #fff;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.25;
}

.brand-logo {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand-name { display: flex; flex-direction: column; min-width: 0; }
.brand-name-main { font-size: 17px; font-weight: 700; line-height: 1.15; }
.brand-name-sub { font-size: 10.5px; font-weight: 400; color: rgba(255, 255, 255, 0.65); letter-spacing: 0; }

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  padding: 12px 14px;
  min-width: 44px;
  min-height: 44px;
}

.nav-items {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  padding: 16px 20px 6px;
}
.nav-group-label:first-child { padding-top: 4px; }

.nav-count {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 1px 7px;
}
.nav-item.active .nav-count { color: var(--accent); background: #fff; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin: 1px 8px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}
.nav-item .icon { flex-shrink: 0; opacity: 0.85; }
.nav-item.active .icon { opacity: 1; }

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.nav-item.active {
  color: var(--accent);
  background: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.nav-badge {
  margin-left: auto;
  background: #fff;
  color: var(--red);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
}

.nav-item.sign-out {
  margin-top: auto;
  color: rgba(255, 255, 255, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: 14px;
}
.nav-item.sign-out:hover { color: #fff; background: rgba(255, 70, 70, 0.35); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  margin-top: 8px;
}
.sidebar-user-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
}
.sidebar-user-info { min-width: 0; display: flex; flex-direction: column; }
.sidebar-user-name { font-size: 12.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role.muted { font-size: 11px; text-transform: capitalize; color: rgba(255, 255, 255, 0.6); }

/* ---------- Layout ---------- */

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { padding: 10px 40px 30px; max-width: 1200px; min-width: 0; width: 100%; flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- Workspace chip bar (persistent, above every page) ---------- */

.workspace-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 40px;
  overflow-x: auto;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  flex-shrink: 0;
}
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.chip .icon { flex-shrink: 0; opacity: 0.8; }
.chip:hover { color: var(--text); border-color: var(--border); }
.chip.active {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(122, 26, 46, 0.3);
}
.chip.active .icon { opacity: 1; }
.chip-count {
  background: var(--bg);
  color: inherit;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.chip.active .chip-count { background: rgba(255, 255, 255, 0.25); color: #fff; }

/* ---------- Sidebar product switcher (replaces a plain "Products" link) ---------- */

.sidebar-product-switcher { position: relative; padding: 0 8px; margin-bottom: 6px; }

.product-switcher-trigger {
  width: 100%;
  border: 1px solid transparent;
  /* `.nav-item`'s own 13.5px (below) was previously being wiped out by a
     `font: inherit` here — a <button> doesn't inherit font-size from
     ancestors by default, so that shorthand fell back to the body's
     default size instead, rendering noticeably larger than every other
     sidebar item. */
  font-family: inherit;
  font-size: 13.5px;
  text-align: left;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 700;
  padding-top: 10px;
  padding-bottom: 10px;
  /* `.nav-item`'s own `margin: 1px 8px` (below) was stacking on top of this
     wrapper's own `padding: 0 8px`, insetting the button an extra 8px on
     the left while letting it overflow 8px past the wrapper's right edge —
     out of alignment with every plain .nav-item below it. The wrapper
     alone is responsible for the horizontal inset here. */
  margin: 0;
}
.product-switcher-trigger .product-switcher-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-switcher-trigger .icon:first-child { color: #fff; opacity: 0.9; }
.product-switcher-trigger:hover { color: #fff; background: rgba(255, 255, 255, 0.2); }
.product-switcher-trigger:disabled { cursor: default; opacity: 0.6; }
.product-switcher-trigger .icon:last-child { transition: transform 0.12s ease; opacity: 0.8; flex-shrink: 0; }
.product-switcher-trigger[aria-expanded="true"] .icon:last-child { transform: rotate(180deg); }
.product-switcher-trigger[aria-expanded="true"] { border-color: rgba(255, 255, 255, 0.5); }
.product-switcher-trigger:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.5); }

.product-switcher-menu {
  list-style: none;
  margin: 4px 8px 0;
  padding: 6px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 30;
}
.product-switcher-menu li {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-switcher-menu li:hover,
.product-switcher-menu li:focus-visible { background: var(--bg); outline: none; }
.product-switcher-menu li[aria-selected="true"] { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.product-switcher-manage {
  margin-top: 4px;
  padding-top: 10px !important;
  border-top: 1px solid var(--border-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Email chip/tag input (Email Lists page) ---------- */

.divider { border: none; border-top: 1px solid var(--border-soft); margin: 16px 0; }

.chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg);
}
.chip-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip-input-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-input-chips:empty { display: none; }
.chip-input-field {
  flex: 1;
  min-width: 160px;
  border: none;
  background: none;
  padding: 6px 4px;
  font-family: inherit;
  font-size: 13px;
}
.chip-input-field:focus { outline: none; box-shadow: none; }

.chip-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  max-width: 100%;
}
.chip-tag-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}
.chip-tag-text[contenteditable="true"] {
  white-space: normal;
  outline: none;
  background: #fff;
  border-radius: 4px;
  padding: 0 4px;
  box-shadow: 0 0 0 2px var(--accent);
}
.chip-tag-edit, .chip-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.6);
  color: inherit;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
}
.chip-tag-edit:hover, .chip-tag-remove:hover { background: #fff; }
.chip-tag-remove:hover { color: var(--red); }

/* Saved emails already in a list render as plain rows, not chips — chips
   are reserved for the "still typing, not saved yet" add-emails input. */
.email-rows { border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.email-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.email-row:last-child { border-bottom: none; }
.email-row-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.email-row-text[contenteditable="true"] {
  white-space: normal;
  outline: none;
  background: var(--bg);
  border-radius: 4px;
  padding: 0 4px;
  box-shadow: 0 0 0 2px var(--accent);
}
.email-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.email-row .chip-tag-edit, .email-row .chip-tag-remove { background: var(--bg); }
.email-row .chip-tag-edit:hover, .email-row .chip-tag-remove:hover { background: var(--border-soft); }

.email-list-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.email-list-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-soft);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.email-list-card:hover { border-color: var(--accent); }
.email-list-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.email-list-card .chip-count { background: var(--bg); color: var(--text); }
.email-list-card.active .chip-count { background: var(--accent); color: #fff; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }

h2 { margin: 0 0 4px; font-size: 21px; font-weight: 700; letter-spacing: -0.015em; }
.main h2::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2.5px;
  background: var(--accent-gradient);
  margin-right: 9px;
  vertical-align: middle;
  transform: translateY(-2px);
}
h3 { font-size: 14.5px; font-weight: 600; margin: 0 0 10px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
  overflow-x: auto; /* a wide table inside scrolls within its own card rather than blowing out the page */
}

.campaign-card {
  cursor: pointer;
  min-height: 172px;
  display: flex;
  flex-direction: column;
  border-color: transparent;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.campaign-card:hover, .campaign-card:focus-visible { box-shadow: var(--shadow-lg); transform: translateY(-1px); outline: none; }
.campaign-card .stat { text-align: left; }
.campaign-card .label { color: currentColor; opacity: 0.7; }

/* ---------- Setup guide ---------- */

.wizard-progress {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
  max-width: 560px;
}
.wizard-progress-step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.wizard-progress-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}
.wizard-progress-step.current .wizard-progress-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.wizard-progress-step.done .wizard-progress-dot { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.wizard-progress-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.wizard-progress-step.current .wizard-progress-label { color: var(--text); font-weight: 600; }
.wizard-progress-line { flex: 1; height: 1px; background: var(--border); margin: 0 8px 20px; min-width: 20px; }

.wizard-step { max-width: 480px; margin: 0 auto; text-align: center; }
.wizard-step input, .wizard-step textarea { text-align: left; }
.wizard-step h3 { margin-top: 0; }
.wizard-step .muted { margin-bottom: 16px; }

.wizard-illustration {
  width: 80px;
  height: 80px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

/* align-items defaults to stretch on a flex row — fine when every action
   is the same kind of control, but a <button> next to a <label> styled as
   a button (the CSV-upload trigger) can report different natural heights
   to the flex algorithm, and stretch then inflates the shorter-content one
   to match rather than sizing each to its own content. Center-aligning
   avoids that regardless of why the natural heights differ. */
.wizard-actions { display: flex; align-items: center; gap: 10px; justify-content: flex-start; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Notifications ---------- */

.notification-list { display: flex; flex-direction: column; gap: 8px; }

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  box-shadow: var(--shadow-sm);
}
.notification-item.high { border-left-color: var(--red); }
.notification-item.clickable { cursor: pointer; transition: box-shadow 0.12s ease, transform 0.05s ease; }
.notification-item.clickable:hover { box-shadow: var(--shadow); }
.notification-item.clickable:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.notification-icon {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.notification-item.high .notification-icon { background: var(--red-soft); color: var(--red); }

.notification-body { flex: 1; min-width: 0; }
.notification-title { font-size: 13.5px; font-weight: 600; }
.notification-detail { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.notification-time { font-size: 11.5px; white-space: nowrap; flex-shrink: 0; padding-top: 2px; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--bg); }

/* A table with more columns than usually fit a row comfortably (e.g. a
   campaign list's leads table, with Name/Email/Company/Status/Sequence/
   Next send/Actions all at once) — smaller type and tighter controls so a
   row stays on one line instead of its action buttons wrapping. */
.compact-table { font-size: 12px; }
.compact-table th, .compact-table td { padding: 6px 8px; white-space: nowrap; }
.compact-table td.name-cell, .compact-table td.email-cell { white-space: normal; }
.compact-table .btn { padding: 4px 9px; font-size: 11.5px; }
.compact-table select { padding: 3px 6px; font-size: 11.5px; height: auto; }
.compact-table .badge { font-size: 10px; padding: 2px 7px; }
.compact-table .actions-cell { display: flex; gap: 4px; flex-wrap: nowrap; }
.compact-table .actions-cell > * { margin-left: 0 !important; }

/* ---------- Buttons ---------- */

.btn {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(68, 51, 184, 0.25);
  transition: filter 0.12s ease, transform 0.05s ease, box-shadow 0.12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn.secondary { background: var(--panel); border: 1px solid var(--border); color: var(--text); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { background: #f6d9d7; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  box-shadow: none;
  flex-shrink: 0;
}
.icon-btn .icon { width: 14px; height: 14px; }
.icon-btn.armed { box-shadow: 0 0 0 2px var(--accent); }
.icon-btn.danger.armed { box-shadow: 0 0 0 2px var(--red); }

/* Browsers give form controls their own default font rather than
   inheriting the page's — <button> isn't covered by the input/textarea/
   select rule below, so without this every button in the app (including
   .btn and .tab-btn, which don't set font-family themselves) silently
   renders in the browser's UI font instead of Poppins. */
button { font-family: inherit; }

/* ---------- Forms ---------- */

input, textarea, select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-soft); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, textarea:disabled, select:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }

/* Select2 (used for the working-hours timezone picker, searchable among
   ~30 IANA zone names) — loosely matched to this app's own input styling
   rather than its default theme. */
.select2-container { width: 100% !important; }
.select2-container .select2-selection--single {
  height: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.select2-container .select2-selection--single .select2-selection__rendered { color: var(--text); padding: 0; line-height: 1.3; }
.select2-container .select2-selection--single .select2-selection__arrow { height: 100%; top: 0; right: 8px; }
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select2-dropdown { border-color: var(--border); border-radius: var(--radius-sm); }
.select2-search--dropdown .select2-search__field { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 8px; }
.select2-results__option--highlighted[aria-selected] { background: var(--accent) !important; }

label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin: 12px 0 5px; }

/* Visually hidden but still announced by assistive tech — used to give a
   proper <label> to compact "quick add" inputs that rely on placeholder
   text alone for their sighted hint. */
.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;
}

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }

.stat { text-align: center; }
.stat .value { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.stat .value.accent { color: var(--accent); }
.stat .label { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat.sm .value { font-size: 16px; }

.stat-link {
  cursor: pointer;
  padding: 8px;
  margin: -8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease;
}
.stat-link:hover, .stat-link:focus-visible { background: var(--accent-soft); outline: none; }

.highlight-stat { text-align: center; }
.highlight-stat .value { font-size: 28px; }

.campaign-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 20px;
}
.flow-card {
  background: var(--accent-gradient);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 120px;
  flex: 1 1 140px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(68, 51, 184, 0.25);
  transition: filter 0.12s ease, transform 0.08s ease;
}
.flow-card:hover { filter: brightness(1.08); }
.flow-card:active { transform: translateY(1px); }
.flow-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.flow-card .flow-value { font-size: 22px; font-weight: 700; }
.flow-card .flow-label { font-size: 12px; opacity: 0.9; margin-top: 2px; }
.flow-arrow { color: var(--muted); font-size: 16px; flex-shrink: 0; }

@media (max-width: 760px) {
  .campaign-flow { flex-direction: column; align-items: stretch; }
  .flow-arrow { transform: rotate(90deg); align-self: center; }
}

/* ---------- Working hours (drag-to-select weekly grid) ---------- */

.wh-grid-wrap { overflow-x: auto; margin-top: 10px; }
.wh-grid {
  display: grid;
  grid-template-columns: 50px repeat(7, minmax(44px, 1fr));
  min-width: 460px;
  user-select: none;
}
.wh-grid-corner { background: transparent; }
.wh-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--muted);
}
.wh-day-header:hover { background: var(--bg); }
.wh-day-header.selected { color: var(--accent); }
.wh-hour-label {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  padding-right: 6px;
  line-height: 16px;
  white-space: nowrap;
}
.wh-cell {
  border: 1px solid var(--border-soft);
  border-left: none;
  border-top: none;
  background: var(--panel);
  cursor: pointer;
}
.wh-cell.selected { background: var(--accent); border-color: var(--accent); }

@media (max-width: 500px) {
  .wh-grid { min-width: 400px; }
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.stat-row:first-child { padding-top: 4px; }
.stat-row-label { font-size: 13px; color: var(--muted); }
.stat-row-value { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* A merge-field placeholder shown as a reference, e.g. {{first_name}} —
   not clickable, just visually distinct from surrounding text. */
code { background: var(--bg); border: 1px solid var(--border-soft); border-radius: 4px; padding: 1px 5px; font-size: 0.92em; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* A hover popover for showing an email's subject/body without a click —
   used by Scheduled sends to preview a step's content. Plain CSS :hover/
   :focus-within rather than JS, so it works the instant the markup exists. */
.preview-popover { position: relative; cursor: help; display: inline-block; }
.preview-popover-content {
  display: none;
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  margin-top: 6px;
  width: 320px;
  max-width: min(320px, 80vw);
  max-height: 260px;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  cursor: auto;
}
.preview-popover:hover .preview-popover-content,
.preview-popover:focus-within .preview-popover-content {
  display: block;
}
.preview-popover-subject { font-weight: 600; margin-bottom: 6px; }

.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }

.msg-bubble { padding: 11px 15px; border-radius: 12px; margin-bottom: 10px; max-width: 70%; white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; }
.msg-inbound { background: var(--bg); border: 1px solid var(--border-soft); }
.msg-outbound { background: var(--accent-soft); margin-left: auto; }
.msg-draft { background: var(--amber-soft); margin-left: auto; border: 1px dashed var(--amber); }

/* ---------- Conversations (WhatsApp Web-style two-pane layout) ---------- */

.chat-page { display: flex; flex-direction: column; height: 100%; min-height: 480px; }
.chat-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.chat-sidebar {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  background: var(--panel);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  max-height: 100%;
}
.chat-row {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.1s ease;
}
.chat-row:hover { background: var(--bg); }
.chat-row.active { background: var(--accent-soft); }
.chat-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.chat-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.chat-row-body { min-width: 0; flex: 1; }
.chat-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-row-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-time { font-size: 10.5px; color: var(--muted); flex-shrink: 0; }
.chat-row-bottom { margin-top: 2px; }
.chat-row-preview { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.chat-row-status { margin-top: 5px; }

.chat-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
.chat-thread-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel);
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-header-name { font-weight: 600; font-size: 14px; }
.chat-header-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; }
.pending-actions-panel {
  flex-shrink: 0;
  max-height: 38%;
  overflow-y: auto;
  margin: 0 16px 12px;
}
.chat-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
}
.chat-composer textarea { flex: 1; resize: none; }

@media (max-width: 860px) {
  .chat-shell { flex-direction: column; height: auto; }
  .chat-sidebar { width: 100%; height: auto; max-height: 240px; position: static; border-right: none; border-bottom: 1px solid var(--border-soft); }
  .chat-page { height: auto; }
}

.error-text { color: var(--red); font-size: 13px; margin-top: 8px; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- Modal ---------- */

body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 25, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-card {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-card.wide { max-width: 760px; padding: 0; }
.modal-card.wide h3 { margin: 20px 20px 0; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
}
.modal-close:hover { color: var(--text); }

.step-row { border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px; margin-bottom: 8px; background: var(--bg); }

/* ---------- Tabs (campaign detail page sections) ---------- */

.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Auth pages (login / register / reset password) ---------- */

.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, var(--accent-soft) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, var(--accent-soft) 0%, transparent 45%),
    var(--bg);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 22px;
  color: var(--text);
}
.auth-brand .brand-logo { background: var(--accent-gradient); color: #fff; }
.auth-brand .brand-name-sub { color: var(--muted); }

.auth-card h2 { font-size: 20px; margin-bottom: 4px; }
.auth-card .muted { font-size: 13px; margin-bottom: 4px; }

.auth-card form { margin-top: 18px; }

.auth-card .btn { width: 100%; padding: 10px 16px; font-size: 13.5px; margin-top: 6px; }

.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-switch a { color: var(--accent); text-decoration: none; cursor: pointer; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

.error-box {
  display: none;
  background: var(--red-soft);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-top: 14px;
}
.error-box:not(:empty) { display: block; }

.success-box {
  display: none;
  background: var(--green-soft);
  color: var(--green);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-top: 14px;
}
.success-box:not(:empty) { display: block; }

.login-wrap { display: flex; align-items: center; justify-content: center; width: 100%; }
.login-box { width: 360px; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 0;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .sidebar-header { padding: 10px 8px 10px 4px; }
  .sidebar h1 { padding: 0 0 0 12px; }
  .hamburger-btn { display: block; }
  .sidebar-user { display: none; }

  .nav-items {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--accent-gradient);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 50px);
    overflow-y: auto;
    padding: 6px 0;
  }
  .nav-items.open { display: flex; }
  .nav-item { margin: 1px 8px; }
  .nav-item.sign-out { margin-top: 1px; border-top: 1px solid var(--border-soft); border-left: none; padding-top: 9px; padding-left: 20px; border-radius: 7px; }

  /* .app-shell stacks sidebar above content here, so "fill the remaining
     row height" no longer applies — let .main size to its content and the
     whole page scroll, same as the sidebar's own height:auto above. */
  .main { padding: 14px 16px 18px; max-width: 100%; flex: none; min-height: 0; overflow-y: visible; }
  .workspace-chips { padding: 10px 16px; }

  h2 { font-size: 18px; }

  .card { padding: 14px 16px; }

  .tab-bar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab-btn { flex-shrink: 0; padding: 9px 12px; }

  .msg-bubble { max-width: 88%; }

  .auth-card { padding: 26px 22px; }
}
