/* =====================================================================
   BalMunshi UI · v1.0
   Components built only from tokens (../tokens/tokens.css).
   Load order: tokens.css → bm-ui.css → your page CSS.
   All classes start with bm- so the kit never collides with a project.
   No framework, no build step. Works with server-rendered HTML + htmx.
   ===================================================================== */

/* ---------- 1. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bm-bg);
  color: var(--bm-text);
  font: var(--bm-weight-regular) var(--bm-text-base)/var(--bm-leading) var(--bm-font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; }
a { color: var(--bm-accent-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--bm-accent-hover); }
:focus-visible { outline: 2px solid var(--bm-focus); outline-offset: 2px; border-radius: var(--bm-radius-sm); }
::selection { background: var(--bm-accent-soft); }
hr { border: 0; border-top: 1px solid var(--bm-line); margin: var(--bm-space-6) 0; }
[hidden] { display: none !important; }

.bm-h1, .bm-h2, .bm-h3, .bm-h4 { margin: 0; font-family: var(--bm-font-display); color: var(--bm-text); text-wrap: balance; }
.bm-h1 { font-size: clamp(36px, 6vw, var(--bm-text-6xl)); font-weight: var(--bm-weight-hero); line-height: 1; letter-spacing: -0.035em; }
.bm-h2 { font-size: clamp(28px, 3.8vw, var(--bm-text-4xl)); font-weight: var(--bm-weight-display); line-height: 1.08; letter-spacing: -0.03em; }
.bm-h3 { font-size: var(--bm-text-xl); font-weight: 700; line-height: 1.25; letter-spacing: -0.015em; }
.bm-h4 { font-size: var(--bm-text-lg); font-weight: 700; line-height: 1.3; }
.bm-lede { font-size: var(--bm-text-lg); color: var(--bm-text-2); max-width: 62ch; margin: 0; }
.bm-text-2 { color: var(--bm-text-2); }
.bm-muted { color: var(--bm-muted); }
.bm-small { font-size: var(--bm-text-sm); }
.bm-eyebrow { font: var(--bm-weight-medium) var(--bm-text-xs)/1 var(--bm-font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--bm-accent-text); }
.bm-mono, .bm-money { font-family: var(--bm-font-mono); font-variant-numeric: tabular-nums; }
.bm-money { font-weight: var(--bm-weight-medium); white-space: nowrap; }
.bm-kbd { font: var(--bm-weight-medium) var(--bm-text-xs)/1 var(--bm-font-mono); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--bm-line-strong); border-bottom-width: 2px; background: var(--bm-surface); color: var(--bm-text-2); }
.bm-code { font: var(--bm-text-sm)/1.7 var(--bm-font-mono); background: var(--bm-surface-3); padding: 2px 6px; border-radius: 5px; }
.bm-pre { margin: 0; font: var(--bm-text-sm)/1.7 var(--bm-font-mono); background: var(--bm-elevated); color: #e2e8f0; padding: var(--bm-space-4) var(--bm-space-5); border-radius: var(--bm-radius-lg); overflow-x: auto; }

/* ---------- 2. Layout ---------- */
.bm-container { width: 100%; max-width: var(--bm-container); margin-inline: auto; padding-inline: var(--bm-gutter); }
.bm-stack { display: flex; flex-direction: column; gap: var(--bm-gap, var(--bm-space-4)); }
.bm-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bm-gap, var(--bm-space-3)); }
.bm-row--between { justify-content: space-between; }
.bm-grid { display: grid; gap: var(--bm-gap, var(--bm-space-4)); grid-template-columns: repeat(auto-fill, minmax(min(var(--bm-min, 240px), 100%), 1fr)); }
/* Fill the row: items stretch to share the width instead of leaving empty columns (marketing pages, short lists) */
.bm-grid--fit { grid-template-columns: repeat(auto-fit, minmax(min(var(--bm-min, 240px), 100%), 1fr)); }
.bm-spacer { flex: 1; }
.bm-divider { height: 1px; background: var(--bm-line); border: 0; margin: 0; }
.bm-section { padding-block: clamp(48px, 7vw, 96px); }
.bm-bg-grid {
  background-image: linear-gradient(var(--bm-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bm-grid) 1px, transparent 1px);
  background-size: 56px 56px;
}

/* ---------- 3. Buttons ---------- */
.bm-btn {
  --_bg: var(--bm-surface); --_fg: var(--bm-text); --_bd: var(--bm-line-strong); --_bg-h: var(--bm-surface-3);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--bm-space-2);
  height: var(--bm-control-h); padding-inline: var(--bm-space-4);
  border: 1px solid var(--_bd); border-radius: var(--bm-radius-md);
  background: var(--_bg); color: var(--_fg);
  font: var(--bm-weight-semibold) var(--bm-text-md)/1 var(--bm-font-body); white-space: nowrap;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color var(--bm-fast) ease, border-color var(--bm-fast) ease, transform var(--bm-fast) ease, box-shadow var(--bm-fast) ease;
}
.bm-btn:hover { background: var(--_bg-h); color: var(--_fg); }
.bm-btn:active { transform: translateY(1px); }
.bm-btn:disabled, .bm-btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.bm-btn--primary { --_bg: var(--bm-accent); --_fg: var(--bm-on-accent); --_bd: transparent; --_bg-h: var(--bm-accent-hover); box-shadow: 0 8px 22px -12px var(--bm-accent); }
.bm-btn--dark { --_bg: var(--bm-contrast); --_fg: var(--bm-on-contrast); --_bd: transparent; --_bg-h: var(--bm-contrast-hover); }
.bm-btn--ghost { --_bg: transparent; --_bd: transparent; --_fg: var(--bm-text-2); --_bg-h: var(--bm-surface-3); }
.bm-btn--danger { --_bg: var(--bm-danger-fill); --_fg: #fff; --_bd: transparent; --_bg-h: var(--bm-danger); }
.bm-btn--success { --_bg: var(--bm-success-fill); --_fg: #fff; --_bd: transparent; --_bg-h: var(--bm-success); }
.bm-btn--sm { height: var(--bm-control-h-sm); padding-inline: var(--bm-space-3); font-size: var(--bm-text-sm); border-radius: var(--bm-radius-sm); }
.bm-btn--lg { height: var(--bm-control-h-lg); padding-inline: var(--bm-space-6); font-size: var(--bm-text-base); }
.bm-btn--block { width: 100%; }
.bm-btn--icon { width: var(--bm-control-h); padding: 0; }
.bm-btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.bm-btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--_fg); border-right-color: transparent; animation: bm-spin .7s linear infinite;
}
@keyframes bm-spin { to { transform: rotate(360deg); } }

/* ---------- 4. Forms ---------- */
.bm-field { display: grid; gap: 6px; align-content: start; }
.bm-label { font-size: var(--bm-text-sm); font-weight: var(--bm-weight-semibold); color: var(--bm-text); }
.bm-label .bm-req { color: var(--bm-accent-text); }
.bm-hint { font-size: var(--bm-text-sm); color: var(--bm-muted); }
.bm-error { font-size: var(--bm-text-sm); color: var(--bm-danger); }
.bm-input, .bm-select, .bm-textarea {
  width: 100%; height: var(--bm-control-h); padding: 0 var(--bm-space-3);
  background: var(--bm-surface); color: var(--bm-text);
  border: 1px solid var(--bm-line-strong); border-radius: var(--bm-radius-md);
  font: var(--bm-text-base) var(--bm-font-body);
  transition: border-color var(--bm-fast) ease, box-shadow var(--bm-fast) ease;
}
.bm-textarea { height: auto; min-height: 96px; padding: var(--bm-space-3); resize: vertical; line-height: var(--bm-leading); }
.bm-select { appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--bm-muted) 50%), linear-gradient(135deg, var(--bm-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.bm-input::placeholder, .bm-textarea::placeholder { color: var(--bm-placeholder); }
.bm-input:hover, .bm-select:hover, .bm-textarea:hover { border-color: var(--bm-muted); }
.bm-input:focus, .bm-select:focus, .bm-textarea:focus { outline: none; border-color: var(--bm-accent); box-shadow: 0 0 0 3px var(--bm-accent-soft); }
.bm-input[aria-invalid="true"], .bm-select[aria-invalid="true"], .bm-textarea[aria-invalid="true"] { border-color: var(--bm-danger-fill); box-shadow: 0 0 0 3px var(--bm-danger-soft); }
.bm-input:disabled, .bm-select:disabled, .bm-textarea:disabled { background: var(--bm-surface-2); color: var(--bm-muted); cursor: not-allowed; }
.bm-input-group { display: flex; align-items: stretch; }
.bm-input-group > .bm-addon {
  display: inline-flex; align-items: center; padding-inline: var(--bm-space-3);
  border: 1px solid var(--bm-line-strong); background: var(--bm-surface-2); color: var(--bm-muted);
  font: var(--bm-weight-medium) var(--bm-text-md) var(--bm-font-mono);
}
.bm-input-group > .bm-addon:first-child { border-right: 0; border-radius: var(--bm-radius-md) 0 0 var(--bm-radius-md); }
.bm-input-group > .bm-addon:last-child { border-left: 0; border-radius: 0 var(--bm-radius-md) var(--bm-radius-md) 0; }
.bm-input-group > .bm-input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bm-input-group > .bm-input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.bm-check, .bm-radio { display: inline-flex; align-items: center; gap: var(--bm-space-2); font-size: var(--bm-text-md); cursor: pointer; }
.bm-check input, .bm-radio input { width: 18px; height: 18px; margin: 0; accent-color: var(--bm-accent); cursor: pointer; }
.bm-switch { display: inline-flex; align-items: center; gap: var(--bm-space-3); cursor: pointer; font-size: var(--bm-text-md); }
.bm-switch input { appearance: none; width: 40px; height: 24px; margin: 0; border-radius: var(--bm-radius-full); background: var(--bm-surface-3); border: 1px solid var(--bm-line-strong); position: relative; cursor: pointer; transition: background-color var(--bm-base) var(--bm-ease); }
.bm-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--bm-shadow-sm); transition: transform var(--bm-base) var(--bm-ease); }
.bm-switch input:checked { background: var(--bm-accent); border-color: transparent; }
.bm-switch input:checked::after { transform: translateX(16px); }
.bm-range { width: 100%; height: 32px; margin: 0; accent-color: var(--bm-accent); cursor: pointer; }
/* Form layout: one column on phones, two from 560 px. Add .bm-span-2 to a field to take the full row. */
.bm-form-grid { display: grid; gap: var(--bm-space-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) { .bm-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .bm-form-grid > .bm-span-2 { grid-column: 1 / -1; } }
/* Honeypot for spam bots: keep it in the DOM but out of sight */
.bm-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- 5. Cards & tiles ---------- */
.bm-card { background: var(--bm-surface); border: 1px solid var(--bm-line); border-radius: var(--bm-radius-lg); box-shadow: var(--bm-shadow-sm); }
.bm-card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--bm-space-3); padding: var(--bm-space-4) var(--bm-space-5); border-bottom: 1px solid var(--bm-line); }
.bm-card__title { margin: 0; font: 700 var(--bm-text-lg)/1.3 var(--bm-font-display); letter-spacing: -0.01em; }
.bm-card__body { padding: var(--bm-space-5); }
.bm-card__footer { display: flex; gap: var(--bm-space-2); justify-content: flex-end; padding: var(--bm-space-3) var(--bm-space-5); border-top: 1px solid var(--bm-line); background: var(--bm-surface-2); border-radius: 0 0 var(--bm-radius-lg) var(--bm-radius-lg); }
.bm-card--flat { box-shadow: none; }
.bm-card--raised { box-shadow: var(--bm-shadow-md); }
.bm-card--accent { border-color: var(--bm-accent-line); background: linear-gradient(180deg, var(--bm-accent-soft), transparent 55%), var(--bm-surface); }

.bm-stat { display: grid; gap: 6px; padding: var(--bm-space-5); background: var(--bm-surface); border: 1px solid var(--bm-line); border-radius: var(--bm-radius-lg); }
.bm-stat__label { font-size: var(--bm-text-sm); color: var(--bm-muted); }
.bm-stat__value { font: 800 var(--bm-text-3xl)/1.05 var(--bm-font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.bm-stat__meta { font: var(--bm-text-xs)/1.4 var(--bm-font-mono); color: var(--bm-muted); }
.bm-stat--alert { border-color: var(--bm-accent-line); background: linear-gradient(180deg, var(--bm-accent-soft), transparent 80%), var(--bm-surface); }
.bm-stat--alert .bm-stat__value { color: var(--bm-accent-text); }
.bm-trend-up { color: var(--bm-success); } .bm-trend-down { color: var(--bm-danger); }

/* ---------- 6. Badges & status ---------- */
.bm-badge {
  --_c: var(--bm-text-2); --_bg: var(--bm-surface-3);
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding-inline: 8px;
  border-radius: var(--bm-radius-sm); background: var(--_bg); color: var(--_c);
  font: 600 11px/1 var(--bm-font-mono); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}
.bm-badge--success { --_c: var(--bm-success); --_bg: var(--bm-success-soft); }
.bm-badge--warning { --_c: var(--bm-warning); --_bg: var(--bm-warning-soft); }
.bm-badge--danger  { --_c: var(--bm-danger);  --_bg: var(--bm-danger-soft); }
.bm-badge--info    { --_c: var(--bm-info);    --_bg: var(--bm-info-soft); }
.bm-badge--accent  { --_c: var(--bm-accent-text); --_bg: var(--bm-accent-soft); }
.bm-badge--solid   { --_c: var(--bm-on-accent); --_bg: var(--bm-accent); }
.bm-pill { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 28px; padding: 3px 12px; border-radius: var(--bm-radius-full); border: 1px solid var(--bm-line-strong); background: var(--bm-surface); font-size: var(--bm-text-sm); color: var(--bm-text-2); }

/* Membership status: always pair colour with a word, never colour alone */
.bm-status { display: inline-flex; align-items: center; gap: 7px; font-size: var(--bm-text-sm); font-weight: var(--bm-weight-semibold); color: var(--bm-text); }
.bm-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--_dot, var(--bm-muted)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--_dot, var(--bm-muted)) 20%, transparent); }
.bm-status--active   { --_dot: var(--bm-state-active); }
.bm-status--expiring { --_dot: var(--bm-state-expiring); }
.bm-status--expired  { --_dot: var(--bm-state-expired); }
.bm-status--frozen   { --_dot: var(--bm-state-frozen); }
.bm-status--live::before { animation: bm-pulse 1.8s ease-in-out infinite; }
@keyframes bm-pulse { 50% { box-shadow: 0 0 0 6px transparent; } }

/* ---------- 6b. Line icons as masks, and the tick ----------
   One drawing of each small icon, used by alerts, checklists and bm-tick, so they never differ.
   <span class="bm-tick" aria-label="Done"></span>  (bm-tick--sm for 24px) */
:root {
  --bm-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  --bm-icon-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6L6 18M6 6l12 12'/%3E%3C/svg%3E");
  --bm-icon-warn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v7M12 17.5v.5'/%3E%3C/svg%3E");
  --bm-icon-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 11v6.5M12 6.5v.5'/%3E%3C/svg%3E");
}
.bm-tick { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; color: var(--bm-success); background: var(--bm-success-soft); border: 1px solid color-mix(in srgb, var(--bm-success) 35%, transparent); }
.bm-tick::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--bm-icon-check) center / contain no-repeat; mask: var(--bm-icon-check) center / contain no-repeat; }
.bm-tick--sm { width: 24px; height: 24px; border-radius: 8px; }
.bm-tick--sm::before { width: 13px; height: 13px; }

/* ---------- 6c. Scrollbars ----------
   Thin, rounded, in the theme's own grey, on the page and inside every scrolling box. */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--bm-text) 24%, transparent) transparent; }
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb { border-radius: 999px; border: 2px solid transparent; background: color-mix(in srgb, var(--bm-text) 24%, transparent) content-box; }
  ::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--bm-text) 40%, transparent) content-box; }
}

/* ---------- 7. Alerts & banners ---------- */
/* A tinted card with an icon tile (v1.7; round in v1.1): tick success, ! warning, × danger, i info. Same HTML as before. */
.bm-alert {
  --_c: var(--bm-info-fill); --_icon: var(--bm-icon-info);
  display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: var(--bm-space-3); row-gap: 4px; align-items: start;
  padding: 14px var(--bm-space-4); border-radius: var(--bm-radius-lg);
  background: color-mix(in srgb, var(--_c) 7%, var(--bm-surface));
  border: 1px solid color-mix(in srgb, var(--_c) 26%, var(--bm-line));
  box-shadow: var(--bm-shadow-sm); color: var(--bm-text); font-size: var(--bm-text-md); line-height: 1.5;
}
/* the icon is the same soft tile with a line icon as bm-tick (1.7), so a tick looks the same everywhere */
.bm-alert::before, .bm-alert::after { content: ""; grid-column: 1; grid-row: 1; width: 26px; height: 26px; margin-top: -1px; border-radius: 8px; }
.bm-alert::before { background: color-mix(in srgb, var(--_c) 16%, transparent); border: 1px solid color-mix(in srgb, var(--_c) 38%, transparent); }
.bm-alert::after { border-radius: 0; background: var(--_c); -webkit-mask: var(--_icon) center / 15px no-repeat; mask: var(--_icon) center / 15px no-repeat; }
.bm-alert > * { grid-column: 2; min-width: 0; }
.bm-alert__title { font-weight: var(--bm-weight-semibold); color: var(--bm-text); margin: 0 0 2px; }
.bm-alert p { margin: 0; }
.bm-alert--success { --_c: var(--bm-success-fill, var(--bm-success)); --_icon: var(--bm-icon-check); }
.bm-alert--warning { --_c: var(--bm-warning-fill, var(--bm-warning)); --_icon: var(--bm-icon-warn); }
.bm-alert--danger  { --_c: var(--bm-danger-fill, var(--bm-danger));  --_icon: var(--bm-icon-cross); }
.bm-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--bm-space-3); padding: 10px var(--bm-gutter); background: var(--bm-elevated); color: #fff; font-size: var(--bm-text-md); text-align: center; }
.bm-banner--accent { background: var(--bm-accent); }
.bm-banner a { color: inherit; font-weight: var(--bm-weight-semibold); }

/* Check-in result banner: GREEN / AMBER / RED */
.bm-checkin { border-radius: var(--bm-radius-lg); overflow: hidden; border: 1px solid var(--bm-line); background: var(--bm-surface); }
.bm-checkin__head { display: flex; align-items: center; gap: var(--bm-space-3); padding: var(--bm-space-3) var(--bm-space-4); color: #fff; background: var(--_c, var(--bm-state-active)); }
.bm-checkin__head b { font: 800 var(--bm-text-md)/1 var(--bm-font-display); letter-spacing: .04em; text-transform: uppercase; }
.bm-checkin__head span { margin-left: auto; font: var(--bm-text-sm) var(--bm-font-mono); opacity: .92; }
.bm-checkin__body { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bm-space-2); padding: 10px var(--bm-space-4); }
.bm-checkin__body form { margin: 0; }                 /* a form's default bottom margin made the card taller than its buttons */
.bm-checkin__body:empty { display: none; }
.bm-checkin__head { padding-block: 10px; }
.bm-checkin--green { --_c: var(--bm-state-active); }
.bm-checkin--amber { --_c: var(--bm-state-expiring); }
.bm-checkin--red   { --_c: var(--bm-state-expired); }

/* ---------- 8. Tables ---------- */
.bm-table-wrap { overflow-x: auto; border: 1px solid var(--bm-line); border-radius: var(--bm-radius-lg); background: var(--bm-surface); }
.bm-table { width: 100%; border-collapse: collapse; font-size: var(--bm-text-md); }
/* Tables never squeeze: cells stay on one line and the wrapper scrolls sideways on small screens.
   Add .bm-table--wrap to let long text wrap instead. */
.bm-table th, .bm-table td { white-space: nowrap; }
.bm-table--wrap th, .bm-table--wrap td { white-space: normal; }
.bm-table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.bm-table th { text-align: left; padding: 10px var(--bm-space-4); font: 600 var(--bm-text-xs)/1.2 var(--bm-font-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--bm-muted); background: var(--bm-surface-2); border-bottom: 1px solid var(--bm-line); white-space: nowrap; }
.bm-table td { padding: 12px var(--bm-space-4); border-bottom: 1px solid var(--bm-line); vertical-align: middle; }
.bm-table tbody tr:last-child td { border-bottom: 0; }
.bm-table tbody tr:hover td { background: var(--bm-surface-2); }
.bm-table .bm-num { text-align: right; font-family: var(--bm-font-mono); font-variant-numeric: tabular-nums; }
.bm-cell-person { display: flex; align-items: center; gap: var(--bm-space-3); min-width: 0; }
.bm-cell-person b { display: block; font-weight: var(--bm-weight-semibold); }
.bm-cell-person small { display: block; color: var(--bm-muted); font-size: var(--bm-text-sm); }

/* ---------- 9. Avatar ---------- */
.bm-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; overflow: hidden; background: var(--bm-surface-3); color: var(--bm-text-2); font: 600 var(--bm-text-sm)/1 var(--bm-font-body); }
.bm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bm-avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.bm-avatar--lg { width: 56px; height: 56px; font-size: var(--bm-text-lg); }

/* ---------- 10. Tabs & segmented ---------- */
/* the line under the tabs is a shadow, not a border, so the active tab needs no negative margin and the row never gets an up-down scrollbar */
.bm-tabs { display: flex; gap: var(--bm-space-1); box-shadow: inset 0 -1px 0 var(--bm-line); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.bm-tab { appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: 0; padding: 10px var(--bm-space-3); font: var(--bm-weight-semibold) var(--bm-text-md) var(--bm-font-body); color: var(--bm-muted); cursor: pointer; white-space: nowrap; }
.bm-tab:hover { color: var(--bm-text); }
.bm-tab[aria-selected="true"] { color: var(--bm-text); border-bottom-color: var(--bm-accent); }
.bm-segmented { display: inline-flex; align-self: flex-start; justify-self: start; padding: 3px; gap: 2px; border-radius: var(--bm-radius-md); background: var(--bm-surface-3); }
.bm-segmented button { appearance: none; border: 0; background: transparent; height: 30px; padding-inline: var(--bm-space-3); border-radius: 7px; font: var(--bm-weight-semibold) var(--bm-text-sm) var(--bm-font-body); color: var(--bm-muted); cursor: pointer; }
.bm-segmented button[aria-pressed="true"] { background: var(--bm-surface); color: var(--bm-text); box-shadow: var(--bm-shadow-sm); }

/* ---------- 11. Breadcrumb & pagination ---------- */
.bm-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; font-size: var(--bm-text-sm); color: var(--bm-muted); }
.bm-breadcrumb li + li::before { content: "/"; margin-right: 6px; opacity: .6; }
.bm-breadcrumb a { color: var(--bm-text-2); text-decoration: none; }
.bm-pagination { display: flex; gap: var(--bm-space-1); align-items: center; }
.bm-pagination a, .bm-pagination span { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding-inline: 8px; border-radius: var(--bm-radius-sm); font: var(--bm-weight-medium) var(--bm-text-sm) var(--bm-font-mono); color: var(--bm-text-2); text-decoration: none; }
.bm-pagination a:hover { background: var(--bm-surface-3); }
.bm-pagination [aria-current="page"] { background: var(--bm-contrast); color: var(--bm-on-contrast); }

/* ---------- 12. Progress, skeleton, empty state ---------- */
.bm-progress { height: 8px; border-radius: var(--bm-radius-full); background: var(--bm-surface-3); overflow: hidden; }
.bm-progress > i { display: block; height: 100%; width: var(--bm-value, 0%); background: var(--bm-accent); border-radius: inherit; transition: width var(--bm-slow) var(--bm-ease); }
.bm-skeleton { border-radius: var(--bm-radius-sm); background: linear-gradient(90deg, var(--bm-surface-3) 25%, var(--bm-surface-2) 50%, var(--bm-surface-3) 75%); background-size: 200% 100%; animation: bm-shimmer 1.4s linear infinite; min-height: 12px; }
@keyframes bm-shimmer { to { background-position: -200% 0; } }
.bm-empty { display: grid; justify-items: center; gap: var(--bm-space-3); text-align: center; padding: var(--bm-space-12) var(--bm-space-6); border: 1px dashed var(--bm-line-strong); border-radius: var(--bm-radius-lg); color: var(--bm-text-2); }
.bm-empty__icon { width: 48px; height: 48px; border-radius: var(--bm-radius-lg); display: grid; place-items: center; background: var(--bm-accent-soft); color: var(--bm-accent-text); }
.bm-empty h3 { margin: 0; font: 700 var(--bm-text-lg) var(--bm-font-display); color: var(--bm-text); }

/* ---------- 13. Dialog (native <dialog>) ---------- */
.bm-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: hidden; padding: 0; border: 1px solid var(--bm-line); border-radius: var(--bm-radius-xl); background: var(--bm-surface); color: var(--bm-text); box-shadow: var(--bm-shadow-lg); }
.bm-dialog::backdrop { background: var(--bm-overlay); backdrop-filter: blur(2px); }
.bm-dialog__header { display: flex; align-items: center; justify-content: space-between; gap: var(--bm-space-3); padding: var(--bm-space-5) var(--bm-space-6) 0; }
.bm-dialog__title { margin: 0; font: 800 var(--bm-text-xl)/1.2 var(--bm-font-display); letter-spacing: -0.02em; }
.bm-dialog__body { padding: var(--bm-space-4) var(--bm-space-6); color: var(--bm-text-2); }
/* 1.9: the title and the buttons always stay in view; only the middle scrolls, and only when it must. A form with many
   fields takes bm-dialog--wide: a wider box whose form grid has three columns on a desktop. */
.bm-dialog[open] { display: flex; flex-direction: column; }
.bm-dialog > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.bm-dialog__header, .bm-dialog__footer { flex: none; }
.bm-dialog__body { overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }
.bm-dialog--wide { width: min(880px, calc(100vw - 32px)); }
@media (min-width: 860px) { .bm-dialog--wide .bm-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.bm-dialog__footer { display: flex; justify-content: flex-end; gap: var(--bm-space-2); padding: var(--bm-space-4) var(--bm-space-6) var(--bm-space-5); }
.bm-dialog[open] { animation: bm-pop var(--bm-base) var(--bm-ease); }
@keyframes bm-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- 14. Toast ---------- */
.bm-toasts { position: fixed; z-index: var(--bm-z-toast); right: var(--bm-space-4); bottom: calc(var(--bm-space-4) + env(safe-area-inset-bottom, 0px)); display: grid; gap: var(--bm-space-2); width: min(360px, calc(100vw - 32px)); }
.bm-toast { display: flex; gap: var(--bm-space-3); align-items: center; padding: 12px var(--bm-space-4); border-radius: var(--bm-radius-lg); background: var(--bm-elevated); color: #fff; box-shadow: var(--bm-shadow-lg); font-size: var(--bm-text-md); animation: bm-pop var(--bm-base) var(--bm-ease); }
.bm-toast::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--_c, var(--bm-accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--_c, var(--bm-accent)) 25%, transparent); }
.bm-toast--success { --_c: #10b981; } .bm-toast--warning { --_c: #f59e0b; } .bm-toast--danger { --_c: #ef4444; }

/* ---------- 15. Tooltip (CSS only: data-tip) ---------- */
[data-bm-tip] { position: relative; }
[data-bm-tip]:hover::after, [data-bm-tip]:focus-visible::after {
  content: attr(data-bm-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  padding: 6px 9px; border-radius: var(--bm-radius-sm); background: var(--bm-elevated); color: #fff; font: var(--bm-weight-medium) var(--bm-text-xs)/1.3 var(--bm-font-body);
  width: max-content; max-width: min(260px, 80vw); white-space: normal; text-align: center; letter-spacing: 0; text-transform: none; pointer-events: none; z-index: var(--bm-z-dropdown);
}
/* Page loader (kit 1.4): <div class="bm-loader" data-bm-loader hidden role="status">…animated mark…</div>.
   The mark is drawn twice: the base in the text colour (white on dark, ink on light) and a red copy clipped to a band
   as wide as the M, which slides from the G to the M. bm-ui.js shows it when a page takes a moment to open. */
.bm-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; }
.bm-loader { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; background: color-mix(in srgb, var(--bm-bg) 78%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: bm-loader-in 180ms var(--bm-ease) both; }
.bm-loader[hidden] { display: none; }
.bm-loader__mark { width: 88px; height: auto; overflow: visible; }
.bm-loader__base { fill: var(--bm-text); }
.bm-loader__red { fill: #e11d48; }
@keyframes bm-loader-in { from { opacity: 0; } }

/* Tooltips near a screen edge (bm-ui.js sets these on hover/focus): stay inside the window */
[data-bm-tip].bm-tip--start:hover::after, [data-bm-tip].bm-tip--start:focus-visible::after { left: 0; transform: none; text-align: left; }
[data-bm-tip].bm-tip--end:hover::after, [data-bm-tip].bm-tip--end:focus-visible::after { left: auto; right: 0; transform: none; text-align: left; }
[data-bm-tip].bm-tip--below:hover::after, [data-bm-tip].bm-tip--below:focus-visible::after { bottom: auto; top: calc(100% + 8px); }
/* Inside a scrolling box (table wrap): placed on the window, so the box never scrolls because of a tip (kit 1.5) */
[data-bm-tip].bm-tip--fixed:hover::after, [data-bm-tip].bm-tip--fixed:focus-visible::after { position: fixed; left: var(--bm-tip-x); right: auto; top: auto; bottom: var(--bm-tip-b); transform: translateX(-50%); }
[data-bm-tip].bm-tip--fixed.bm-tip--below:hover::after, [data-bm-tip].bm-tip--fixed.bm-tip--below:focus-visible::after { top: var(--bm-tip-y); bottom: auto; }
/* Info dot next to a label: <span class="bm-info" tabindex="0" data-bm-tip="What this number means">i</span> */
.bm-info { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-left: 4px; border-radius: 50%; border: 1px solid currentColor; font: 600 10px/1 var(--bm-font-body); color: var(--bm-muted); cursor: help; vertical-align: 1px; opacity: .8; }
.bm-info:hover, .bm-info:focus-visible { opacity: 1; color: var(--bm-text); }
.bm-info[data-bm-tip]:hover::after, .bm-info[data-bm-tip]:focus-visible::after { text-align: left; font-size: var(--bm-text-xs); }

/* Popover menu (kit 1.3): <details class="bm-popover" data-bm-popover><summary>…</summary><div class="bm-popover__panel">…</div></details>.
   Esc or a click outside closes it (bm-ui.js). Add .bm-popover--end to align the panel to the right edge. */
.bm-popover { position: relative; }
.bm-popover > summary { list-style: none; cursor: pointer; }
.bm-popover > summary::-webkit-details-marker { display: none; }
.bm-popover__panel { position: absolute; top: calc(100% + 8px); left: 0; z-index: var(--bm-z-dropdown); min-width: 240px; max-width: min(360px, calc(100vw - 24px)); padding: 6px; border-radius: var(--bm-radius-lg); background: var(--bm-surface); border: 1px solid var(--bm-line); box-shadow: var(--bm-shadow-lg); animation: bm-pop-in 140ms var(--bm-ease); }
.bm-popover--end .bm-popover__panel { left: auto; right: 0; }
.bm-popover__head { padding: 10px 10px 8px; border-bottom: 1px solid var(--bm-line); margin-bottom: 4px; }
.bm-popover__head b { display: block; color: var(--bm-text); }
.bm-popover__item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: var(--bm-radius-md); background: none; color: var(--bm-text-2); font: var(--bm-weight-medium) var(--bm-text-md)/1.2 var(--bm-font-body); text-align: left; text-decoration: none; cursor: pointer; }
.bm-popover__item:hover, .bm-popover__item:focus-visible { background: var(--bm-surface-3); color: var(--bm-text); outline: none; }
.bm-popover__item svg { width: 17px; height: 17px; flex: none; }
.bm-popover__item .bm-badge { margin-left: auto; }
.bm-popover__sep { height: 1px; margin: 4px 0; background: var(--bm-line); }
@keyframes bm-pop-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- 16. Top bar (marketing & app) ---------- */
.bm-topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: var(--bm-z-sticky); background: color-mix(in srgb, var(--bm-surface) 86%, transparent); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px); border-bottom: 1px solid var(--bm-line); }
.bm-topbar__row { display: flex; align-items: center; gap: var(--bm-space-5); height: var(--bm-topbar-h); }
.bm-topbar__logo { display: inline-flex; align-items: center; height: 30px; }
.bm-topbar__logo img { height: 100%; width: auto; display: block; }
.bm-topbar__links { display: flex; gap: var(--bm-space-5); }
.bm-topbar__links a { color: var(--bm-text-2); font-size: var(--bm-text-md); font-weight: var(--bm-weight-medium); text-decoration: none; }
.bm-topbar__links a:hover, .bm-topbar__links a[aria-current="page"] { color: var(--bm-text); }
@media (max-width: 820px) { .bm-topbar__links { display: none; } }
/* Mobile menu: <button class="bm-topbar__toggle" data-bm-menu> + <div class="bm-topbar__drawer"><nav>…links…</nav></div> inside .bm-topbar */
.bm-topbar__toggle { display: none; flex: none; }
.bm-topbar__drawer { display: none; border-top: 1px solid var(--bm-line); background: var(--bm-surface); max-height: calc(100dvh - var(--bm-topbar-h)); overflow-y: auto; }
.bm-topbar__drawer nav { display: grid; padding: var(--bm-space-2) var(--bm-gutter) var(--bm-space-4); }
.bm-topbar__drawer a { display: flex; align-items: center; min-height: 48px; font-size: var(--bm-text-lg); font-weight: var(--bm-weight-semibold); color: var(--bm-text); text-decoration: none; border-bottom: 1px solid var(--bm-line); }
.bm-topbar__drawer a:last-child { border-bottom: 0; }
@media (max-width: 820px) {
  .bm-topbar__toggle { display: inline-flex; }
  .bm-topbar[data-open="true"] .bm-topbar__drawer { display: block; }
  .bm-topbar__row { gap: var(--bm-space-3); }
}

/* ---------- 17. App shell: sidebar + main ---------- */
.bm-app { display: grid; grid-template-columns: var(--bm-sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.bm-sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; scrollbar-width: none; display: flex; flex-direction: column; gap: var(--bm-space-4); padding: var(--bm-space-4) var(--bm-space-3); background: var(--bm-surface); border-right: 1px solid var(--bm-line); }
/* a short window: the menu still scrolls (wheel, touch, keys) but no bar is drawn over it */
.bm-sidebar::-webkit-scrollbar { display: none; }
.bm-sidebar__logo { display: flex; align-items: center; height: 40px; padding-inline: var(--bm-space-2); }
.bm-sidebar__logo img { height: 28px; width: auto; }
.bm-sidebar__section { font: 600 11px/1 var(--bm-font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--bm-muted); padding: var(--bm-space-3) var(--bm-space-3) var(--bm-space-1); }
.bm-menu { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
.bm-menu a { display: flex; align-items: center; gap: var(--bm-space-3); height: 38px; padding-inline: var(--bm-space-3); border-radius: var(--bm-radius-md); color: var(--bm-text-2); text-decoration: none; font-size: var(--bm-text-md); font-weight: var(--bm-weight-medium); }
.bm-menu a:hover { background: var(--bm-surface-3); color: var(--bm-text); }
.bm-menu a[aria-current="page"] { background: var(--bm-accent-soft); color: var(--bm-accent-text); font-weight: var(--bm-weight-semibold); }
.bm-menu svg { width: 18px; height: 18px; flex: none; }
.bm-menu .bm-count { margin-left: auto; font: 600 11px/1 var(--bm-font-mono); padding: 4px 6px; border-radius: 6px; background: var(--bm-accent); color: #fff; }
/* Collapsible sidebar (kit 1.2, desktop only). :root[data-sidebar="collapsed"] shows an icon rail; hovering or
   focusing it opens it over the page; the pin button ([data-bm-sidebar-pin]) switches it and bm-ui.js remembers
   the choice. Wrap menu text in .bm-menu__label; anything else to hide goes in .bm-sidebar__wide, and a
   compact logo in .bm-sidebar__narrow. */
.bm-sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: var(--bm-space-2); }
.bm-sidebar__pin svg { transition: transform var(--bm-base) var(--bm-ease); }
.bm-sidebar__narrow { display: none; }
@keyframes bm-sidebar-fade { from { opacity: 0; transform: translateX(-4px); } }
@media (min-width: 961px) {
  .bm-app { transition: grid-template-columns 240ms var(--bm-ease); }
  .bm-sidebar { width: var(--bm-sidebar-w); overflow-x: hidden; transition: width 240ms var(--bm-ease), box-shadow 240ms var(--bm-ease); }
  .bm-menu__label, .bm-sidebar .bm-btn--block { white-space: nowrap; }
  :root[data-sidebar="collapsed"] .bm-app { grid-template-columns: 72px minmax(0, 1fr); }
  /* collapsed: the rail floats over the page (fixed), so opening it on hover never widens the page (no sideways
     scroll); while it opens, its content is laid out at full width and only revealed, so long names don't wrap
     into many lines for a moment (no up-down scroll) */
  :root[data-sidebar="collapsed"] .bm-sidebar { position: fixed; top: 0; left: 0; width: 72px; z-index: var(--bm-z-overlay); overflow-y: hidden; }
  :root[data-sidebar="collapsed"] .bm-main { grid-column: 2; grid-row: 1; }
  :root[data-sidebar="collapsed"] .bm-sidebar:is(:hover, :focus-within) > * { min-width: calc(var(--bm-sidebar-w) - 2 * var(--bm-space-3) - 1px); }
  :root[data-sidebar="collapsed"] .bm-sidebar:is(:hover, :focus-within) { overflow-y: auto; }
  :root[data-sidebar="collapsed"] .bm-sidebar:is(:hover, :focus-within) :is(.bm-menu__label, .bm-sidebar__wide, .bm-sidebar__section, .bm-sidebar__pin) { animation: bm-sidebar-fade 240ms var(--bm-ease) both; }
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-menu__label,
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__wide,
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__section,
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__pin { display: none; }
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__wide { display: none !important; }   /* beats the logo theme rules */
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__narrow { display: block; height: 30px; width: auto; }
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__head { justify-content: center; }
  /* compact logo: .bm-sidebar__narrow (light) + .bm-sidebar__narrow.bm-sidebar__narrow--dark (dark backgrounds) */
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__narrow--dark { display: none; }
  :root[data-theme="dark"][data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__narrow:not(.bm-sidebar__narrow--dark) { display: none; }
  :root[data-theme="dark"][data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__narrow--dark { display: block; }
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-menu a,
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-btn--block { justify-content: center; padding-inline: 0; }
  :root[data-sidebar="collapsed"] .bm-sidebar:hover, :root[data-sidebar="collapsed"] .bm-sidebar:focus-within { width: var(--bm-sidebar-w); box-shadow: var(--bm-shadow-lg); }
  :root[data-sidebar="collapsed"] .bm-sidebar__pin svg { transform: rotate(180deg); }
  /* counts (e.g. alerts) become a small number on the icon's corner instead of disappearing */
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-menu a { position: relative; }
  :root[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-menu .bm-count { position: absolute; top: 3px; right: 6px; margin: 0; min-width: 16px; padding: 3px 4px; font-size: 9.5px; line-height: 1; text-align: center; border-radius: 999px; box-shadow: 0 0 0 2px var(--bm-surface); }
}
@media (max-width: 960px) { .bm-sidebar__pin { display: none; } }
@media (prefers-reduced-motion: reduce) { .bm-app, .bm-sidebar { transition: none !important; } .bm-sidebar * { animation: none !important; } }
@media (min-width: 961px) and (prefers-color-scheme: dark) {
  :root:not([data-theme])[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__narrow:not(.bm-sidebar__narrow--dark) { display: none; }
  :root:not([data-theme])[data-sidebar="collapsed"] .bm-sidebar:not(:hover):not(:focus-within) .bm-sidebar__narrow--dark { display: block; }
}
/* Phone drawer: a dim backdrop; tapping it (or Esc) closes the menu */
@media (max-width: 960px) { .bm-app[data-nav="open"]::after { content: ""; position: fixed; inset: 0; z-index: calc(var(--bm-z-overlay) - 1); background: var(--bm-overlay); } }
.bm-main { min-width: 0; display: flex; flex-direction: column; }
.bm-main__bar { position: sticky; top: 0; z-index: var(--bm-z-sticky); display: flex; align-items: center; gap: var(--bm-space-3); height: var(--bm-topbar-h); padding-inline: var(--bm-space-6); background: color-mix(in srgb, var(--bm-bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--bm-line); }
.bm-main__content { padding: var(--bm-space-6); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--bm-space-6); align-content: start; }
.bm-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--bm-space-4); }
.bm-page-head h1 { margin: 0; font: 800 var(--bm-text-2xl)/1.15 var(--bm-font-display); letter-spacing: -0.02em; }
.bm-menu-toggle { display: none; }
@media (max-width: 960px) {
  .bm-app { grid-template-columns: minmax(0, 1fr); }
  .bm-sidebar { position: fixed; inset: 0 auto 0 0; width: min(var(--bm-sidebar-w), 86vw); z-index: var(--bm-z-overlay); transform: translateX(-100%); transition: transform var(--bm-base) var(--bm-ease); box-shadow: var(--bm-shadow-lg); }
  .bm-app[data-nav="open"] .bm-sidebar { transform: none; }
  .bm-menu-toggle { display: inline-flex; }
  .bm-main__bar, .bm-main__content { padding-inline: var(--bm-space-4); }
}

/* ---------- 18. Theme-aware logo & theme toggle ---------- */
/* <img class="bm-logo-light" src=".../logo-horizontal-color.svg"> + <img class="bm-logo-dark" src=".../logo-horizontal-reverse.svg"> */
.bm-logo-dark { display: none !important; }
:root[data-theme="dark"] .bm-logo-light { display: none !important; }
:root[data-theme="dark"] .bm-logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .bm-logo-light { display: none !important; }
  :root:not([data-theme]) .bm-logo-dark { display: block !important; }
}
.bm-theme-toggle .bm-icon-sun { display: none; }
:root[data-theme="dark"] .bm-theme-toggle .bm-icon-sun { display: block; }
:root[data-theme="dark"] .bm-theme-toggle .bm-icon-moon { display: none; }

/* ---------- 19. Choice cards & segmented radios (settings, plan pickers) ---------- */
/* <label class="bm-choice"><input type="radio" name="x" value="a"> …content… </label> */
.bm-choice { position: relative; display: grid; gap: var(--bm-space-2); padding: var(--bm-space-3); background: var(--bm-surface); border: 1px solid var(--bm-line-strong); border-radius: var(--bm-radius-lg); cursor: pointer; transition: border-color var(--bm-fast) ease, box-shadow var(--bm-fast) ease; }
.bm-choice:hover { border-color: var(--bm-muted); }
.bm-choice > input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.bm-choice:has(> input:checked) { border-color: var(--bm-accent); box-shadow: 0 0 0 3px var(--bm-accent-soft); }
.bm-choice:has(> input:focus-visible) { outline: 2px solid var(--bm-focus); outline-offset: 2px; }
.bm-choice__title { display: flex; align-items: center; justify-content: space-between; gap: var(--bm-space-2); font-weight: var(--bm-weight-semibold); font-size: var(--bm-text-md); }
.bm-choice__title::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--bm-line-strong); flex: none; }
.bm-choice:has(> input:checked) .bm-choice__title::after { border: 5px solid var(--bm-accent); }
.bm-choice__desc { font-size: var(--bm-text-sm); color: var(--bm-muted); }
.bm-choices { display: grid; gap: var(--bm-space-3); grid-template-columns: repeat(auto-fill, minmax(var(--bm-min, 150px), 1fr)); }

/* Segmented radios: <div class="bm-segmented" role="radiogroup"><label><input type="radio" name="bm-theme" value="light">Light</label>… */
.bm-segmented label { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding-inline: var(--bm-space-3); border-radius: 7px; font: var(--bm-weight-semibold) var(--bm-text-sm) var(--bm-font-body); color: var(--bm-muted); cursor: pointer; }
.bm-segmented label > input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.bm-segmented label:has(> input:checked) { background: var(--bm-surface); color: var(--bm-text); box-shadow: var(--bm-shadow-sm); }
.bm-segmented label:has(> input:focus-visible) { outline: 2px solid var(--bm-focus); outline-offset: 1px; }

/* Theme preview tile: <span class="bm-style-preview" data-style="onyx"><i></i><i></i><i></i></span> */
.bm-style-preview { --_bg: var(--bm-style-ink-bg); --_line: rgba(255, 255, 255, .72); --_line-2: rgba(255, 255, 255, .32);
  display: grid; align-content: center; gap: 6px; height: 72px; padding: 12px 14px; border-radius: var(--bm-radius-md); background: var(--_bg); border: 1px solid rgba(127, 127, 127, .2); }
.bm-style-preview i { display: block; height: 7px; border-radius: 4px; background: var(--_line-2); }
.bm-style-preview i:first-child { width: 55%; background: var(--_line); }
.bm-style-preview i:nth-child(2) { width: 80%; }
.bm-style-preview i:last-child { width: 32%; height: 12px; background: var(--bm-rose); }
.bm-style-preview[data-style="light"]    { --_bg: var(--bm-style-light-bg);    --_line: rgba(15, 23, 42, .75); --_line-2: rgba(15, 23, 42, .22); }
.bm-style-preview[data-style="ink"]      { --_bg: var(--bm-style-ink-bg); }
.bm-style-preview[data-style="onyx"]     { --_bg: var(--bm-style-onyx-bg); }
.bm-style-preview[data-style="amoled"]   { --_bg: var(--bm-style-amoled-bg); }
.bm-style-preview[data-style="graphite"] { --_bg: var(--bm-style-graphite-bg); }
.bm-style-preview[data-style="system"]   { background: linear-gradient(135deg, var(--bm-style-light-bg) 0 50%, var(--bm-style-ink-bg) 50% 100%); --_line: rgba(127, 127, 127, .8); --_line-2: rgba(127, 127, 127, .4); }

/* ---------- 20. Mobile-first helpers & content blocks ---------- */
/* Horizontal scroll row (chips, steps, small cards) instead of squeezing: <div class="bm-scroll-x">…</div> */
.bm-scroll-x { display: flex; gap: var(--bm-gap, var(--bm-space-2)); overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; padding-bottom: 4px; scrollbar-width: thin; }
.bm-scroll-x > * { flex: 0 0 auto; scroll-snap-align: start; }

/* Action row: buttons stack full-width on phones */
.bm-actions { display: flex; flex-wrap: wrap; gap: var(--bm-space-3); align-items: center; }
@media (max-width: 560px) { .bm-actions > .bm-btn { flex: 1 1 100%; } }

/* Section heading block */
.bm-section-head { display: grid; gap: var(--bm-space-3); max-width: 760px; margin-bottom: clamp(24px, 5vw, 48px); }
.bm-section-head > p { margin: 0; color: var(--bm-text-2); font-size: var(--bm-text-lg); }
.bm-section-head--center { margin-inline: auto; text-align: center; justify-items: center; }

/* Offer flag: bright yellow "FREE" sticker that pulls the eye. Use sparingly (offers only).
   Inline: <span class="bm-flag">Free</span>
   On a button corner: <a class="bm-btn bm-has-flag">…<span class="bm-flag bm-flag--corner">Free</span></a>
   Gentle wiggle every few seconds: add bm-flag--pop (stops for reduced motion). */
.bm-flag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px; background: var(--bm-highlight); color: var(--bm-on-highlight);
  font: 800 11px/1.2 var(--bm-font-mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; vertical-align: middle;
  transform: rotate(-3deg); box-shadow: 0 2px 0 rgba(15, 23, 42, .18), 0 6px 16px -6px var(--bm-highlight); }
.bm-flag--lg { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.bm-has-flag { position: relative; }
.bm-flag--corner { position: absolute; top: -14px; right: -8px; z-index: 1; pointer-events: none; }
.bm-flag--pop { animation: bm-flag-pop 4s var(--bm-ease) infinite; }
@keyframes bm-flag-pop { 0%, 82%, 100% { transform: rotate(-3deg) scale(1); } 86% { transform: rotate(4deg) scale(1.12); } 90% { transform: rotate(-6deg) scale(1.12); } 94% { transform: rotate(-3deg) scale(1); } }
/* Yellow announcement strip above the top bar */
.bm-banner--highlight { background: var(--bm-highlight); color: var(--bm-on-highlight); text-decoration: none; font-weight: var(--bm-weight-semibold); }
.bm-banner--highlight:hover { color: var(--bm-on-highlight); }
.bm-banner--highlight .bm-flag { background: var(--bm-on-highlight); color: var(--bm-highlight); box-shadow: none; }

/* Small animated sparkle for "new" / "launching soon" labels: <span class="bm-spark" aria-hidden="true">✦</span> */
.bm-spark { display: inline-block; color: var(--bm-accent); line-height: 1; animation: bm-spark 2.4s var(--bm-ease) infinite; }
@keyframes bm-spark { 0%, 100% { transform: rotate(0) scale(1); opacity: 1; } 50% { transform: rotate(90deg) scale(.72); opacity: .6; } }

/* Icon tile */
.bm-icon-tile { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--bm-accent-soft); color: var(--bm-accent-text); }
.bm-icon-tile svg { width: 22px; height: 22px; }
.bm-icon-tile--success { background: var(--bm-success-soft); color: var(--bm-success); }
.bm-icon-tile--warning { background: var(--bm-warning-soft); color: var(--bm-warning); }
.bm-icon-tile--info { background: var(--bm-info-soft); color: var(--bm-info); }

/* Check list */
.bm-checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--bm-space-3); }
.bm-checklist--inline { display: flex; flex-wrap: wrap; gap: var(--bm-space-2) var(--bm-space-5); }
.bm-checklist li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: var(--bm-space-3); align-items: start; color: var(--bm-text-2); }
.bm-checklist li::before { content: ""; width: 18px; height: 18px; margin-top: 3px; background: var(--bm-accent);
  -webkit-mask: var(--bm-icon-check) center / contain no-repeat; mask: var(--bm-icon-check) center / contain no-repeat; }

/* Accordion (FAQ): <div class="bm-accordion"><details><summary>Q</summary><p>A</p></details></div> */
.bm-accordion { border-top: 1px solid var(--bm-line); }
.bm-accordion details { border-bottom: 1px solid var(--bm-line); }
.bm-accordion summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: var(--bm-space-4); min-height: 56px; padding: var(--bm-space-3) 2px; font: var(--bm-weight-semibold) var(--bm-text-lg)/1.4 var(--bm-font-body); color: var(--bm-text); }
.bm-accordion summary::-webkit-details-marker { display: none; }
.bm-accordion summary::after { content: "+"; flex: none; color: var(--bm-accent-text); font: 500 22px/1 var(--bm-font-mono); }
.bm-accordion details[open] summary::after { content: "\2212"; }
.bm-accordion details > :not(summary) { margin: 0; padding: 0 2px var(--bm-space-5); color: var(--bm-text-2); max-width: 70ch; }

/* ---------- 21. Editor (Markdown + HTML, with a live preview) ----------
   <div class="bm-editor" data-bm-editor> bar (tools + Write/Preview) and panes (textarea + preview).
   bm-editor--split: on a wide screen both panes show side by side and the Write/Preview switch hides. */
.bm-editor { border: 1px solid var(--bm-line-strong); border-radius: var(--bm-radius-md); background: var(--bm-surface); overflow: hidden; }
.bm-editor:focus-within { border-color: var(--bm-accent); }
.bm-editor__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--bm-space-2); padding: 6px 8px; border-bottom: 1px solid var(--bm-line); background: var(--bm-surface-2); flex-wrap: wrap; }
.bm-editor__tools { display: flex; gap: 2px; flex-wrap: wrap; }
.bm-editor__tools button { appearance: none; border: 0; background: none; color: var(--bm-text-2); min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--bm-radius-sm); font: var(--bm-weight-medium) var(--bm-text-sm) var(--bm-font-body); cursor: pointer; }
.bm-editor__tools button:hover { background: var(--bm-surface); color: var(--bm-text); }
.bm-editor__tools button:focus-visible { outline: 2px solid var(--bm-accent); outline-offset: -2px; }
.bm-editor__panes { display: grid; }
.bm-editor__input { display: block; width: 100%; min-height: 260px; border: 0; padding: 12px 14px; resize: vertical; background: transparent; color: var(--bm-text); font: var(--bm-text-sm)/1.6 var(--bm-font-mono); outline: none; }
.bm-editor__preview { min-height: 260px; padding: 12px 14px; overflow: auto; }
.bm-editor__frame { display: block; width: 100%; height: 420px; border: 0; border-radius: var(--bm-radius-sm); background: var(--bm-white, white); }
.bm-editor:not([data-view="preview"]) .bm-editor__preview { display: none; }
.bm-editor[data-view="preview"] .bm-editor__input { display: none; }
.bm-editor[data-view="preview"] .bm-editor__tools { visibility: hidden; }
@media (min-width: 1000px) {
  .bm-editor--split .bm-editor__panes { grid-template-columns: 1fr 1fr; }
  .bm-editor--split .bm-editor__input, .bm-editor--split .bm-editor__preview { display: block !important; min-height: 440px; }
  .bm-editor--split .bm-editor__preview { border-left: 1px solid var(--bm-line); background: var(--bm-surface-2); }
  .bm-editor--split .bm-editor__tabs { display: none; }
  .bm-editor--split .bm-editor__tools { visibility: visible !important; }
}

/* ---------- 22. Rows that open, with a peek card ----------
   A list row is the link to its page: <tr data-bm-href="/plans/1" tabindex="0">. No "Edit" / "View" button at the
   end. Resting the mouse on the row shows a small card with a little more: put
   <template data-bm-peek> … </template> inside the row's first cell (bm-peek__title, bm-peek__list of dt/dd pairs). */
[data-bm-href] { cursor: pointer; }
.bm-table tbody tr[data-bm-href] td { transition: background var(--bm-fast) var(--bm-ease); }
.bm-table tbody tr[data-bm-href]:hover td { background: var(--bm-surface-2); }
[data-bm-href]:focus-visible { outline: 2px solid var(--bm-accent); outline-offset: -2px; }
.bm-peek-card { position: fixed; z-index: var(--bm-z-toast); width: max-content; max-width: min(320px, calc(100vw - 16px)); padding: 12px 14px; border-radius: var(--bm-radius-lg); background: var(--bm-surface); border: 1px solid var(--bm-line-strong); box-shadow: var(--bm-shadow-lg); color: var(--bm-text); font-size: var(--bm-text-sm); line-height: 1.45; pointer-events: none; animation: bm-pop-in 120ms var(--bm-ease); }
.bm-peek__title { display: block; margin-bottom: 8px; font-size: var(--bm-text-md); }
.bm-peek__list { display: grid; gap: 4px; margin: 0; }
.bm-peek__list > div { display: grid; grid-template-columns: minmax(84px, auto) minmax(0, 1fr); gap: 12px; }
.bm-peek__list dt { color: var(--bm-muted); }
.bm-peek__list dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.bm-peek__note { margin: 8px 0 0; color: var(--bm-text-2); }
.bm-peek__hint { display: block; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--bm-line); color: var(--bm-muted); font-size: var(--bm-text-xs); }

/* ---------- 23. Motion preference ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
