/* Carbon Design System–inspired theme for Newsletter sender.
   Tokens follow IBM Carbon v11 (White + Gray 100 themes). Not the Carbon library itself —
   hand-built to match its look: flat surfaces, square corners, IBM Plex Sans, Blue 60 accent. */

:root {
  --bg: #ffffff;
  --layer: #f4f4f4;
  --layer-accent: #e0e0e0;
  --border-subtle: #e0e0e0;
  --border-strong: #8d8d8d;
  --text: #161616;
  --text-2: #525252;
  --text-placeholder: #a8a8a8;
  --link: #0f62fe;
  --brand: #0f62fe;
  --brand-hover: #0353e9;
  --brand-active: #002d9c;
  --on-brand: #ffffff;
  --secondary-btn: #393939;
  --secondary-btn-hover: #4c4c4c;
  --danger: #da1e28;
  --danger-hover: #ba1b23;
  --focus: #0f62fe;
  --success: #24a148;
  --success-ink: #0e6027;
  --warning: #f1c21b;
  --warning-ink: #684e00;
  --error: #da1e28;
  --error-ink: #a2191f;
  --info: #0043ce;
  --info-ink: #0043ce;
  --nbg-success: #defbe6;
  --nbg-warning: #fff8e1;
  --nbg-error: #fff1f1;
  --nbg-info: #edf5ff;
  --tag-gray-bg: #e0e0e0; --tag-gray-ink: #393939;
  --tag-green-bg: #defbe6; --tag-green-ink: #0e6027;
  --tag-blue-bg: #d0e2ff; --tag-blue-ink: #0043ce;
  --tag-red-bg: #fff1f1; --tag-red-ink: #a2191f;
  --tag-yellow-bg: #fcf4d6; --tag-yellow-ink: #684e00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --layer: #262626;
    --layer-accent: #393939;
    --border-subtle: #393939;
    --border-strong: #6f6f6f;
    --text: #f4f4f4;
    --text-2: #c6c6c6;
    --text-placeholder: #6f6f6f;
    --link: #78a9ff;
    --brand: #0f62fe;
    --brand-hover: #0353e9;
    --brand-active: #002d9c;
    --on-brand: #ffffff;
    --secondary-btn: #6f6f6f;
    --secondary-btn-hover: #8d8d8d;
    --danger: #da1e28;
    --danger-hover: #ba1b23;
    --focus: #4589ff;
    --success: #42be65;
    --success-ink: #42be65;
    --warning: #f1c21b;
    --warning-ink: #f1c21b;
    --error: #fa4d56;
    --error-ink: #ff8389;
    --info: #4589ff;
    --info-ink: #4589ff;
    --nbg-success: #0e2a14;
    --nbg-warning: #2d2503;
    --nbg-error: #2d0d0f;
    --nbg-info: #001141;
    --tag-gray-bg: #393939; --tag-gray-ink: #f4f4f4;
    --tag-green-bg: #0e2a14; --tag-green-ink: #42be65;
    --tag-blue-bg: #001141; --tag-blue-ink: #78a9ff;
    --tag-red-bg: #2d0d0f; --tag-red-ink: #ff8389;
    --tag-yellow-bg: #2d2503; --tag-yellow-ink: #f1c21b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.43 "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.plain { display: grid; place-items: center; min-height: 100vh; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- UI Shell header (Carbon header is always dark, in both themes) ---------- */
.top {
  display: flex; align-items: center; height: 48px; padding: 0 16px;
  background: #161616; border-bottom: 1px solid #393939;
  position: sticky; top: 0; z-index: 10;
}
.brand {
  font-weight: 600; font-size: 15px; color: #f4f4f4; text-decoration: none;
  padding: 0 16px 0 0; margin-right: 16px; border-right: 1px solid #393939; height: 48px;
  display: flex; align-items: center;
}
.top nav { display: flex; height: 100%; }
.top nav a {
  color: #c6c6c6; text-decoration: none; font-size: 14px; padding: 0 16px;
  height: 100%; display: flex; align-items: center; border-bottom: 3px solid transparent;
}
.top nav a:hover { color: #f4f4f4; background: #262626; }
.top nav a.current { color: #f4f4f4; border-bottom-color: #0f62fe; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.top-right .muted { color: #98a2b3; }

main { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
main.narrow { max-width: 480px; } main.center { text-align: center; }

h1 { font-size: 28px; line-height: 1.25; font-weight: 600; margin: 0 0 4px; letter-spacing: 0; }
h2 { font-size: 16px; line-height: 1.375; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--text-2); } .small { font-size: 12px; }
.good { color: var(--success-ink); } .bad { color: var(--error-ink); }
code {
  font-family: "IBM Plex Mono", ui-monospace, monospace; background: var(--layer-accent);
  padding: 1px 5px; border-radius: 2px; font-size: 12px;
}

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; margin-bottom: 24px; align-items: flex-start; }
.spread h1 { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1px; margin: 0 0 24px; background: var(--border-subtle); border: 1px solid var(--border-subtle); }
.grid2 > * { background: var(--bg); }
.grid2.tall { grid-template-columns: 1fr 1fr; align-items: start; gap: 24px; background: none; border: none; }
@media (max-width: 800px) { .grid2.tall { grid-template-columns: 1fr; } }

/* ---------- Tile (Carbon: flat, square, 1px border, no shadow) ---------- */
.panel, .card, .tile {
  background: var(--layer); border: 1px solid var(--border-subtle); border-radius: 0; padding: 16px;
}
.panel.narrow { max-width: 520px; display: flex; flex-direction: column; gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; margin: 0 0 24px; background: var(--border-subtle); border: 1px solid var(--border-subtle); }
.cards .card { border: none; }
.num { font-size: 32px; font-weight: 600; line-height: 1.2; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
label.check { flex-direction: row; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text); }
input[type=text], input[type=email], input[type=search], select, textarea {
  font: 14px/1.4 "IBM Plex Sans", sans-serif; padding: 0 12px; height: 40px;
  border: none; border-bottom: 1px solid var(--border-strong); border-radius: 0;
  background: var(--layer); color: var(--text); min-width: 0; appearance: none;
}
textarea { height: auto; padding: 8px 12px; min-height: 72px; resize: vertical; }
input[type=text]:focus, input[type=email]:focus, input[type=search]:focus, select:focus, textarea:focus {
  outline: none; box-shadow: inset 0 0 0 2px var(--focus);
}
input::placeholder, textarea::placeholder { color: var(--text-placeholder); }
select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='%23525252' d='M8 11L3 6h10z'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}
input[type=file] { font: 13px "IBM Plex Sans", sans-serif; color: var(--text); }
input[type=checkbox] {
  appearance: none; width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 auto;
  border: 1px solid var(--border-strong); background: var(--layer); position: relative; cursor: pointer;
}
input[type=checkbox]:checked { background: var(--brand); border-color: var(--brand); }
input[type=checkbox]:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ---------- Buttons (Carbon: square, regular weight, 40px) ---------- */
.btn {
  font: 14px/1 "IBM Plex Sans", sans-serif; font-weight: 400; padding: 0 16px; height: 40px;
  border-radius: 0; border: 1px solid transparent; background: var(--brand); color: var(--on-brand);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: background-color 70ms;
}
.btn:hover { background: var(--brand-hover); } .btn:active { background: var(--brand-active); }
.btn.secondary { background: var(--secondary-btn); } .btn.secondary:hover { background: var(--secondary-btn-hover); }
.btn.ghost, .btn.tertiary { background: transparent; color: var(--link); border-color: var(--link); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover, .btn.tertiary:hover { background: var(--layer-accent); }
.btn.danger { background: var(--danger); color: #fff; } .btn.danger:hover { background: var(--danger-hover); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.link-btn { background: none; border: 0; color: var(--link); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* ---------- Data table (Carbon DataTable) ---------- */
table { width: 100%; border-collapse: collapse; background: var(--bg); }
thead th {
  text-align: left; padding: 0 16px; height: 40px; background: var(--layer-accent);
  font-size: 13px; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--border-strong);
}
tbody td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; font-size: 14px; }
tbody tr:hover td { background: var(--layer-accent); }

/* ---------- Tag (Carbon Tag component) ---------- */
.pill { font-size: 12px; font-weight: 400; padding: 2px 10px; border-radius: 999px; background: var(--tag-gray-bg); color: var(--tag-gray-ink); vertical-align: middle; display: inline-block; }
.pill.sent, .pill.done, .pill.active { background: var(--tag-green-bg); color: var(--tag-green-ink); }
.pill.running, .pill.sending { background: var(--tag-blue-bg); color: var(--tag-blue-ink); }
.pill.failed, .pill.unsubscribed { background: var(--tag-red-bg); color: var(--tag-red-ink); }
.pill.paused, .pill.unknown, .pill.pending { background: var(--tag-yellow-bg); color: var(--tag-yellow-ink); }

/* ---------- Notification (Carbon Inline Notification) ---------- */
.notification, .flash, .callout {
  display: flex; gap: 12px; padding: 13px 16px; margin: 0 0 16px; border-radius: 0;
  border-left: 3px solid var(--border-strong); background: var(--layer);
}
.notification svg, .flash svg, .callout svg { flex: 0 0 auto; margin-top: 1px; }
.notification .content, .flash .content, .callout .content { flex: 1; min-width: 0; }
.notification .title, .flash .title, .callout .title { font-weight: 600; font-size: 14px; }
.notification .body, .flash .body, .callout .body { font-size: 14px; color: var(--text-2); margin-top: 2px; }
.notification ul, .flash ul, .callout ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--text-2); }
.notification.success, .flash.ok { border-left-color: var(--success); background: var(--nbg-success); }
.notification.success .title, .flash.ok .title { color: var(--success-ink); }
.notification.warning, .callout.warn { border-left-color: var(--warning); background: var(--nbg-warning); }
.notification.warning .title, .callout.warn .title { color: var(--warning-ink); }
.notification.error, .flash.err { border-left-color: var(--error); background: var(--nbg-error); }
.notification.error .title, .flash.err .title { color: var(--error-ink); }
.notification.info, .callout.info { border-left-color: var(--info); background: var(--nbg-info); }
.notification.info .title, .callout.info .title { color: var(--info-ink); }

/* ---------- Progress bar (Carbon Progress Bar) ---------- */
.bar { height: 8px; background: var(--border-subtle); overflow: hidden; margin-bottom: 8px; }
.bar > div { height: 100%; background: var(--brand); transition: width .4s; }

/* ---------- Step tracker (Carbon Progress Indicator) ---------- */
.steps { display: flex; align-items: flex-start; list-style: none; padding: 0; margin: 4px 0 28px; }
.steps .step { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 0 0 auto; width: 120px; }
.steps .step .circle {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--text-2); flex: 0 0 auto;
}
.steps .step .label { font-size: 12px; color: var(--text-2); text-align: center; }
.steps .step.done .circle { background: var(--success); border-color: var(--success); color: #fff; }
.steps .step.current .circle { border-color: var(--brand); color: var(--brand); }
.steps .step.current .label { color: var(--text); font-weight: 600; }
.steps .step-line { flex: 1 1 auto; height: 2px; background: var(--border-subtle); margin-top: 11px; min-width: 24px; }
@media (max-width: 700px) { .steps { overflow-x: auto; } .steps .step { width: 88px; } }

.preview { width: 100%; height: 520px; border: 1px solid var(--border-subtle); background: #fff; }

/* ---------- Content switcher (Carbon Content Switcher, replaces plain filter chips) ---------- */
.filter { margin: 0 0 20px; }
.switcher { display: inline-flex; border: 1px solid var(--border-strong); }
.switcher a {
  padding: 0 14px; height: 32px; display: flex; align-items: center; text-decoration: none;
  color: var(--text); font-size: 13px; background: var(--layer); border-right: 1px solid var(--border-strong);
}
.switcher a:last-child { border-right: none; }
.switcher a:hover { background: var(--layer-accent); }
.switcher a.on { background: var(--text); color: var(--bg); }
.chip { padding: 4px 12px; border: 1px solid var(--border-strong); text-decoration: none; color: var(--text); font-size: 13px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.retry { border-top: 1px solid var(--border-subtle); margin-top: 16px; padding-top: 16px; }
.dry { margin-top: 12px; }
.dry ul { padding-left: 20px; margin: 6px 0 10px; font-size: 13px; color: var(--text-2); }
.sample { padding: 2px 0; }
