/* =============================================================================
   CRM, этап 1 — общий стиль страниц входа, регистрации и кабинета.
   Без внешних CDN и шрифтов: только системные шрифты (кириллица есть везде).
   ============================================================================= */

:root {
    --navy: #0f2747;
    --navy-soft: #16365c;
    --accent: #2f6feb;
    --accent-hover: #2459c4;
    --bg: #f2f5fa;
    --surface: #ffffff;
    --text: #1c2430;
    --muted: #65718a;
    --border: #d9e1ee;
    --border-focus: #2f6feb;
    --danger-bg: #fef3f2;
    --danger-border: #f5c6c2;
    --danger-text: #b42318;
    --success-bg: #ecfdf3;
    --success-border: #b7e4c7;
    --success-text: #067647;
    --radius: 14px;
    --shadow: 0 18px 45px rgba(15, 39, 71, .12);

    /* Палитра страницы входа (.login-*).
       Меняются здесь — и градиент панели, кнопка и ссылки подхватят новые цвета. */
    --brand-900: #0b1f3a;
    --brand-800: #142c5c;
    --brand-700: #1e3a8a;
    --brand-600: #362fc0;
    --brand-500: #4338ca;
    --brand-400: #4f46e5;
    --brand-300: #6366f1;
    --brand-tint: #eef2ff;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* -----------------------------------------------------------------------------
   Страницы входа / регистрации: карточка по центру
   -------------------------------------------------------------------------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
        radial-gradient(1100px 520px at 50% -10%, #1b3f6b 0%, #0f2747 48%, #0b1c33 100%);
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 36px 34px 28px;
}

.brand {
    margin-bottom: 24px;
    text-align: left;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    height: 46px;
    padding: 0 10px;
    border-radius: 11px;
    background: var(--navy);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
}

.brand-mark--small {
    min-width: 38px;
    height: 38px;
    font-size: 11px;
    border-radius: 9px;
}

.brand-title {
    margin: 16px 0 4px;
    font-size: 23px;
    line-height: 1.25;
    font-weight: 650;
    color: var(--navy);
}

.brand-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* -----------------------------------------------------------------------------
   Поля формы
   -------------------------------------------------------------------------- */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-soft);
}

.field input {
    width: 100%;
    padding: 11px 13px;
    font: inherit;
    color: var(--text);
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 9px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.field input::placeholder {
    color: #9aa6bb;
}

.field input:hover {
    border-color: #c3cfe1;
}

.field input:focus {
    outline: none;
    background: #fff;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(47, 111, 235, .16);
}

.field-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

/* -----------------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 18px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease, transform .05s ease;
}

.btn:hover {
    background: var(--accent-hover);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 111, 235, .3);
}

.btn:disabled {
    background: #9db4d8;
    cursor: not-allowed;
}

.btn-ghost {
    width: auto;
    padding: 8px 16px;
    color: #fff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .45);
    font-weight: 500;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, .12);
}

/* -----------------------------------------------------------------------------
   Сообщения
   -------------------------------------------------------------------------- */
.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 9px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert p {
    margin: 0;
}

.alert p + p {
    margin-top: 6px;
}

.alert-error {
    color: var(--danger-text);
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

.alert-success {
    color: var(--success-text);
    background: var(--success-bg);
    border-color: var(--success-border);
}

.auth-switch {
    margin: 22px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   Кабинет
   -------------------------------------------------------------------------- */
.app-page {
    background: var(--bg);
    min-height: 100vh;
}

.topbar {
    background: var(--navy);
    color: #fff;
}

.topbar-inner {
    max-width: 1040px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .01em;
}

.topbar-logout {
    margin-left: auto;
}

.app-main {
    max-width: 1040px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px 28px;
}

.panel-title {
    margin: 0 0 10px;
    font-size: 22px;
    color: var(--navy);
    font-weight: 650;
}

.panel-text {
    margin: 0 0 8px;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.role-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    background: #e8effc;
    color: #1f4fa8;
}

.role-badge--admin {
    background: #fdecec;
    color: #b42318;
}

.role-badge--moderator {
    background: #fff4e5;
    color: #a15c00;
}

.tiles {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.tile-title {
    margin: 0 0 6px;
    font-size: 16px;
    color: var(--navy);
    font-weight: 600;
}

.tile-text {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* -----------------------------------------------------------------------------
   Мобильные
   -------------------------------------------------------------------------- */
@media (max-width: 520px) {
    .auth-card {
        padding: 26px 20px 22px;
        border-radius: 12px;
    }

    .brand-title {
        font-size: 20px;
    }

    .panel {
        padding: 20px 18px;
    }

    .topbar-inner {
        padding: 12px 14px;
    }

    .topbar-title {
        font-size: 13px;
    }

    .app-main {
        padding: 20px 14px 40px;
    }
}

/* =============================================================================
   СТРАНИЦА ВХОДА (index.php) — двухколоночный макет.
   Все классы с префиксом .login- живут только здесь и не задевают
   register.php (.auth-page/.auth-card/.brand) и dashboard.php.
   Палитра — в :root (--brand-*), локальные поверхности — в .login-page.
   ============================================================================= */
.login-page {
    /* Светлая тема: поверхности и текст именно страницы входа */
    --login-bg: #f4f6fb;
    --login-surface: #ffffff;
    --login-text: #0f172a;
    --login-muted: #64748b;
    --login-border: #e2e8f0;
    --login-field-bg: #f8fafc;
    --login-field-text: #0f172a;
    --login-placeholder: #94a3b8;

    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    background: var(--login-bg);
    color: var(--login-text);
}

.login-shell {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 46%) minmax(0, 1fr);
    min-height: 0;
}

/* ------------------------------- Левая панель ------------------------------ */
.login-brand {
    position: relative;
    isolation: isolate;
    display: flex;
    overflow: hidden;
    color: #fff;
    /* Два больших полупрозрачных круга + тонкая сетка + базовый градиент.
       Всё средствами CSS, без единой внешней картинки. */
    background:
        radial-gradient(760px 760px at 88% -8%, rgba(129, 140, 248, .55), transparent 62%),
        radial-gradient(640px 640px at 0% 106%, rgba(56, 189, 248, .28), transparent 62%),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, .055) 0 1px, transparent 1px 58px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, .055) 0 1px, transparent 1px 58px),
        linear-gradient(155deg, var(--brand-900) 0%, var(--brand-700) 55%, var(--brand-500) 100%);
}

.login-brand__inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: clamp(32px, 4vw, 56px);
}

.login-brand__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 15px;
    font-size: 25px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    color: #fff;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .3);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 10px 24px -12px rgba(0, 0, 0, .55);
}

.login-brand__name {
    margin: 18px 0 0;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: #fff;
}

.login-brand__tagline {
    max-width: 32ch;
    margin: 8px 0 0;
    font-size: 15px;
    line-height: 1.55;
    color: rgba(226, 232, 240, .8);
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: auto 0;
    padding: 24px 0;
    list-style: none;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    line-height: 1.4;
    color: rgba(238, 242, 255, .94);
}

.login-feature__check {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    color: #c7d2fe;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
}

.login-feature__check svg {
    width: 14px;
    height: 14px;
}

.login-feature__text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.login-eye__show,
.login-eye__hide {
    display: block;
}

.login-brand__copyright {
    margin: 0;
    font-size: 12.5px;
    letter-spacing: .01em;
    color: rgba(203, 213, 225, .62);
}

/* ------------------------------- Правая колонка ---------------------------- */
.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: clamp(28px, 4vw, 56px) clamp(20px, 4vw, 48px);
    background: var(--login-surface);
}

.login-card {
    width: 100%;
    max-width: 420px;
    min-width: 0;
    animation: login-card-in .45s cubic-bezier(.2, .7, .3, 1) both;
}

.login-form {
    margin: 0;
}

.login-brand__head {
    flex: 0 0 auto;
}

.login-title {
    margin: 0;
    font-size: 27px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
    color: var(--login-text);
}

.login-subtitle {
    margin: 8px 0 26px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--login-muted);
}

/* ------------------------------- Сообщения --------------------------------- */
.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 20px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid transparent;
    border-left-width: 3px;
    border-radius: 12px;
    animation: login-alert-in .25s ease-out both;
}

.login-alert__body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: break-word;
}

.login-alert p {
    margin: 0;
}

.login-alert p + p {
    margin-top: 4px;
}

.login-alert__icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

.login-alert__icon svg {
    display: block;
    width: 18px;
    height: 18px;
}

.login-alert--error {
    color: #b42318;
    background: #fef3f2;
    border-color: #fecdc9;
    border-left-color: #ef4444;
}

.login-alert--warn {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
    border-left-color: #f59e0b;
}

.login-alert--success {
    color: #067647;
    background: #ecfdf3;
    border-color: #bbf7d0;
    border-left-color: #12b76a;
}

.login-alert--info {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
    border-left-color: #3b82f6;
}

/* --------------------------------- Поля ------------------------------------ */
.login-field {
    margin-bottom: 18px;
}

.login-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--login-text);
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

.login-field-icon {
    position: absolute;
    left: 15px;
    width: 18px;
    height: 18px;
    color: var(--login-placeholder);
    pointer-events: none;
    transition: color .15s ease;
}

.login-input {
    width: 100%;
    min-width: 0;
    height: 50px;
    padding: 0 14px 0 44px;
    font-family: inherit;
    font-size: 16px; /* 16px и больше: iOS не масштабирует страницу при фокусе */
    line-height: 1.2;
    color: var(--login-field-text);
    background: var(--login-field-bg);
    border: 1px solid var(--login-border);
    border-radius: 11px;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.login-input--password {
    padding-right: 52px;
}

.login-input::placeholder {
    color: var(--login-placeholder);
    opacity: 1;
}

.login-input:hover {
    border-color: #cbd5e1;
}

.login-input:focus {
    outline: none;
    background: var(--login-surface);
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .14);
}

.login-input-wrap:focus-within .login-field-icon {
    color: var(--brand-500);
}

/* Автозаполнение Chrome не должно заливать поле жёлтым */
.login-input:-webkit-autofill {
    -webkit-text-fill-color: var(--login-field-text);
    box-shadow: inset 0 0 0 100px var(--login-field-bg);
}

/* Кнопка-глазок */
.login-eye {
    position: absolute;
    top: 50%;
    right: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--login-muted);
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    transform: translateY(-50%);
    transition: color .15s ease, background-color .15s ease;
}

.login-eye:hover {
    color: var(--brand-500);
    background: rgba(79, 70, 229, .09);
}

.login-eye:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
}

.login-eye svg {
    width: 19px;
    height: 19px;
}

.login-eye svg[hidden] {
    display: none;
}

/* --------------------------------- Кнопка ---------------------------------- */
.login-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 52px;
    margin-top: 6px;
    padding: 0 20px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .01em;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 55%, var(--brand-400) 100%);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 12px 24px -10px rgba(67, 56, 202, .65), inset 0 1px 0 rgba(255, 255, 255, .18);
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.login-submit svg {
    width: 18px;
    height: 18px;
    transition: transform .18s ease;
}

.login-submit:hover {
    transform: translateY(-1px);
    filter: saturate(1.06);
    box-shadow: 0 18px 30px -12px rgba(67, 56, 202, .72), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.login-submit:hover svg {
    transform: translateX(2px);
}

.login-submit:active {
    transform: translateY(0) scale(.995);
    box-shadow: 0 6px 14px -8px rgba(67, 56, 202, .7);
}

.login-submit:focus-visible {
    outline: 3px solid rgba(99, 102, 241, .45);
    outline-offset: 3px;
}

.login-submit:disabled {
    opacity: .55;
    cursor: not-allowed;
    filter: grayscale(.2);
    transform: none;
    box-shadow: none;
}

/* --------------------------- Ссылки и подписи ------------------------------ */
.login-switch {
    margin: 22px 0 0;
    font-size: 14.5px;
    text-align: center;
    color: var(--login-muted);
}

.login-switch a {
    color: var(--brand-500);
    font-weight: 600;
    text-decoration: none;
}

.login-switch a:hover {
    text-decoration: underline;
}

.login-footnote {
    margin: 26px 0 0;
    font-size: 12px;
    letter-spacing: .02em;
    text-align: center;
    color: #94a3b8;
}

/* --------------------- Мобильная шапка (только <= 900px) ------------------- */
.login-mobilebar {
    display: none;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    height: 64px;
    padding: 0 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-700) 60%, var(--brand-500) 100%);
    box-shadow: 0 6px 18px -10px rgba(11, 31, 58, .8);
}

.login-mobilebar__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 16px;
    font-weight: 700;
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .26);
}

.login-mobilebar__name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
}

/* -------------------------------- Анимации --------------------------------- */
@keyframes login-card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes login-alert-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --------------------------- Планшет / мобильный --------------------------- */
@media (max-width: 900px) {
    .login-mobilebar {
        display: flex;
    }

    .login-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .login-brand {
        display: none;
    }

    .login-panel {
        align-items: flex-start;
        justify-content: center;
        padding: 32px 20px 40px;
        background: var(--login-bg);
    }

    .login-card {
        max-width: 440px;
        margin: 0 auto;
    }
}

@media (max-width: 420px) {
    .login-panel {
        padding: 24px 16px 32px;
    }

    .login-title {
        font-size: 26px;
    }

    .login-subtitle {
        margin-bottom: 22px;
        font-size: 14.5px;
    }

    .login-input {
        height: 52px;
    }
}

/* -------------------------------- Тёмная тема ------------------------------ */
@media (prefers-color-scheme: dark) {
    .login-page {
        --login-bg: #0b1220;
        --login-surface: #111827;
        --login-text: #e5e7eb;
        --login-muted: #94a3b8;
        --login-border: #273449;
        --login-field-bg: #0f1729;
        --login-field-text: #e5e7eb;
        --login-placeholder: #64748b;
    }

    .login-input:hover {
        border-color: #334155;
    }

    .login-input:focus {
        background: var(--login-field-bg);
    }

    .login-submit {
        box-shadow: 0 14px 28px -12px rgba(0, 0, 0, .75), inset 0 1px 0 rgba(255, 255, 255, .16);
    }

    .login-alert--error {
        color: #fca5a5;
        background: rgba(239, 68, 68, .1);
        border-color: rgba(239, 68, 68, .32);
        border-left-color: #ef4444;
    }

    .login-alert--warn {
        color: #fcd34d;
        background: rgba(245, 158, 11, .1);
        border-color: rgba(245, 158, 11, .32);
        border-left-color: #f59e0b;
    }

    .login-alert--success {
        color: #6ee7b7;
        background: rgba(16, 185, 129, .1);
        border-color: rgba(16, 185, 129, .32);
        border-left-color: #10b981;
    }

    .login-alert--info {
        color: #93c5fd;
        background: rgba(59, 130, 246, .1);
        border-color: rgba(59, 130, 246, .32);
        border-left-color: #3b82f6;
    }

    .login-switch a {
        color: #a5b4fc;
    }

    .login-footnote {
        color: #64748b;
    }
}

/* ------------------------- Уважение к настройкам ОС ------------------------ */
@media (prefers-reduced-motion: reduce) {
    .login-card,
    .login-alert {
        animation: none;
    }

    .login-input,
    .login-submit,
    .login-submit svg,
    .login-eye,
    .login-field-icon {
        transition: none;
    }
}

/* =============================================================================
   ЭТАП 2 — каркас кабинета (сайдбар + хедер), реестр клиентов, дашборд.
   Блок дописан в конец файла: правила этапа 1 (.login-*, .auth-*, .panel,
   .btn, .field и т.д.) не изменяются, только дополняются модификаторами.
   Палитра берётся из :root (--brand-*), поверхности — из локальных переменных.
   ============================================================================= */

:root {
    --sidebar-w: 264px;
    --header-h: 68px;

    --app-bg: #f4f6fb;
    --app-surface: #ffffff;
    --app-text: #1c2430;
    --app-muted: #65718a;
    --app-border: #e4eaf3;
    --app-line: #eef2f7;
    --app-hover: rgba(67, 56, 202, .04);
    --app-shadow: 0 10px 30px -18px rgba(15, 23, 42, .35);
}

.app-body {
    margin: 0;
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--app-text);
}

.icon {
    display: block;
    flex: 0 0 auto;
}

/* -----------------------------------------------------------------------------
   Сайдбар
   -------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 16px 14px 14px;
    overflow-y: auto;
    color: #cbd5e1;
    background:
        radial-gradient(420px 260px at 100% 0%, rgba(79, 70, 229, .38), transparent 70%),
        linear-gradient(180deg, #0b1f3a 0%, #101f3d 100%);
    border-right: 1px solid rgba(255, 255, 255, .08);
    transition: transform .22s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 6px 8px 18px;
    color: #fff;
    text-decoration: none;
}

.sidebar__brand:hover {
    color: #fff;
    text-decoration: none;
}

.sidebar__logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 11px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    box-shadow: 0 10px 20px -10px rgba(79, 70, 229, .9), inset 0 1px 0 rgba(255, 255, 255, .25);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
}

.sidebar__brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar__name {
    font-size: 14.5px;
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: -.01em;
}

.sidebar__sub {
    margin-top: 2px;
    font-size: 10px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}

.sidebar__nav {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__section-title {
    margin: 14px 10px 6px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}

.sidebar__link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    height: 42px;
    padding: 0 12px;
    border-radius: 10px;
    color: rgba(255, 255, 255, .82);
    font-size: 14px;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.sidebar a.sidebar__link:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
    text-decoration: none;
}

.sidebar__icon {
    display: inline-flex;
    color: rgba(255, 255, 255, .72);
}

.sidebar__label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.sidebar__link--active {
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-weight: 600;
}

.sidebar__link--active .sidebar__icon {
    color: #fff;
}

.sidebar__link--active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--brand-400);
}

.sidebar__link--disabled {
    opacity: .45;
    cursor: default;
}

.sidebar__soon {
    flex: 0 0 auto;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .09);
    color: rgba(255, 255, 255, .75);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: .02em;
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding: 12px 4px 2px;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.sidebar__user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.sidebar__user-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.sidebar__user-role {
    font-size: 11.5px;
    color: rgba(255, 255, 255, .55);
}

.sidebar__logout {
    margin: 0;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: rgba(255, 255, 255, .7);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, .1);
    color: #fff;
}

/* -----------------------------------------------------------------------------
   Аватары
   -------------------------------------------------------------------------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    user-select: none;
}

.avatar--brand {
    background: linear-gradient(135deg, #6366f1, #4338ca);
}

.avatar--sm {
    width: 32px;
    height: 32px;
    font-size: 11.5px;
}

/* -----------------------------------------------------------------------------
   Хедер
   -------------------------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-h);
    margin-left: var(--sidebar-w);
    padding: 0 32px;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--app-border);
}

.header__burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-left: -6px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--app-text);
    cursor: pointer;
}

.header__burger:hover {
    background: rgba(15, 23, 42, .06);
}

.header__titles {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.header__title {
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--app-text);
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.01em;
}

.header__crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    color: var(--app-muted);
    font-size: 11.5px;
}

.header__crumbs a {
    color: var(--app-muted);
    text-decoration: none;
}

.header__crumbs a:hover {
    color: var(--brand-500);
    text-decoration: none;
}

.header__crumb-sep {
    opacity: .6;
}

.header__right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.header__name {
    max-width: 190px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13.5px;
    font-weight: 600;
}

/* Выпадающее меню пользователя (нативный <details>, без JS) */
.user-menu {
    position: relative;
}

.user-menu__summary {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 4px 6px 4px 4px;
    border-radius: 999px;
    cursor: pointer;
    list-style: none;
    transition: background .15s ease;
}

.user-menu__summary::-webkit-details-marker {
    display: none;
}

.user-menu__summary:hover {
    background: #f1f5f9;
}

.user-menu__chevron {
    display: inline-flex;
    color: var(--app-muted);
    transition: transform .18s ease;
}

.user-menu[open] .user-menu__chevron {
    transform: rotate(180deg);
}

.user-menu__panel {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 40;
    min-width: 224px;
    padding: 8px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    box-shadow: 0 24px 50px -22px rgba(15, 23, 42, .5);
}

.user-menu__head {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
    padding: 10px 10px 12px;
    border-bottom: 1px solid var(--app-line);
}

.user-menu__name {
    font-size: 14px;
    font-weight: 650;
}

.user-menu__role {
    font-size: 12px;
    color: var(--app-muted);
}

.user-menu__form {
    margin: 0;
}

.user-menu__logout {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #b42318;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    transition: background .15s ease;
}

.user-menu__logout:hover {
    background: #fef2f2;
}

/* -----------------------------------------------------------------------------
   Основная область
   -------------------------------------------------------------------------- */
.app-body .app-main {
    max-width: none;
    min-height: calc(100vh - var(--header-h));
    margin: 0 0 0 var(--sidebar-w);
    padding: 26px 32px 56px;
}

.app-content {
    max-width: 1440px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-head__text {
    min-width: 0;
}

.page-title {
    margin: 0;
    color: var(--app-text);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
}

.page-subtitle {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0 0;
    color: var(--app-muted);
    font-size: 13.5px;
}

.page-subtitle strong {
    color: var(--app-text);
    font-weight: 650;
}

.page-subtitle__dot {
    opacity: .6;
}

/* -----------------------------------------------------------------------------
   Панель инструментов
   -------------------------------------------------------------------------- */
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.toolbar__search {
    position: relative;
    flex: 1 1 320px;
    min-width: 220px;
}

.toolbar__search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    display: flex;
    transform: translateY(-50%);
    color: var(--app-muted);
    pointer-events: none;
}

.toolbar__search input {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 42px;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 11px;
    font: inherit;
    font-size: 14.5px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.toolbar__search input::placeholder {
    color: #94a3b8;
}

.toolbar__search input:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, .12);
}

.toolbar__select select {
    height: 44px;
    min-width: 170px;
    padding: 0 12px;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 11px;
    font: inherit;
    font-size: 14.5px;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.toolbar__select select:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, .12);
}

.btn--auto {
    width: auto;
    height: 44px;
    padding: 0 18px;
    gap: 8px;
    border-radius: 11px;
    font-size: 14px;
}

.btn--outline {
    color: var(--app-text);
    background: var(--app-surface);
    border-color: var(--app-border);
}

.btn--outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* -----------------------------------------------------------------------------
   Таблица клиентов
   -------------------------------------------------------------------------- */
.table-card {
    overflow: hidden;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow);
}

.table-wrap {
    overflow: auto;
    max-height: min(72vh, 880px);
}

.data-table {
    width: 100%;
    min-width: 940px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--app-line);
    color: var(--app-muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .07em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--app-line);
    color: var(--app-text);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background .12s ease;
}

.data-table tbody tr:hover {
    background: var(--app-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.col-num {
    width: 52px;
    color: var(--app-muted);
    font-variant-numeric: tabular-nums;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    text-decoration: none;
}

.sort-link:hover {
    color: var(--brand-500);
    text-decoration: none;
}

.sort-link.is-active {
    color: var(--brand-500);
}

.sort-arrow {
    display: inline-flex;
}

.cell-person {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.cell-name {
    font-weight: 600;
}

.cell-date {
    white-space: nowrap;
}

.cell-age {
    color: var(--app-muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.cell-phone a {
    color: var(--app-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
    text-decoration: none;
}

.cell-phone a:hover {
    color: var(--brand-500);
    text-decoration: underline;
}

.country-chip {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--brand-tint);
    color: #3730a3;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.cell-address {
    max-width: 260px;
    color: var(--app-muted);
}

.cell-added {
    color: var(--app-muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.cell-empty {
    color: #a3aec2;
}

/* -----------------------------------------------------------------------------
   Пагинация
   -------------------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--app-line);
}

.pagination__info {
    color: var(--app-muted);
    font-size: 13px;
}

.pagination__pages {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--app-text);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.page-btn:hover {
    background: #f1f5f9;
    color: var(--app-text);
    text-decoration: none;
}

.page-btn--active {
    background: var(--brand-500);
    color: #fff;
    font-weight: 650;
    box-shadow: 0 6px 14px -6px rgba(67, 56, 202, .8);
}

.page-btn--active:hover {
    background: var(--brand-500);
    color: #fff;
}

.page-btn--arrow {
    color: var(--app-muted);
}

.page-btn.is-disabled {
    opacity: .35;
    pointer-events: none;
}

.page-ellipsis {
    padding: 0 4px;
    color: var(--app-muted);
}

/* -----------------------------------------------------------------------------
   Пустое состояние
   -------------------------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 24px;
    text-align: center;
}

.empty-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    border-radius: 16px;
    background: var(--brand-tint);
    color: var(--brand-500);
}

.empty-state__title {
    margin: 0 0 6px;
    color: var(--app-text);
    font-size: 17px;
    font-weight: 650;
}

.empty-state__text {
    max-width: 420px;
    margin: 0 0 16px;
    color: var(--app-muted);
    font-size: 13.5px;
}

.empty-state code {
    padding: 1px 5px;
    border-radius: 5px;
    background: #f1f5f9;
    color: #334155;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92em;
}

/* -----------------------------------------------------------------------------
   Метрики и панели дашборда
   -------------------------------------------------------------------------- */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 20px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow);
}

.metric-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin-bottom: 6px;
    border-radius: 11px;
    background: var(--brand-tint);
    color: var(--brand-500);
}

.metric-card__icon--indigo {
    background: var(--brand-tint);
    color: var(--brand-500);
}

.metric-card__icon--violet {
    background: #f3e8ff;
    color: #7e22ce;
}

.metric-card__icon--sky {
    background: #e0f2fe;
    color: #0369a1;
}

.metric-card__icon--green {
    background: #dcfce7;
    color: #15803d;
}

.metric-card__label {
    color: var(--app-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.metric-card__value {
    color: var(--app-text);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.02em;
}

.metric-card__value--text {
    font-size: 20px;
}

.metric-card__hint {
    color: var(--app-muted);
    font-size: 12.5px;
}

.panel-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 16px;
    padding: 22px 24px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow);
}

.panel-card__title {
    margin: 0 0 6px;
    color: var(--app-text);
    font-size: 16px;
    font-weight: 650;
}

.panel-card__head {
    flex: 1 1 320px;
    min-width: 0;
}

.panel-card__text {
    max-width: 640px;
    margin: 0;
    color: var(--app-muted);
    font-size: 13.5px;
}

.panel-card--muted {
    background: transparent;
    border-style: dashed;
    box-shadow: none;
}

/* -----------------------------------------------------------------------------
   Служебное
   -------------------------------------------------------------------------- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(8, 15, 30, .55);
}

/* -----------------------------------------------------------------------------
   Планшет и мобильные
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 30px 60px rgba(2, 8, 23, .45);
    }

    .app-header {
        height: 60px;
        margin-left: 0;
        padding: 0 16px;
        gap: 12px;
    }

    .header__burger {
        display: inline-flex;
    }

    .header__crumbs {
        display: none;
    }

    .header__name,
    .user-menu__chevron {
        display: none;
    }

    .app-body .app-main {
        margin-left: 0;
        padding: 18px 16px 40px;
    }

    .table-wrap {
        max-height: none;
    }

    .page-title {
        font-size: 23px;
    }
}

@media (max-width: 600px) {
    .app-body .app-main {
        padding: 16px 14px 36px;
    }

    .page-title {
        font-size: 21px;
    }

    .header__right .role-badge {
        display: none;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar__search {
        flex: 1 1 auto;
        min-width: 0;
    }

    .toolbar__select select {
        width: 100%;
    }

    .toolbar .btn {
        width: 100%;
    }

    .pagination {
        flex-direction: column;
        align-items: flex-start;
    }

    .pagination__pages {
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .panel-card {
        padding: 18px;
    }

    .data-table {
        min-width: 760px;
    }

    .col-added {
        display: none;
    }
}

/* -----------------------------------------------------------------------------
   Тёмная тема
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    .app-body {
        --app-bg: #0b1220;
        --app-surface: #111827;
        --app-text: #e5e7eb;
        --app-muted: #94a3b8;
        --app-border: #1f2b3d;
        --app-line: #1b2537;
        --app-hover: rgba(99, 102, 241, .1);
        --app-shadow: 0 10px 30px -18px rgba(0, 0, 0, .75);

        background: var(--app-bg);
        color: var(--app-text);
    }

    .app-header {
        background: rgba(17, 24, 39, .92);
    }

    .header__burger:hover {
        background: rgba(255, 255, 255, .08);
    }

    .user-menu__summary:hover {
        background: rgba(255, 255, 255, .07);
    }

    .user-menu__panel {
        background: #0f1729;
        border-color: #22304a;
    }

    .user-menu__logout {
        color: #fca5a5;
    }

    .user-menu__logout:hover {
        background: rgba(239, 68, 68, .12);
    }

    .toolbar__search input,
    .toolbar__select select {
        background: #0f1729;
        border-color: #253247;
        color: #e5e7eb;
    }

    .toolbar__search input::placeholder {
        color: #64748b;
    }

    .btn--outline {
        background: transparent;
        border-color: #253247;
        color: #e5e7eb;
    }

    .btn--outline:hover {
        background: rgba(255, 255, 255, .06);
        border-color: #334155;
    }

    .data-table thead th {
        background: #0f1729;
        color: #94a3b8;
    }

    .country-chip {
        background: rgba(99, 102, 241, .16);
        color: #a5b4fc;
    }

    .page-btn:hover {
        background: rgba(255, 255, 255, .07);
    }

    .cell-empty {
        color: #64748b;
    }

    .empty-state code {
        background: #0f1729;
        color: #cbd5e1;
    }

    .metric-card__icon--violet {
        background: rgba(168, 85, 247, .16);
        color: #c084fc;
    }

    .metric-card__icon,
    .metric-card__icon--indigo,
    .empty-state__icon {
        background: rgba(99, 102, 241, .16);
        color: #a5b4fc;
    }

    .metric-card__icon--sky {
        background: rgba(56, 189, 248, .14);
        color: #7dd3fc;
    }

    .metric-card__icon--green {
        background: rgba(34, 197, 94, .14);
        color: #86efac;
    }

    .role-badge {
        background: rgba(59, 130, 246, .18);
        color: #93c5fd;
    }

    .role-badge--admin {
        background: rgba(239, 68, 68, .16);
        color: #fca5a5;
    }

    .role-badge--moderator {
        background: rgba(245, 158, 11, .16);
        color: #fcd34d;
    }
}

/* -----------------------------------------------------------------------------
   Уважение к настройкам ОС
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .data-table tbody tr,
    .user-menu__chevron,
    .page-btn,
    .icon-btn,
    .sidebar__link,
    .user-menu__summary {
        transition: none;
    }
}


/* =============================================================================
   ЭТАП 3 — карточка клиента, вкладки, задачи и сделки, документы, SIP.
   Дописано в конец: правила этапов 1–2 выше не изменяются.
   Используются те же переменные --brand-* и --app-*.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Общие мелочи
   -------------------------------------------------------------------------- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--app-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.back-link:hover {
    color: var(--brand-500);
}

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.45;
}

.alert__icon {
    display: inline-flex;
    flex: 0 0 auto;
    margin-top: 1px;
}

.alert--success {
    color: var(--success-text);
    background: var(--success-bg);
    border-color: var(--success-border);
}

.alert--error {
    color: var(--danger-text);
    background: var(--danger-bg);
    border-color: var(--danger-border);
}

.alert--warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

.alert--info {
    color: var(--brand-700);
    background: var(--brand-tint);
    border-color: #c7d2fe;
}

.alert code {
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(15, 23, 42, .06);
    font-size: 12.5px;
}

.btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--app-muted);
    box-shadow: none;
}

.btn--ghost:hover {
    background: var(--app-hover);
    color: var(--app-text);
}

.is-disabled,
.btn.is-disabled {
    opacity: .55;
    cursor: default;
    pointer-events: none;
}

.soon-badge {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(100, 116, 139, .16);
    color: var(--app-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.req {
    color: var(--danger-text);
}

.cell-note {
    display: block;
    max-width: 360px;
    margin-top: 3px;
    overflow: hidden;
    color: var(--app-muted);
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-nowrap {
    white-space: nowrap;
}

.cell-link {
    color: inherit;
    text-decoration: none;
}

.cell-link:hover {
    color: var(--brand-500);
    text-decoration: underline;
}

.cell-date--overdue {
    color: var(--danger-text);
    font-weight: 650;
}

.row-done .cell-name {
    color: var(--app-muted);
    text-decoration: line-through;
}

.metric-card__value--sm {
    font-size: 20px;
    line-height: 1.3;
}

/* -----------------------------------------------------------------------------
   Метрики карточки
   -------------------------------------------------------------------------- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

a.metric-card {
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

a.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px -22px rgba(15, 23, 42, .45);
}

/* -----------------------------------------------------------------------------
   Шапка карточки клиента
   -------------------------------------------------------------------------- */
.client-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 18px;
    padding: 24px 26px;
    background:
        radial-gradient(700px 220px at 0% 0%, rgba(79, 70, 229, .12), transparent 70%),
        linear-gradient(135deg, var(--app-surface) 0%, rgba(67, 56, 202, .05) 100%);
    border: 1px solid var(--app-border);
    border-radius: 18px;
    box-shadow: var(--app-shadow);
}

.client-hero__main {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.client-hero__text {
    min-width: 0;
}

.avatar--xl {
    width: 68px;
    height: 68px;
    font-size: 23px;
    letter-spacing: .03em;
    box-shadow: 0 10px 24px -12px rgba(11, 31, 58, .55);
}

.client-hero__name {
    margin: 0;
    color: var(--app-text);
    font-size: 25px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
}

.client-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    color: var(--app-muted);
    font-size: 13.5px;
}

.client-meta__sep {
    opacity: .5;
}

.client-meta__phone {
    color: var(--brand-600);
    font-weight: 650;
    text-decoration: none;
}

.client-meta__phone:hover {
    text-decoration: underline;
}

.client-hero__address {
    margin: 8px 0 0;
    color: var(--app-muted);
    font-size: 13px;
}

.client-hero__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    max-width: 520px;
}

.client-hero__actions .btn {
    width: auto;
    padding: 10px 14px;
    font-size: 13.5px;
    white-space: nowrap;
}

.btn-phone {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-size: 14px;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 10px 22px -12px rgba(5, 150, 105, .8);
    transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
}

.btn-phone:hover {
    color: #fff;
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 14px 26px -12px rgba(5, 150, 105, .85);
}

.btn-phone:active {
    transform: translateY(0);
}

.btn-phone--disabled {
    background: #cbd5e1;
    color: #fff;
    box-shadow: none;
    cursor: not-allowed;
    filter: grayscale(.2);
}

.sip-hint {
    color: var(--app-muted);
    font-size: 12px;
    text-decoration: none;
}

a.sip-hint:hover {
    color: var(--brand-500);
    text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   Вкладки
   -------------------------------------------------------------------------- */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 18px;
    overflow-x: auto;
    border-bottom: 1px solid var(--app-border);
    scrollbar-width: thin;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 15px;
    border-bottom: 2px solid transparent;
    color: var(--app-muted);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.tab:hover {
    color: var(--app-text);
    background: var(--app-hover);
}

.tab--active {
    color: var(--brand-600);
    border-bottom-color: var(--brand-500);
}

.tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--brand-tint);
    color: var(--brand-600);
    font-size: 11px;
    font-weight: 700;
}

/* -----------------------------------------------------------------------------
   Заголовок карточки-таблицы и лента действий
   -------------------------------------------------------------------------- */
.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--app-line);
}

.card-head__title {
    margin: 0;
    color: var(--app-text);
    font-size: 16px;
    font-weight: 700;
}

.card-head__hint {
    margin: 0;
    color: var(--app-muted);
    font-size: 12.5px;
}

.activity-list {
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

.activity {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    border-bottom: 1px solid var(--app-line);
}

.activity:last-child {
    border-bottom: 0;
}

.activity__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--brand-tint);
    color: var(--brand-500);
}

.activity__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.activity__title {
    overflow: hidden;
    color: var(--app-text);
    font-size: 13.5px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity__meta {
    color: var(--app-muted);
    font-size: 12px;
}

.activity__date {
    margin-left: auto;
    color: var(--app-muted);
    font-size: 12px;
    white-space: nowrap;
    text-decoration: none;
}

.activity__date:hover {
    color: var(--brand-500);
}

/* -----------------------------------------------------------------------------
   Раскрывающиеся формы (details)
   -------------------------------------------------------------------------- */
.drawer {
    margin-bottom: 16px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow);
}

.drawer__summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    color: var(--brand-600);
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
}

.drawer__summary::-webkit-details-marker {
    display: none;
}

.drawer__summary::-moz-list-bullet {
    list-style: none;
}

.drawer__summary:hover {
    background: var(--app-hover);
    border-radius: 14px;
}

.drawer[open] .drawer__summary {
    border-bottom: 1px solid var(--app-line);
    border-radius: 14px 14px 0 0;
}

.drawer__body {
    padding: 18px 18px 20px;
}

/* -----------------------------------------------------------------------------
   Формы: сетка, поля, ошибки
   -------------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}

.form-grid .field {
    margin-bottom: 0;
}

.field--wide {
    grid-column: 1 / -1;
}

.field select,
.field textarea {
    width: 100%;
    padding: 11px 13px;
    font: inherit;
    color: var(--text);
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 9px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.field textarea {
    min-height: 84px;
    resize: vertical;
}

.field select:focus,
.field textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(47, 111, 235, .16);
}

.field--error input,
.field--error select,
.field--error textarea {
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

.field__error {
    display: block;
    margin-top: 5px;
    color: var(--danger-text);
    font-size: 12px;
}

.field__hint {
    display: block;
    margin-top: 5px;
    color: var(--app-muted);
    font-size: 12px;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    grid-column: 1 / -1;
    padding-top: 2px;
}

.form-actions .btn {
    width: auto;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 2px 0;
    color: var(--app-text);
    font-size: 13.5px;
    cursor: pointer;
}

.checkbox input {
    width: 17px;
    height: 17px;
    margin: 2px 0 0;
    accent-color: var(--brand-500);
}

/* -----------------------------------------------------------------------------
   Бейджи приоритетов и статусов
   -------------------------------------------------------------------------- */
.badge-priority,
.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-priority--low {
    background: #f1f5f9;
    color: #475569;
}

.badge-priority--normal {
    background: #e0edff;
    color: #1d4ed8;
}

.badge-priority--high {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-status--new {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-status--progress {
    background: #fef3c7;
    color: #92400e;
}

.badge-status--won {
    background: #dcfce7;
    color: #15803d;
}

.badge-status--lost {
    background: #e2e8f0;
    color: #475569;
}

.badge-status--open {
    background: #e0edff;
    color: #1d4ed8;
}

.badge-status--done {
    background: #dcfce7;
    color: #15803d;
}

/* -----------------------------------------------------------------------------
   Таблицы: действия в строке, деньги, иконки файлов
   -------------------------------------------------------------------------- */
.table-actions,
.col-actions {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.inline-form select {
    width: auto;
    padding: 6px 9px;
    font: inherit;
    font-size: 12.5px;
    color: var(--text);
    background: var(--app-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.btn-link {
    padding: 2px;
    border: 0;
    background: none;
    color: var(--brand-600);
    font: inherit;
    font-size: 12.5px;
    font-weight: 650;
    cursor: pointer;
}

.btn-link:hover {
    color: var(--brand-500);
    text-decoration: underline;
}

.col-money,
.cell-money {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-money {
    font-weight: 650;
}

.col-icon {
    width: 42px;
    text-align: center;
}

.file-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #f1f5f9;
    color: #475569;
}

.file-icon--pdf {
    background: #fee2e2;
    color: #b91c1c;
}

.file-icon--doc {
    background: #dbeafe;
    color: #1d4ed8;
}

.file-icon--xls {
    background: #dcfce7;
    color: #15803d;
}

.file-icon--img {
    background: #f3e8ff;
    color: #7e22ce;
}

.file-icon--zip {
    background: #fef3c7;
    color: #92400e;
}

.file-icon--txt {
    background: #f1f5f9;
    color: #475569;
}

.doc-link {
    color: var(--brand-600);
    font-size: 13.5px;
    font-weight: 650;
    text-decoration: none;
}

.doc-link:hover {
    text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   Документы: фильтры и зона загрузки
   -------------------------------------------------------------------------- */
.doc-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow);
}

.doc-filters .toolbar__search,
.doc-filters .toolbar__select {
    flex: 1 1 190px;
}

.doc-filters__date {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--app-muted);
    font-size: 12.5px;
}

.doc-filters__date input {
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.upload-dropzone {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 14px;
    margin: 18px 20px 20px;
    padding: 18px;
    border: 1.5px dashed #c7d2fe;
    border-radius: 12px;
    background: rgba(67, 56, 202, .03);
}

.upload-dropzone__field {
    flex: 1 1 220px;
    min-width: 0;
}

.upload-dropzone__field label {
    display: block;
    margin-bottom: 6px;
    color: var(--navy-soft);
    font-size: 12.5px;
    font-weight: 600;
}

.upload-dropzone__field input[type="file"] {
    width: 100%;
    padding: 9px 11px;
    font: inherit;
    font-size: 13px;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.upload-dropzone__field select {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: 13.5px;
    color: var(--text);
    background: var(--app-surface);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.upload-dropzone .btn {
    width: auto;
}

/* -----------------------------------------------------------------------------
   Настройки SIP
   -------------------------------------------------------------------------- */
.sip-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.sip-card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow);
}

.sip-form {
    padding: 18px 20px 20px;
}

.sip-card--info {
    padding-bottom: 18px;
}

.sip-steps {
    margin: 0;
    padding: 14px 20px 0 38px;
    color: var(--app-text);
    font-size: 13.5px;
    line-height: 1.55;
}

.sip-steps li {
    margin-bottom: 10px;
    padding-left: 2px;
}

.sip-steps li::marker {
    color: var(--brand-500);
    font-weight: 700;
}

.sip-card--info .sip-hint {
    display: block;
    padding: 12px 20px 0;
}

/* -----------------------------------------------------------------------------
   Телефон в таблице клиентов
   -------------------------------------------------------------------------- */
.phone-cell {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.phone-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--app-border);
    border-radius: 50%;
    color: var(--brand-500);
    background: var(--app-surface);
    text-decoration: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.phone-btn:hover {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
}

/* -----------------------------------------------------------------------------
   Таблицы на узких экранах
   -------------------------------------------------------------------------- */
.table-card .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* -----------------------------------------------------------------------------
   Тёмная тема
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    .client-hero {
        background:
            radial-gradient(700px 220px at 0% 0%, rgba(99, 102, 241, .18), transparent 70%),
            linear-gradient(135deg, #111a2b 0%, #151d33 100%);
    }

    .avatar--xl {
        box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .7);
    }

    .tabs {
        border-bottom-color: #263148;
    }

    .tab:hover {
        background: rgba(255, 255, 255, .04);
    }

    .tab__count {
        background: rgba(99, 102, 241, .2);
        color: #c7d2fe;
    }

    .activity__icon {
        background: rgba(99, 102, 241, .18);
        color: #a5b4fc;
    }

    .drawer__summary:hover {
        background: rgba(255, 255, 255, .04);
    }

    .field select,
    .field textarea,
    .doc-filters__date input {
        color: #e2e8f0;
        background: #0f1729;
        border-color: #2b3750;
    }

    .field select:focus,
    .field textarea:focus {
        background: #111c30;
    }

    .inline-form select,
    .upload-dropzone__field input[type="file"],
    .upload-dropzone__field select {
        color: #e2e8f0;
        background: #0f1729;
        border-color: #2b3750;
    }

    .upload-dropzone {
        background: rgba(99, 102, 241, .08);
        border-color: #3b4a6b;
    }

    .upload-dropzone__field label {
        color: #cbd5e1;
    }

    .phone-btn {
        background: #131d31;
        border-color: #2b3750;
        color: #a5b4fc;
    }

    .badge-priority--low,
    .badge-status--lost,
    .file-icon,
    .file-icon--txt {
        background: rgba(148, 163, 184, .18);
        color: #cbd5e1;
    }

    .badge-priority--normal,
    .badge-status--new,
    .badge-status--open {
        background: rgba(59, 130, 246, .18);
        color: #93c5fd;
    }

    .badge-priority--high {
        background: rgba(239, 68, 68, .18);
        color: #fca5a5;
    }

    .badge-status--progress {
        background: rgba(245, 158, 11, .18);
        color: #fcd34d;
    }

    .badge-status--won,
    .badge-status--done {
        background: rgba(34, 197, 94, .18);
        color: #86efac;
    }

    .file-icon--pdf {
        background: rgba(239, 68, 68, .16);
        color: #fca5a5;
    }

    .file-icon--doc {
        background: rgba(59, 130, 246, .18);
        color: #93c5fd;
    }

    .file-icon--xls {
        background: rgba(34, 197, 94, .16);
        color: #86efac;
    }

    .file-icon--img {
        background: rgba(168, 85, 247, .16);
        color: #c084fc;
    }

    .file-icon--zip {
        background: rgba(245, 158, 11, .16);
        color: #fcd34d;
    }

    .alert--warning {
        color: #fcd34d;
        background: rgba(245, 158, 11, .12);
        border-color: rgba(245, 158, 11, .32);
    }

    .alert--info {
        color: #c7d2fe;
        background: rgba(99, 102, 241, .12);
        border-color: rgba(99, 102, 241, .3);
    }

    .alert--success {
        color: #86efac;
        background: rgba(34, 197, 94, .12);
        border-color: rgba(34, 197, 94, .3);
    }

    .alert--error {
        color: #fca5a5;
        background: rgba(239, 68, 68, .12);
        border-color: rgba(239, 68, 68, .3);
    }

    .alert code {
        background: rgba(255, 255, 255, .08);
        color: #cbd5e1;
    }

    .soon-badge {
        background: rgba(148, 163, 184, .2);
        color: #cbd5e1;
    }

    .btn-phone--disabled {
        background: #334155;
    }
}

/* -----------------------------------------------------------------------------
   Адаптивность карточки
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .client-hero {
        flex-direction: column;
        align-items: stretch;
        padding: 20px;
    }

    .client-hero__actions {
        justify-content: flex-start;
        max-width: none;
    }

    .client-hero__actions .btn,
    .client-hero__actions .btn-phone {
        flex: 1 1 auto;
        justify-content: center;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .sip-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .doc-filters .toolbar__search,
    .doc-filters .toolbar__select {
        flex: 1 1 100%;
    }

    .upload-dropzone {
        align-items: stretch;
    }

    .upload-dropzone .btn {
        width: 100%;
    }

    .card-head {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .metrics-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .client-hero {
        gap: 16px;
    }

    .client-hero__main {
        align-items: flex-start;
    }

    .avatar--xl {
        width: 54px;
        height: 54px;
        font-size: 18px;
    }

    .client-hero__name {
        font-size: 21px;
    }

    .client-hero__actions .btn,
    .client-hero__actions .btn-phone {
        flex: 1 1 100%;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .btn {
        width: 100%;
    }

    .doc-filters__date {
        flex: 1 1 100%;
    }

    .doc-filters__date input {
        flex: 1;
    }

    .activity {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .activity__date {
        margin-left: 44px;
    }

    .upload-dropzone {
        margin: 14px 14px 16px;
    }
}

/* -----------------------------------------------------------------------------
   Уважение к настройкам ОС
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .btn-phone,
    .tab,
    .metric-card,
    a.metric-card,
    .phone-btn {
        transition: none;
    }

    a.metric-card:hover,
    .btn-phone:hover {
        transform: none;
    }
}

/* Мелочь этапа 3: элементы строки метаданных в шапке карточки */
.client-meta__item {
    white-space: nowrap;
}

/* =============================================================================
   ЭТАП 4 — звонки из CRM: плавающее окно вызова и история вызовов.
   Блок дописан в конец файла. Правила этапов 1–3 не изменяются: используются
   те же переменные (--brand-*, --app-*), поэтому тёмная тема и мобильная
   вёрстка подхватываются автоматически.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Индикатор режима звонков в настройках
   -------------------------------------------------------------------------- */
.sip-mode {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 10px 0 4px;
    padding: 10px 12px;
    border: 1px dashed var(--app-border);
    border-radius: 12px;
    background: var(--app-bg);
}

.sip-mode__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--app-muted);
    font-size: 13px;
    font-weight: 700;
}

.sip-mode--ready {
    border-style: solid;
    border-color: rgba(22, 163, 74, .35);
    background: rgba(22, 163, 74, .08);
}

.sip-mode--ready .sip-mode__badge {
    color: #15803d;
}

.sip-mode__hint {
    color: var(--app-muted);
    font-size: 12px;
    line-height: 1.4;
}

.sip-subtitle {
    margin: 16px 0 6px;
    color: var(--app-text);
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .01em;
}

/* -----------------------------------------------------------------------------
   Плавающее окно звонка
   -------------------------------------------------------------------------- */
.call-widget {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 900;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 18px;
    box-shadow: 0 24px 60px -22px rgba(15, 23, 42, .55);
    overflow: hidden;
    animation: call-slide-up .28s cubic-bezier(.22, .9, .34, 1);
    color: var(--app-text);
}

.call-widget[hidden] {
    display: none;
}

@keyframes call-slide-up {
    from {
        opacity: 0;
        transform: translateY(18px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.call-widget__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 14px;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 58%, var(--brand-400) 100%);
    color: #fff;
}

.call-widget__avatar-wrap {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
}

.call-widget__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .32);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .02em;
}

/* Пульсирующее кольцо вокруг аватара — только для входящего звонка */
.call-pulse {
    position: absolute;
    inset: -6px;
    display: none;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .75);
    animation: call-pulse 1.6s ease-out infinite;
}

.call-widget--incoming .call-pulse {
    display: block;
}

@keyframes call-pulse {
    0% {
        opacity: .9;
        transform: scale(.86);
    }
    70% {
        opacity: 0;
        transform: scale(1.35);
    }
    100% {
        opacity: 0;
        transform: scale(1.35);
    }
}

.call-widget__who {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.call-widget__name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.call-widget__phone {
    color: rgba(255, 255, 255, .82);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

.call-widget__min {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease;
}

.call-widget__min:hover {
    background: rgba(255, 255, 255, .26);
}

.call-widget__min:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Плашка демо-режима */
.call-note-demo {
    padding: 7px 14px;
    background: #fef3c7;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    font-size: 11.5px;
    font-weight: 600;
    text-align: center;
}

.call-note-demo[hidden] {
    display: none;
}

.call-widget__body {
    padding: 16px 16px 18px;
    text-align: center;
}

.call-widget__status {
    min-height: 20px;
    color: var(--app-muted);
    font-size: 13.5px;
    font-weight: 600;
}

.call-widget__timer {
    margin-top: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 38px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.call-widget__error {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 12.5px;
    font-weight: 600;
}

.call-widget__error[hidden] {
    display: none;
}

/* -----------------------------------------------------------------------------
   Кнопки управления
   -------------------------------------------------------------------------- */
.call-controls {
    display: grid;
    grid-template-columns: repeat(4, 56px);
    justify-content: center;
    column-gap: 14px;
    row-gap: 28px;
    margin-top: 18px;
}

.call-controls[hidden] {
    display: none;
}

.call-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--app-bg);
    color: var(--app-text);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.call-btn:hover {
    transform: translateY(-1px);
}

.call-btn:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
}

.call-btn__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.call-btn__icon svg {
    display: block;
}

/* Подпись под круглой кнопкой, чтобы не сжимать саму кнопку */
.call-btn__label {
    position: absolute;
    top: calc(100% + 5px);
    left: 50%;
    width: 82px;
    transform: translateX(-50%);
    color: var(--app-muted);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
    pointer-events: none;
}

.call-btn--mute {
    background: #eef2ff;
    color: #3730a3;
}

.call-btn--hold {
    background: #fef3c7;
    color: #92400e;
}

.call-btn--keypad {
    background: #e0f2fe;
    color: #075985;
}

.call-btn--volume {
    background: #f1f5f9;
    color: #334155;
}

/* Включённое состояние: микрофон выключен, удержание, открытая панель */
.call-btn.is-active {
    background: var(--brand-500);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(67, 56, 202, .18);
}

.call-btn--hold.is-active {
    background: #d97706;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, .22);
}

.call-btn--hangup {
    grid-column: 1 / -1;
    justify-self: center;
    width: 64px;
    height: 64px;
    background: #dc2626;
    color: #fff;
    box-shadow: 0 10px 22px -10px rgba(220, 38, 38, .8);
}

.call-btn--hangup:hover {
    background: #b91c1c;
}

.call-btn--answer {
    background: #16a34a;
    color: #fff;
    box-shadow: 0 10px 22px -10px rgba(22, 163, 74, .8);
}

.call-btn--close {
    grid-column: 1 / -1;
    justify-self: center;
    background: var(--app-bg);
    color: var(--app-muted);
}

.call-controls--incoming {
    grid-template-columns: repeat(2, 64px);
    column-gap: 28px;
    row-gap: 30px;
}

.call-controls--incoming .call-btn {
    width: 64px;
    height: 64px;
}

.call-controls--ended {
    grid-template-columns: 56px;
    margin-top: 12px;
}

/* -----------------------------------------------------------------------------
   Клавиатура DTMF
   -------------------------------------------------------------------------- */
.call-keypad {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    background: var(--app-bg);
}

.call-keypad[hidden] {
    display: none;
}

.call-keypad__display {
    min-height: 26px;
    margin-bottom: 10px;
    color: var(--app-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 18px;
    letter-spacing: .16em;
    word-break: break-all;
}

.call-keypad__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.call-keypad__key {
    height: 44px;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: var(--app-surface);
    color: var(--app-text);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s ease, transform .12s ease;
}

.call-keypad__key:hover {
    background: var(--app-hover);
}

.call-keypad__key:active {
    transform: scale(.95);
}

.call-keypad__key:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 1px;
}

.call-keypad__close {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 5px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--app-muted);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
}

.call-keypad__close:hover {
    background: var(--app-hover);
    color: var(--app-text);
}

/* -----------------------------------------------------------------------------
   Громкость
   -------------------------------------------------------------------------- */
.call-volume {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 10px 12px;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: var(--app-bg);
}

.call-volume[hidden] {
    display: none;
}

.call-volume__label {
    color: var(--app-muted);
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

.call-volume input[type="range"] {
    flex: 1 1 auto;
    accent-color: var(--brand-500);
}

.call-volume__value {
    min-width: 38px;
    color: var(--app-text);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* -----------------------------------------------------------------------------
   Свёрнутое окно
   -------------------------------------------------------------------------- */
.call-collapsed {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
}

.call-collapsed[hidden] {
    display: none;
}

.call-collapsed__status {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--app-muted);
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.call-collapsed .call-widget__timer {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.call-collapsed__expand {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    color: var(--app-text);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
}

.call-collapsed__expand:hover {
    background: var(--app-hover);
}

.call-widget--minimized {
    width: 268px;
}

.call-widget--minimized .call-widget__header {
    padding: 10px 12px;
}

.call-widget--minimized .call-widget__avatar-wrap,
.call-widget--minimized .call-widget__avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

/* Плашка «Сохранено в историю» */
.call-toast {
    padding: 9px 14px;
    border-top: 1px solid rgba(22, 163, 74, .25);
    background: rgba(22, 163, 74, .1);
    color: #15803d;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.call-toast[hidden] {
    display: none;
}

/* -----------------------------------------------------------------------------
   История вызовов
   -------------------------------------------------------------------------- */
.toolbar--calls .toolbar__search {
    flex: 1 1 220px;
}

.toolbar__date {
    display: inline-flex;
    align-items: center;
}

.toolbar__date input[type="date"] {
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    background: var(--app-surface);
    color: var(--app-text);
    font: inherit;
    font-size: 13px;
}

.toolbar__date input[type="date"]:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, .12);
}

.calls-table .cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.call-number {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.call-dir {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.call-dir--out {
    color: #1d4ed8;
}

.call-dir--in {
    color: #15803d;
}

.badge-call-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-call-status--completed {
    background: #dcfce7;
    color: #15803d;
}

.badge-call-status--no_answer {
    background: #f1f5f9;
    color: #475569;
}

.badge-call-status--busy {
    background: #fef3c7;
    color: #92400e;
}

.badge-call-status--failed {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-call-status--canceled {
    background: #f8fafc;
    color: #64748b;
}

.call-retry-btn {
    padding: 5px 10px;
    font-size: 11.5px;
    white-space: nowrap;
}

/* -----------------------------------------------------------------------------
   Тёмная тема
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    .sip-mode {
        background: #0f1729;
        border-color: #253247;
    }

    .sip-mode--ready {
        background: rgba(22, 163, 74, .14);
        border-color: rgba(22, 163, 74, .4);
    }

    .sip-mode--ready .sip-mode__badge {
        color: #4ade80;
    }

    .call-widget {
        border-color: #253247;
        box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8);
    }

    .call-note-demo {
        background: rgba(217, 119, 6, .18);
        border-bottom-color: rgba(217, 119, 6, .35);
        color: #fbbf24;
    }

    .call-btn {
        background: #172033;
        color: #e2e8f0;
    }

    .call-btn--mute {
        background: rgba(99, 102, 241, .18);
        color: #c7d2fe;
    }

    .call-btn--hold {
        background: rgba(217, 119, 6, .2);
        color: #fcd34d;
    }

    .call-btn--keypad {
        background: rgba(14, 165, 233, .18);
        color: #7dd3fc;
    }

    .call-btn--volume {
        background: #1c2740;
        color: #cbd5e1;
    }

    .call-btn.is-active {
        background: var(--brand-400);
        color: #fff;
    }

    .call-btn--hold.is-active {
        background: #d97706;
    }

    .call-keypad,
    .call-volume {
        background: #0d1526;
        border-color: #253247;
    }

    .call-keypad__key {
        background: #16213a;
        border-color: #2a3852;
        color: #e5e7eb;
    }

    .call-keypad__key:hover {
        background: #1d2a45;
    }

    .call-widget__error {
        background: rgba(220, 38, 38, .16);
        border-color: rgba(220, 38, 38, .35);
        color: #fca5a5;
    }

    .call-toast {
        background: rgba(22, 163, 74, .14);
        border-top-color: rgba(22, 163, 74, .3);
        color: #4ade80;
    }

    .badge-call-status--completed {
        background: rgba(22, 163, 74, .18);
        color: #4ade80;
    }

    .badge-call-status--no_answer {
        background: rgba(148, 163, 184, .16);
        color: #cbd5e1;
    }

    .badge-call-status--busy {
        background: rgba(217, 119, 6, .2);
        color: #fcd34d;
    }

    .badge-call-status--failed {
        background: rgba(220, 38, 38, .2);
        color: #fca5a5;
    }

    .badge-call-status--canceled {
        background: rgba(148, 163, 184, .12);
        color: #94a3b8;
    }

    .call-dir--out {
        color: #93c5fd;
    }

    .call-dir--in {
        color: #86efac;
    }

    .toolbar__date input[type="date"] {
        background: #0f1729;
        border-color: #253247;
        color: #e5e7eb;
        color-scheme: dark;
    }
}

/* -----------------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .call-widget {
        right: 16px;
        bottom: 16px;
        width: 320px;
    }

    .toolbar--calls .toolbar__search {
        flex-basis: 100%;
    }
}

@media (max-width: 600px) {
    .call-widget {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-width: none;
        border-radius: 18px 18px 0 0;
        border-bottom: 0;
        max-height: 92vh;
        overflow-y: auto;
    }

    .call-widget--minimized {
        right: 12px;
        bottom: 12px;
        left: auto;
        width: calc(100vw - 24px);
        border-radius: 16px;
    }

    .call-controls {
        grid-template-columns: repeat(4, 60px);
        column-gap: 12px;
        row-gap: 30px;
    }

    .call-btn {
        width: 60px;
        height: 60px;
    }

    .call-btn--hangup {
        width: 68px;
        height: 68px;
    }

    .call-controls--incoming {
        grid-template-columns: repeat(2, 68px);
        column-gap: 32px;
    }

    .call-controls--incoming .call-btn {
        width: 68px;
        height: 68px;
    }

    .call-btn__label {
        width: 76px;
        font-size: 10.5px;
    }

    .call-widget__timer {
        font-size: 34px;
    }

    .toolbar__date {
        flex: 1 1 46%;
    }

    .toolbar__date input[type="date"] {
        width: 100%;
    }

    .calls-table .call-retry-btn span {
        display: none;
    }
}

/* -----------------------------------------------------------------------------
   Уважение к настройкам ОС: без анимаций
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .call-widget {
        animation: none;
    }

    .call-pulse {
        display: none !important;
        animation: none;
    }

    .call-btn,
    .call-keypad__key {
        transition: none;
    }

    .call-btn:hover {
        transform: none;
    }
}

/* Кнопки звонка стали <button> вместо <a>: возвращаем им поведение ссылки */
button.btn-phone,
button.phone-btn {
    font-family: inherit;
    cursor: pointer;
}

button.phone-btn {
    padding: 0;
}

/* Состояния окна звонка */
.call-widget--visible {
    display: block;
}

.call-widget--ended .call-widget__timer {
    color: var(--app-muted);
}

.call-widget--ended .call-widget__status {
    color: var(--app-text);
    font-weight: 700;
}

/* Входящий звонок: «Ответить» и «Отклонить» стоят в один ряд */
.call-controls--incoming .call-btn--hangup {
    grid-column: auto;
    justify-self: center;
    width: 64px;
    height: 64px;
}

.call-collapsed__history {
    color: var(--brand-500);
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.call-collapsed__history:hover {
    text-decoration: underline;
}

/* -----------------------------------------------------------------------------
   История вызовов: плашка клиента, вкладка «Звонки» в карточке
   -------------------------------------------------------------------------- */
.calls-client-note {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 11px 16px;
    border: 1px solid var(--app-border);
    border-left: 3px solid var(--brand-500);
    border-radius: 12px;
    background: var(--brand-tint);
    color: var(--app-text);
    font-size: 13.5px;
}

.calls-client-note__icon {
    display: inline-flex;
    color: var(--brand-500);
}

.calls-client-note__text {
    min-width: 0;
}

.calls-client-note__link {
    margin-left: auto;
    color: var(--brand-600);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.calls-client-note__link:hover {
    text-decoration: underline;
}

.calls-tab-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.calls-tab-head__text {
    min-width: 0;
}

.calls-tab-head__title {
    margin: 0;
    color: var(--app-text);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.calls-tab-head__hint {
    margin: 4px 0 0;
    color: var(--app-muted);
    font-size: 12.5px;
}

.calls-tab-head__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Компактные метрики внутри вкладки */
.tab-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.tab-metric {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 13px 15px;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
}

.tab-metric__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-bottom: 3px;
    border-radius: 8px;
    background: var(--brand-tint);
    color: var(--brand-600);
}

.tab-metric__icon--indigo {
    background: rgba(67, 56, 202, .12);
    color: var(--brand-600);
}

.tab-metric__icon--sky {
    background: rgba(14, 165, 233, .12);
    color: #0369a1;
}

.tab-metric__icon--green {
    background: rgba(22, 163, 74, .12);
    color: #15803d;
}

.tab-metric__icon--violet {
    background: rgba(139, 92, 246, .12);
    color: #6d28d9;
}

.tab-metric__label {
    color: var(--app-muted);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tab-metric__value {
    color: var(--app-text);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.tab-metric__value--sm {
    font-size: 15px;
    line-height: 1.35;
}

.tab-metric__hint {
    color: var(--app-muted);
    font-size: 11.5px;
}

/* Фильтры внутри вкладки звонков */
.calls-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    background: var(--app-surface);
}

.calls-filters__date {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--app-muted);
    font-size: 12.5px;
}

.calls-filters__date input[type="date"] {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    background: var(--app-surface);
    color: var(--app-text);
    font: inherit;
    font-size: 13px;
}

.calls-filters__date input[type="date"]:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, .12);
}

/* Компактная таблица звонков в карточке */
.calls-table--compact th,
.calls-table--compact td {
    padding-top: 9px;
    padding-bottom: 9px;
    font-size: 12.5px;
}

.calls-table--compact .call-retry-btn {
    font-size: 11px;
}

.badge-call-status--unknown {
    background: #f1f5f9;
    color: #475569;
}

@media (prefers-color-scheme: dark) {
    .calls-client-note {
        background: rgba(99, 102, 241, .14);
        border-color: #253247;
        border-left-color: var(--brand-400);
        color: #e5e7eb;
    }

    .calls-client-note__link {
        color: #a5b4fc;
    }

    .tab-metric {
        border-color: #253247;
        box-shadow: 0 12px 26px -20px rgba(0, 0, 0, .8);
    }

    .tab-metric__icon {
        background: rgba(99, 102, 241, .2);
        color: #c7d2fe;
    }

    .tab-metric__icon--indigo {
    background: rgba(67, 56, 202, .12);
    color: var(--brand-600);
}

.tab-metric__icon--sky {
        background: rgba(14, 165, 233, .2);
        color: #7dd3fc;
    }

    .tab-metric__icon--green {
        background: rgba(22, 163, 74, .2);
        color: #86efac;
    }

    .tab-metric__icon--violet {
        background: rgba(139, 92, 246, .22);
        color: #c4b5fd;
    }

    .calls-filters {
        border-color: #253247;
    }

    .calls-filters__date input[type="date"] {
        background: #0f1729;
        border-color: #2b3750;
        color: #e5e7eb;
        color-scheme: dark;
    }

    .badge-call-status--unknown {
        background: rgba(148, 163, 184, .16);
        color: #cbd5e1;
    }
}

@media (max-width: 1100px) {
    .tab-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .tab-metrics {
        grid-template-columns: 1fr;
    }

    .calls-tab-head__actions {
        width: 100%;
    }

    .calls-tab-head__actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .calls-filters {
        gap: 10px;
    }

    .calls-filters .toolbar__select,
    .calls-filters__date {
        flex: 1 1 100%;
    }

    .calls-filters__date input[type="date"] {
        flex: 1 1 auto;
    }

    .calls-client-note__link {
        margin-left: 0;
    }
}

/* =============================================================================
   ЭТАП 5 — закрепление клиентов, сделки и задачи, упрощённые SIP-настройки.
   Блок только дополняет существующие правила: старые селекторы не меняются.
   ============================================================================= */

/* --- Плитки метрик в ряд (дашборд, сделки, задачи) ------------------------- */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metrics-row .metric-card {
    min-width: 0;
}

.metric-card__icon--red {
    background: #fee2e2;
    color: #b91c1c;
}

.metric-card__icon--amber {
    background: #fef3c7;
    color: #b45309;
}

a.metric-card {
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

a.metric-card:hover {
    border-color: var(--brand-400);
    box-shadow: 0 14px 32px -20px rgba(67, 56, 202, .55);
}

.metric-card--overdue .metric-card__value {
    color: #b91c1c;
}

/* --- Действия в панели дашборда -------------------------------------------- */
.panel-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* --- Владелец клиента: ячейка таблицы и форма смены ------------------------ */
.owner-cell {
    min-width: 190px;
    white-space: nowrap;
}

.owner-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.owner-select,
.status-select {
    height: 32px;
    max-width: 190px;
    padding: 0 8px;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.owner-select:focus,
.status-select:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, .12);
}

.owner-save {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    color: var(--brand-600);
    background: var(--brand-tint);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.owner-save:hover {
    color: #fff;
    background: var(--brand-500);
}

.owner-save:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
}

.badge-owner {
    display: inline-flex;
    align-items: center;
    max-width: 190px;
    padding: 3px 9px;
    overflow: hidden;
    color: var(--app-text);
    background: var(--app-hover);
    border: 1px solid var(--app-border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.owner-none {
    color: #94a3b8;
    font-size: 12.5px;
}

/* В шапке карточки клиента */
.client-owner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    font-size: 13.5px;
}

.client-owner__label {
    color: var(--app-muted);
    font-weight: 600;
}

.owner-form--hero .owner-select {
    height: 36px;
    font-size: 13px;
}

/* --- Подсказка под полем (кнопка + сноска) --------------------------------- */
.hint-inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.hint-inline__note {
    color: var(--app-muted);
    font-size: 12px;
}

.btn--sm {
    height: 34px;
    padding: 0 12px;
    border-radius: 9px;
    font-size: 12.5px;
}

/* --- Свёрнутый блок «Подробнее» -------------------------------------------- */
.details-inline {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--app-hover);
    border: 1px solid var(--app-border);
    border-radius: 10px;
    font-size: 12.5px;
}

.details-inline summary {
    color: var(--brand-600);
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.details-inline summary::-webkit-details-marker {
    display: none;
}

.details-inline summary::before {
    content: '+';
    display: inline-block;
    width: 16px;
    font-weight: 700;
}

.details-inline[open] summary::before {
    content: '−';
}

.details-inline p {
    margin: 8px 0 0;
    color: var(--app-muted);
    line-height: 1.55;
}

.checkbox__note {
    display: block;
    margin-top: 2px;
    color: var(--app-muted);
    font-size: 12px;
    font-weight: 400;
}

/* --- Раскрывающаяся форма создания ----------------------------------------- */
.form-inline-card {
    margin-bottom: 16px;
}

/* --- Расширенная панель фильтров ------------------------------------------- */
.toolbar--wrap {
    align-items: flex-end;
}

.toolbar__date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--app-muted);
    font-size: 12.5px;
}

.toolbar__date input[type="date"] {
    height: 44px;
    padding: 0 10px;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 11px;
    font: inherit;
    font-size: 13.5px;
}

.toolbar__date input[type="date"]:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px rgba(67, 56, 202, .12);
}

.toolbar__check {
    height: 44px;
    align-items: center;
    font-size: 13px;
    white-space: nowrap;
}

/* --- Смена статуса сделки в строке ----------------------------------------- */
.deal-status-form {
    gap: 6px;
}

.inline-form.deal-status-form {
    display: inline-flex;
    align-items: center;
}

/* --- Дополнительная строка индикатора SIP ---------------------------------- */
.sip-mode__hint--extra {
    display: block;
    margin-top: 4px;
    color: var(--brand-600);
    font-weight: 600;
}

/* --- Нейтральная плашка «Звонок через MicroSIP» ---------------------------- */
.call-note-neutral {
    padding: 7px 14px;
    background: #e0edff;
    border-bottom: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 11.5px;
    font-weight: 600;
    text-align: center;
}

.call-note-neutral[hidden] {
    display: none;
}

/* --- Тёмная тема ----------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    .metric-card__icon--red {
        background: rgba(239, 68, 68, .18);
        color: #fca5a5;
    }

    .metric-card__icon--amber {
        background: rgba(217, 119, 6, .2);
        color: #fbbf24;
    }

    .metric-card--overdue .metric-card__value {
        color: #fca5a5;
    }

    .owner-select,
    .status-select,
    .toolbar__date input[type="date"] {
        background: #0f1729;
        border-color: #253247;
        color: #e2e8f0;
    }

    .badge-owner {
        background: rgba(99, 102, 241, .14);
        border-color: #253247;
        color: #e2e8f0;
    }

    .owner-none {
        color: #64748b;
    }

    .call-note-neutral {
        background: rgba(59, 130, 246, .18);
        border-bottom-color: rgba(59, 130, 246, .35);
        color: #93c5fd;
    }

    .details-inline {
        background: #0f1729;
        border-color: #253247;
    }

    .details-inline summary {
        color: #a5b4fc;
    }

    .sip-mode__hint--extra {
        color: #a5b4fc;
    }

    .owner-save {
        background: rgba(99, 102, 241, .2);
        color: #c7d2fe;
    }
}

/* --- Мобильные ------------------------------------------------------------- */
@media (max-width: 1100px) {
    .metrics-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .table-card {
        overflow-x: auto;
    }

    .table-wrap {
        max-height: none;
    }

    .toolbar--wrap .toolbar__search,
    .toolbar--wrap .toolbar__select,
    .toolbar--wrap .toolbar__date {
        flex: 1 1 100%;
    }

    .toolbar__date input[type="date"] {
        flex: 1 1 auto;
        width: 100%;
    }
}

@media (max-width: 600px) {
    .metrics-row {
        grid-template-columns: 1fr;
    }

    .owner-form,
    .deal-status-form {
        flex-wrap: wrap;
    }

    .owner-select,
    .status-select {
        max-width: 100%;
        flex: 1 1 auto;
    }

    .client-owner {
        align-items: flex-start;
        flex-direction: column;
    }

    .hint-inline {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel-card__actions {
        width: 100%;
    }

    .panel-card__actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* =============================================================================
   ЭТАП 6 — дашборд с графиками, нейтральная плашка «раздел не инициализирован».
   Блок только дополняет существующие правила: старые селекторы не меняются.
   ============================================================================= */

/* --- Нейтральная техническая плашка (таблицы нет, миграция не выполнена) --- */
.section-pending {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px 18px;
    border: 1px solid #cfd9e8;
    border-radius: 12px;
    background: #f4f7fc;
    color: #3d4a60;
}

.section-pending__icon {
    flex: 0 0 auto;
    margin-top: 1px;
    color: #64748b;
}

.section-pending__body {
    min-width: 0;
}

.section-pending__title {
    margin: 0 0 3px;
    font-size: 13.5px;
    font-weight: 650;
    color: #334155;
}

.section-pending__text {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: #55637c;
}

/* --- Шапка дашборда --- */
.dash-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 22px;
    margin-bottom: 20px;
    padding: 26px 28px;
    border-radius: 18px;
    background: linear-gradient(125deg, #1e3a8a 0%, #4338ca 52%, #6366f1 100%);
    color: #ffffff;
    box-shadow: 0 22px 45px -26px rgba(30, 58, 138, .75);
}

.dash-hero__text {
    min-width: 0;
}

.dash-hero__eyebrow {
    margin: 0 0 6px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .72);
}

.dash-hero__title {
    margin: 0 0 6px;
    font-size: 27px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -.02em;
    color: #ffffff;
}

.dash-hero__date {
    margin: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, .82);
}

.dash-hero__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.dash-hero .role-badge {
    background: rgba(255, 255, 255, .18);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, .28);
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quick-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, .34);
    background: rgba(255, 255, 255, .14);
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.quick-action:hover {
    background: rgba(255, 255, 255, .24);
    border-color: rgba(255, 255, 255, .5);
    transform: translateY(-1px);
}

.quick-action .icon {
    flex: 0 0 auto;
}

/* --- Плитки метрик --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.metric-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 18px 20px 16px;
    border: 1px solid var(--app-border);
    border-radius: 16px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
    color: inherit;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

a.metric-tile:hover {
    border-color: var(--brand-400);
    box-shadow: 0 16px 34px -24px rgba(67, 56, 202, .6);
    transform: translateY(-1px);
}

.metric-tile--wide {
    grid-column: span 1;
}

.metric-tile__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 4px;
    border-radius: 12px;
    background: var(--brand-tint);
    color: var(--brand-500);
}

.metric-tile__icon--indigo {
    background: #eef2ff;
    color: #4338ca;
}

.metric-tile__icon--violet {
    background: #f3e8ff;
    color: #7e22ce;
}

.metric-tile__icon--green {
    background: #dcfce7;
    color: #15803d;
}

.metric-tile__icon--sky {
    background: #e0f2fe;
    color: #0369a1;
}

.metric-tile__icon--amber {
    background: #fef3c7;
    color: #b45309;
}

.metric-tile__label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--app-muted);
}

.metric-tile__value {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -.02em;
    color: var(--app-text);
}

.metric-tile__value--money {
    font-size: 25px;
}

.metric-tile__badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: #b42318;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
}

.metric-tile__foot {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--app-muted);
}

.metric-delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
}

.metric-delta--up {
    color: #15803d;
}

.metric-delta--down {
    color: #b42318;
}

.metric-delta--flat {
    color: var(--app-muted);
    font-weight: 500;
}

/* --- Сетка графиков --- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card,
.dash-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 20px 22px 18px;
    border: 1px solid var(--app-border);
    border-radius: 16px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow);
}

.chart-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 14px;
}

.chart-card__title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    color: var(--app-text);
}

.chart-card__title .icon {
    color: var(--brand-500);
}

.chart-card__meta {
    font-size: 13px;
    color: var(--app-muted);
}

.chart-card__link {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-500);
    text-decoration: none;
}

.chart-card__link:hover {
    text-decoration: underline;
}

.chart-card__body {
    flex: 1 1 auto;
    min-width: 0;
}

.chart-scroll {
    overflow-x: auto;
}

.chart-scroll .chart-svg {
    min-width: 420px;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    margin: 0;
    padding: 18px;
    border: 1px dashed var(--app-border);
    border-radius: 12px;
    color: var(--app-muted);
    font-size: 13.5px;
    text-align: center;
}

/* --- Сам SVG --- */
.chart-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 300px;
    overflow: visible;
}

.chart-svg .chart-grid {
    stroke: var(--app-line);
    stroke-width: 1;
    stroke-dasharray: 4 5;
}

.chart-svg .chart-axis {
    stroke: var(--app-border);
    stroke-width: 1;
}

.chart-svg .chart-axis-text {
    fill: var(--app-muted);
    font-family: inherit;
    font-size: 15px;
}

.chart-svg--bars {
    max-height: 280px;
}

.chart-svg--area {
    max-height: 250px;
}

.chart-svg .chart-bar {
    cursor: default;
}

.chart-svg .chart-bar path {
    transition: opacity .15s ease;
}

.chart-svg .chart-bar:hover path {
    opacity: .82;
}

/* Кольцевая */
.chart-donut-wrap {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.chart-svg--donut {
    width: 190px;
    max-width: 100%;
    flex: 0 0 auto;
}

.chart-donut__track {
    color: var(--app-line);
    opacity: .7;
}

.chart-donut__slice {
    transition: opacity .15s ease;
}

.chart-donut__slice:hover {
    opacity: .82;
}

.chart-svg--donut .chart-donut__value {
    fill: var(--app-text);
    font-family: inherit;
    font-size: 25px;
    font-weight: 700;
}

.chart-svg--donut .chart-donut__label {
    fill: var(--app-muted);
    font-family: inherit;
    font-size: 12.5px;
}

.chart-legend {
    flex: 1 1 190px;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.chart-legend__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--app-line);
    font-size: 13px;
}

.chart-legend__item:last-child {
    border-bottom: 0;
}

.chart-legend__dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.chart-legend__label {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--app-text);
}

.chart-legend__count {
    color: var(--app-muted);
    font-variant-numeric: tabular-nums;
}

.chart-legend__sum {
    min-width: 84px;
    color: var(--app-text);
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Горизонтальные полосы */
.chart-svg--hbars .chart-hbar__label {
    fill: var(--app-text);
    font-family: inherit;
    font-size: 15px;
}

.chart-svg--hbars .chart-hbar__value {
    fill: var(--app-muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
}

.chart-hbar__track {
    fill: var(--app-line);
}

/* --- Нижние блоки --- */
.dash-bottom {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.activity-list,
.upcoming-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--app-line);
}

.activity-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.activity-item__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #eef2ff;
    color: #4338ca;
}

.activity-item__icon--green {
    background: #dcfce7;
    color: #15803d;
}

.activity-item__icon--violet {
    background: #f3e8ff;
    color: #7e22ce;
}

.activity-item__icon--sky {
    background: #e0f2fe;
    color: #0369a1;
}

.activity-item__icon--amber {
    background: #fef3c7;
    color: #b45309;
}

.activity-item__icon--grey {
    background: #f1f5f9;
    color: #64748b;
}

.activity-item__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.activity-item__text {
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--app-text);
}

.activity-item__client {
    font-size: 12.5px;
    color: var(--app-muted);
}

.activity-item__client a {
    color: var(--brand-500);
    text-decoration: none;
}

.activity-item__client a:hover {
    text-decoration: underline;
}

.activity-item__time {
    flex: 0 0 auto;
    padding-top: 2px;
    font-size: 13px;
    color: var(--app-muted);
    white-space: nowrap;
}

.upcoming-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--app-line);
}

.upcoming-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.upcoming-item__main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.upcoming-item__title {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--app-text);
}

.upcoming-item__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12.5px;
    color: var(--app-muted);
}

.upcoming-item__meta a {
    color: var(--brand-500);
    text-decoration: none;
}

.upcoming-item__meta a:hover {
    text-decoration: underline;
}

.upcoming-item__side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: 0 0 auto;
}

.upcoming-item__date {
    font-size: 13px;
    font-weight: 600;
    color: var(--app-text);
    white-space: nowrap;
}

.badge-overdue {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: #b42318;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Тёмная тема --- */
@media (prefers-color-scheme: dark) {
    .dash-hero {
        background: linear-gradient(125deg, #172554 0%, #312e81 55%, #4338ca 100%);
        box-shadow: 0 22px 45px -28px rgba(0, 0, 0, .85);
    }

    .metric-tile__icon--indigo {
        background: rgba(99, 102, 241, .18);
        color: #a5b4fc;
    }

    .metric-tile__icon--violet {
        background: rgba(168, 85, 247, .16);
        color: #d8b4fe;
    }

    .metric-tile__icon--green {
        background: rgba(22, 163, 74, .18);
        color: #86efac;
    }

    .metric-tile__icon--sky {
        background: rgba(14, 165, 233, .18);
        color: #7dd3fc;
    }

    .metric-tile__icon--amber {
        background: rgba(217, 119, 6, .18);
        color: #fcd34d;
    }

    .metric-tile__badge,
    .badge-overdue {
        background: rgba(239, 68, 68, .16);
        color: #fca5a5;
    }

    .metric-delta--up {
        color: #4ade80;
    }

    .metric-delta--down {
        color: #fca5a5;
    }

    .section-pending {
        background: #0f1729;
        border-color: #22304a;
        color: #cbd5e1;
    }

    .section-pending__icon {
        color: #94a3b8;
    }

    .section-pending__title {
        color: #e5e7eb;
    }

    .section-pending__text {
        color: #94a3b8;
    }

    .activity-item__icon--grey {
        background: rgba(148, 163, 184, .16);
        color: #cbd5e1;
    }

    .chart-card__title .icon {
        color: #a5b4fc;
    }
}

/* --- Адаптив --- */
@media (max-width: 1100px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .charts-grid,
    .dash-bottom {
        grid-template-columns: minmax(0, 1fr);
    }

    .dash-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 22px 20px;
    }

    .dash-hero__side {
        align-items: flex-start;
        width: 100%;
    }

    .dash-hero__title {
        font-size: 23px;
    }
}

@media (max-width: 600px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .metric-tile {
        padding: 14px 14px 12px;
    }

    .metric-tile__value {
        font-size: 24px;
    }

    .metric-tile__value--money {
        font-size: 19px;
    }

    .chart-card,
    .dash-card {
        padding: 16px 14px;
    }

    .chart-donut-wrap {
        justify-content: center;
    }

    .quick-action {
        flex: 1 1 auto;
        justify-content: center;
    }

    .activity-item__time {
        font-size: 12px;
    }
}

@media (max-width: 420px) {
    .metrics-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* =============================================================================
   ЭТАП 7 — модальное окно, колокольчик, всплывающие напоминания и навигация
   Блок дописан в конец: правила ниже переопределяют более ранние.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Навигация и кнопки: без подчёркивания в любом состоянии
   -------------------------------------------------------------------------- */

/* Глобальное a:hover { text-decoration: underline } остаётся только для
   смысловых ссылок в тексте. Всё, что является навигацией или кнопкой,
   подчёркивание не получает — ни при hover, ни при focus. */
.sidebar a,
.sidebar a:hover,
.sidebar a:focus,
.sidebar a:active,
.sidebar__link,
.sidebar__link:hover,
.sidebar__link:focus,
.sidebar__link--active,
.sidebar__link--active:hover,
.header__crumbs a,
.header__crumbs a:hover,
.user-menu a,
.user-menu a:hover,
.user-menu__summary,
.user-menu__summary:hover,
.nav-link,
.nav-link:hover,
.tab,
.tab:hover,
.tab:focus,
.tab:active,
.tab--active,
.tab--active:hover,
.tabs a,
.tabs a:hover,
.btn,
.btn:hover,
.btn:focus,
.btn:active,
.btn--outline,
.btn-link,
.btn-link:hover,
.metric-tile,
.metric-tile:hover,
.metric-card,
.metric-card:hover,
.pagination a,
.pagination a:hover,
.breadcrumbs a,
.breadcrumbs a:hover,
.quick-action,
.quick-action:hover,
.notif-bell,
.notif-bell:hover,
.notif-tab,
.notif-tab:hover,
.notif-sound,
.notif-sound:hover,
.notif-mark-all,
.notif-mark-all:hover,
.toast__btn,
.toast__btn:hover,
.toast a,
.toast a:hover,
.modal a,
.modal a:hover,
.cell-link,
.cell-link:hover,
.cell-phone a,
.cell-phone a:hover,
.client-meta__phone,
.client-meta__phone:hover,
tr a.client-link,
tr a.client-link:hover {
    text-decoration: none;
}

/* Ссылки в таблицах (клиент, сделка, задача) — цветом, без подчёркивания. */
td a:not(.btn):not(.tab),
td a:not(.btn):not(.tab):hover,
.table a:not(.btn),
.table a:not(.btn):hover {
    text-decoration: none;
}

td a:not(.btn):not(.tab):hover {
    color: var(--brand-500);
}

/* Смысловые ссылки в тексте: подчёркивание только при наведении. */
.prose a,
.field__hint a,
.alert a,
.card-head__hint a,
.sip-hint a,
.sip-details a,
.login-footnote a,
.auth-switch a {
    text-decoration: none;
    border-bottom: 1px solid rgba(67, 56, 202, .35);
}

.prose a:hover,
.field__hint a:hover,
.alert a:hover,
.card-head__hint a:hover,
.sip-hint a:hover,
.sip-details a:hover,
.login-footnote a:hover,
.auth-switch a:hover {
    text-decoration: none;
    border-bottom-color: currentColor;
}

/* Активный пункт меню: фон и полоса слева, без подчёркивания. */
.sidebar__link--active {
    background: rgba(255, 255, 255, .12);
}

.sidebar__link--active:hover {
    background: rgba(255, 255, 255, .16);
}

/* Кнопки и навигация: фокус показываем кольцом, а не подчёркиванием. */
a:focus-visible,
button:focus-visible,
.sidebar__link:focus-visible,
.tab:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
    text-decoration: none;
}

/* -----------------------------------------------------------------------------
   2. Модальное окно (.modal, .modal__overlay, .modal__dialog, .modal__close)
   -------------------------------------------------------------------------- */

body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.modal[hidden] {
    display: none;
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
    animation: modal-fade .16s ease-out;
}

.modal__dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--app-surface);
    color: var(--app-text);
    border: 1px solid var(--app-border);
    border-radius: 18px;
    box-shadow: 0 32px 70px -30px rgba(15, 23, 42, .55);
    animation: modal-pop .18s ease-out;
}

.modal__head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 14px;
    background: var(--app-surface);
    border-bottom: 1px solid var(--app-line);
}

.modal__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.modal__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--app-muted);
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.modal__close:hover {
    background: var(--app-hover);
    color: var(--app-text);
}

.modal__body {
    display: grid;
    gap: 16px;
    padding: 20px 24px 24px;
}

.modal .form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--app-line);
}

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

@keyframes modal-pop {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* -----------------------------------------------------------------------------
   3. Колокольчик в шапке
   -------------------------------------------------------------------------- */

.notif {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--app-border);
    border-radius: 11px;
    background: var(--app-surface);
    color: var(--app-muted);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.notif-bell:hover,
.notif.is-open .notif-bell {
    background: var(--app-hover);
    color: var(--brand-500);
    border-color: rgba(67, 56, 202, .28);
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--app-surface);
}

.notif-badge[hidden] {
    display: none;
}

.notif-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 900;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 16px;
    box-shadow: 0 26px 60px -28px rgba(15, 23, 42, .45);
    overflow: hidden;
}

.notif-panel[hidden] {
    display: none;
}

.notif-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
}

.notif-panel__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--app-text);
}

.notif-sound {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border: 1px solid var(--app-border);
    border-radius: 999px;
    background: transparent;
    color: var(--app-muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: color .15s ease, background .15s ease;
}

.notif-sound:hover {
    background: var(--app-hover);
    color: var(--app-text);
}

.notif-sound[aria-pressed="false"] {
    color: #b42318;
    border-color: rgba(180, 35, 24, .3);
}

.notif-tabs {
    display: flex;
    gap: 4px;
    padding: 0 12px;
    border-bottom: 1px solid var(--app-line);
}

.notif-tab {
    padding: 9px 10px 10px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--app-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease;
}

.notif-tab:hover {
    color: var(--app-text);
}

.notif-tab.is-active {
    color: var(--brand-500);
    border-bottom-color: var(--brand-500);
}

.notif-body {
    max-height: 380px;
    overflow-y: auto;
    padding: 6px;
}

.notif-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notif-item {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 10px;
    border-radius: 11px;
    color: var(--app-text);
    transition: background .15s ease;
}

.notif-item:hover {
    background: var(--app-hover);
}

.notif-item__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--brand-tint);
    color: var(--brand-500);
}

.notif-item__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.notif-item__title {
    font-size: 13.5px;
    font-weight: 650;
    color: var(--app-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-item__meta {
    font-size: 12px;
    color: var(--app-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notif-item__time {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-500);
}

.notif-item__time.is-overdue {
    color: #b42318;
}

/* Прочитанное напоминание — приглушённое. */
.notif-item.is-read {
    opacity: .62;
}

.notif-item.is-read .notif-item__title {
    font-weight: 550;
}

.notif-empty {
    margin: 0;
    padding: 26px 16px;
    text-align: center;
    color: var(--app-muted);
    font-size: 13px;
}

.notif-panel__foot {
    padding: 10px 12px 12px;
    border-top: 1px solid var(--app-line);
    background: var(--app-surface);
}

.notif-mark-all {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--app-border);
    border-radius: 10px;
    background: var(--app-surface);
    color: var(--app-text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.notif-mark-all:hover:not(:disabled) {
    background: var(--app-hover);
    color: var(--brand-500);
}

.notif-mark-all:disabled {
    opacity: .5;
    cursor: default;
}

/* -----------------------------------------------------------------------------
   4. Всплывающие напоминания (.toast-stack)
   -------------------------------------------------------------------------- */

.toast-stack {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 352px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

/* При активном окне звонка стек поднимается выше виджета. */
.toast-stack--above-call {
    bottom: 110px;
}

.toast {
    pointer-events: auto;
    background: var(--app-surface);
    color: var(--app-text);
    border: 1px solid var(--app-border);
    border-left: 4px solid var(--brand-500);
    border-radius: 14px;
    box-shadow: 0 22px 45px -24px rgba(15, 23, 42, .5);
    padding: 12px 14px 12px;
    animation: toast-in .2s ease-out;
}

.toast--urgent {
    border-color: rgba(220, 38, 38, .55);
    border-left-color: #dc2626;
    box-shadow: 0 22px 45px -24px rgba(220, 38, 38, .45);
}

.toast__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.toast__icon {
    display: inline-flex;
    color: var(--brand-500);
}

.toast--urgent .toast__icon {
    color: #dc2626;
}

.toast__eyebrow {
    flex: 1 1 auto;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--app-muted);
}

.toast__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--app-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.toast__close:hover {
    background: var(--app-hover);
    color: var(--app-text);
}

.toast__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast__title {
    font-size: 14px;
    font-weight: 650;
    color: var(--app-text);
}

.toast__meta {
    font-size: 12.5px;
    color: var(--app-muted);
}

.toast__actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.toast__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 11px;
    border: 1px solid var(--app-border);
    border-radius: 9px;
    background: var(--app-surface);
    color: var(--app-text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.toast__btn:hover {
    background: var(--app-hover);
}

.toast__btn--primary {
    border-color: transparent;
    background: var(--brand-500);
    color: #fff;
}

.toast__btn--primary:hover {
    background: var(--brand-600);
    color: #fff;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -----------------------------------------------------------------------------
   5. Настройки SIP: необязательные поля браузерных звонков
   -------------------------------------------------------------------------- */

.field__optional {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--app-hover);
    color: var(--app-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.hint-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin-top: 2px;
}

.hint-inline__note {
    color: var(--app-muted);
    font-size: 12px;
}

.sip-details {
    margin-top: 8px;
    border: 1px solid var(--app-line);
    border-radius: 10px;
    background: var(--app-hover);
}

.sip-details > summary {
    padding: 8px 12px;
    color: var(--brand-500);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.sip-details > summary::-webkit-details-marker {
    display: none;
}

.sip-details > summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 6px;
    transition: transform .15s ease;
}

.sip-details[open] > summary::before {
    transform: rotate(90deg);
}

.sip-details__body {
    padding: 0 12px 10px;
    color: var(--app-muted);
    font-size: 12.5px;
}

.sip-details__body p {
    margin: 0 0 8px;
}

.sip-details__body p:last-child {
    margin-bottom: 0;
}

.checkbox__hint {
    display: block;
    margin-top: 2px;
    color: var(--app-muted);
    font-size: 12px;
    font-weight: 400;
}

/* --- STUN/TURN: прохождение через NAT -------------------------------------- */
.sip-nat__head {
    margin-top: 4px;
    padding-top: 14px;
    border-top: 1px solid var(--app-line);
}

.sip-nat__title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.sip-nat__hint {
    margin: 0;
    color: var(--app-muted);
    font-size: 12.5px;
    line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
    .sip-nat__head {
        border-top-color: #1f2937;
    }
}

/* -----------------------------------------------------------------------------
   6. Тёмная тема
   -------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
    body.modal-open {
        background: #0b1220;
    }

    .modal__overlay {
        background: rgba(2, 6, 23, .72);
    }

    .modal__dialog,
    .notif-panel,
    .notif-panel__foot,
    .modal__head,
    .toast {
        background: #111827;
        color: #e5e7eb;
        border-color: #1f2937;
    }

    .modal__dialog {
        box-shadow: 0 34px 80px -30px rgba(0, 0, 0, .9);
    }

    .modal__head {
        border-bottom-color: #1f2937;
    }

    .modal__title,
    .notif-panel__title,
    .notif-item__title,
    .notif-mark-all,
    .toast__title,
    .toast__btn {
        color: #e5e7eb;
    }

    .modal__close,
    .notif-bell,
    .notif-tab,
    .notif-sound,
    .toast__close,
    .toast__meta,
    .notif-item__meta {
        color: #9ca3af;
    }

    .notif-bell,
    .notif-mark-all,
    .notif-sound,
    .toast,
    .toast__btn,
    .sip-details {
        border-color: #1f2937;
    }

    .notif-bell {
        background: #111827;
    }

    .notif-bell:hover,
    .notif.is-open .notif-bell {
        background: #1b2434;
        color: #a5b4fc;
    }

    .notif-badge {
        box-shadow: 0 0 0 2px #111827;
    }

    .notif-panel {
        box-shadow: 0 28px 65px -25px rgba(0, 0, 0, .95);
    }

    .notif-tabs,
    .notif-panel__foot,
    .modal .form-actions {
        border-color: #1f2937;
    }

    .notif-item__icon {
        background: rgba(99, 102, 241, .18);
        color: #a5b4fc;
    }

    .notif-item:hover,
    .notif-mark-all:hover:not(:disabled),
    .toast__btn:hover,
    .modal__close:hover,
    .notif-sound:hover {
        background: #1b2434;
    }

    .notif-item.is-read {
        opacity: .55;
    }

    .notif-empty {
        color: #9ca3af;
    }

    .toast {
        border-left-color: #6366f1;
    }

    .toast--urgent {
        border-color: rgba(248, 113, 113, .45);
        border-left-color: #ef4444;
    }

    .sip-details {
        background: #0f172a;
    }

    .sip-details__body,
    .hint-inline__note,
    .checkbox__hint,
    .field__optional {
        color: #9ca3af;
    }

    .field__optional {
        background: #1b2434;
    }

    .toast__btn--primary {
        background: #4f46e5;
        color: #fff;
    }
}

/* -----------------------------------------------------------------------------
   7. Мобильные: панель и тосты на всю ширину
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
    .modal {
        align-items: flex-end;
        padding: 12px 8px;
    }

    .modal__dialog {
        max-height: calc(100vh - 24px);
        border-radius: 16px;
    }

    .modal__head {
        padding: 16px 16px 12px;
    }

    .modal__body {
        padding: 16px;
    }

    .notif-panel {
        position: fixed;
        top: calc(var(--header-h) - 4px);
        right: 8px;
        left: 8px;
        width: auto;
        max-width: none;
    }

    .notif-body {
        max-height: 60vh;
    }

    .toast-stack,
    .toast-stack--above-call {
        right: 8px;
        left: 8px;
        bottom: 8px;
        width: auto;
        max-width: none;
    }

    .toast-stack--above-call {
        bottom: 96px;
    }

    .toast {
        padding: 11px 12px;
    }
}

@media (max-width: 420px) {
    .toast__actions {
        flex-direction: column;
    }

    .toast__btn {
        width: 100%;
    }
}

/* -----------------------------------------------------------------------------
   8. Уважение к prefers-reduced-motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .modal__overlay,
    .modal__dialog,
    .toast {
        animation: none;
    }

    .sidebar__link,
    .notif-bell,
    .notif-item,
    .toast__btn,
    .btn,
    .tab,
    .modal__close {
        transition: none;
    }

    .sip-details > summary::before {
        transition: none;
    }
}

/* Блок «Напомнить за» в формах задач (этап 7) */
.remind-field {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
}

.remind-field legend {
    padding: 0;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--app-text);
}

.remind-field .checkbox {
    margin: 0;
}

@media (prefers-color-scheme: dark) {
    .remind-field legend {
        color: #e5e7eb;
    }
}

/* Чекбоксы «Напомнить за» в один ряд с переносом */
.remind-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    width: 100%;
}

/* Быстрая правка срока прямо в таблице задач */
.task-reschedule {
    display: inline-block;
    margin-left: 10px;
}

.task-reschedule__form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.task-reschedule__form input[type="date"],
.task-reschedule__form input[type="time"] {
    width: auto;
    min-width: 130px;
    padding: 6px 8px;
    font-size: 13px;
}

.task-reschedule__form .btn {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .task-reschedule {
        display: block;
        margin: 6px 0 0;
    }

    .task-reschedule__form {
        width: 100%;
    }

    .task-reschedule__form input[type="date"],
    .task-reschedule__form input[type="time"] {
        flex: 1 1 130px;
        min-width: 0;
    }
}
