/* Расписание: насыщенные карточки, мягкие анимации, линия «сейчас».
   Подключается после crm-theme.css и переопределяет только сетку расписания. */

body.crm-ui {
    --sv-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --sv-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --sv-brand-a: #2563eb;
    --sv-brand-b: #7c3aed;
}

/* --- Цвета направлений: градиент + цветная тень --- */
.crm-week-card.tone-mint   { --sv-a: #34d399; --sv-b: #059669; --sv-glow: 5, 150, 105; }
.crm-week-card.tone-sun    { --sv-a: #fbbf24; --sv-b: #ea580c; --sv-glow: 234, 88, 12; }
.crm-week-card.tone-lilac  { --sv-a: #a78bfa; --sv-b: #7c3aed; --sv-glow: 124, 58, 237; }
.crm-week-card.tone-rose   { --sv-a: #fb7185; --sv-b: #e11d48; --sv-glow: 225, 29, 72; }
.crm-week-card.tone-sky    { --sv-a: #38bdf8; --sv-b: #2563eb; --sv-glow: 37, 99, 235; }
.crm-week-card.tone-peach  { --sv-a: #fb923c; --sv-b: #e8431c; --sv-glow: 232, 67, 28; }
.crm-week-card.tone-teal   { --sv-a: #2dd4bf; --sv-b: #0f766e; --sv-glow: 15, 118, 110; }
.crm-week-card.tone-coral  { --sv-a: #f87171; --sv-b: #dc2626; --sv-glow: 220, 38, 38; }
.crm-week-card.tone-indigo { --sv-a: #818cf8; --sv-b: #4338ca; --sv-glow: 67, 56, 202; }
.crm-week-card.tone-lime   { --sv-a: #84cc16; --sv-b: #3f7d0b; --sv-glow: 63, 125, 11; }

body.crm-ui .crm-week-card[class*="tone-"] {
    background: linear-gradient(150deg, var(--sv-a) 0%, var(--sv-b) 100%) !important;
    border: 0 !important;
    border-radius: 12px;
    color: #fff !important;
    box-shadow:
        0 1px 2px rgba(var(--sv-glow), 0.25),
        0 4px 12px -4px rgba(var(--sv-glow), 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.28);
    transition:
        transform 0.28s var(--sv-ease),
        box-shadow 0.28s var(--sv-ease),
        filter 0.28s var(--sv-ease),
        opacity 0.2s ease;
}

/* Блик по карточке при наведении */
body.crm-ui .crm-week-card[class*="tone-"]::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.32) 50%, transparent 70%);
    transform: translateX(-120%);
    pointer-events: none;
}

body.crm-ui .crm-week-card[class*="tone-"]:hover::before {
    transform: translateX(120%);
    transition: transform 0.8s var(--sv-ease);
}

body.crm-ui .crm-week-card[class*="tone-"]:not(.is-pressing):not(.is-dragging):not(.is-pending):hover,
body.crm-ui .crm-week-card[class*="tone-"]:not(.is-pressing):not(.is-dragging):not(.is-pending):focus-visible {
    transform: translateY(-2px) scale(1.015);
    filter: saturate(1.12);
    box-shadow:
        0 2px 4px rgba(var(--sv-glow), 0.25),
        0 14px 28px -8px rgba(var(--sv-glow), 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.32);
    outline: none;
}

body.crm-ui .crm-week-card[class*="tone-"].is-open {
    box-shadow:
        0 0 0 2px #fff,
        0 0 0 4px rgb(var(--sv-glow)),
        0 14px 28px -8px rgba(var(--sv-glow), 0.6);
}

/* Перетаскивание не трогаем: свои transform задаёт schedule-drag.js */
body.crm-ui .crm-week-card.is-dragging,
body.crm-ui .crm-week-card.is-pending,
body.crm-ui .crm-week-card.is-pressing,
body.crm-ui .crm-week-card.is-returning,
body.crm-ui .crm-week-card.is-landing {
    filter: saturate(1.15);
}

body.crm-ui .crm-week-card.is-dragging::before,
body.crm-ui .crm-week-card.is-pending::before {
    display: none;
}

/* Текст на цветном фоне */
body.crm-ui .crm-week-card[class*="tone-"] strong,
body.crm-ui .crm-week-card[class*="tone-"] .crm-week-card__name {
    color: #fff !important;
    font-weight: 800;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}

body.crm-ui .crm-week-card[class*="tone-"] .crm-week-card__trainer {
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 600;
}

body.crm-ui .crm-week-card[class*="tone-"] span,
body.crm-ui .crm-week-card[class*="tone-"] small,
body.crm-ui .crm-week-card[class*="tone-"] .crm-week-person,
body.crm-ui .crm-week-card[class*="tone-"] .crm-week-more {
    color: rgba(255, 255, 255, 0.85) !important;
}

body.crm-ui .crm-week-card[class*="tone-"] .crm-week-card__cover {
    font-style: normal;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
}

/* Бейджи «ждут» / «✓ из» / «пробн.» — стеклянные пилюли */
body.crm-ui .crm-week-card[class*="tone-"] .crm-week-mark,
body.crm-ui .crm-week-card[class*="tone-"] .crm-week-trial {
    border: 0 !important;
    background: rgba(255, 255, 255, 0.94) !important;
    box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.25);
}

body.crm-ui .crm-week-card[class*="tone-"] .crm-week-mark.is-wait {
    color: #c2410c !important;
    animation: sv-pulse 2.2s ease-in-out infinite;
}

body.crm-ui .crm-week-card[class*="tone-"] .crm-week-mark.is-done {
    color: #15803d !important;
}

body.crm-ui .crm-week-card[class*="tone-"] .crm-week-trial {
    color: #a16207 !important;
}

body.crm-ui .crm-week-check {
    box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(0, 0, 0, 0.25);
    animation: sv-pop-in 0.5s var(--sv-spring) both;
}

@keyframes sv-pulse {
    0%, 100% { box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(255, 255, 255, 0.7); }
    50% { box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.25), 0 0 0 5px rgba(255, 255, 255, 0); }
}

/* --- Появление карточек каскадом --- */
.crm-week.sv-enter .crm-week-card,
.crm-week-stack.sv-enter .crm-week-card {
    animation: sv-card-in 0.55s var(--sv-ease) both;
    animation-delay: calc(var(--sv-i, 0) * 28ms);
}

@keyframes sv-card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

@keyframes sv-pop-in {
    from { opacity: 0; transform: scale(0.3); }
    to { opacity: 1; transform: scale(1); }
}

/* --- Сетка --- */
body.crm-ui .crm-week {
    border-radius: 16px;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
}

body.crm-ui .crm-week-head {
    background: var(--surface);
    border-radius: 16px 16px 0 0;
}

body.crm-ui .crm-week-day {
    padding: 10px 6px 12px;
    transition: background-color 0.2s ease;
}

body.crm-ui a.crm-week-day b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 16px;
    font-weight: 800;
    transition: transform 0.25s var(--sv-spring), background-color 0.2s ease, color 0.2s ease;
}

body.crm-ui a.crm-week-day:hover b {
    transform: scale(1.1);
    background: rgba(37, 99, 235, 0.1);
    color: var(--sv-brand-a);
}

body.crm-ui .crm-week-day span {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

body.crm-ui .crm-week-day.is-today,
body.crm-ui .crm-week-day.is-selected,
body.crm-ui .crm-week-day:hover {
    background: transparent;
}

body.crm-ui .crm-week-day.is-today b,
body.crm-ui .crm-week-day.is-today:hover b {
    color: #fff;
    background: linear-gradient(135deg, var(--sv-brand-a), var(--sv-brand-b));
    box-shadow: 0 6px 14px -4px rgba(91, 33, 182, 0.55);
}

body.crm-ui .crm-week-day.is-today span {
    color: var(--sv-brand-a);
}

/* Колонка «сегодня» и линия текущего времени */
.sv-today-col {
    position: relative;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(37, 99, 235, 0.07), rgba(124, 58, 237, 0.04));
    z-index: 0;
}

.sv-now {
    position: absolute;
    left: -4px;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #f43f5e, #fb7185);
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.6);
    z-index: 20;
    pointer-events: none;
}

.sv-now::before {
    content: "";
    position: absolute;
    left: -5px;
    top: -5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #f43f5e;
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.6);
    animation: sv-now 2s ease-out infinite;
}

.sv-now[hidden] {
    display: none;
}

@keyframes sv-now {
    0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.55); }
    100% { box-shadow: 0 0 0 10px rgba(244, 63, 94, 0); }
}

body.crm-ui .crm-week-time {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.crm-ui .crm-week-slot {
    border-radius: 10px;
    transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

body.crm-ui .crm-week-slot:hover,
body.crm-ui .crm-week-slot:focus-visible {
    background: rgba(37, 99, 235, 0.08);
    box-shadow: inset 0 0 0 1.5px rgba(37, 99, 235, 0.35);
}

body.crm-ui .crm-week-slot:hover::after {
    content: "+";
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--sv-brand-a);
    font-size: 20px;
    font-weight: 700;
    animation: sv-pop-in 0.25s var(--sv-spring) both;
}

/* --- Панель недели и переключатель --- */
body.crm-ui .crm-schedule-toolbar {
    border-radius: 16px;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -14px rgba(15, 23, 42, 0.14);
}

body.crm-ui .crm-week-arrow {
    border-radius: 10px;
    transition: transform 0.2s var(--sv-spring), background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

body.crm-ui .crm-week-arrow:hover {
    transform: scale(1.08);
    background: rgba(37, 99, 235, 0.08);
}

body.crm-ui .crm-week-arrow:active {
    transform: scale(0.94);
}

body.crm-ui .crm-view-switch {
    padding: 3px;
    gap: 2px;
    border-radius: 12px;
    border-color: transparent;
    background: var(--crm-well, #f1f5f9);
}

body.crm-ui .crm-view-switch a,
body.crm-ui .crm-view-switch button {
    border-radius: 9px;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

body.crm-ui .crm-view-switch a:not(.is-active):hover,
body.crm-ui .crm-view-switch button:not(.is-active):hover {
    background: rgba(255, 255, 255, 0.7);
}

body.crm-ui .crm-view-switch a.is-active,
body.crm-ui .crm-view-switch button.is-active {
    background: linear-gradient(135deg, var(--sv-brand-a), var(--sv-brand-b));
    box-shadow: 0 6px 14px -6px rgba(91, 33, 182, 0.6);
}

/* Чипы тренеров */
body.crm-ui .crm-trainer-chip {
    transition: transform 0.2s var(--sv-spring), background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

body.crm-ui .crm-trainer-chip:hover {
    transform: translateY(-1px);
}

body.crm-ui .crm-trainer-chip.is-on {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--sv-brand-a), var(--sv-brand-b));
    box-shadow: 0 6px 14px -6px rgba(91, 33, 182, 0.6);
}

/* Сводка отметок */
body.crm-ui .crm-mark-summary {
    border-radius: 16px;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -14px rgba(15, 23, 42, 0.14);
    animation: sv-card-in 0.5s var(--sv-ease) both;
}

body.crm-ui .crm-mark-summary__wait {
    transition: transform 0.2s var(--sv-spring), background-color 0.2s ease;
}

body.crm-ui .crm-mark-summary__wait:not(:disabled):hover {
    transform: scale(1.04);
}

.is-only-unmarked .crm-week-card[data-live-card]:not(.is-unmarked) {
    filter: grayscale(1);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

/* Мобильный список по дням */
body.crm-ui .crm-week-stack .crm-week-card[class*="tone-"] {
    border-radius: 14px;
}

/* Тёмная тема */
html[data-theme="dark"] body.crm-ui .sv-today-col {
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.1), rgba(167, 139, 250, 0.06));
}

html[data-theme="dark"] body.crm-ui .crm-view-switch a:not(.is-active):hover,
html[data-theme="dark"] body.crm-ui .crm-view-switch button:not(.is-active):hover {
    background: rgba(255, 255, 255, 0.08);
}

@media (prefers-reduced-motion: reduce) {
    .crm-week.sv-enter .crm-week-card,
    .crm-week-stack.sv-enter .crm-week-card,
    body.crm-ui .crm-mark-summary,
    body.crm-ui .crm-week-check,
    body.crm-ui .crm-week-card .crm-week-mark.is-wait,
    .sv-now::before {
        animation: none !important;
    }

    body.crm-ui .crm-week-card[class*="tone-"]::before {
        display: none;
    }
}

/* ============================================================
   Боковая панель занятия: шаги, прогресс, подсказки, анимации
   ============================================================ */
.crm-drawer {
    animation: sv-drawer-in 0.42s var(--sv-ease, cubic-bezier(0.22, 1, 0.36, 1)) both;
}

.crm-drawer-backdrop {
    animation: sv-fade-in 0.3s ease both;
    backdrop-filter: blur(2px);
}

@keyframes sv-drawer-in {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@keyframes sv-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.crm-drawer__head h2 {
    font-size: 20px;
    font-weight: 800;
}

.crm-drawer__close {
    border-radius: 50%;
    transition: transform 0.25s ease, background-color 0.2s ease, color 0.2s ease;
}

.crm-drawer__close:hover {
    transform: rotate(90deg);
}

/* Карточка с данными занятия */
.crm-drawer__meta {
    margin: 4px 16px 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f8fafc;
    animation: sv-rise 0.45s 0.05s var(--sv-ease, ease) both;
}

.crm-drawer__meta div {
    grid-template-columns: 130px 1fr;
}

.crm-drawer__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.crm-drawer__tools .crm-drawer__edit,
.crm-drawer__tools .crm-drawer__delete button {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    margin: 0;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.crm-drawer__tools .crm-drawer__edit {
    background: rgba(22, 119, 255, 0.1);
}

.crm-drawer__tools .crm-drawer__delete {
    margin: 0;
}

.crm-drawer__tools .crm-drawer__delete button {
    background: rgba(194, 65, 12, 0.08);
}

.crm-drawer__tools .crm-drawer__edit:hover,
.crm-drawer__tools .crm-drawer__delete button:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.crm-drawer__tools .crm-drawer__edit:hover { background: rgba(22, 119, 255, 0.18); }
.crm-drawer__tools .crm-drawer__delete button:hover { background: rgba(194, 65, 12, 0.16); }

/* Подмена — свёрнута, пока не нужна */
details.crm-cover-box,
.crm-step,
.crm-mark-progress {
    flex-shrink: 0;
}

details.crm-cover-box {
    margin: 0 16px 16px;
    padding: 0;
    overflow: hidden;
    animation: sv-rise 0.45s 0.1s var(--sv-ease, ease) both;
}

.crm-cover-box__summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    list-style: none;
    transition: background-color 0.2s ease;
}

.crm-cover-box__summary::-webkit-details-marker {
    display: none;
}

.crm-cover-box__summary::after {
    content: "";
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    color: rgba(0, 0, 0, 0.4);
    transform: rotate(45deg);
    transition: transform 0.25s ease;
}

details[open] > .crm-cover-box__summary::after {
    transform: rotate(-135deg);
}

.crm-cover-box__summary:hover {
    background: rgba(15, 23, 42, 0.03);
}

.crm-cover-box__summary b {
    display: block;
    font-size: 13px;
}

.crm-cover-box__summary small {
    display: block;
    color: rgba(0, 0, 0, 0.5);
    font-size: 12px;
}

.crm-cover-box__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: #fff4d6;
    color: #b45309;
    font-weight: 800;
}

details.crm-cover-box > :not(summary) {
    margin-left: 12px;
    margin-right: 12px;
}

details.crm-cover-box > .crm-cover-form {
    padding-top: 4px;
}

details.crm-cover-box > .crm-drawer__hint {
    margin-top: 8px;
    margin-bottom: 12px;
}

details[open].crm-cover-box > :not(summary) {
    animation: sv-rise 0.3s var(--sv-ease, ease) both;
}

/* Шаги */
.crm-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 4px 16px 10px;
    animation: sv-rise 0.45s 0.15s var(--sv-ease, ease) both;
}

.crm-step__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    box-shadow: 0 6px 14px -6px rgba(91, 33, 182, 0.7);
}

.crm-step__num--sm {
    width: 22px;
    height: 22px;
    font-size: 12px;
}

.crm-step__title {
    margin: 2px 0 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: rgba(0, 0, 0, 0.88);
}

.crm-step__text {
    margin: 2px 0 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: rgba(0, 0, 0, 0.5);
}

.crm-drawer-add .crm-step {
    margin: 8px 0 12px;
}

/* Прогресс отметок */
.crm-mark-progress {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 16px 12px;
    padding: 10px 12px;
    border-radius: 14px;
    background: #f5f7ff;
    animation: sv-rise 0.45s 0.2s var(--sv-ease, ease) both;
}

.crm-mark-progress__bar {
    flex: 1 1 100%;
    height: 8px;
    border-radius: 999px;
    background: #e3e8f5;
    overflow: hidden;
}

.crm-mark-progress__bar i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    transition: width 0.5s var(--sv-ease, ease), background 0.3s ease;
}

.crm-mark-progress.is-full .crm-mark-progress__bar i {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.crm-mark-progress__text {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.6);
}

.crm-mark-progress__text b {
    color: rgba(0, 0, 0, 0.88);
}

.crm-mark-progress.is-full .crm-mark-progress__text {
    color: #15803d;
    font-weight: 600;
}

.crm-mark-progress__all {
    margin-left: auto;
    padding: 6px 12px;
    border: 0;
    border-radius: 999px;
    background: #22c55e;
    color: #fff;
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 14px -6px rgba(22, 163, 74, 0.8);
    transition: transform 0.2s var(--sv-spring, ease), background-color 0.2s ease;
}

.crm-mark-progress__all:hover {
    transform: translateY(-1px) scale(1.04);
    background: #16a34a;
}

.crm-mark-progress__all[hidden] {
    display: none;
}

/* Клиенты */
.crm-drawer-person {
    animation: sv-rise 0.45s var(--sv-ease, ease) both;
    transition: border-color 0.25s ease, background-color 0.3s ease, box-shadow 0.3s ease;
}

.crm-drawer-people > :nth-child(1) { animation-delay: 0.22s; }
.crm-drawer-people > :nth-child(2) { animation-delay: 0.27s; }
.crm-drawer-people > :nth-child(3) { animation-delay: 0.32s; }
.crm-drawer-people > :nth-child(4) { animation-delay: 0.37s; }
.crm-drawer-people > :nth-child(5) { animation-delay: 0.42s; }
.crm-drawer-people > :nth-child(n+6) { animation-delay: 0.46s; }

.crm-drawer-person.is-ok {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.07), #fff 70%);
}

.crm-drawer-person.is-miss {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.06), #fff 70%);
}

.crm-drawer-person__toggles {
    position: relative;
}

.crm-mark-btn {
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.crm-mark-btn:not(:disabled):active {
    transform: scale(0.96);
}

.crm-mark-btn.is-pop {
    animation: sv-mark-pop 0.42s var(--sv-spring, ease);
}

.crm-mark-btn.is-pop .crm-mark-btn__icon {
    animation: sv-icon-spin 0.45s var(--sv-spring, ease);
}

.crm-mark-btn.is-ok.is-on:not(.is-saved) {
    box-shadow: 0 6px 16px -8px rgba(34, 197, 94, 0.8);
}

.crm-mark-btn.is-miss.is-on:not(.is-saved) {
    box-shadow: 0 6px 16px -8px rgba(239, 68, 68, 0.8);
}

@keyframes sv-mark-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes sv-icon-spin {
    from { transform: scale(0.4) rotate(-90deg); }
    to { transform: none; }
}

@keyframes sv-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

/* Подсказка-«рука» у первого неотмеченного клиента */
.crm-coach {
    position: absolute;
    left: 25%;
    top: calc(100% + 10px);
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 10px 24px -8px rgba(17, 24, 39, 0.55);
    transform: translateX(-50%);
    animation: sv-coach-in 0.4s var(--sv-spring, ease) both, sv-coach-bob 1.8s 0.4s ease-in-out infinite;
}

.crm-coach::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 100%;
    margin-left: -6px;
    border: 6px solid transparent;
    border-bottom-color: #111827;
}

.crm-coach__hand {
    display: inline-block;
}

.crm-coach.is-leaving {
    animation: sv-coach-out 0.25s ease forwards;
}

.crm-drawer-person:has(.crm-coach) .crm-mark-btn.is-ok {
    animation: sv-ring-ok 1.8s ease-out infinite;
}

@keyframes sv-coach-in {
    from { opacity: 0; transform: translate(-50%, -8px) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes sv-coach-bob {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, 4px); }
}

@keyframes sv-coach-out {
    to { opacity: 0; transform: translate(-50%, 6px) scale(0.9); }
}

@keyframes sv-ring-ok {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
    70%, 100% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
}

/* Нижняя панель: шаг 2 — сохранить */
.crm-drawer__actions {
    flex-wrap: wrap;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid #eef0f4;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
}

.crm-save-hint {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 2px;
    font-size: 12.5px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.55);
    transition: color 0.2s ease;
}

.crm-save-hint.is-dirty {
    color: #4338ca;
}

.crm-save-hint.is-done {
    color: #15803d;
}

.crm-save-hint.is-done .crm-step__num {
    background: #22c55e;
    box-shadow: none;
}

.crm-save-hint.is-dirty .crm-step__num {
    animation: sv-ring-brand 1.6s ease-out infinite;
}

#attendance-save:not(:disabled) {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-color: transparent;
    box-shadow: 0 10px 22px -10px rgba(91, 33, 182, 0.8);
    animation: sv-save-glow 1.8s ease-in-out infinite;
}

@keyframes sv-save-glow {
    0%, 100% { box-shadow: 0 10px 22px -10px rgba(91, 33, 182, 0.8), 0 0 0 0 rgba(124, 58, 237, 0.35); }
    50% { box-shadow: 0 10px 22px -10px rgba(91, 33, 182, 0.8), 0 0 0 6px rgba(124, 58, 237, 0); }
}

@keyframes sv-ring-brand {
    0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.5); }
    70%, 100% { box-shadow: 0 0 0 8px rgba(124, 58, 237, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .crm-drawer,
    .crm-drawer-backdrop,
    .crm-drawer__meta,
    details.crm-cover-box,
    .crm-step,
    .crm-mark-progress,
    .crm-drawer-person,
    .crm-coach,
    .crm-mark-btn.is-pop,
    .crm-mark-btn.is-pop .crm-mark-btn__icon,
    .crm-drawer-person:has(.crm-coach) .crm-mark-btn.is-ok,
    .crm-save-hint .crm-step__num,
    #attendance-save:not(:disabled) {
        animation: none !important;
    }
}
