/* Notification Console. Every color is a variable, so the theme switch only swaps the palette. */
:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --sunken: #f9fafb;
  --text: #101828;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e5e7eb;
  --line-strong: #d0d5dd;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-line: #c7d2fe;
  --primary-text: #3730a3;
  --on-primary: #ffffff;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --ok-line: #abefc6;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-line: #fedf89;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --bad-line: #fecdca;
  --run: #175cd3;
  --run-bg: #eff8ff;
  --run-line: #b2ddff;
  --idle: #475467;
  --idle-bg: #f2f4f7;
  --shadow: 0 1px 2px rgb(16 24 40 / 5%);
  --focus: rgb(79 70 229 / 18%);
  --knob: #ffffff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #131a2b;
  --sunken: #0f1524;
  --text: #e6e8ee;
  --muted: #9aa4b8;
  --faint: #7c879c;
  --line: #222b40;
  --line-strong: #303b57;
  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: rgb(129 140 248 / 14%);
  --primary-line: rgb(129 140 248 / 38%);
  --primary-text: #c7d2fe;
  --on-primary: #0b1020;
  --ok: #4ade80;
  --ok-bg: rgb(34 197 94 / 13%);
  --ok-line: rgb(34 197 94 / 35%);
  --warn: #fbbf24;
  --warn-bg: rgb(245 158 11 / 12%);
  --warn-line: rgb(245 158 11 / 35%);
  --bad: #f87171;
  --bad-bg: rgb(239 68 68 / 13%);
  --bad-line: rgb(239 68 68 / 35%);
  --run: #60a5fa;
  --run-bg: rgb(59 130 246 / 13%);
  --run-line: rgb(59 130 246 / 35%);
  --idle: #a4adbf;
  --idle-bg: rgb(148 163 184 / 13%);
  --shadow: 0 1px 2px rgb(0 0 0 / 45%);
  --focus: rgb(129 140 248 / 30%);
  --knob: #0b1020;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--idle-bg);
  font-family: var(--mono);
  font-size: 12.5px;
}
small, .muted { color: var(--muted); }
small { font-size: 12.5px; }
.mt { margin-top: 16px; }
.hint { margin-top: 8px; color: var(--muted); font-size: 12.5px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1040px, calc(100% - 48px));
  height: 56px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  font-size: 13px;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.topbar-actions form { margin: 0; }
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-weight: 400;
}
.theme-switch:hover { background: none; color: var(--text); }
.theme-switch .track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .2s;
}
.theme-switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: 0 1px 2px rgb(0 0 0 / 25%);
  transition: transform .2s;
}
:root[data-theme="dark"] .theme-switch .track { background: var(--primary); }
:root[data-theme="dark"] .theme-switch .track::after { transform: translateX(16px); }

/* Page */
.page { width: min(1040px, calc(100% - 48px)); margin: 28px auto 48px; }
.page.narrow { width: min(860px, calc(100% - 48px)); }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.015em; }
.page-head p { margin-top: 4px; color: var(--muted); }

/* Buttons */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--primary);
  box-shadow: var(--shadow);
  color: var(--on-primary);
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--primary-hover); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.ghost { background: var(--surface); border-color: var(--line-strong); box-shadow: none; color: var(--text); }
.ghost:hover { background: var(--sunken); }
.plain { background: transparent; box-shadow: none; color: var(--muted); }
.plain:hover { background: var(--idle-bg); }
.danger { color: var(--bad); }
.solid-danger { background: var(--bad); color: var(--on-primary); }
.solid-danger:hover { background: var(--bad); filter: brightness(.92); }
.small { padding: 5px 10px; border-radius: 8px; font-size: 12.5px; }

/* Messages */
.alert {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 13.5px;
}
.alert.error { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad); }
.alert.warning { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn); }
.alert.success { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok); }
.alert.info { border-color: var(--run-line); background: var(--run-bg); color: var(--run); }
.alert a { color: inherit; text-decoration: underline; }
.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 1px solid var(--run-line);
  border-radius: 12px;
  background: var(--run-bg);
  color: var(--run);
}
.banner b { color: var(--text); }
.banner .grow { flex: 1; min-width: 0; }
.banner .progress { margin-top: 8px; background: var(--run-line); }
.pulse { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--run); box-shadow: 0 0 0 4px var(--run-bg); }

/* Cards and tables */
.card {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.card-head p { color: var(--muted); font-size: 13px; }
.empty { padding: 22px 20px; color: var(--muted); }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--idle-bg);
  color: var(--idle);
  font-size: 12px;
  font-weight: 700;
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-align: left;
  text-transform: uppercase;
}
td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--sunken); }
.title { font-weight: 600; }
.sub { color: var(--muted); font-size: 12.5px; }
.snippet {
  display: block;
  max-width: 300px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
}
.actions { display: flex; justify-content: flex-end; gap: 6px; }
.actions form { display: flex; gap: 6px; margin: 0; }

/* Badges, tags, progress */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--idle-bg);
  color: var(--idle);
  font-size: 12px;
  font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.completed, .badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.running, .badge.queued { background: var(--run-bg); color: var(--run); }
.badge.failed { background: var(--bad-bg); color: var(--bad); }
.badge.stopped { background: var(--warn-bg); color: var(--warn); }
.tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--idle-bg);
  color: var(--idle);
  font-size: 11.5px;
  font-weight: 600;
}
.tag.accent { background: var(--primary-soft); color: var(--primary-text); }
.progress { width: 110px; height: 6px; overflow: hidden; border-radius: 999px; background: var(--line); }
.progress.wide { width: 100%; height: 8px; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.progress.grey > span { background: var(--faint); }
.progress-cell { display: flex; align-items: center; gap: 10px; }
.live { font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat small { font-size: 12px; }
.stat strong { display: block; font-size: 24px; letter-spacing: -.01em; }

/* Forms */
.stack { display: grid; gap: 14px; }
.field { display: grid; align-content: start; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; }
input, textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--focus); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
textarea { min-height: 250px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.7; }
textarea.short { min-height: 150px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline input { width: 180px; }
.inline input[type="datetime-local"] { width: 230px; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sunken);
  cursor: pointer;
}
.check input { flex: none; margin-top: 3px; }
.check b { font-weight: 600; }
.check small { display: block; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}
.pill:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.pill input { margin: 0; }
.options { display: grid; gap: 8px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
}
.option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.option input { flex: none; margin-top: 3px; }
.option b { font-weight: 600; }
.option small { display: block; }
.segmented { display: inline-flex; gap: 2px; width: max-content; padding: 3px; border-radius: 10px; background: var(--idle-bg); }
.segmented label { position: relative; padding: 6px 16px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.segmented label:has(input:checked) { background: var(--surface); box-shadow: var(--shadow); color: var(--text); }
.segmented input, .audience input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:focus-visible), .option:has(input:focus-visible),
.pill:has(input:focus-visible), .audience:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Composer */
.stepper { display: flex; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; counter-reset: step; }
.stepper li { flex: 1; min-width: 0; counter-increment: step; }
.stepper button {
  position: relative;
  justify-content: flex-start;
  width: 100%;
  padding: 8px 8px 12px;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--faint);
  font-size: 12.5px;
}
.stepper button:hover { background: none; color: var(--text); }
.stepper button::before {
  content: counter(step);
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--idle-bg);
  color: var(--idle);
  font-size: 11.5px;
  font-weight: 700;
}
.stepper button::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 0;
  left: 8px;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
}
.stepper button[aria-current="step"] { color: var(--text); }
.stepper button[aria-current="step"]::before { background: var(--primary); color: var(--on-primary); }
.stepper button[aria-current="step"]::after { background: var(--primary); }
.stepper button.done { color: var(--muted); }
.stepper button.done::before { content: "✓"; background: var(--primary-soft); color: var(--primary); }
.stepper button.done::after { background: var(--primary-line); }
.panel {
  margin-bottom: 16px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.panel-head { margin-bottom: 16px; }
.panel-head h2 { display: flex; align-items: center; gap: 6px; font-size: 18px; letter-spacing: -.01em; }
.panel-head p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.wizard-nav { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
html:not(.js) .js-only { display: none; }
.audiences { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.audience {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.audience:hover { border-color: var(--primary-line); }
.audience:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--focus); }
.audience-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--idle-bg);
  font-size: 18px;
}
.audience:has(input:checked) .audience-icon { background: var(--surface); }
.audience-body { display: grid; gap: 3px; }
.audience-body strong { font-size: 15px; }
.audience-body span { color: var(--muted); font-size: 13px; }
.audience-body em { margin-top: 4px; color: var(--idle); font-size: 12px; font-style: normal; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 6px; }
.chip {
  padding: 4px 10px;
  border: 1px solid var(--primary-line);
  border-radius: 999px;
  background: var(--primary-soft);
  box-shadow: none;
  color: var(--primary-text);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
}
.chip:hover { background: var(--primary-line); }
.review {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0 0 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sunken);
  font-size: 13px;
}
.review dt { color: var(--muted); font-weight: 600; }
.review dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Parts of the composer that depend on the chosen audience, query type or repeat interval.
   "revert" restores the element's own display (block, inline, list-item). */
.wizard [data-only], .wizard [data-kind], .wizard .sched-only { display: none; }
.wizard:has([name="audience"][value="inactive"]:checked) [data-only~="inactive"],
.wizard:has([name="audience"][value="accounts"]:checked) [data-only~="accounts"],
.wizard:has([name="audience"][value="all"]:checked) [data-only~="all"],
.wizard:has([name="audience"][value="custom"]:checked) [data-only~="custom"],
.wizard:has([name="audience"][value="inactive"]:checked) [data-kind~="inactive"],
.wizard:has([name="audience"][value="accounts"]:checked) [data-kind~="account"],
.wizard:has([name="audience"][value="all"]:checked) [data-kind~="customer"],
.wizard:has([name="audience"][value="custom"]:checked):has([name="custom_returns"][value="accounts"]:checked) [data-kind~="account"],
.wizard:has([name="audience"][value="custom"]:checked):has([name="custom_returns"][value="customers"]:checked) [data-kind~="customer"],
.wizard:has([name="repeat_minutes"]:not(:placeholder-shown):valid) .sched-only { display: revert; }
.wizard:has([name="repeat_minutes"]:not(:placeholder-shown):valid) .once-only { display: none; }

/* "Send again" for one-off campaigns: a popover from a table row, or in the page flow (.inline). */
.retrigger { position: relative; }
.table-scroll:has(.retrigger[open]) { overflow: visible; }
.retrigger summary { list-style: none; }
.retrigger summary::-webkit-details-marker { display: none; }
.retrigger[open] summary { background: var(--sunken); }
.retrigger-form {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  width: 320px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(16 24 40 / 14%);
  text-align: left;
  white-space: normal;
}
.retrigger-form .option span { flex: 1; min-width: 0; }
.retrigger-form .option input[type="datetime-local"] { width: 100%; margin: 6px 0 2px; }
.retrigger-form .hint { margin: 0; }
.retrigger-form button { justify-self: end; }
.retrigger.inline { margin-top: 10px; }
.retrigger.inline .retrigger-form { position: static; width: auto; max-width: 420px; box-shadow: var(--shadow); }
.campaign-actions {
  margin: -6px 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sunken);
}
.campaign-actions .inline small { flex: 1; min-width: 220px; }

/* Campaign page */
.boxes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.box { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.box h3, .section h3 { margin-bottom: 8px; font-size: 14px; }
.section { margin-top: 18px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
pre {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sunken);
  color: var(--text);
  font: 12.5px/1.7 var(--mono);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Sign in */
.login-card {
  display: grid;
  gap: 16px;
  width: min(400px, 100%);
  margin: 10vh auto 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 22px; }

@media (max-width: 760px) {
  .grid-2, .grid-3, .audiences, .boxes { grid-template-columns: 1fr; }
  .stepper { flex-wrap: wrap; }
  .stepper li { flex: 1 0 30%; }
  .page-head { flex-direction: column; align-items: flex-start; }
  th, td { padding: 10px 12px; }
}
