/* =========================================================================
   B⁴e Studio — Components v1.0   (требует tokens.css)
   Префикс классов: b4-   Модификаторы: --variant   Состояния: .is-*
   ========================================================================= */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: var(--fs-body); line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 0;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; transition: color var(--dur-hover) var(--ease); }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--primary-soft-hover); }
h1, h2, h3, h4, p { margin: 0; }
code, kbd { font-family: var(--font-mono); font-size: 0.875em; }

/* ---------- Typography ---------- */
.b4-h1       { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 700; letter-spacing: var(--ls-tight); }
.b4-display  { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: 700; letter-spacing: var(--ls-tight); }
.b4-h2       { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 700; letter-spacing: var(--ls-snug); }
.b4-title    { font-size: var(--fs-title); line-height: var(--lh-title); font-weight: 600; letter-spacing: var(--ls-snug); }
.b4-h3       { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 600; }
.b4-body-lg  { font-size: var(--fs-body-lg); line-height: var(--lh-body-lg); }
.b4-body     { font-size: var(--fs-body); line-height: var(--lh-body); }
.b4-small    { font-size: var(--fs-small); line-height: var(--lh-small); }
.b4-overline { font-size: var(--fs-overline); line-height: var(--lh-overline); font-weight: 600; text-transform: uppercase; letter-spacing: var(--ls-overline); }
.b4-mono     { font-family: var(--font-mono); font-size: 13px; }
.b4-muted    { color: var(--text-muted); }
.b4-secondary{ color: var(--text-secondary); }
.b4-accent-text { color: var(--accent-text); }
.b4-primary-text { color: var(--primary); }
.b4-num      { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.b4-container { width: 100%; max-width: calc(var(--container-max) + 2 * var(--page-pad)); margin-inline: auto; padding-inline: var(--page-pad); }
.b4-grid { display: grid; grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr)); gap: var(--grid-gutter); }
.b4-stack { display: flex; flex-direction: column; gap: var(--gap, var(--space-4)); }
.b4-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--space-3)); }
.b4-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.b4-divider { height: 1px; background: var(--divider); border: 0; margin: var(--space-6) 0; }

/* ---------- Icons ---------- */
.b4-icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; }
.b4-icon--16 { width: 16px; height: 16px; }
.b4-icon--24 { width: 24px; height: 24px; }
.b4-icon--32 { width: 32px; height: 32px; }
.b4-icon--success { color: var(--success); } .b4-icon--warning { color: var(--warning); }
.b4-icon--error { color: var(--error); } .b4-icon--info { color: var(--info); }
.b4-icon-tile { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: var(--radius-lg); background: var(--primary-soft); color: var(--primary); flex: none; }
.b4-icon-tile--accent { background: var(--accent-soft); color: var(--accent-text); }
.b4-icon-tile--sm { width: 40px; height: 40px; border-radius: var(--radius-md); }

/* Логотип: переключение по теме */
.b4-logo { height: 32px; width: auto; min-width: 100px; }
.b4-logo-l { display: var(--show-light); }
.b4-logo-d { display: var(--show-dark); }
.b4-on-dark .b4-logo-l { display: none; }
.b4-on-dark .b4-logo-d { display: inline-block; }

/* =========================================================================
   Buttons
   ========================================================================= */
.b4-btn {
  --btn-h: var(--control-h-m);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--btn-h); padding: 0 18px; border-radius: var(--radius-md);
  border: 1px solid transparent; background: var(--primary); color: var(--text-on-primary);
  font-size: var(--fs-ui); line-height: 1; font-weight: 600; white-space: nowrap;
  cursor: pointer; text-decoration: none; user-select: none; position: relative;
  transition: background-color var(--dur-control) var(--ease), border-color var(--dur-control) var(--ease), color var(--dur-control) var(--ease), box-shadow var(--dur-hover) var(--ease);
}
.b4-btn:hover { background: var(--primary-hover); color: var(--text-on-primary); }
.b4-btn:active { background: var(--primary-active); }
.b4-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.b4-btn .b4-icon { width: 18px; height: 18px; }
.b4-btn--s { --btn-h: var(--control-h-s); padding: 0 12px; font-size: var(--fs-small); gap: 6px; }
.b4-btn--s .b4-icon { width: 16px; height: 16px; }
.b4-btn--l { --btn-h: var(--control-h-l); padding: 0 24px; font-size: var(--fs-body); }
.b4-btn--l .b4-icon { width: 20px; height: 20px; }
.b4-btn--block { width: 100%; }

.b4-btn--accent { background: var(--accent); color: var(--text-on-accent); }
.b4-btn--accent:hover { background: var(--accent-hover); color: var(--text-on-accent); }
.b4-btn--accent:active { background: var(--orange-700); color: #fff; }
.b4-btn--secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.b4-btn--secondary:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-muted); }
.b4-btn--secondary:active { background: var(--surface-3); }
.b4-btn--soft { background: var(--primary-soft); color: var(--primary-soft-text); }
.b4-btn--soft:hover { background: var(--primary-soft-hover); color: var(--primary-soft-text); }
.b4-btn--soft:active { background: var(--primary-soft-hover); }
.b4-btn--ghost { background: transparent; color: var(--text-secondary); }
.b4-btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.b4-btn--ghost:active { background: var(--surface-3); }
.b4-btn--danger { background: var(--danger); color: #fff; }
.b4-btn--danger:hover { background: var(--danger-hover); color: #fff; }
.b4-btn--danger:active { background: var(--red-700); }
.b4-btn--link { background: none; color: var(--link); padding: 0 2px; height: auto; border: 0; }
.b4-btn--link:hover, .b4-btn--link:active { background: none; color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }
.b4-btn--inverse { background: #fff; color: var(--navy-900); }
.b4-btn--inverse:hover { background: var(--navy-100); color: var(--navy-900); }
.b4-btn--outline-inverse { background: transparent; color: #fff; border-color: rgba(255,255,255,.36); }
.b4-btn--outline-inverse:hover { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.6); }

.b4-btn--icon { width: var(--btn-h); padding: 0; }
.b4-btn--round { border-radius: var(--radius-full); }

.b4-btn:disabled, .b4-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.b4-btn.is-loading { color: transparent !important; pointer-events: none; }
.b4-btn.is-loading > * { visibility: hidden; }
.b4-btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-on-primary) var(--text-on-primary) transparent transparent;
  animation: b4-spin .7s linear infinite;
}
.b4-btn--accent.is-loading::after { border-color: var(--text-on-accent) var(--text-on-accent) transparent transparent; }
.b4-btn--secondary.is-loading::after, .b4-btn--ghost.is-loading::after { border-color: var(--text) var(--text) transparent transparent; }

/* Круглые action-кнопки (Далее / Создать) */
.b4-fab { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; background: var(--accent); color: var(--text-on-accent); transition: background-color var(--dur-control) var(--ease); }
.b4-fab:hover { background: var(--accent-hover); }
.b4-fab--primary { background: var(--primary); color: var(--text-on-primary); }
.b4-fab--primary:hover { background: var(--primary-hover); }
.b4-fab:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* =========================================================================
   Forms
   ========================================================================= */
.b4-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.b4-label { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text); }
.b4-label .req { color: var(--accent-text); margin-left: 2px; }
.b4-hint { display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-small); line-height: 18px; color: var(--text-muted); }
.b4-hint .b4-icon { width: 16px; height: 16px; margin-top: 1px; }

.b4-input {
  width: 100%; height: var(--input-h); padding: 0 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: var(--fs-body); line-height: var(--lh-body);
  transition: border-color var(--dur-hover) var(--ease), box-shadow var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease);
  appearance: none; -webkit-appearance: none;
}
.b4-input::placeholder { color: var(--text-muted); opacity: .85; }
.b4-input:hover { border-color: var(--text-muted); }
.b4-input:focus, .b4-input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-tint); }
.b4-input:disabled { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; border-color: var(--border); }
.b4-input[readonly] { background: var(--surface-2); }
textarea.b4-input { height: auto; min-height: 112px; padding: 10px 14px; resize: vertical; }
.b4-input--s { height: 36px; font-size: 14px; padding: 0 12px; }

.b4-field.is-error .b4-input { border-color: var(--error); }
.b4-field.is-error .b4-input:focus { box-shadow: 0 0 0 3px var(--error-soft); }
.b4-field.is-error .b4-hint { color: var(--error-text); }
.b4-field.is-success .b4-input { border-color: var(--success); }
.b4-field.is-success .b4-hint { color: var(--success-text); }

.b4-input-wrap { position: relative; display: flex; align-items: center; }
.b4-input-wrap > .b4-icon { position: absolute; left: 14px; color: var(--text-muted); pointer-events: none; }
.b4-input-wrap > .b4-input { padding-left: 42px; }
.b4-input-wrap > .b4-input--s { padding-left: 38px; }
.b4-input-wrap--s > .b4-icon { left: 12px; width: 18px; height: 18px; }
.b4-input-wrap .b4-kbd { position: absolute; right: 10px; }
.b4-kbd { display: inline-flex; align-items: center; height: 22px; padding: 0 6px; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--surface-2); font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.b4-select { position: relative; }
.b4-select select { padding-right: 40px; cursor: pointer; }
.b4-select .b4-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

/* Checkbox / Radio */
.b4-choice { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 15px; line-height: 22px; color: var(--text); }
.b4-choice small { display: block; color: var(--text-muted); font-size: var(--fs-small); line-height: 18px; }
.b4-check, .b4-radio {
  appearance: none; -webkit-appearance: none; margin: 1px 0 0; flex: none; width: 20px; height: 20px;
  border: 1.5px solid var(--border-strong); background: var(--surface) center / 14px no-repeat; cursor: pointer;
  transition: background-color var(--dur-control) var(--ease), border-color var(--dur-control) var(--ease), box-shadow var(--dur-hover) var(--ease);
}
.b4-check { border-radius: 6px; }
.b4-radio { border-radius: 50%; }
.b4-check:hover, .b4-radio:hover { border-color: var(--primary); }
.b4-check:focus-visible, .b4-radio:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-tint); border-color: var(--primary); }
.b4-check:checked { background-color: var(--primary); border-color: var(--primary); background-image: var(--icon-check); }
.b4-check:indeterminate { background-color: var(--primary); border-color: var(--primary); background-image: var(--icon-dash); }
.b4-radio:checked { border-color: var(--primary); background: radial-gradient(circle, var(--primary) 0 4.5px, var(--surface) 5px); }
.b4-check:disabled, .b4-radio:disabled { opacity: .45; cursor: not-allowed; }
.b4-choice:has(:disabled) { color: var(--text-muted); cursor: not-allowed; }

/* Switch */
.b4-switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; width: 40px; height: 24px; border-radius: var(--radius-full);
  background: var(--border-strong) radial-gradient(circle, #fff 0 8px, transparent 8.5px) no-repeat;
  background-size: 24px 24px; background-position: 0 0; cursor: pointer;
  transition: background-color var(--dur-control) var(--ease), background-position var(--dur-control) var(--ease);
}
.b4-switch:checked { background-color: var(--primary); background-image: radial-gradient(circle, var(--text-on-primary) 0 8px, transparent 8.5px); background-position: 16px 0; }
.b4-switch:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.b4-switch:disabled { opacity: .45; cursor: not-allowed; }

/* Segmented control */
.b4-segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: 10px; background: var(--surface-3); }
.b4-segmented label { position: relative; }
.b4-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.b4-segmented span { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--text-secondary); cursor: pointer; transition: background-color var(--dur-control) var(--ease), color var(--dur-control) var(--ease), box-shadow var(--dur-control) var(--ease); white-space: nowrap; }
.b4-segmented span:hover { color: var(--text); }
.b4-segmented input:checked + span { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1); }
.b4-segmented input:focus-visible + span { box-shadow: var(--focus-ring); }

/* =========================================================================
   Tabs
   ========================================================================= */
.b4-tabs { display: flex; gap: var(--space-6); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.b4-tabs::-webkit-scrollbar { display: none; }
.b4-tab { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0; border: 0; background: none; color: var(--text-muted); font-size: var(--fs-ui); font-weight: 600; cursor: pointer; white-space: nowrap; transition: color var(--dur-hover) var(--ease); }
.b4-tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); transform: scaleX(0); transition: transform var(--dur-surface) var(--ease); }
.b4-tab:hover { color: var(--text); }
.b4-tab[aria-selected="true"] { color: var(--primary); }
.b4-tab[aria-selected="true"]::after { transform: scaleX(1); }
.b4-tab .b4-badge { height: 20px; }
.b4-tabpanel[hidden] { display: none; }
.b4-tabpanel { padding-top: var(--space-6); }

/* =========================================================================
   Badges, tags, status chips
   ========================================================================= */
.b4-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-full); font-size: 12px; line-height: 1; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-secondary); }
.b4-badge--primary { background: var(--primary-soft); color: var(--primary-soft-text); }
.b4-badge--accent  { background: var(--accent-soft); color: var(--accent-text); }
.b4-badge--success { background: var(--success-soft); color: var(--success-text); }
.b4-badge--warning { background: var(--warning-soft); color: var(--warning-text); }
.b4-badge--error   { background: var(--error-soft); color: var(--error-text); }
.b4-badge--info    { background: var(--info-soft); color: var(--info-text); }
.b4-badge--solid   { background: var(--primary); color: var(--text-on-primary); }
.b4-badge--solid-accent { background: var(--accent); color: var(--text-on-accent); }
.b4-badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b4-badge--count { min-width: 20px; height: 20px; padding: 0 6px; justify-content: center; font-size: 11px; }

.b4-tag { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.b4-tag button { display: grid; place-items: center; width: 18px; height: 18px; margin-right: -4px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--text-muted); cursor: pointer; }
.b4-tag button:hover { background: var(--surface-3); color: var(--text); }
.b4-tag button .b4-icon { width: 14px; height: 14px; }
.b4-tag--active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-soft-text); }

.b4-status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.b4-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--navy-400); }
.b4-status--success::before { background: var(--success); }
.b4-status--warning::before { background: var(--warning); }
.b4-status--error::before { background: var(--error); }
.b4-status--info::before { background: var(--info); }
.b4-status--primary::before { background: var(--primary); }
.b4-status--accent::before { background: var(--accent); }

/* =========================================================================
   Avatars
   ========================================================================= */
.b4-avatar { --s: 40px; position: relative; display: inline-grid; place-items: center; flex: none; width: var(--s); height: var(--s); border-radius: 50%; background: var(--primary-soft); color: var(--primary-soft-text); font-size: calc(var(--s) * .38); font-weight: 700; letter-spacing: .01em; }
.b4-avatar--24 { --s: 24px; } .b4-avatar--32 { --s: 32px; } .b4-avatar--56 { --s: 56px; } .b4-avatar--72 { --s: 72px; }
.b4-avatar--navy { background: var(--navy-700); color: #fff; }
.b4-avatar--accent { background: var(--accent-soft); color: var(--accent-text); }
.b4-avatar--sky { background: var(--blue-300); color: var(--navy-900); }
.b4-avatar[data-status]::after { content: ""; position: absolute; right: 0; bottom: 0; width: 28%; height: 28%; border-radius: 50%; border: 2px solid var(--surface); background: var(--navy-400); }
.b4-avatar[data-status="online"]::after { background: var(--success); }
.b4-avatar-group { display: inline-flex; }
.b4-avatar-group .b4-avatar { box-shadow: 0 0 0 2px var(--surface); }
.b4-avatar-group .b4-avatar + .b4-avatar { margin-left: -8px; }

/* =========================================================================
   Tooltip  — [data-tooltip="Текст"]
   ========================================================================= */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: var(--z-tooltip);
  transform: translate(-50%, 4px); opacity: 0; pointer-events: none; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--radius-sm); background: var(--surface-inverse); color: var(--text-inverse);
  font-size: 12px; line-height: 16px; font-weight: 500; box-shadow: var(--shadow-2);
  transition: opacity var(--dur-hover) var(--ease), transform var(--dur-hover) var(--ease);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: 300ms; }

/* =========================================================================
   Alerts & toasts
   ========================================================================= */
.b4-alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-lg); border: 1px solid transparent; background: var(--info-soft); color: var(--text); }
.b4-alert > .b4-icon { width: 22px; height: 22px; margin-top: 1px; color: var(--info); }
.b4-alert__body { flex: 1; min-width: 0; }
.b4-alert__title { font-weight: 700; font-size: 15px; line-height: 22px; }
.b4-alert__text { font-size: 14px; line-height: 21px; color: var(--text-secondary); }
.b4-alert__close { margin: -4px -6px 0 0; }
.b4-alert--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.b4-alert--success > .b4-icon { color: var(--success); }
.b4-alert--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 26%, transparent); }
.b4-alert--warning > .b4-icon { color: var(--warning); }
.b4-alert--error { background: var(--error-soft); border-color: color-mix(in srgb, var(--error) 22%, transparent); }
.b4-alert--error > .b4-icon { color: var(--error); }
.b4-alert--info { border-color: color-mix(in srgb, var(--info) 22%, transparent); }

.b4-toast-region { position: fixed; right: 24px; bottom: 24px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 12px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.b4-toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 14px 14px 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-3); position: relative; overflow: hidden; animation: b4-toast-in var(--dur-surface) var(--ease); }
.b4-toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--info); }
.b4-toast > .b4-icon { width: 22px; height: 22px; color: var(--info); margin-top: 1px; }
.b4-toast--success::before, .b4-toast--success > .b4-icon { color: var(--success); background: none; }
.b4-toast--success::before { background: var(--success); }
.b4-toast--warning > .b4-icon { color: var(--warning); } .b4-toast--warning::before { background: var(--warning); }
.b4-toast--error > .b4-icon { color: var(--error); } .b4-toast--error::before { background: var(--error); }
.b4-toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--dur-surface) var(--ease), transform var(--dur-surface) var(--ease); }
.b4-toast--static { animation: none; box-shadow: var(--shadow-2); }
@keyframes b4-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =========================================================================
   Progress, spinner, skeleton
   ========================================================================= */
.b4-progress { height: 8px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.b4-progress > span { display: block; height: 100%; width: var(--value, 0%); border-radius: inherit; background: var(--primary); transition: width var(--dur-surface) var(--ease); }
.b4-progress--s { height: 4px; }
.b4-progress--success > span { background: var(--success); }
.b4-progress--accent > span { background: var(--accent); }
.b4-progress--warning > span { background: var(--warning); }
.b4-progress-meta { display: flex; justify-content: space-between; font-size: var(--fs-small); color: var(--text-muted); margin-bottom: 6px; }
.b4-progress-meta b { color: var(--text); font-weight: 600; }

.b4-spinner { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--primary); animation: b4-spin .8s linear infinite; flex: none; }
.b4-spinner--s { width: 16px; height: 16px; border-width: 2px; }
.b4-spinner--l { width: 40px; height: 40px; border-width: 3px; }
@keyframes b4-spin { to { transform: rotate(360deg); } }

.b4-skeleton { display: block; border-radius: var(--radius-sm); background: var(--skeleton) linear-gradient(90deg, transparent 0, var(--skeleton-shine) 50%, transparent 100%) no-repeat; background-size: 200% 100%; animation: b4-shimmer 1.4s var(--ease) infinite; height: 14px; }
.b4-skeleton--circle { border-radius: 50%; }
@keyframes b4-shimmer { from { background-position: 150% 0; } to { background-position: -150% 0; } }

/* =========================================================================
   Breadcrumbs, pagination
   ========================================================================= */
.b4-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); list-style: none; padding: 0; margin: 0; }
.b4-breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; }
.b4-breadcrumbs li + li::before { content: "/"; color: var(--border-strong); }
.b4-breadcrumbs a { color: var(--text-muted); }
.b4-breadcrumbs a:hover { color: var(--primary); }
.b4-breadcrumbs [aria-current] { color: var(--text); font-weight: 600; }

.b4-pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.b4-page { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 8px; border-radius: var(--radius-md); border: 1px solid transparent; background: none; color: var(--text-secondary); font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease); }
.b4-page:hover { background: var(--surface-2); color: var(--text); }
.b4-page[aria-current="page"] { background: var(--primary); color: var(--text-on-primary); }
.b4-page:disabled { opacity: .4; cursor: not-allowed; }
.b4-page .b4-icon { width: 18px; height: 18px; }
.b4-page--gap { pointer-events: none; color: var(--text-muted); }

/* =========================================================================
   Cards
   ========================================================================= */
.b4-card { position: relative; display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-6); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.b4-card--flat { background: var(--surface-2); border-color: transparent; }
.b4-card--elevated { border-color: transparent; box-shadow: var(--shadow-2); }
.b4-card--interactive { transition: box-shadow var(--dur-surface) var(--ease), border-color var(--dur-surface) var(--ease), transform var(--dur-surface) var(--ease); cursor: pointer; }
.b4-card--interactive:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); transform: translateY(-2px); }
.b4-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.b4-card__title { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 700; }
.b4-card__text { color: var(--text-secondary); font-size: 15px; line-height: 24px; }
.b4-card__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.b4-card--pad-s { padding: var(--space-4); gap: var(--space-3); }

/* Service */
.b4-service .b4-card__foot { padding-top: var(--space-2); }
.b4-service__link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; }
.b4-service__link .b4-icon { width: 18px; height: 18px; transition: transform var(--dur-hover) var(--ease); }
.b4-service:hover .b4-service__link .b4-icon { transform: translateX(3px); }
.b4-service__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; color: var(--text-secondary); }
.b4-service__list li { display: flex; gap: 8px; align-items: center; }
.b4-service__list li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); flex: none; }

/* Case */
.b4-case { padding: 0; overflow: hidden; gap: 0; }
.b4-case__cover { position: relative; aspect-ratio: 16 / 10; background: var(--gradient-dark); overflow: hidden; }
.b4-case__cover svg { width: 100%; height: 100%; }
.b4-case__cover .b4-badge { position: absolute; left: 16px; top: 16px; }
.b4-case__body { display: flex; flex-direction: column; gap: 12px; padding: var(--space-6); flex: 1; }
.b4-case__metric { display: flex; align-items: baseline; gap: 8px; margin-top: auto; padding-top: var(--space-4); border-top: 1px solid var(--divider); }
.b4-case__metric strong { font-size: 28px; line-height: 32px; font-weight: 800; color: var(--primary); letter-spacing: var(--ls-tight); }
.b4-case__metric span { font-size: 14px; color: var(--text-muted); }

/* Metric / KPI */
.b4-metric { gap: var(--space-3); }
.b4-metric__label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--text-muted); font-weight: 500; }
.b4-metric__value { font-size: 32px; line-height: 40px; font-weight: 700; letter-spacing: var(--ls-tight); font-variant-numeric: tabular-nums; }
.b4-metric__value small { font-size: 18px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.b4-metric__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.b4-delta { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: var(--radius-full); font-size: 12px; font-weight: 700; background: var(--success-soft); color: var(--success-text); }
.b4-delta .b4-icon { width: 14px; height: 14px; }
.b4-delta--down { background: var(--error-soft); color: var(--error-text); }
.b4-delta--flat { background: var(--surface-3); color: var(--text-secondary); }
.b4-sparkline { width: 112px; height: 40px; flex: none; overflow: visible; }
.b4-sparkline path { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.b4-sparkline .area { fill: var(--primary-soft); stroke: none; }
.b4-sparkline circle { fill: var(--chart-3); stroke: var(--surface); stroke-width: 2; }

/* Pricing */
.b4-pricing { gap: var(--space-5); padding: var(--space-8); }
.b4-pricing__name { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 700; }
.b4-pricing__price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.b4-pricing__price strong { font-size: 36px; line-height: 44px; font-weight: 800; letter-spacing: var(--ls-tight); }
.b4-pricing__price span { color: var(--text-muted); font-size: 15px; }
.b4-pricing__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 15px; }
.b4-pricing__list li { display: flex; gap: 10px; align-items: flex-start; }
.b4-pricing__list .b4-icon { width: 20px; height: 20px; color: var(--success); margin-top: 1px; }
.b4-pricing__list li.is-off { color: var(--text-muted); }
.b4-pricing__list li.is-off .b4-icon { color: var(--text-muted); }
.b4-pricing--featured { border: 2px solid var(--primary); box-shadow: var(--shadow-2); }
.b4-pricing--featured .b4-pricing__flag { position: absolute; top: -13px; left: var(--space-8); }

/* Note card (вместо отзывов — факты/принципы) */
.b4-note { border-left: 3px solid var(--accent); border-radius: 0 var(--radius-lg) var(--radius-lg) 0; background: var(--surface-2); border-top: 0; border-right: 0; border-bottom: 0; }

/* =========================================================================
   Table
   ========================================================================= */
.b4-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.b4-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 20px; }
.b4-table th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); background: var(--surface-2); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.b4-table td { padding: 14px 16px; border-bottom: 1px solid var(--divider); vertical-align: middle; white-space: nowrap; }
.b4-table tbody tr { transition: background-color var(--dur-hover) var(--ease); }
.b4-table tbody tr:hover { background: var(--surface-2); }
.b4-table tbody tr.is-selected { background: var(--primary-soft); }
.b4-table tbody tr:last-child td { border-bottom: 0; }
.b4-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.b4-table .col-check { width: 44px; padding-right: 0; }
.b4-table .b4-check { display: block; }
.b4-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.b4-sort .b4-icon { width: 14px; height: 14px; opacity: .5; }
.b4-sort:hover { color: var(--text); }
th[aria-sort] .b4-sort { color: var(--primary); }
th[aria-sort] .b4-sort .b4-icon { opacity: 1; }
.b4-cell-user { display: flex; align-items: center; gap: 12px; }
.b4-cell-user b { display: block; font-weight: 600; color: var(--text); }
.b4-cell-user span:not(.b4-avatar) { display: block; color: var(--text-muted); font-size: 13px; }
.b4-table-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--text-muted); }

/* =========================================================================
   Dropdown menu
   ========================================================================= */
.b4-dropdown { position: relative; display: inline-block; }
.b4-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--z-dropdown); min-width: 220px; padding: 6px;
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity var(--dur-surface) var(--ease), transform var(--dur-surface) var(--ease), visibility 0s linear var(--dur-surface);
}
.b4-menu--right { left: auto; right: 0; }
.b4-dropdown.is-open .b4-menu, .b4-menu--static { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.b4-menu--static { position: static; }
.b4-menu__item { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border: 0; border-radius: var(--radius-md); background: none; color: var(--text); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer; text-decoration: none; }
.b4-menu__item .b4-icon { width: 18px; height: 18px; color: var(--text-muted); }
.b4-menu__item:hover, .b4-menu__item:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.b4-menu__item kbd { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.b4-menu__item--danger, .b4-menu__item--danger .b4-icon { color: var(--error-text); }
.b4-menu__item--danger:hover { background: var(--error-soft); color: var(--error-text); }
.b4-menu__sep { height: 1px; margin: 6px 4px; background: var(--divider); }
.b4-menu__label { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }

/* =========================================================================
   Modal & drawer (на <dialog>)
   ========================================================================= */
.b4-modal, .b4-drawer { border: 0; padding: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow-3); }
.b4-modal { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border-radius: var(--radius-xl); }
.b4-modal::backdrop, .b4-drawer::backdrop { background: var(--overlay); }
.b4-modal[open] { animation: b4-modal-in var(--dur-modal) var(--ease); }
.b4-modal[open]::backdrop, .b4-drawer[open]::backdrop { animation: b4-fade var(--dur-modal) var(--ease); }
.b4-modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 0; }
.b4-modal__title { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 700; }
.b4-modal__body { padding: 16px 24px 24px; display: grid; gap: 16px; color: var(--text-secondary); }
.b4-modal__foot { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--divider); background: var(--surface-2); flex-wrap: wrap; }
.b4-modal--static { position: static; display: block; box-shadow: var(--shadow-3); width: 100%; max-width: 520px; animation: none; }
@keyframes b4-modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes b4-fade { from { opacity: 0; } to { opacity: 1; } }

.b4-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(480px, 100vw); height: 100vh; max-height: 100vh; max-width: 100vw; border-radius: var(--radius-xl) 0 0 var(--radius-xl); display: none; flex-direction: column; }
.b4-drawer[open] { display: flex; animation: b4-drawer-in var(--dur-modal) var(--ease); }
.b4-drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--divider); }
.b4-drawer__body { flex: 1; overflow-y: auto; padding: 24px; display: grid; gap: 24px; align-content: start; }
.b4-drawer__foot { display: flex; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--divider); }
@keyframes b4-drawer-in { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =========================================================================
   Site navbar & mobile menu
   ========================================================================= */
.b4-navbar { position: sticky; top: 0; z-index: var(--z-sticky); height: var(--navbar-h); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--divider); }
.b4-navbar__inner { height: 100%; display: flex; align-items: center; gap: var(--space-8); }
.b4-navbar__brand { display: inline-flex; flex: none; }
.b4-navbar__brand .b4-logo { height: 34px; }
.b4-navbar__links { display: flex; gap: var(--space-1); list-style: none; margin: 0 auto 0 0; padding: 0; }
.b4-navbar__link { display: inline-flex; align-items: center; height: 40px; padding: 0 12px; border-radius: var(--radius-md); color: var(--text-secondary); font-size: 15px; font-weight: 600; transition: color var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease); }
.b4-navbar__link:hover { color: var(--text); background: var(--surface-2); }
.b4-navbar__link[aria-current="page"] { color: var(--primary); }
.b4-navbar__actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.b4-navbar__burger { display: none; }
@media (max-width: 1023px) {
  .b4-navbar__links, .b4-navbar__actions .b4-hide-mobile { display: none; }
  .b4-navbar__burger { display: inline-flex; }
}
.b4-mobile-nav { position: fixed; inset: var(--navbar-h) 0 0 0; z-index: var(--z-overlay); background: var(--bg); padding: var(--space-6) var(--page-pad) var(--space-8); display: flex; flex-direction: column; gap: var(--space-2); overflow-y: auto; opacity: 0; visibility: hidden; transform: translateY(-8px); transition: opacity var(--dur-surface) var(--ease), transform var(--dur-surface) var(--ease), visibility 0s linear var(--dur-surface); }
.b4-mobile-nav.is-open { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.b4-mobile-nav a:not(.b4-btn) { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--divider); font-size: 20px; font-weight: 600; color: var(--text); }
.b4-mobile-nav .b4-btn { margin-top: var(--space-6); }
@media (min-width: 1024px) { .b4-mobile-nav { display: none; } }

/* =========================================================================
   App shell: sidebar, topbar, bottom nav
   ========================================================================= */
.b4-app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; background: var(--bg-subtle); }
.b4-sidebar-scrim { display: none; }
.b4-content > * { min-width: 0; }
@media (max-width: 1023px) { .b4-sidebar-scrim { display: block; } }
.b4-sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--space-6); padding: var(--space-6) var(--space-4); background: var(--sidebar-bg); color: var(--sidebar-text); overflow-y: auto; }
.b4-sidebar__brand { padding: 0 var(--space-2); }
.b4-sidebar__brand .b4-logo { height: 30px; }
.b4-sidebar__group { display: grid; gap: 2px; }
.b4-sidebar__label { padding: 0 12px 8px; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #8C9AB0; }
.b4-sidebar__item { position: relative; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: var(--radius-md); color: var(--sidebar-text); font-size: 15px; font-weight: 500; transition: background-color var(--dur-hover) var(--ease), color var(--dur-hover) var(--ease); }
.b4-sidebar__item .b4-icon { color: #8C9AB0; transition: color var(--dur-hover) var(--ease); }
.b4-sidebar__item:hover { background: rgba(255,255,255,.06); color: #fff; }
.b4-sidebar__item:hover .b4-icon { color: #fff; }
.b4-sidebar__item[aria-current="page"] { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.b4-sidebar__item[aria-current="page"] .b4-icon { color: var(--blue-300); }
.b4-sidebar__item[aria-current="page"]::before { content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--blue-300); }
.b4-sidebar__item .b4-badge { margin-left: auto; height: 20px; padding: 0 7px; font-size: 11px; }
.b4-sidebar__foot { margin-top: auto; display: grid; gap: var(--space-3); }
.b4-sidebar__promo { padding: var(--space-4); border-radius: var(--radius-lg); background: var(--gradient-dark); border: 1px solid rgba(255,255,255,.08); color: #fff; display: grid; gap: 10px; font-size: 14px; line-height: 20px; }
.b4-sidebar__promo p { color: #CBD4E1; }
.b4-sidebar__user { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--radius-md); }
.b4-sidebar__user b { display: block; color: #fff; font-size: 14px; }
.b4-sidebar__user span:not(.b4-avatar) { display: block; font-size: 12px; color: #8C9AB0; }

.b4-main { min-width: 0; display: flex; flex-direction: column; }
.b4-topbar { position: sticky; top: 0; z-index: var(--z-sticky); height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-4); padding: 0 var(--space-8); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.b4-topbar__search { flex: 1; max-width: 440px; }
.b4-topbar__actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.b4-topbar__burger { display: none; }
.b4-notify { position: relative; }
.b4-notify::after { content: ""; position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.b4-content { padding: var(--space-8); display: grid; gap: var(--space-6); align-content: start; }
.b4-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.b4-page-head p { color: var(--text-muted); margin-top: 4px; }

.b4-bottom-nav { display: none; }
@media (max-width: 1023px) {
  .b4-app { grid-template-columns: minmax(0, 1fr); }
  .b4-sidebar { position: fixed; inset: 0 auto 0 0; z-index: var(--z-drawer); width: 280px; transform: translateX(-100%); transition: transform var(--dur-modal) var(--ease); box-shadow: var(--shadow-3); }
  .b4-sidebar.is-open { transform: none; }
  .b4-sidebar-scrim { position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--overlay); opacity: 0; visibility: hidden; transition: opacity var(--dur-modal) var(--ease), visibility 0s linear var(--dur-modal); }
  .b4-sidebar.is-open + .b4-sidebar-scrim { opacity: 1; visibility: visible; transition-delay: 0s; }
  .b4-topbar__burger { display: inline-flex; }
  .b4-topbar { padding: 0 var(--space-4); }
  .b4-content { padding: var(--space-6) var(--space-4); }
}
@media (max-width: 767px) {
  .b4-topbar__search { display: none; }
  .b4-main { padding-bottom: 72px; }
  .b4-bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky); display: grid; grid-template-columns: repeat(5, 1fr); height: 64px; padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(11,18,32,.06); }
  .b4-bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
  .b4-bottom-nav a[aria-current="page"] { color: var(--primary); }
}

/* =========================================================================
   Footer
   ========================================================================= */
.b4-footer { background: var(--gradient-dark); background-color: var(--navy-900); color: #CBD4E1; padding: var(--space-16) 0 var(--space-8); }
.b4-footer a { color: #CBD4E1; }
.b4-footer a:hover { color: #fff; }
.b4-footer__grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: var(--space-8); }
.b4-footer__title { color: #fff; font-size: 14px; font-weight: 700; margin-bottom: var(--space-4); }
.b4-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 15px; }
.b4-footer__bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: var(--space-12); padding-top: var(--space-6); border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; color: #8C9AB0; }
@media (max-width: 1023px) { .b4-footer__grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 767px) { .b4-footer__grid { grid-template-columns: 1fr; } }

/* =========================================================================
   Stepper (процесс)
   ========================================================================= */
.b4-stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--steps, 5), minmax(0, 1fr)); gap: var(--space-4); counter-reset: step; }
.b4-step { position: relative; display: grid; gap: 8px; align-content: start; counter-increment: step; }
.b4-step__marker { position: relative; z-index: 1; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); color: var(--text-muted); font-weight: 700; font-size: 15px; }
.b4-step__marker::before { content: counter(step, decimal-leading-zero); }
.b4-step::after { content: ""; position: absolute; top: 20px; left: 48px; right: calc(-1 * var(--space-4) + 8px); height: 2px; background: var(--border); }
.b4-step:last-child::after { display: none; }
.b4-step__title { font-weight: 700; font-size: 17px; line-height: 24px; margin-top: 8px; }
.b4-step__text { font-size: 14px; line-height: 22px; color: var(--text-secondary); }
.b4-step__meta { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.b4-step.is-done .b4-step__marker { border-color: var(--primary); background: var(--primary); color: var(--text-on-primary); }
.b4-step.is-done .b4-step__marker::before { content: ""; width: 18px; height: 18px; background: var(--icon-check) center / contain no-repeat; }
.b4-step.is-done::after { background: var(--primary); }
.b4-step.is-current .b4-step__marker { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 4px var(--accent-soft); }
@media (max-width: 767px) {
  .b4-stepper { grid-template-columns: 1fr; gap: 0; }
  .b4-step { grid-template-columns: 40px 1fr; column-gap: 16px; padding-bottom: var(--space-6); }
  .b4-step > :not(.b4-step__marker) { grid-column: 2; }
  .b4-step__marker { grid-row: 1 / span 3; }
  .b4-step__title { margin-top: 8px; }
  .b4-step::after { top: 44px; bottom: 4px; left: 19px; right: auto; width: 2px; height: auto; }
}

/* =========================================================================
   Accordion (<details>)
   ========================================================================= */
.b4-accordion { border-top: 1px solid var(--border); }
.b4-accordion details { border-bottom: 1px solid var(--border); }
.b4-accordion summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; cursor: pointer; list-style: none; font-size: 18px; line-height: 26px; font-weight: 600; transition: color var(--dur-hover) var(--ease); }
.b4-accordion summary::-webkit-details-marker { display: none; }
.b4-accordion summary:hover { color: var(--primary); }
.b4-accordion summary .b4-icon { flex: none; width: 32px; height: 32px; padding: 6px; border-radius: 50%; background: var(--surface-2); color: var(--text-secondary); transition: transform var(--dur-surface) var(--ease), background-color var(--dur-surface) var(--ease), color var(--dur-surface) var(--ease); }
.b4-accordion details[open] summary .b4-icon { transform: rotate(180deg); background: var(--primary); color: var(--text-on-primary); }
.b4-accordion__body { padding: 0 48px 24px 0; color: var(--text-secondary); font-size: 16px; line-height: 26px; }
.b4-accordion details[open] .b4-accordion__body { animation: b4-fade var(--dur-surface) var(--ease); }

/* =========================================================================
   Empty state
   ========================================================================= */
.b4-empty { display: grid; justify-items: center; text-align: center; gap: var(--space-3); padding: var(--space-12) var(--space-6); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.b4-empty__art { width: 96px; height: 96px; margin-bottom: var(--space-2); }
.b4-empty__title { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 700; }
.b4-empty__text { max-width: 400px; color: var(--text-muted); font-size: 15px; }
.b4-empty .b4-cluster { margin-top: var(--space-3); justify-content: center; }

/* =========================================================================
   Kanban (CRM pipeline)
   ========================================================================= */
.b4-kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(272px, 1fr); gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-3); scroll-snap-type: x proximity; }
.b4-kanban__col { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-lg); background: var(--surface-3); min-height: 200px; scroll-snap-align: start; }
.b4-kanban__head { display: grid; gap: 8px; padding: 4px 4px 8px; }
.b4-kanban__head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.b4-kanban__name { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.b4-kanban__name::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--stage, var(--primary)); }
.b4-kanban__sum { font-size: 13px; color: var(--text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.b4-kanban__bar { height: 3px; border-radius: 3px; background: var(--stage, var(--primary)); opacity: .9; }
.b4-deal { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius-md); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); cursor: grab; transition: box-shadow var(--dur-surface) var(--ease), border-color var(--dur-surface) var(--ease); }
.b4-deal:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.b4-deal__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.b4-deal__title { font-weight: 700; font-size: 15px; line-height: 21px; }
.b4-deal__company { font-size: 13px; color: var(--text-muted); }
.b4-deal__amount { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.b4-deal__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--divider); font-size: 12px; color: var(--text-muted); }
.b4-deal__foot .b4-cluster { --gap: 4px; }
.b4-deal__foot .b4-icon { width: 14px; height: 14px; }
.b4-deal.is-hot { border-left: 3px solid var(--accent); }
.b4-kanban__add { display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: none; color: var(--text-muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.b4-kanban__add:hover { color: var(--primary); border-color: var(--primary); background: var(--surface); }

/* =========================================================================
   Timeline / activity
   ========================================================================= */
.b4-timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.b4-timeline__item { position: relative; display: grid; grid-template-columns: 36px 1fr; gap: 14px; padding-bottom: var(--space-5); }
.b4-timeline__item::before { content: ""; position: absolute; left: 17px; top: 38px; bottom: 2px; width: 2px; background: var(--divider); }
.b4-timeline__item:last-child { padding-bottom: 0; }
.b4-timeline__item:last-child::before { display: none; }
.b4-timeline__dot { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.b4-timeline__dot .b4-icon { width: 18px; height: 18px; }
.b4-timeline__dot--accent { background: var(--accent-soft); color: var(--accent-text); }
.b4-timeline__dot--success { background: var(--success-soft); color: var(--success-text); }
.b4-timeline__dot--muted { background: var(--surface-3); color: var(--text-muted); }
.b4-timeline__text { font-size: 14px; line-height: 21px; color: var(--text-secondary); padding-top: 2px; }
.b4-timeline__text b { color: var(--text); font-weight: 600; }
.b4-timeline__time { display: block; margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.b4-timeline__quote { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface-2); font-size: 14px; color: var(--text-secondary); }

/* ---------- List rows (документы, задачи) ---------- */
.b4-list { list-style: none; margin: 0; padding: 0; display: grid; }
.b4-list__row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--divider); min-width: 0; }
.b4-list__row:last-child { border-bottom: 0; }
.b4-list__main { flex: 1; min-width: 0; }
.b4-list__main b { display: block; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b4-list__main span { display: block; font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b4-list__row.is-done b { color: var(--text-muted); text-decoration: line-through; font-weight: 500; }

/* ---------- Chart card ---------- */
.b4-chart { width: 100%; height: auto; overflow: visible; }
.b4-chart .grid line { stroke: var(--chart-grid); stroke-width: 1; }
.b4-chart .axis text, .b4-chart text.axis { fill: var(--text-muted); font-size: 12px; font-family: var(--font-sans); }
.b4-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-secondary); }
.b4-legend span { display: inline-flex; align-items: center; gap: 8px; }
.b4-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
