/*
 * FlowCRM — компоненты интерфейса.
 * Этап 14: визуальный язык — из docs/design/components.css. Имена классов,
 * на которые завязан Alpine/JS (:class, статусы, data-атрибуты), оставлены
 * как были — меняется только их CSS-тело. Новая разметка (то, чего не было
 * в приложении) называется как в прототипе. Токены — из tokens.css.
 */

/* ===== Сброс списков/картинок, общие мелочи (доп. к tokens.css) ===== */
h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { max-width: 100%; }
.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; }

/* ===== Guest layout (auth, онбординг, письма-страницы, ошибки) ===== */
.guest-layout { min-height: 100vh; display: grid; place-items: center; padding: 30px 18px; background: var(--canvas); }
.guest-wrap { width: min(930px, 100%); display: grid; grid-template-columns: .75fr 1.1fr; gap: 30px; align-items: center; }
.guest-intro { padding: 20px; }
.guest-intro .brand-mark { margin-bottom: 28px; }
.guest-intro h1 { max-width: 320px; margin: 0 0 12px; font-size: 34px; line-height: 1.1; letter-spacing: -.06em; }
.guest-intro p { max-width: 310px; color: var(--ink-soft); font-size: 14px; line-height: 1.65; }
.guest-note { display: flex; align-items: center; gap: 8px; margin-top: 22px; color: var(--accent-strong); font-size: 12px; font-weight: 600; }
.guest-note svg { width: 16px; flex: 0 0 auto; }
.guest-card { width: 100%; max-width: 420px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-md); }
.guest-card__top { margin-bottom: 18px; }
.guest-card__logo { font-weight: 700; letter-spacing: -.04em; font-size: 17px; }
.guest-card__title { font-size: 19px; font-weight: 650; letter-spacing: -.03em; margin-bottom: 4px; }
.guest-card__subtitle { color: var(--ink-faint); font-size: 12.5px; line-height: 1.55; margin-bottom: 20px; }
.guest-card__footer { margin-top: 17px; display: flex; justify-content: space-between; gap: 10px; color: var(--ink-faint); font-size: 12px; }
.guest-card__step { color: var(--accent-strong); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.guest-card__error-icon { margin: 0 auto 16px; }
@media (max-width: 720px) {
    .guest-wrap { grid-template-columns: 1fr; gap: 6px; }
    .guest-intro { padding: 4px; text-align: center; }
    .guest-intro h1 { max-width: none; margin: 10px 0 8px; font-size: 27px; }
    .guest-intro p { max-width: none; margin-left: auto; margin-right: auto; }
    .guest-note { justify-content: center; }
}

/* ===== App shell: sidebar / topbar / page ===== */
.app-shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; z-index: var(--z-sidebar); inset: 0 auto 0 0; width: var(--sidebar-w); display: flex; flex-direction: column; padding: 22px 14px 16px; background: var(--surface); border-right: 1px solid var(--line); transition: width var(--normal) var(--ease); }
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 26px; font-weight: 700; letter-spacing: -.04em; font-size: 17px; color: var(--ink); }
.brand-mark { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--accent); box-shadow: 0 5px 12px rgba(87,87,201,.2); }
.brand-mark svg { width: 16px; height: 16px; }
.sidebar__nav { display: grid; gap: 4px; }
.sidebar__link { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 11px; border-radius: var(--r-sm); color: var(--ink-soft); font-weight: 500; font-size: 13.5px; transition: background var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease); }
.sidebar__link:hover { color: var(--ink); background: var(--surface-tint); transform: translateX(1px); }
.sidebar__link.is-active { color: var(--accent-strong); background: var(--accent-soft); font-weight: 600; }
.sidebar__link-icon { width: 18px; height: 18px; flex: 0 0 auto; display: grid; place-items: center; }
.sidebar__link-icon svg { width: 18px; height: 18px; stroke-width: 1.7; }
.sidebar__footer { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid var(--line); }
.sidebar__company { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.sidebar__company .avatar { width: 30px; height: 30px; font-size: 10px; }
.sidebar__company strong { display: block; font-size: 12px; }
.sidebar__company span { display: block; color: var(--ink-faint); font-size: 11px; margin-top: 2px; }

.app-main { width: calc(100% - var(--sidebar-w)); margin-left: var(--sidebar-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: var(--z-topbar); height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 var(--page-pad); background: rgba(246,247,251,.9); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.topbar__search { width: min(370px, 42vw); position: relative; }
.topbar__search svg { position: absolute; z-index: 1; top: 12px; left: 12px; width: 16px; height: 16px; color: var(--ink-faint); pointer-events: none; }
.topbar__search .input { padding-left: 36px; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.topbar__bell-wrap { position: relative; }
.topbar__bell { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-sm); color: var(--ink-soft); background: transparent; border: none; transition: background var(--fast) var(--ease), color var(--fast) var(--ease); }
.topbar__bell:hover { color: var(--ink); background: var(--surface-tint); }
.topbar__bell svg { width: 18px; height: 18px; }
.topbar__bell-count { position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px; display: flex; align-items: center; justify-content: center; border-radius: 99px; background: var(--danger); color: #fff; font-size: 9px; font-weight: 700; line-height: 1; border: 1.5px solid var(--surface); }
.topbar-divider { width: 1px; height: 24px; background: var(--line-strong); margin: 0 4px; }
.topbar__user { display: flex; align-items: center; gap: 9px; padding: 0 4px; border-radius: var(--r-sm); transition: background var(--fast) var(--ease); }
.topbar__user:hover { background: var(--surface-tint); }
.topbar__user .avatar { width: 28px; height: 28px; }
.user-name, .topbar__user span:last-child { color: var(--ink-soft); font-size: 13px; }

.dropdown-anchor { position: relative; }
.dropdown { position: absolute; z-index: var(--z-dropdown); top: calc(100% + 7px); right: 0; min-width: 210px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-float); animation: pop-in var(--normal) var(--ease); }
.dropdown-item { width: 100%; display: flex; align-items: center; gap: 9px; min-height: 37px; border: 0; border-radius: 7px; padding: 0 10px; color: var(--ink-soft); background: transparent; text-align: left; font-size: 12px; }
.dropdown-item:hover { color: var(--ink); background: var(--surface-tint); }
.dropdown-item svg { width: 15px; height: 15px; }

.notif-dropdown { position: absolute; z-index: var(--z-dropdown); top: calc(100% + 9px); right: 0; width: 320px; max-height: 420px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-float); display: flex; flex-direction: column; animation: pop-in var(--normal) var(--ease); }
@media (max-width: 480px) {
    /* На узком экране бургер-колокольчик стоит близко к левому краю — фикс-ширина
       320px с right:0 относительно него уводила панель за левую границу viewport. */
    .notif-dropdown { position: fixed; left: 10px; right: 10px; top: var(--topbar-h); width: auto; }
}
.notif-dropdown__header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.notif-dropdown__list { overflow-y: auto; padding-top: 4px; }
.notif-dropdown__empty { padding: 22px 10px; text-align: center; color: var(--ink-faint); font-size: 12px; }
.notif-item { width: 100%; display: block; text-align: left; min-height: 44px; padding: 8px 10px; border: 0; border-radius: 8px; color: var(--ink-soft); background: transparent; font-size: 12px; cursor: pointer; }
.notif-item:hover { background: var(--surface-tint); }
.notif-item--unread { background: var(--accent-faint); }
.notif-item__actions { display: flex; gap: 6px; margin-top: 8px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-3px) scale(.98); } to { opacity: 1; transform: none; } }

.page { max-width: 1540px; margin: 0 auto; padding: 30px var(--page-pad) 48px; }
.page__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page__title { margin: 0; font-size: 25px; line-height: 1.15; letter-spacing: -.045em; font-weight: 700; }
.page__subtitle { margin: 7px 0 0; color: var(--ink-faint); font-size: 13px; }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* ===== Фильтры (строка над списком/канбаном) ===== */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter { min-width: 150px; flex: 1 1 150px; }
.filter.search { flex: 2 1 240px; }
.filter .input, .filter .select { min-height: 38px; }
.filter-actions { display: flex; align-items: center; gap: 8px; }
.filters-toggle { display: none; }
.filters-backdrop { display: none; }
.filters__title { display: none; }
.tabs.ai-layout__tabs { display: none; }

@media (max-width: 960px) {
    :root { --sidebar-w: 68px; }
    .sidebar { padding: 20px 10px 13px; }
    .sidebar__brand { justify-content: center; padding: 0 0 26px; }
    .sidebar__brand span:not(.brand-mark), .sidebar__link span:last-child, .sidebar__company strong, .sidebar__company span { display: none; }
    .sidebar__link { justify-content: center; padding: 0; }
    .sidebar__footer { padding: 14px 0 0; }
    .sidebar__company { justify-content: center; }
}
@media (max-width: 720px) {
    .topbar { height: 62px; padding: 0 16px; }
    .topbar__search { width: auto; flex: 1; }
    .user-name, .topbar-divider { display: none; }
    .page { padding: 22px 16px 36px; }
    .page__header { display: block; }
}

/* ===== Avatar ===== */
.avatar { position: relative; width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: #3f418d; background: #e4e4fb; font-size: 10px; font-weight: 700; }
.avatar--sm { width: 22px; height: 22px; font-size: 9px; }
.avatar--md { width: 28px; height: 28px; font-size: 10px; }
.avatar--lg { width: 44px; height: 44px; font-size: 13px; }
.avatar--lead .avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar--lead .avatar__fallback { position: relative; }
.avatar.pink { color: #8d4c6c; background: #f5e0ec; }
.avatar.green { color: #39705b; background: #dcefe7; }
.avatar.gold { color: #896328; background: #faecd3; }
.avatar-group { display: flex; align-items: center; }
.avatar-group .avatar { border: 2px solid var(--surface); margin-left: -7px; }
.avatar-group .avatar:first-child { margin-left: 0; }
.icon-source { width: 25px; height: 25px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 7px; color: var(--accent-strong); background: var(--accent-soft); }
.icon-source svg { width: 14px; height: 14px; }

/* ===== Button ===== */
.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--r-sm); padding: 0 14px; color: var(--ink); background: var(--surface); font-weight: 600; font-size: 13px; white-space: nowrap; transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn.is-disabled { cursor: not-allowed; opacity: .5; transform: none; box-shadow: none; }
.btn svg { width: 16px; height: 16px; stroke-width: 1.8; }
.btn-primary { color: #fff; background: var(--accent); border-color: transparent; box-shadow: 0 3px 7px rgba(87,87,201,.18); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-outline { border-color: var(--line-strong); background: var(--surface); }
.btn-outline:hover { background: var(--surface-subtle); border-color: #b9bbca; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-tint); box-shadow: none; }
.btn-danger { color: var(--danger); border-color: #f0c7cd; background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 40px; height: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; height: 34px; }
.btn-block { width: 100%; }

/* ===== Card ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); padding: 20px; }
.card + .card { margin-top: 16px; }
.card__title { margin: 0 0 15px; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.card__title--flush { margin-bottom: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.section-head h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.02em; }
.section-head p { margin: 3px 0 0; color: var(--ink-faint); font-size: 12px; }
.small-strong { font-size: 12px; }
.card--narrow { max-width: 480px; }
.card--warning { border-color: #efdcb0; background: var(--warning-soft); }
.card--muted { opacity: .7; }

/* ===== Settings: каналы ===== */
.settings-tabs { overflow: auto; margin-bottom: 21px; }
.channels-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.channel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.channel-brand { display: flex; align-items: center; gap: 10px; }
.channel-icon { width: 35px; height: 35px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: var(--accent-strong); background: var(--accent-soft); }
.channel-icon svg { width: 18px; height: 18px; }
.channel-brand strong { display: block; font-size: 14px; }
.channel-brand span { display: block; margin-top: 2px; color: var(--ink-faint); font-size: 11px; }
.qr-image { max-width: 220px; width: 100%; border-radius: var(--r-md); border: 1px solid var(--line); }
.warning-note { margin-top: 4px; margin-bottom: 11px; padding: 9px 10px; border-radius: 8px; color: var(--warning); background: var(--warning-soft); font-size: 11px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; }
.inline-form .input, .inline-form .select { flex: 1; }
@media (max-width: 720px) { .channels-grid { grid-template-columns: 1fr; } }

/* ===== Control: метрики ===== */
.stat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; margin-bottom: 22px; }
.stat-card { min-height: 112px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; }
.stat-card__value { margin-top: 12px; font-size: 23px; font-weight: 700; letter-spacing: -.06em; }
.stat-card__label { color: var(--ink-faint); font-size: 11px; }
.stat-card--warning .stat-card__value { color: var(--warning); }
.stat-card--danger .stat-card__value { color: var(--danger); }
.control-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(500px, 1.5fr); gap: 18px; align-items: start; }
.attention-list { display: grid; gap: 2px; }
.attention-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.attention-list li:last-child { border-bottom: 0; }
.attention-list a { color: var(--ink); text-decoration: underline; text-decoration-color: #e8b7be; text-underline-offset: 3px; }
@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .control-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { min-height: 96px; }
    .stat-card__value { font-size: 20px; }
}

/* ===== AI-сотрудник ===== */
.ai-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); gap: 20px; align-items: start; }
.ai-sandbox { position: sticky; top: calc(var(--topbar-h) + 18px); }
.ai-sandbox__messages { min-height: 320px; display: flex; flex-direction: column; gap: 10px; padding: 15px; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: var(--r-md); overflow-y: auto; max-height: calc(100vh - var(--topbar-h) - 260px); }
.ai-sandbox__understood { margin-top: 12px; padding: 11px 12px; border-radius: 9px; color: var(--accent-strong); background: var(--accent-soft); font-size: 11px; }
.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; display: inline-flex; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: flex; align-items: center; min-height: 35px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-soft); background: var(--surface); font-size: 12px; cursor: pointer; transition: all var(--fast) var(--ease); }
.choice input:checked + span { color: var(--accent-strong); border-color: #c7c7f3; background: var(--accent-soft); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 13px 14px; border: 1px solid #efdcb0; border-radius: var(--r-md); color: var(--warning); background: var(--warning-soft); font-size: 12px; }
.notice svg { width: 16px; flex: 0 0 auto; }
.notice--success { border-color: #bfe3d2; color: var(--success); background: var(--success-soft); }
/* Код привязки Telegram (этап 18) — крупно и по центру, чтобы легко прочитать с телефона. */
.telegram-code { margin-bottom: 14px; padding: 14px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-strong); font-family: 'SF Mono', Consolas, monospace; font-size: 28px; font-weight: 700; letter-spacing: .1em; text-align: center; }
.week-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.compact-time { width: 96px; }
.form-section { padding: 19px 0; border-bottom: 1px solid var(--line); }
.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: 0; }
@media (max-width: 960px) {
    .ai-layout { grid-template-columns: 1fr; }
    .ai-sandbox { position: static; }
    .ai-sandbox__messages { max-height: 360px; }
}

/* ===== Badge / pill ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 4px 8px; font-size: 11px; font-weight: 600; line-height: 1.1; white-space: nowrap; color: var(--ink-soft); background: #f0f1f5; }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-info { color: var(--blue); background: var(--blue-soft); }
.badge-accent { color: var(--accent-strong); background: var(--accent-soft); }
.status-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: currentColor; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ===== Столбики расхода по дням (Подписка и баланс, этап 17) ===== */
.spend-chart { display: flex; align-items: flex-end; gap: 3px; height: 64px; padding-top: 4px; margin-bottom: 16px; }
.spend-chart__bar { flex: 1 1 0; min-width: 2px; height: var(--h, 2%); border-radius: 2px 2px 0 0; background: var(--accent-soft); transition: background var(--fast) var(--ease); position: relative; }
.spend-chart__bar:hover { background: var(--accent); }
.spend-chart__bar[data-label]:after { content: attr(data-label); position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 4px; font-size: 9px; color: var(--ink-faint); white-space: nowrap; }

/* ===== Температура ===== */
.temperature { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.temperature.cold, .temperature[data-temperature="cold"] { color: var(--blue); }
.temperature.warm, .temperature[data-temperature="warm"] { color: var(--warning); }
.temperature.hot, .temperature[data-temperature="hot"] { color: var(--danger); }

/* ===== Form controls ===== */
.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field__label { color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.field__hint { color: var(--ink-faint); font-size: 12px; }
.field__error { color: var(--danger); font-size: 11px; }
.input, .select, .textarea { width: 100%; min-height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 12px; color: var(--ink); background: var(--surface); outline: none; transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.textarea { min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: #9b9eae; }
.input:hover, .select:hover, .textarea:hover { border-color: #b8bbc9; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(87,87,201,.13); }
.input.is-error, .select.is-error, .textarea.is-error { border-color: var(--danger); }
.select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.checkbox, .radio { display: inline-flex; align-items: center; gap: 9px; min-height: 32px; color: var(--ink-soft); font-size: 13px; cursor: pointer; }
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch { position: relative; width: 42px; height: 24px; display: inline-flex; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; border-radius: 99px; background: #d5d7e2; transition: background var(--normal) var(--ease); pointer-events: none; }
.switch-track:after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(22,25,46,.2); transition: transform var(--normal) var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track:after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid rgba(87,87,201,.18); outline-offset: 2px; }

/* ===== Tabs / segmented ===== */
.tabs { display: flex; align-items: center; gap: 3px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs__item { min-height: 40px; position: relative; border: 0; padding: 0 12px; color: var(--ink-faint); background: transparent; font-size: 13px; font-weight: 600; }
.tabs__item:after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: transparent; transition: background var(--normal) var(--ease); }
.tabs__item:hover { color: var(--ink); }
.tabs__item.is-active { color: var(--accent-strong); }
.tabs__item.is-active:after { background: var(--accent); }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.segmented button, .segmented a { min-height: 32px; display: inline-flex; align-items: center; border: 0; border-radius: 6px; padding: 0 11px; color: var(--ink-faint); background: transparent; font-size: 12px; font-weight: 600; }
.segmented button.is-active, .segmented a.is-active { color: var(--accent-strong); background: var(--accent-soft); }
.segmented-link { min-height: 32px; display: inline-flex; align-items: center; padding: 0 11px; border-radius: 6px; color: var(--ink-faint); font-size: 12px; font-weight: 600; }
.segmented-link:hover { color: var(--ink); background: var(--surface-tint); }

/* ===== Панель лида (side panel) ===== */
.panel-overlay { position: fixed; z-index: var(--z-panel-backdrop); inset: 0; background: rgba(32,34,50,.17); display: flex; justify-content: flex-end; animation: fade-in var(--normal) var(--ease); }
.panel { position: relative; z-index: var(--z-panel); width: min(560px, 42vw); min-width: 450px; height: 100%; overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-float); animation: panel-in var(--normal) var(--ease); }
.panel__inner { display: flex; flex-direction: column; min-height: 100%; }
.panel__header { position: relative; padding: 24px 25px 16px; }
.panel__body { flex: 1; padding: 0 25px 30px; }
.panel__close { position: absolute; top: 20px; right: 20px; }
@keyframes panel-in { from { opacity: .6; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@media (max-width: 960px) {
    .panel { width: min(560px, calc(100vw - 68px)); }
}
@media (max-width: 720px) {
    .panel { width: calc(100vw - 68px); min-width: 0; }
    .panel__header, .panel__body { padding-left: 17px; padding-right: 17px; }
}

/* ===== Modal ===== */
.modal-overlay { position: fixed; z-index: var(--z-modal); inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(32,34,50,.24); animation: fade-in var(--normal) var(--ease); }
.modal { width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-float); padding: 20px 22px 22px; animation: modal-in var(--normal) var(--ease); }
.modal--sm { width: min(400px, 100%); }
.modal__title { margin: 0 0 15px; font-size: 18px; font-weight: 650; letter-spacing: -.035em; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 19px; flex-wrap: wrap; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }

/* ===== Popover (попап записи в календаре) ===== */
.popover { position: fixed; z-index: var(--z-dropdown); width: 280px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-float); }
.popover h3, .popover .modal__title { font-size: 14px; }

/* ===== Toast ===== */
.toast-container { position: fixed; z-index: var(--z-toast); top: 18px; right: 18px; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { display: flex; gap: 11px; align-items: flex-start; padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r-md); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-float); font-size: 12px; animation: toast-in var(--normal) var(--ease); }
.toast strong, .toast > strong { display: block; font-size: 12px; }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }
.toast-warning { border-left: 3px solid var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }

/* ===== Table ===== */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; font-size: 12px; }
.table th { padding: 12px 14px; color: var(--ink-faint); background: var(--surface-subtle); border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; white-space: nowrap; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--fast) var(--ease); cursor: pointer; }
.table tbody tr:hover { background: var(--accent-faint); }
.table td.is-danger { color: var(--danger); }
.table tbody tr.is-danger-row { background: var(--danger-soft); }

/* ===== Панель лида: детали, AI-передача, следующий шаг ===== */
.lead-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.lead-controls .select { min-height: 36px; font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.detail-grid .field { margin-bottom: 0; }
.amount-field { position: relative; }
.amount-field .input { padding-right: 32px; }
.amount-field span { position: absolute; top: 10px; right: 12px; color: var(--ink-faint); font-size: 12px; }
.ai-handoff { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0; padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-subtle); }
.ai-handoff strong { display: block; font-size: 12px; }
.ai-handoff small { display: block; color: var(--ink-faint); margin-top: 2px; font-size: 11px; }
.next-step { padding: 13px 14px; border-radius: var(--r-md); background: var(--accent-faint); border: 1px solid #e2e2ff; }
.next-step.overdue { border-color: #f2d3d7; background: var(--danger-soft); }
.next-step-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.next-step-head strong { font-size: 12px; }
.next-step p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.next-step-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; color: var(--ink-faint); font-size: 11px; }

/* ===== Kanban =====
   Доска — flex-ряд с горизонтальной прокруткой внутри себя (этап 14б, п.1):
   при grid+auto-fit колонки на 1400px заворачивались во второй ряд, а
   карточки (min-content шире 190px) вылезали за границу колонки. Флекс с
   фиксированной шириной колонки не допускает ни того, ни другого ни на
   одном брейкпоинте — переносится не сетка колонок, а сама доска (по
   горизонтали, внутри .kanban), страница по горизонтали не скроллится. */
.kanban { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { flex: 0 0 272px; min-width: 272px; }
.kanban-column__header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; min-height: 42px; padding: 3px 6px 11px; }
.kanban-column__title { font-size: 12px; font-weight: 650; }
.kanban-column__meta { color: var(--ink-faint); font-size: 10px; white-space: nowrap; }
.kanban-column__list { display: grid; gap: 9px; min-height: 120px; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: #f1f2f7; }
.lead-card { position: relative; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: 0 2px 7px rgba(31,35,66,.035); cursor: pointer; overflow: hidden; transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), border-color var(--fast) var(--ease); }
/* .lead-card:hover ставит transform и тем самым создаёт свой контекст наложения —
   без явного z-index меню «⋯» этой карточки красится ПОД следующей карточкой
   в списке. Поднимаем саму карточку, пока её меню открыто. */
.lead-card--menu-open { z-index: 2; overflow: visible; }
.lead-card:hover { transform: translateY(-2px); border-color: #c9cbe1; box-shadow: var(--shadow-md); }
.lead-card.sortable-ghost { opacity: .72; border: 1px dashed var(--accent); background: var(--accent-faint); }
.lead-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.lead-card__top > .flex { min-width: 0; }
.lead-card__name { min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card__interest { margin-top: 3px; color: var(--ink-faint); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-card__badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.lead-card__badges .badge { padding: 3px 5px; font-size: 10px; }

/* Меню «⋯» на карточке — «Переместить в этап», альтернатива drag&drop на тач (этап 21, п.2) */
.card-menu { position: relative; display: inline-flex; }
.card-menu__list { position: absolute; z-index: var(--z-dropdown); top: calc(100% + 4px); right: 0; width: 190px; max-height: 260px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-float); animation: pop-in var(--normal) var(--ease); }
.card-menu__title { padding: 6px 8px 8px; color: var(--ink-faint); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.card-menu__item { display: block; width: 100%; text-align: left; min-height: 34px; padding: 0 8px; border: 0; border-radius: 7px; color: var(--ink-soft); background: transparent; font-size: 12.5px; }
.card-menu__item:hover { background: var(--surface-tint); color: var(--ink); }
.card-menu__item.is-current { color: var(--accent-strong); font-weight: 600; }
@media (max-width: 720px) {
    .kanban-column { flex-basis: 240px; min-width: 240px; }
}

/* ===== Фильтры ===== */
.filter-control { max-width: 220px; min-height: 38px; }
.filter-control--sm { max-width: 170px; min-height: 34px; font-size: 12px; }
.filter-control--lg { max-width: 300px; }

/* ===== Списки воронки (онбординг шаг 2, предложение AI) ===== */
.stage-list { display: grid; gap: 8px; margin-bottom: 20px; }
.stage-list__item { padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-subtle); font-size: 12.5px; }

/* ===== Чат ===== */
.chat { display: grid; gap: 10px; padding-top: 4px; }
.chat__messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: var(--space, 2px) 0; }
.chat-message { display: flex; margin-bottom: 0; }
.chat-message--client { justify-content: flex-start; }
.chat-message--ai, .chat-message--manager { justify-content: flex-end; }
.chat-message--system { justify-content: center; }
.chat-message__bubble { max-width: 82%; padding: 10px 12px; border-radius: 12px 12px 12px 4px; color: var(--ink); background: #f0f1f5; font-size: 12px; }
.chat-message--ai .chat-message__bubble, .chat-message--manager .chat-message__bubble { border-radius: 12px 12px 4px 12px; color: #fff; background: var(--accent); }
.chat-message__meta { display: block; margin-top: 5px; color: var(--ink-faint); font-size: 10px; }
.chat-message--ai .chat-message__meta, .chat-message--manager .chat-message__meta { color: #d9d9ff; }
.chat-message__system { color: var(--ink-faint); font-size: 10.5px; text-align: center; padding: 2px 12px; }
.chat__input { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.chat__input .input { min-height: 38px; }
.chat__input--client { border-top: none; padding-top: 0; margin-top: 8px; }

/* ===== Мягкий блок / инфо-список / история (панель лида) ===== */
.soft-box { padding: 13px 14px; border-radius: var(--r-md); background: var(--surface-tint); }
.soft-box h3 { margin: 0 0 6px; font-size: 12px; }
.soft-box p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.info-list { display: grid; gap: 10px; }
.info-row { display: flex; justify-content: space-between; gap: 14px; font-size: 12px; }
.info-row dt { color: var(--ink-faint); margin: 0; }
.info-row dd { margin: 0; color: var(--ink-soft); text-align: right; }
.history { display: grid; gap: 11px; }
.history-item { position: relative; display: grid; grid-template-columns: 9px 1fr; gap: 10px; }
.history-item:before { content: ''; width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.history-item strong { display: block; font-size: 12px; }
.history-item span { display: block; color: var(--ink-faint); margin-top: 2px; font-size: 11px; }

/* ===== Empty state / skeleton ===== */
.empty-state { min-height: 160px; display: grid; place-items: center; padding: 25px; text-align: center; }
.empty-state__title { margin: 0; font-size: 14px; font-weight: 600; }
.empty-state p { max-width: 280px; margin: 6px auto 0; color: var(--ink-faint); font-size: 12px; }
.empty-state h3 { margin: 0; font-size: 14px; }
.empty-state-icon { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 11px; border-radius: 13px; color: var(--accent); background: var(--accent-soft); }
.table-card { min-width: 0; }
.skeleton { position: relative; overflow: hidden; border-radius: 6px; background: #eceef4; }
.skeleton:after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: skeleton 1.2s infinite; }
@keyframes skeleton { to { transform: translateX(100%); } }
.skeleton-line { height: 10px; }
.skeleton-line.wide { width: 72%; }
.skeleton-line.short { width: 38%; }

/* ===== Витрина компонентов (design-system.blade.php) ===== */
.component-showcase-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.demo-lead { max-width: 290px; }
.showcase-columns { display: grid; grid-template-columns: minmax(250px, .65fr) minmax(280px, 1fr); gap: 28px; align-items: start; }
@media (max-width: 720px) {
    .component-showcase-grid, .showcase-columns { grid-template-columns: 1fr; }
}

/* ===== Focus ===== */
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 3px solid rgba(87,87,201,.26); outline-offset: 2px; }

/* ===== Utility ===== */
.link { color: var(--accent-strong); font-weight: 600; }
.link:hover { text-decoration: underline; }
/* Кнопка внутри текста, выглядящая как .link — например «Вернуться в
   панель» посреди предложения в жёлтой полосе impersonation (этап 23). */
.inline-form-link { display: inline; }
.inline-form-link button.link { border: 0; padding: 0; background: transparent; font: inherit; }
.text-muted { color: var(--ink-faint); }
.text-faint { color: var(--ink-faint); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 12.5px; }
.text-center { text-align: center; }
.text-xs { font-size: 11px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-start { justify-content: flex-start; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mb-6 { margin-bottom: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.rotate-180 { transform: rotate(180deg); }

/* ===== Календарь записей ===== */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.cal-toolbar__nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-toolbar__label { min-width: 170px; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.cal-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.cal-grid { display: grid; }
.cal-grid__corner { position: sticky; left: 0; z-index: 4; background: var(--surface); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-grid__head { min-height: 49px; padding: 11px 8px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; font-size: 11px; }
.cal-grid__head--today { color: var(--accent-strong); background: var(--accent-faint); }
.cal-grid__head-day { color: var(--ink-faint); font-size: 10px; text-transform: uppercase; letter-spacing: .02em; }
.cal-grid__head-date { display: block; font-size: 12px; font-weight: 650; }
.cal-grid__time-col { position: sticky; left: 0; z-index: 4; padding-top: 49px; background: var(--surface-subtle); border-right: 1px solid var(--line); }
.cal-grid__time { position: absolute; left: 0; right: 0; padding: 0 8px 0 10px; color: var(--ink-faint); font-size: 10px; text-align: right; transform: translateY(-6px); }
.cal-col { position: relative; border-left: 1px solid var(--line); background: repeating-linear-gradient(to bottom, transparent 0, transparent 20px, var(--line) 21px, transparent 22px, transparent 41px); }
.cal-slot { position: absolute; left: 0; right: 0; z-index: 1; cursor: pointer; }
.cal-slot:hover { background: var(--accent-faint); }
.cal-slot--off { background: #f7f7fa; cursor: default; }
.cal-slot--off:hover { background: #f7f7fa; }
.cal-now-line { position: absolute; z-index: 3; left: 0; right: 0; height: 2px; background: var(--danger); }
.cal-now-line::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.cal-event { position: absolute; z-index: 2; left: 5px; right: 5px; display: grid; align-content: center; gap: 2px; overflow: hidden; padding: 4px 8px; border-left: 3px solid currentColor; border-radius: 6px; cursor: pointer; transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.cal-event:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.cal-event__name { color: var(--ink); font-size: 11px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event__meta { color: var(--ink-soft); font-size: 10px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event--scheduled { color: var(--accent); background: var(--accent-soft); }
.cal-event--arrived { color: var(--success); background: var(--success-soft); }
.cal-event--no_show { color: var(--danger); background: var(--danger-soft); }
.cal-event--cancelled { color: #9396a4; background: #f0f1f4; text-decoration: line-through; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; color: var(--ink-faint); font-size: 11px; }
.cal-legend__dot { width: 8px; height: 8px; display: inline-block; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.cal-legend__dot--scheduled { background: var(--accent); }
.cal-legend__dot--arrived { background: var(--success); }
.cal-legend__dot--no_show { background: var(--danger); }
.cal-legend__dot--cancelled { background: #9396a4; }
.slot-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.slot-chip { min-height: 34px; padding: 0 11px; border: 1px solid #cfcff4; border-radius: 8px; color: var(--accent-strong); background: var(--accent-faint); font-size: 12px; transition: all var(--fast) var(--ease); }
.slot-chip:hover, .slot-chip.is-selected { color: #fff; border-color: var(--accent); background: var(--accent); }
@media (max-width: 720px) {
    .cal-toolbar { display: block; }
    .cal-toolbar > * + * { margin-top: 11px; }
}

/* ===== Экран специалиста «Мои записи» (этап 19, п.7) ===== */
.my-bottomnav { display: none; }
@media (max-width: 720px) {
    .my-page { padding-bottom: 70px; } /* место под фиксированную нижнюю навигацию */
    .my-bottomnav {
        display: flex; position: fixed; z-index: var(--z-sidebar); inset: auto 0 0 0;
        border-top: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-float);
    }
    .my-bottomnav__item {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        padding: 9px 4px 8px; border: 0; background: transparent; color: var(--ink-faint); font-size: 10.5px;
    }
    .my-bottomnav__item svg { width: 19px; height: 19px; }
    .my-bottomnav__item.is-active { color: var(--accent-strong); }
}

/* ===== Мобильная версия (этап 21) — брейкпоинт ≤768px из спеки =====
   Планшет (769–1024, боковое меню-иконки) и десктоп (>1024) уже были
   готовы раньше (см. @media 960px/720px выше) — здесь только сама
   мобильная раскладка: нижняя навигация вместо сайдбара, компактный топбар,
   доска/таблицы/панель/модалки под тач и один палец. */
.bottom-nav { display: none; }
.topbar__search-toggle { display: none; }
.topbar__section-title { display: none; }
.stage-chips { display: none; }
.panel__close-label { display: none; }
@media (max-width: 768px) {
    .sidebar { display: none; }
    .app-main { width: 100%; margin-left: 0; }
    .page { padding-bottom: 84px; } /* место под фикс. нижнюю навигацию */

    /* --- Нижняя навигация (роли — тот же $navItems, что и у сайдбара) --- */
    .bottom-nav {
        display: flex; position: fixed; z-index: var(--z-sidebar); inset: auto 0 0 0;
        border-top: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-float);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .bottom-nav__item {
        position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        padding: 9px 4px 8px; border: 0; background: transparent; color: var(--ink-faint); font-size: 10.5px;
    }
    .bottom-nav__item svg { width: 19px; height: 19px; }
    .bottom-nav__item.is-active { color: var(--accent-strong); }
    .bottom-nav__badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 14px; height: 14px; padding: 0 3px; display: flex; align-items: center; justify-content: center; border-radius: 99px; background: var(--danger); color: #fff; font-size: 8.5px; font-weight: 700; line-height: 1; }

    /* --- Топбар: заголовок раздела + иконка поиска вместо всегда открытого поля --- */
    .topbar__search { display: none; }
    .topbar__search.is-open { display: flex; align-items: center; position: absolute; inset: 0 16px; z-index: 1; width: auto; background: var(--surface); }
    .topbar__search-toggle { display: grid; width: 40px; height: 40px; place-items: center; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-soft); }
    .topbar__section-title { display: block; margin-right: auto; font-size: 15px; font-weight: 650; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* --- Кнопки/поля — минимум 44px и 16px, чтобы iOS не зумил при фокусе --- */
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }
    .btn-icon { width: 44px; height: 44px; }
    .input, .select, .textarea { min-height: 44px; font-size: 16px; }
    .textarea { min-height: 96px; }
    .checkbox, .radio { min-height: 40px; }

    /* --- Формы в одну колонку --- */
    .detail-grid { grid-template-columns: 1fr; }
    .card--narrow { max-width: none; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .inline-form .input, .inline-form .select, .inline-form .btn { width: 100%; }

    /* Настройки → Специалисты: строки с несколькими полями/чекбоксами (этап 25,
       найдено при финальной проверке) — без переноса вылезали за 390px. */
    .specialist-row { flex-wrap: wrap; }
    .specialist-row .input { flex: 1 1 140px; min-width: 0; }
    .specialist-row .btn { flex: 0 0 auto; }
    .specialist-days { flex-wrap: wrap; }

    /* --- Фильтры — выезжающий снизу лист вместо строки (этап 21, п.2) --- */
    .filters-toggle { display: inline-flex; position: relative; }
    .filters-toggle__badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px; display: flex; align-items: center; justify-content: center; border-radius: 99px; background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 700; line-height: 1; }
    .filters-backdrop.is-open { display: block; position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(20, 21, 41, .38); animation: fade-in var(--normal) var(--ease); }
    .filters {
        position: fixed; inset: auto 0 0 0; z-index: calc(var(--z-modal) + 1);
        flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 0;
        max-height: 82vh; overflow-y: auto;
        padding: 18px 17px calc(18px + env(safe-area-inset-bottom, 0));
        border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--surface); box-shadow: var(--shadow-float);
        transform: translateY(100%); transition: transform var(--normal) var(--ease);
    }
    .filters.is-open { transform: none; }
    .filters:not(.is-open) { visibility: hidden; }
    .filter, .filter.search { min-width: 0; flex: none; }
    .filter-actions { flex-wrap: wrap; }
    .filters__title { display: block; margin: 0 0 2px; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }

    /* --- AI-сотрудник: вкладки «Настройки | Проверить AI» вместо двух
       колонок сразу (этап 21, п.5) --- */
    .tabs.ai-layout__tabs { display: flex; margin-bottom: 14px; }
    .is-hidden-mobile { display: none; }
    .ai-sandbox__messages { max-height: calc(100vh - var(--topbar-h) - 230px); }

    /* --- Модалки и попапы записи (тот же .modal/.modal-overlay) — нижние листы --- */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal { width: 100%; max-width: 100%; max-height: 86vh; border-radius: var(--r-xl) var(--r-xl) 0 0; animation: sheet-in var(--normal) var(--ease); }
    .modal--sm { width: 100%; }

    /* --- Боковая панель лида — на весь экран, липкие вкладки, поле ввода
       прижато книзу (этап 21, п.2). Полную «шапку в одну строку» не делаем —
       риск сломать уже отлаженные поля важнее выигрыша по высоте, весь
       контент и так доступен прокруткой внутри панели, ничего не теряется. --- */
    .panel-overlay { background: var(--surface); }
    .panel { width: 100vw; min-width: 0; border-left: 0; }
    .panel__close { width: auto; padding: 0 10px 0 4px; }
    .panel__close svg { flex-shrink: 0; }
    .panel__close-label { display: inline; margin-left: 6px; color: var(--ink-soft); font-size: 13px; font-weight: 600; vertical-align: middle; }
    .panel .tabs { position: sticky; top: 0; z-index: 3; background: var(--surface); margin: 0 -17px; padding: 0 17px; }
    .chat__input { position: sticky; bottom: 0; z-index: 2; background: var(--surface); margin: 14px -17px 0; padding: 14px 17px calc(14px + env(safe-area-inset-bottom, 0)); }

    /* --- Канбан: широкие колонки, тап-скролл по одной за раз --- */
    .kanban-column { flex: 0 0 86vw; min-width: 86vw; }
    .stage-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 2px; }
    .stage-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 99px; color: var(--ink-soft); background: var(--surface); font-size: 12px; font-weight: 600; white-space: nowrap; }
    .stage-chip__count { min-width: 18px; padding: 1px 5px; border-radius: 99px; background: var(--surface-tint); color: var(--ink-faint); font-size: 10.5px; text-align: center; }

    /* --- Записи: закреплённая колонка времени при горизонтальной прокрутке недели --- */
    .cal-wrap { overflow-x: auto; }
    .cal-grid__time-col, .cal-grid__corner { position: sticky; left: 0; z-index: 2; background: var(--canvas); }

    /* --- Таблица лидов → карточки-строки (этап 21, п.2); .table-responsive — opt-in,
       остальные таблицы сайта продолжают просто скроллиться внутри .table-wrap. --- */
    .table-responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
    .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
    .table-responsive { min-width: 0; border-spacing: 0; }
    .table-responsive tbody tr { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); }
    .table-responsive tbody tr:last-child { margin-bottom: 0; }
    .table-responsive td { padding: 6px 0; border: 0; }
    .table-responsive td:before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--ink-faint); font-size: 11px; font-weight: 600; }
    .table-responsive td:empty { display: none; }

    /* --- Уведомления: см. правило ≤480px выше — здесь просто не мешаем ему --- */
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: .7; } to { transform: none; opacity: 1; } }

/* ===== Обучающий режим (этап 22) =====
   .tour-backdrop — прозрачный на вид, но перехватывает клики по всей странице
   (в т.ч. под «вырезом» — спека прямо просит, чтобы элемент под подсветкой не
   нажимался мимо кнопок тура); само затемнение с «вырезом» рисует не он, а
   box-shadow у .tour-highlight (классический приём: огромный spread вокруг
   рамки красит всё, кроме самой рамки). Z-index — выше самого высокого токена
   (--z-toast: 120), отдельного токена не заводили: это разовый оверлей. */
.tour-backdrop { position: fixed; inset: 0; z-index: 199; background: transparent; }
.tour-highlight { position: fixed; z-index: 200; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(20, 21, 41, .6); pointer-events: none; transition: top var(--fast) var(--ease), left var(--fast) var(--ease), width var(--fast) var(--ease), height var(--fast) var(--ease); }
.tour-card { position: fixed; z-index: 201; width: 300px; max-width: calc(100vw - 24px); padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-float); animation: pop-in var(--normal) var(--ease); }
.tour-card__counter { margin-bottom: 6px; color: var(--accent-strong); font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.tour-card__title { margin-bottom: 6px; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.tour-card__body { margin-bottom: 14px; color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; }
.tour-card__actions { display: flex; align-items: center; gap: 8px; }
.tour-card__spacer { flex: 1; }
@media (max-width: 768px) {
    .tour-card--docked {
        top: auto !important; left: 0 !important; right: 0; bottom: 0;
        width: 100%; max-width: none; border-radius: var(--r-xl) var(--r-xl) 0 0;
        padding: 16px 17px calc(16px + env(safe-area-inset-bottom, 0));
        animation: sheet-in var(--normal) var(--ease);
    }
}
