/* ==========================================================================
   Mailboy design system
   "Modern post office": ink-blue type on cool paper, one bold signature —
   the airmail stripe — used for the sidebar edge, the logo and in-transit
   progress. Everything else stays quiet.
   ========================================================================== */

@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-latin-400-normal.81419bf5abb5.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-latin-500-normal.8e986e86d57e.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-latin-600-normal.a1e2a2d7d4c0.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-latin-500-normal.69988ca9d262.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-latin-600-normal.64a19a7cafc2.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-latin-700-normal.d829c77621b7.woff2") format("woff2"); }

:root {
  --mb-ink: #172036;
  --mb-ink-2: #4a5368;
  --mb-ink-3: #7a8295;
  --mb-blue: #2547d0;
  --mb-blue-600: #1c38a8;
  --mb-blue-050: #eef1fd;
  --mb-red: #d8343f;
  --mb-red-050: #fdeeef;
  --mb-green: #1f8a5b;
  --mb-green-050: #e7f4ed;
  --mb-ochre: #b97c06;
  --mb-ochre-050: #fdf4e1;
  --mb-paper: #f5f6f8;
  --mb-surface: #ffffff;
  --mb-line: #e2e5eb;
  --mb-line-strong: #cdd2dc;

  --mb-font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mb-font-display: "Barlow Semi Condensed", "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;

  --mb-radius-sm: 6px;
  --mb-radius: 10px;
  --mb-radius-lg: 14px;

  /* Seamless airmail tile: two red/white/blue/white cycles per 40px tile */
  --mb-airmail: linear-gradient(135deg,
      var(--mb-red) 0 12.5%, #fff 12.5% 25%, var(--mb-blue) 25% 37.5%, #fff 37.5% 50%,
      var(--mb-red) 50% 62.5%, #fff 62.5% 75%, var(--mb-blue) 75% 87.5%, #fff 87.5% 100%);
  --mb-airmail-size: 28px 28px;

  /* Bootstrap bridge */
  --bs-body-font-family: var(--mb-font);
  --bs-body-font-size: 0.9375rem;
  --bs-body-line-height: 1.55;
  --bs-body-color: var(--mb-ink);
  --bs-body-color-rgb: 23, 32, 54;
  --bs-body-bg: var(--mb-paper);
  --bs-emphasis-color: var(--mb-ink);
  --bs-secondary-color: var(--mb-ink-2);
  --bs-tertiary-color: var(--mb-ink-3);
  --bs-border-color: var(--mb-line);
  --bs-border-radius: var(--mb-radius-sm);
  --bs-border-radius-lg: var(--mb-radius);
  --bs-primary: #2547d0;
  --bs-primary-rgb: 37, 71, 208;
  --bs-danger: #d8343f;
  --bs-danger-rgb: 216, 52, 63;
  --bs-success: #1f8a5b;
  --bs-success-rgb: 31, 138, 91;
  --bs-warning: #e0a100;
  --bs-warning-rgb: 224, 161, 0;
  --bs-info: #2b7fb8;
  --bs-info-rgb: 43, 127, 184;
  --bs-link-color: var(--mb-blue);
  --bs-link-color-rgb: 37, 71, 208;
  --bs-link-hover-color: var(--mb-blue-600);
  --bs-link-hover-color-rgb: 28, 56, 168;
  --bs-focus-ring-color: rgba(37, 71, 208, 0.28);
  --bs-primary-text-emphasis: var(--mb-blue-600);
  --bs-primary-bg-subtle: var(--mb-blue-050);
}

body { -webkit-font-smoothing: antialiased; font-feature-settings: "kern"; }
h1, h2, h3, h4, .display-font { font-family: var(--mb-font-display); letter-spacing: -0.005em; color: var(--mb-ink); }
h2 { font-size: 1.3125rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }
.text-muted, .text-secondary { color: var(--mb-ink-2) !important; }
a { text-underline-offset: 0.18em; }
::selection { background: rgba(37, 71, 208, 0.18); }

/* --- Buttons --------------------------------------------------------------- */
.btn { --bs-btn-font-weight: 500; --bs-btn-border-radius: 8px; --bs-btn-padding-x: 0.95rem; }
.btn-sm { --bs-btn-border-radius: 6px; }
.btn-primary {
  --bs-btn-bg: var(--mb-blue); --bs-btn-border-color: var(--mb-blue);
  --bs-btn-hover-bg: var(--mb-blue-600); --bs-btn-hover-border-color: var(--mb-blue-600);
  --bs-btn-active-bg: #172f8c; --bs-btn-active-border-color: #172f8c;
  --bs-btn-disabled-bg: var(--mb-blue); --bs-btn-disabled-border-color: var(--mb-blue);
}
.btn-outline-primary {
  --bs-btn-color: var(--mb-blue); --bs-btn-border-color: rgba(37, 71, 208, 0.45);
  --bs-btn-hover-bg: var(--mb-blue); --bs-btn-hover-border-color: var(--mb-blue);
}
.btn-light {
  --bs-btn-bg: var(--mb-surface); --bs-btn-border-color: var(--mb-line-strong); --bs-btn-color: var(--mb-ink);
  --bs-btn-hover-bg: #eef0f4; --bs-btn-hover-border-color: var(--mb-line-strong);
  --bs-btn-active-bg: #e4e7ee;
}
.btn-ghost { --bs-btn-color: var(--mb-ink-2); --bs-btn-hover-bg: rgba(23, 32, 54, 0.06); --bs-btn-hover-color: var(--mb-ink); border: 0; }
.btn-danger { --bs-btn-bg: var(--mb-red); --bs-btn-border-color: var(--mb-red); }

/* --- App shell --------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
/* No position here: below lg Bootstrap's offcanvas-lg makes the sidebar a
   fixed drawer; overriding it would keep it in the flow and hide the page. */
.sidebar {
  width: 252px; flex-shrink: 0; background: var(--mb-surface);
  display: flex; flex-direction: column; padding: 18px 16px 16px 14px;
}
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .sidebar::after {
    content: ""; position: absolute; top: 0; right: 0; width: 5px; height: 100%;
    background-image: var(--mb-airmail); background-size: var(--mb-airmail-size);
  }
}
.sidebar .offcanvas-body { display: flex; flex-direction: column; padding: 0; height: 100%; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 16px; text-decoration: none; color: var(--mb-ink); }
.brand img { width: 34px; height: auto; }
.brand-name { font-family: var(--mb-font-display); font-weight: 700; font-size: 1.375rem; letter-spacing: -0.01em; }

.ws-switch { width: 100%; text-align: left; border: 1px solid var(--mb-line); background: var(--mb-paper);
  border-radius: var(--mb-radius); padding: 8px 10px; display: flex; align-items: center; gap: 10px; color: var(--mb-ink); }
.ws-switch:hover, .ws-switch:focus-visible { border-color: var(--mb-line-strong); background: #eff1f5; }
.ws-avatar { width: 30px; height: 30px; border-radius: 7px; background: var(--mb-ink); color: #fff; display: grid; place-items: center;
  font-family: var(--mb-font-display); font-weight: 600; font-size: 0.875rem; flex-shrink: 0; }
.ws-meta { min-width: 0; flex: 1; line-height: 1.2; }
.ws-name { font-weight: 600; font-size: 0.9375rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-role { font-size: 0.75rem; color: var(--mb-ink-3); }

.side-nav { list-style: none; margin: 18px 0 0; padding: 0; }
.side-nav-group { font-size: 0.75rem; color: var(--mb-ink-3); margin: 18px 10px 6px; font-weight: 500; }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin: 1px 0; border-radius: 8px;
  color: var(--mb-ink-2); text-decoration: none; font-weight: 500; font-size: 0.9375rem;
}
.side-nav a .bi { font-size: 1.05rem; width: 18px; text-align: center; color: var(--mb-ink-3); }
.side-nav a:hover { background: rgba(23, 32, 54, 0.05); color: var(--mb-ink); }
.side-nav a.active { background: var(--mb-blue-050); color: var(--mb-blue-600); font-weight: 600; }
.side-nav a.active .bi { color: var(--mb-blue); }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--mb-line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; color: var(--mb-ink); text-decoration: none; }
.user-chip:hover { background: rgba(23, 32, 54, 0.05); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--mb-blue-050); color: var(--mb-blue-600);
  display: grid; place-items: center; font-weight: 600; font-size: 0.8125rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-mobile { display: none; }
@media (max-width: 991.98px) {
  .topbar-mobile { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px;
    background: var(--mb-surface); position: sticky; top: 0; z-index: 1020; border-bottom: 1px solid var(--mb-line); }
  .topbar-mobile::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
    background-image: var(--mb-airmail); background-size: var(--mb-airmail-size); }
  .sidebar { width: 280px; }
}
.content { padding: 28px clamp(16px, 3vw, 40px) 56px; max-width: 1360px; width: 100%; }

/* --- Page header -------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-title { font-size: clamp(1.5rem, 1.25rem + 0.9vw, 1.875rem); font-weight: 600; margin: 0; line-height: 1.15; }
.page-sub { color: var(--mb-ink-2); margin: 6px 0 0; max-width: 72ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 0.875rem; margin-bottom: 6px; color: var(--mb-ink-3); }
.crumbs a { color: var(--mb-ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--mb-blue); text-decoration: underline; }

/* --- Panels -------------------------------------------------------------------------- */
.panel { background: var(--mb-surface); border: 1px solid var(--mb-line); border-radius: var(--mb-radius); }
.panel + .panel { margin-top: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid var(--mb-line); }
.panel-title { font-family: var(--mb-font-display); font-size: 1.125rem; font-weight: 600; margin: 0; }
.panel-note { font-size: 0.8125rem; color: var(--mb-ink-3); }
.panel-body { padding: 18px; }
.panel-flush .table { margin: 0; }

/* --- Ledger: KPI band read like a postal receipt --------------------------------- */
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px;
  background: var(--mb-line); border: 1px solid var(--mb-line); border-radius: var(--mb-radius); overflow: hidden; }
.ledger-item { background: var(--mb-surface); padding: 16px 20px 15px; min-width: 0; }
.ledger-label { display: block; font-size: 0.8125rem; color: var(--mb-ink-2); font-weight: 500; }
/* Stat values: UI sans with proportional figures (tabular-nums only for aligned columns) */
.ledger-value { display: block; font-family: var(--mb-font); font-size: 2.25rem; font-weight: 600; line-height: 1.12;
  margin-top: 2px; letter-spacing: -0.015em; }
.ledger-value small { font-size: 1.125rem; color: var(--mb-ink-3); font-weight: 500; margin-left: 2px; }
.ledger-meta { display: block; font-size: 0.8125rem; color: var(--mb-ink-3); margin-top: 2px; line-height: 1.35; }
.delta-up { color: var(--mb-green); }
.delta-down { color: var(--mb-red); }

/* --- Tables ------------------------------------------------------------------------- */
.table-mb { --bs-table-bg: transparent; --bs-table-hover-bg: #f7f8fb; font-size: 0.9rem; margin: 0; }
.table-mb > :not(caption) > * > * { padding: 11px 14px; border-bottom-color: var(--mb-line); }
.table-mb thead th { font-weight: 600; color: var(--mb-ink-2); font-size: 0.8125rem; border-bottom: 1px solid var(--mb-line-strong);
  white-space: nowrap; background: #fafbfc; }
.table-mb tbody tr:last-child > * { border-bottom: 0; }
.table-mb td { vertical-align: middle; }
.table-mb .cell-title { font-weight: 600; color: var(--mb-ink); text-decoration: none; }
.table-mb .cell-title:hover { color: var(--mb-blue); text-decoration: underline; }
.table-mb .cell-sub { display: block; font-size: 0.8125rem; color: var(--mb-ink-3); margin-top: 1px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Status ----------------------------------------------------------------------------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 500; padding: 2px 9px 2px 8px;
  border-radius: 999px; background: #eef0f4; color: var(--mb-ink-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.status-sent, .status-subscribed, .status-done { background: var(--mb-green-050); color: var(--mb-green); }
.status-scheduled, .status-queued, .status-running, .status-pending { background: var(--mb-blue-050); color: var(--mb-blue-600); }
.status-paused, .status-mapping { background: var(--mb-ochre-050); color: var(--mb-ochre); }
.status-failed, .status-bounced, .status-complained { background: var(--mb-red-050); color: var(--mb-red); }
.status-cancelled, .status-unsubscribed, .status-skipped, .status-draft { background: #eef0f4; color: var(--mb-ink-2); }
.status-sending { background: var(--mb-blue-050); color: var(--mb-blue-600); }
.status-sending::before { width: 16px; height: 7px; border-radius: 2px; background-image: var(--mb-airmail);
  background-size: 14px 14px; opacity: 1; animation: airmail-move 1.2s linear infinite; }

/* --- Airmail progress (campaign in transit) ------------------------------------------ */
.airmail-progress { height: 10px; border-radius: 6px; background: #e9ecf2; overflow: hidden; }
.airmail-progress > span { display: block; height: 100%; border-radius: 6px; background-image: var(--mb-airmail);
  background-size: var(--mb-airmail-size); transition: width 0.6s ease; }
.airmail-progress.is-moving > span { animation: airmail-move 1.1s linear infinite; }
@keyframes airmail-move { from { background-position: 0 0; } to { background-position: 28px 0; } }
.simple-progress { height: 6px; border-radius: 4px; background: #e9ecf2; overflow: hidden; }
.simple-progress > span { display: block; height: 100%; background: var(--mb-blue); border-radius: 4px; }
.simple-progress.is-ochre > span { background: #e0a100; }

/* --- Forms ------------------------------------------------------------------------------ */
.form-label { font-weight: 500; font-size: 0.875rem; margin-bottom: 0.3rem; }
.form-control, .form-select { border-color: var(--mb-line-strong); }
.form-control:focus, .form-select:focus { border-color: var(--mb-blue); }
.form-text { color: var(--mb-ink-3); font-size: 0.8125rem; }
.form-section { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 12px 36px; padding: 22px 0; }
.form-section + .form-section { border-top: 1px solid var(--mb-line); }
.panel-body > .form-section:first-of-type { padding-top: 4px; }
.form-section-intro h2 { font-size: 1.0625rem; margin: 0 0 4px; }
.form-section-intro p { color: var(--mb-ink-3); font-size: 0.875rem; margin: 0; }
@media (max-width: 767.98px) { .form-section { grid-template-columns: 1fr; } }
.choice-list { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--mb-line); border-radius: 8px; cursor: pointer; background: var(--mb-surface); }
.choice:hover { border-color: var(--mb-line-strong); }
.choice:has(input:checked) { border-color: var(--mb-blue); background: var(--mb-blue-050); }
.choice small { display: block; color: var(--mb-ink-3); }

/* --- Steps of the campaign setup (a real sequence) ------------------------------------------ */
.steps { list-style: none; padding: 0; margin: 0; }
.step { display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: start; padding: 18px; border-top: 1px solid var(--mb-line); }
.step:first-child { border-top: 0; }
.step-mark { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--mb-line-strong); display: grid; place-items: center;
  font-family: var(--mb-font-display); font-weight: 600; color: var(--mb-ink-3); background: var(--mb-surface); }
.step.is-done .step-mark { border-color: var(--mb-green); background: var(--mb-green); color: #fff; }
.step.is-missing .step-mark { border-color: var(--mb-ochre); color: var(--mb-ochre); }
.step-title { font-weight: 600; margin: 3px 0 2px; font-size: 1rem; }
.step-summary { color: var(--mb-ink-2); font-size: 0.9rem; }
.step-summary .muted { color: var(--mb-ink-3); }

/* --- Misc components -------------------------------------------------------------------------- */
.empty { text-align: center; padding: 48px 20px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: inline-grid; place-items: center; background: var(--mb-blue-050);
  color: var(--mb-blue); font-size: 1.6rem; margin-bottom: 14px; }
.empty h3 { font-size: 1.25rem; margin-bottom: 6px; }
.empty p { color: var(--mb-ink-2); max-width: 52ch; margin: 0 auto 18px; }
.searchbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.searchbar .form-control { max-width: 320px; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pills a { font-size: 0.875rem; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--mb-line); color: var(--mb-ink-2);
  text-decoration: none; background: var(--mb-surface); }
.filter-pills a:hover { border-color: var(--mb-line-strong); color: var(--mb-ink); }
.filter-pills a.active { background: var(--mb-ink); color: #fff; border-color: var(--mb-ink); }
.filter-pills a .count { color: inherit; opacity: 0.65; margin-left: 4px; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 0.9375rem; }
.kv dt { color: var(--mb-ink-3); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.code-inline { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; background: #eef0f4;
  padding: 1px 6px; border-radius: 4px; }
.alert { border-radius: var(--mb-radius); }
.messages { margin-bottom: 18px; }
.chart-box { position: relative; height: 280px; }
.chart-box.is-small { height: 220px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hint { font-size: 0.8125rem; color: var(--mb-ink-3); }
.link-url { max-width: 520px; display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.bar-cell { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.bar-cell .simple-progress { flex: 1; }
.preview-frame { width: 100%; border: 1px solid var(--mb-line); border-radius: var(--mb-radius); background: #fff; min-height: 560px; }
.device-toggle .btn.active { background: var(--mb-ink); color: #fff; border-color: var(--mb-ink); }

/* Template gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.tile { background: var(--mb-surface); border: 1px solid var(--mb-line); border-radius: var(--mb-radius); overflow: hidden; display: flex; flex-direction: column; }
.tile:hover { border-color: var(--mb-line-strong); }
.tile-thumb { position: relative; height: 230px; overflow: hidden; background: #eef0f4; border-bottom: 1px solid var(--mb-line); }
.tile-thumb iframe { position: absolute; top: 0; left: 0; width: 640px; height: 920px; transform: scale(0.36); transform-origin: 0 0; border: 0; pointer-events: none; background: #fff; }
.tile-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.tile-title { font-weight: 600; text-decoration: none; color: var(--mb-ink); }
.tile-title:hover { color: var(--mb-blue); }
.tile-meta { font-size: 0.8125rem; color: var(--mb-ink-3); }
.tile-blank { display: grid; place-items: center; height: 100%; color: var(--mb-ink-3); font-size: 2rem; }

/* Heatmap (opens by weekday and hour) */
.heatmap { display: grid; grid-template-columns: 36px repeat(24, minmax(10px, 1fr)); gap: 3px; font-size: 0.6875rem; color: var(--mb-ink-3); }
.heatmap .hm-cell { aspect-ratio: 1; border-radius: 3px; background: #eef0f4; }
.heatmap .hm-label { display: flex; align-items: center; }
.heatmap .hm-hour { text-align: center; }

/* --- Auth & public pages: the login form arrives in an airmail envelope ----------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: var(--mb-paper); }
.auth-wrap { width: 100%; max-width: 440px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; text-decoration: none; color: var(--mb-ink); }
.auth-brand img { width: 40px; }
.envelope { padding: 9px; border-radius: var(--mb-radius-lg); background-image: var(--mb-airmail); background-size: var(--mb-airmail-size);
  box-shadow: 0 18px 40px -24px rgba(23, 32, 54, 0.35); }
.envelope-inner { background: var(--mb-surface); border-radius: 8px; padding: 30px 30px 26px; }
.envelope-inner h1 { font-size: 1.75rem; font-weight: 600; margin-bottom: 4px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 0.9rem; color: var(--mb-ink-2); }
.public-card { max-width: 520px; margin: 0 auto; background: var(--mb-surface); border: 1px solid var(--mb-line); border-radius: var(--mb-radius-lg); padding: 32px; }

/* Focus visibility */
:focus-visible { outline: 2px solid var(--mb-blue); outline-offset: 2px; }
.btn:focus-visible { box-shadow: 0 0 0 0.2rem var(--bs-focus-ring-color); outline: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Data viz (palette validated with the dataviz six-checks script) ------------------- */
:root {
  --viz-s1: #2547d0; --viz-s2: #eb6834; --viz-s3: #1baf7a; --viz-s4: #eda100; --viz-neg: #d8343f;
  --viz-zero: #eef0f4;
  /* sequential blue ramp (OKLCH, brand hue 266, even lightness steps) */
  --viz-q1: #e3ebfe; --viz-q2: #bdd1fe; --viz-q3: #92b2fe; --viz-q4: #6992fe;
  --viz-q5: #4872ee; --viz-q6: #2c51da; --viz-q7: #1c38b0; --viz-q8: #0f228c;
}
.viz-figure { margin: 0; }
.viz-caption { font-size: 0.8125rem; color: var(--mb-ink-3); margin-top: 8px; }
.viz-table { margin-top: 10px; font-size: 0.8125rem; }
.viz-table summary { color: var(--mb-ink-2); cursor: pointer; width: max-content; }
.viz-table summary:hover { color: var(--mb-blue); }
.viz-table table { margin-top: 8px; }
.viz-table .table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--mb-line); border-radius: 8px; }
/* Tall segmented bar: one whole split into <= 6 parts */
.segbar { display: flex; gap: 2px; height: 28px; border-radius: 4px; overflow: hidden; }
.segbar .seg { min-width: 2px; display: flex; align-items: center; padding: 0 8px; color: #fff; font-size: 0.8125rem; font-weight: 600;
  white-space: nowrap; border-radius: 4px; }
/* color follows the device, never its rank */
.seg-desktop { background: var(--viz-s1); }
.seg-mobile { background: var(--viz-s2); }
.seg-tablet { background: var(--viz-s3); }
.seg-unknown { background: var(--viz-s4); }
.segbar .seg-unknown { color: #172036; }
.seg-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 12px 0 0; font-size: 0.875rem; color: var(--mb-ink-2); }
.seg-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
/* Funnel: ordinal ramp, one bar per stage on a single baseline */
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 96px 1fr 110px; gap: 12px; align-items: center; font-size: 0.875rem; }
.funnel-track { height: 16px; }
.funnel-bar { height: 16px; border-radius: 0 4px 4px 0; min-width: 2px; }
.funnel-row:nth-child(1) .funnel-bar { background: #6992fe; }
.funnel-row:nth-child(2) .funnel-bar { background: #4872ee; }
.funnel-row:nth-child(3) .funnel-bar { background: #2c51da; }
.funnel-row:nth-child(4) .funnel-bar { background: #1c38b0; }
.funnel-value { text-align: right; color: var(--mb-ink); font-variant-numeric: tabular-nums; }
.funnel-value small { color: var(--mb-ink-3); margin-left: 4px; }
/* Heatmap levels */
.heatmap .hm-cell { background: var(--viz-zero); }
.heatmap .hm-cell.l1 { background: var(--viz-q1); } .heatmap .hm-cell.l2 { background: var(--viz-q2); }
.heatmap .hm-cell.l3 { background: var(--viz-q3); } .heatmap .hm-cell.l4 { background: var(--viz-q4); }
.heatmap .hm-cell.l5 { background: var(--viz-q5); } .heatmap .hm-cell.l6 { background: var(--viz-q6); }
.heatmap .hm-cell.l7 { background: var(--viz-q7); } .heatmap .hm-cell.l8 { background: var(--viz-q8); }
.heatmap .hm-cell:hover { outline: 2px solid var(--mb-ink); outline-offset: 1px; }
.scale-legend { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--mb-ink-3); margin-top: 10px; }
.scale-legend span.sw { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }
.bar-inline { height: 6px; border-radius: 0 3px 3px 0; background: var(--viz-s1); min-width: 2px; }
