@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
    --crm-font: "Manrope", "Inter", "IBM Plex Sans", "Segoe UI", "Arial", sans-serif;

    --crm-bg: #eef4fb;
    --crm-bg-2: #f8fbff;
    --crm-sidebar: #0a1221;
    --crm-sidebar-2: #0f1b2f;
    --crm-panel: rgba(255, 255, 255, .86);
    --crm-panel-solid: #ffffff;
    --crm-panel-2: rgba(241, 245, 249, .92);
    --crm-border: rgba(15, 23, 42, .10);
    --crm-border-strong: rgba(15, 23, 42, .18);
    --crm-text: #0f172a;
    --crm-soft: #64748b;
    --crm-muted: #94a3b8;

    --crm-primary: #2563eb;
    --crm-primary-2: #38bdf8;
    --crm-cyan: #06b6d4;
    --crm-violet: #7c3aed;
    --crm-success: #22c55e;
    --crm-warning: #f59e0b;
    --crm-danger: #ef4444;

    --crm-shadow: 0 24px 70px rgba(15, 23, 42, .12);
    --crm-shadow-soft: 0 12px 32px rgba(15, 23, 42, .08);

    --crm-radius-xl: 28px;
    --crm-radius: 20px;
    --crm-radius-sm: 14px;

    --crm-sidebar-width: 288px;
    --crm-topbar-height: 76px;
}

html[data-theme="dark"] {
    --crm-bg: #08111f;
    --crm-bg-2: #0c182b;
    --crm-sidebar: #050b15;
    --crm-sidebar-2: #0b1526;
    --crm-panel: rgba(14, 27, 48, .78);
    --crm-panel-solid: #0e1b30;
    --crm-panel-2: rgba(19, 36, 62, .78);
    --crm-border: rgba(148, 163, 184, .13);
    --crm-border-strong: rgba(148, 163, 184, .24);
    --crm-text: #e7eefb;
    --crm-soft: #9babc1;
    --crm-muted: #62748e;
    --crm-shadow: 0 24px 80px rgba(0, 0, 0, .32);
    --crm-shadow-soft: 0 12px 34px rgba(0, 0, 0, .22);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: var(--crm-font);
    background:
        radial-gradient(circle at 8% 8%, rgba(37, 99, 235, .20), transparent 32rem),
        radial-gradient(circle at 92% 0%, rgba(6, 182, 212, .12), transparent 30rem),
        linear-gradient(135deg, var(--crm-bg), var(--crm-bg-2));
    color: var(--crm-text);
    font-size: 15px;
    letter-spacing: -.01em;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.crm-app {
    min-height: 100vh;
    display: flex;
}

.crm-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--crm-sidebar-width);
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, .18), transparent 18rem),
        linear-gradient(180deg, var(--crm-sidebar), var(--crm-sidebar-2));
    color: #dbeafe;
    border-right: 1px solid rgba(148, 163, 184, .13);
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.crm-sidebar-head {
    min-height: var(--crm-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 18px 14px;
}

.crm-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crm-logo-mark {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(56, 189, 248, .95), rgba(37, 99, 235, .95));
    color: white;
    font-weight: 900;
    font-size: 20px;
    box-shadow: 0 14px 28px rgba(37, 99, 235, .32);
}

.crm-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.12;
}

.crm-logo-text strong {
    font-size: 18px;
    letter-spacing: -.04em;
}

.crm-logo-text small {
    color: #8da1bc;
    font-size: 12px;
    margin-top: 4px;
}

.crm-sidebar-close {
    display: none;
    border: 0;
    background: transparent;
    color: #cbd5e1;
    font-size: 28px;
}

.crm-nav {
    padding: 8px 14px;
    overflow: auto;
    flex: 1;
}

.crm-nav-item {
    width: 100%;
    min-height: 46px;
    border: 0;
    background: transparent;
    color: #aebdd2;
    border-radius: 16px;
    padding: 0 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition:
        background-color .18s ease,
        color .18s ease,
        transform .18s ease,
        box-shadow .18s ease;
    margin-bottom: 5px;
    text-align: left;
    position: relative;
}

.crm-nav-item:hover {
    background: rgba(148, 163, 184, .10);
    color: #ffffff;
    transform: translateX(2px);
}

.crm-nav-item.active {
    background:
        linear-gradient(135deg, rgba(37, 99, 235, .28), rgba(6, 182, 212, .12));
    color: #ffffff;
    box-shadow: inset 3px 0 0 #38bdf8;
}

.crm-nav-icon {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    color: #38bdf8;
    flex: 0 0 25px;
}

.crm-nav-title {
    flex: 1;
    font-weight: 650;
}

.crm-nav-caret {
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    font-size: 22px;
    opacity: .75;
}

.crm-nav-group.open .crm-nav-caret {
    transform: rotate(90deg);
}

.crm-nav-sub {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        max-height .32s cubic-bezier(.2, .8, .2, 1),
        opacity .22s ease,
        transform .22s ease,
        padding .22s ease;
    padding: 0 0 0 48px;
}

.crm-nav-group.open .crm-nav-sub {
    max-height: 260px;
    opacity: 1;
    transform: translateY(0);
    padding: 2px 0 10px 48px;
}

.crm-nav-sub a {
    display: block;
    color: #8fa0b9;
    padding: 9px 12px;
    border-radius: 13px;
    font-size: 14px;
    margin: 2px 0;
    transition: .16s ease;
}

.crm-nav-sub a:hover,
.crm-nav-sub a.active {
    background: rgba(148, 163, 184, .11);
    color: #fff;
}

.crm-sidebar-footer {
    padding: 14px;
}

.crm-mini-card {
    border: 1px solid rgba(148, 163, 184, .14);
    background: rgba(15, 23, 42, .38);
    border-radius: 18px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 11px;
}

.crm-mini-card strong {
    display: block;
    font-size: 13px;
}

.crm-mini-card small {
    display: block;
    color: #879ab6;
    font-size: 12px;
    margin-top: 3px;
}

.crm-status-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 6px rgba(34, 197, 94, .13);
}

.crm-layout {
    width: 100%;
    min-width: 0;
    padding-left: var(--crm-sidebar-width);
}

.crm-topbar {
    position: sticky;
    top: 0;
    height: var(--crm-topbar-height);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: color-mix(in srgb, var(--crm-bg) 72%, transparent);
    backdrop-filter: blur(22px);
    border-bottom: 1px solid var(--crm-border);
}

.crm-topbar-left,
.crm-topbar-right,
.crm-actions,
.crm-hero-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.crm-menu-btn {
    display: none !important;
}

.crm-top-widget {
    min-width: 104px;
    height: 48px;
    padding: 7px 14px;
    border: 1px solid var(--crm-border);
    border-radius: 17px;
    background: var(--crm-panel);
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: var(--crm-shadow-soft);
}

.crm-top-widget span,
.crm-profile-text span {
    color: var(--crm-soft);
    font-size: 12px;
    line-height: 1;
    margin-bottom: 5px;
}

.crm-top-widget strong {
    font-size: 14px;
    line-height: 1;
}

.crm-org-widget {
    min-width: 250px;
}

.crm-org-select {
    border: 0;
    outline: none;
    background: transparent;
    color: var(--crm-text);
    font-weight: 800;
    padding: 0;
    width: 100%;
    appearance: auto;
}

.crm-org-select option {
    color: #0f172a;
}

.crm-theme-toggle {
    height: 48px;
    width: 78px;
    border: 1px solid var(--crm-border);
    border-radius: 999px;
    background: var(--crm-panel);
    color: var(--crm-text);
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    box-shadow: var(--crm-shadow-soft);
}

.crm-theme-sun,
.crm-theme-moon {
    display: grid;
    place-items: center;
    opacity: .42;
}

html[data-theme="light"] .crm-theme-sun,
html[data-theme="dark"] .crm-theme-moon {
    opacity: 1;
    color: var(--crm-primary);
}

.crm-profile {
    border: 1px solid var(--crm-border);
    border-radius: 999px;
    background: var(--crm-panel);
    color: var(--crm-text);
    min-height: 48px;
    padding: 5px 13px 5px 5px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--crm-shadow-soft);
}

.crm-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    color: white;
    font-weight: 900;
}

.crm-profile-text {
    text-align: left;
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.crm-profile-text strong {
    font-size: 13px;
}

.crm-main {
    padding: 26px 28px 42px;
}

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

.crm-page-head h1 {
    margin: 0 0 8px;
    font-size: clamp(25px, 2.8vw, 36px);
    letter-spacing: -.055em;
    font-weight: 850;
}

.crm-breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    color: var(--crm-soft);
    font-size: 14px;
}

.crm-breadcrumbs a:hover {
    color: var(--crm-primary);
}

.crm-dashboard-hero {
    min-height: 170px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-xl);
    background:
        radial-gradient(circle at 18% 12%, rgba(56, 189, 248, .16), transparent 18rem),
        linear-gradient(135deg, var(--crm-panel), color-mix(in srgb, var(--crm-panel-solid) 82%, var(--crm-primary) 18%));
    box-shadow: var(--crm-shadow-soft);
    padding: 26px;
    margin-bottom: 18px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    overflow: hidden;
}

.crm-kicker {
    display: inline-flex;
    color: var(--crm-primary-2);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .12em;
    margin-bottom: 10px;
}

.crm-dashboard-hero h2 {
    margin: 0;
    font-size: clamp(28px, 4vw, 48px);
    letter-spacing: -.065em;
    line-height: 1;
}

.crm-dashboard-hero p {
    max-width: 680px;
    margin: 12px 0 0;
    color: var(--crm-soft);
    font-size: 16px;
}

.crm-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

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

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

.crm-card,
.crm-stat-card {
    border: 1px solid var(--crm-border);
    background: var(--crm-panel);
    border-radius: var(--crm-radius);
    box-shadow: var(--crm-shadow-soft);
    backdrop-filter: blur(18px);
}

.crm-card {
    padding: 20px;
    margin-bottom: 18px;
}

.crm-stat-card {
    padding: 20px;
    min-height: 138px;
    overflow: hidden;
    position: relative;
}

.crm-stat-card:before {
    content: "";
    position: absolute;
    right: -38px;
    top: -38px;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    opacity: .16;
    background: var(--crm-primary);
}

.crm-stat-card.blue:before { background: var(--crm-primary); }
.crm-stat-card.cyan:before { background: var(--crm-cyan); }
.crm-stat-card.violet:before { background: var(--crm-violet); }
.crm-stat-card.green:before { background: var(--crm-success); }

.crm-stat-label {
    display: block;
    color: var(--crm-soft);
    font-size: 14px;
    margin-bottom: 12px;
}

.crm-stat-value {
    display: block;
    font-size: 34px;
    line-height: 1;
    letter-spacing: -.055em;
}

.crm-stat-delta {
    display: inline-block;
    font-size: 13px;
    margin-top: 13px;
    font-weight: 750;
}

.crm-stat-delta.up { color: var(--crm-success); }
.crm-stat-delta.down { color: var(--crm-danger); }
.crm-stat-delta.neutral { color: var(--crm-soft); }

.crm-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.crm-card-header h2 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -.04em;
}

.crm-card-header p {
    margin: 6px 0 0;
    color: var(--crm-soft);
    font-size: 14px;
}

.crm-btn,
.crm-icon-btn {
    border: 0;
    border-radius: 15px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        transform .16s ease,
        box-shadow .16s ease,
        border-color .16s ease,
        background-color .16s ease;
}

.crm-btn {
    padding: 0 17px;
    gap: 8px;
    font-weight: 800;
}

.crm-btn-primary {
    background: linear-gradient(135deg, var(--crm-primary), #1d4ed8);
    color: white;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .26);
}

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

.crm-btn-soft {
    background: var(--crm-panel-2);
    color: var(--crm-text);
    border: 1px solid var(--crm-border);
}

.crm-btn-soft:hover {
    border-color: var(--crm-border-strong);
}

.crm-icon-btn {
    width: 44px;
    background: var(--crm-panel-2);
    border: 1px solid var(--crm-border);
    color: var(--crm-text);
}

.crm-icon-btn:hover {
    border-color: var(--crm-primary);
    color: var(--crm-primary);
}

.crm-chart-placeholder {
    min-height: 280px;
    border: 1px dashed var(--crm-border-strong);
    border-radius: 20px;
    background: color-mix(in srgb, var(--crm-panel-2) 78%, transparent);
    padding: 22px;
    display: flex;
    align-items: flex-end;
}

.crm-bars {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.crm-bars span {
    flex: 1;
    min-width: 18px;
    border-radius: 999px 999px 10px 10px;
    background: linear-gradient(180deg, var(--crm-primary-2), var(--crm-primary));
    opacity: .86;
}

.crm-feed {
    display: grid;
    gap: 12px;
}

.crm-feed-item {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
    background: var(--crm-panel-2);
}

.crm-feed-item > span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--crm-primary);
}

.crm-feed-item.success > span { background: var(--crm-success); }
.crm-feed-item.warning > span { background: var(--crm-warning); }
.crm-feed-item.danger > span { background: var(--crm-danger); }

.crm-feed-item strong {
    display: block;
    font-size: 14px;
}

.crm-feed-item p {
    margin: 4px 0 0;
    color: var(--crm-soft);
    font-size: 13px;
}

.crm-feed-item time {
    color: var(--crm-muted);
    font-size: 13px;
}

.crm-table-wrap {
    overflow: auto;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
}

.crm-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    background: var(--crm-panel-solid);
}

.crm-table th,
.crm-table td {
    padding: 15px 16px;
    text-align: left;
    border-bottom: 1px solid var(--crm-border);
    white-space: nowrap;
}

.crm-table th {
    color: var(--crm-soft);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    background: var(--crm-panel-2);
}

.crm-table tr:hover td {
    background: color-mix(in srgb, var(--crm-primary) 7%, transparent);
}

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

.crm-table-actions {
    text-align: right !important;
}

.crm-badge {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
}

.crm-badge.success {
    color: #bbf7d0;
    background: rgba(34, 197, 94, .17);
}

html[data-theme="light"] .crm-badge.success { color: #166534; }

.crm-badge.warning {
    color: #fde68a;
    background: rgba(245, 158, 11, .18);
}

html[data-theme="light"] .crm-badge.warning { color: #92400e; }

.crm-badge.danger {
    color: #fecaca;
    background: rgba(239, 68, 68, .18);
}

html[data-theme="light"] .crm-badge.danger { color: #991b1b; }

.crm-search,
.crm-field input,
.crm-field select,
.crm-field textarea {
    width: 100%;
    border: 1px solid var(--crm-border);
    border-radius: 15px;
    background: var(--crm-panel-2);
    color: var(--crm-text);
    outline: none;
    transition: .16s ease;
}

.crm-search {
    height: 44px;
    padding: 0 14px;
    min-width: 220px;
}

.crm-field input,
.crm-field select {
    height: 46px;
    padding: 0 14px;
}

.crm-field textarea {
    resize: vertical;
    padding: 12px 14px;
}

.crm-search:focus,
.crm-field input:focus,
.crm-field select:focus,
.crm-field textarea:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, .15);
}

.crm-form {
    display: grid;
    gap: 18px;
}

.crm-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.crm-field {
    display: grid;
    gap: 8px;
}

.crm-field span {
    color: var(--crm-soft);
    font-size: 13px;
    font-weight: 800;
}

.crm-form-footer,
.crm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.crm-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    place-items: center;
    padding: 20px;
}

.crm-modal.open {
    display: grid;
}

.crm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, .72);
    backdrop-filter: blur(10px);
}

.crm-modal-window {
    position: relative;
    width: min(620px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: var(--crm-panel-solid);
    border: 1px solid var(--crm-border);
    border-radius: 24px;
    box-shadow: var(--crm-shadow);
}

.crm-modal-header,
.crm-modal-footer {
    padding: 16px 18px;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-modal-footer {
    border-top: 1px solid var(--crm-border);
    border-bottom: 0;
}

.crm-modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.crm-modal-body {
    padding: 18px;
}

.crm-sidebar-backdrop {
    display: none;
}

@media (max-width: 1180px) {
    .crm-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crm-grid-2 {
        grid-template-columns: 1fr;
    }

    .crm-dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 920px) {
    .crm-sidebar {
        transform: translateX(-100%);
        transition: transform .24s cubic-bezier(.2, .8, .2, 1);
    }

    .crm-app.sidebar-open .crm-sidebar {
        transform: translateX(0);
    }

    .crm-app.sidebar-open .crm-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(2, 6, 23, .58);
        backdrop-filter: blur(5px);
    }

    .crm-sidebar-close {
        display: block;
    }

    .crm-layout {
        padding-left: 0;
    }

    .crm-menu-btn {
        display: inline-flex !important;
    }

    .crm-topbar {
        padding: 0 16px;
    }

    .crm-main {
        padding: 20px 16px 34px;
    }

    .crm-hide-md {
        display: none;
    }
}

@media (max-width: 680px) {
    :root {
        --crm-topbar-height: 68px;
    }

    .crm-grid-4 {
        grid-template-columns: 1fr;
    }

    .crm-card-header,
    .crm-page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .crm-actions,
    .crm-hero-actions {
        width: 100%;
        align-items: stretch;
        flex-wrap: wrap;
    }

    .crm-actions > *,
    .crm-hero-actions > * {
        flex: 1;
    }

    .crm-search {
        min-width: 100%;
    }

    .crm-form-grid {
        grid-template-columns: 1fr;
    }

    .crm-hide-sm,
    .crm-profile-text {
        display: none;
    }

    .crm-profile {
        padding: 5px;
    }

    .crm-org-widget {
        min-width: 190px;
        max-width: 52vw;
    }

    .crm-dashboard-hero {
        padding: 20px;
        border-radius: 22px;
    }

    .crm-stat-card {
        min-height: 118px;
    }
}


/* ===== v3 polish: icons, selects, Cyrillic font rendering ===== */

body {
    font-weight: 500;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.crm-nav-icon svg,
.crm-nav-caret svg,
.crm-icon-btn svg,
.crm-theme-toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

.crm-nav-icon svg,
.crm-theme-toggle svg {
    fill: currentColor;
}

.crm-nav-caret {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
}

.crm-nav-caret svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.crm-icon-btn svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.3;
    stroke-linecap: round;
}

.crm-field select,
.crm-org-select {
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--crm-soft) 50%),
        linear-gradient(135deg, var(--crm-soft) 50%, transparent 50%);
    background-position:
        calc(100% - 21px) 50%,
        calc(100% - 15px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.crm-field select {
    cursor: pointer;
    padding-right: 46px;
    background-color: color-mix(in srgb, var(--crm-panel-2) 88%, var(--crm-primary) 12%);
    border: 1px solid color-mix(in srgb, var(--crm-border) 70%, var(--crm-primary) 30%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04);
}

.crm-field select:hover,
.crm-org-select:hover {
    border-color: var(--crm-primary);
}

.crm-field select:focus {
    background-color: var(--crm-panel-solid);
}

.crm-field select option,
.crm-org-select option {
    background: #ffffff;
    color: #0f172a;
    font-weight: 600;
}

html[data-theme="dark"] .crm-field select option,
html[data-theme="dark"] .crm-org-select option {
    background: #0e1b30;
    color: #e7eefb;
}

.crm-org-select {
    height: 22px;
    padding-right: 28px;
    background-color: transparent;
    background-position:
        calc(100% - 12px) 50%,
        calc(100% - 6px) 50%;
    border-radius: 8px;
    cursor: pointer;
}

.crm-top-widget:has(.crm-org-select) {
    transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.crm-top-widget:has(.crm-org-select):hover {
    border-color: color-mix(in srgb, var(--crm-primary) 55%, var(--crm-border) 45%);
    transform: translateY(-1px);
}

.crm-search,
.crm-field input,
.crm-field select,
.crm-field textarea,
.crm-org-select {
    font-weight: 650;
}

.crm-field span,
.crm-top-widget span,
.crm-profile-text span {
    font-weight: 750;
}

.crm-nav-title,
.crm-logo-text strong,
.crm-page-head h1,
.crm-dashboard-hero h2,
.crm-card-header h2 {
    font-weight: 800;
}

@media (max-width: 680px) {
    .crm-nav-icon svg,
    .crm-nav-caret svg,
    .crm-icon-btn svg,
    .crm-theme-toggle svg {
        width: 19px;
        height: 19px;
    }
}


/* ===== v4 menu sections ===== */
.crm-nav-section {
    margin: 16px 10px 8px;
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .12em;
}

.crm-nav-section:first-child {
    margin-top: 6px;
}


/* ===== v5 custom dropdowns + scrollbars ===== */

* {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--crm-primary) 58%, #334155 42%) color-mix(in srgb, var(--crm-panel-solid) 72%, transparent);
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: color-mix(in srgb, var(--crm-panel-solid) 72%, transparent);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--crm-primary-2) 75%, #334155 25%),
            color-mix(in srgb, var(--crm-primary) 72%, #1e293b 28%)
        );
    border: 2px solid color-mix(in srgb, var(--crm-panel-solid) 72%, transparent);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background:
        linear-gradient(180deg,
            var(--crm-primary-2),
            var(--crm-primary)
        );
}

.crm-nav::-webkit-scrollbar {
    width: 7px;
}

.crm-nav::-webkit-scrollbar-track {
    background: transparent;
}

.crm-nav::-webkit-scrollbar-thumb {
    border: 0;
    background: rgba(56, 189, 248, .28);
}

.crm-dropdown {
    position: relative;
}

.crm-dropdown-btn,
.crm-profile {
    cursor: pointer;
    user-select: none;
}

.crm-org-widget {
    position: relative;
    width: 270px;
    min-width: 270px;
    padding-right: 42px;
    text-align: left;
    border: 1px solid var(--crm-border);
    color: var(--crm-text);
    transition:
        transform .16s ease,
        border-color .16s ease,
        box-shadow .16s ease,
        background-color .16s ease;
}

.crm-org-widget:hover,
.crm-dropdown.open .crm-org-widget,
.crm-dropdown.open .crm-profile {
    border-color: color-mix(in srgb, var(--crm-primary) 58%, var(--crm-border) 42%);
    box-shadow: 0 14px 34px rgba(37, 99, 235, .16);
    transform: translateY(-1px);
}

.crm-dropdown-current {
    display: block;
    max-width: 205px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-dropdown-arrow,
.crm-profile-arrow {
    position: absolute;
    right: 13px;
    top: 50%;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    transform: translateY(-50%);
    color: var(--crm-soft);
    transition: transform .22s cubic-bezier(.2, .8, .2, 1), color .16s ease;
}

.crm-profile-arrow {
    position: static;
    transform: none;
    margin-left: 2px;
}

.crm-dropdown.open .crm-dropdown-arrow {
    transform: translateY(-50%) rotate(180deg);
    color: var(--crm-primary-2);
}

.crm-dropdown.open .crm-profile-arrow {
    transform: rotate(180deg);
    color: var(--crm-primary-2);
}

.crm-dropdown-arrow svg,
.crm-profile-arrow svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.crm-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: max(100%, 260px);
    padding: 8px;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--crm-panel-solid) 92%, var(--crm-primary) 8%),
            var(--crm-panel-solid)
        );
    box-shadow: var(--crm-shadow);
    backdrop-filter: blur(22px);
    z-index: 80;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(.98);
    transform-origin: top;
    transition:
        opacity .18s ease,
        visibility .18s ease,
        transform .18s cubic-bezier(.2, .8, .2, 1);
}

.crm-dropdown-menu-right {
    left: auto;
    right: 0;
    width: 220px;
}

.crm-dropdown.open .crm-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.crm-dropdown-item {
    width: 100%;
    min-height: 42px;
    border: 0;
    background: transparent;
    color: var(--crm-text);
    border-radius: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    text-align: left;
    font-weight: 750;
    transition:
        background-color .14s ease,
        color .14s ease,
        transform .14s ease;
}

.crm-dropdown-item:hover,
.crm-dropdown-item.active {
    background: color-mix(in srgb, var(--crm-primary) 14%, transparent);
    color: color-mix(in srgb, var(--crm-primary-2) 60%, var(--crm-text) 40%);
}

.crm-dropdown-item:hover {
    transform: translateX(2px);
}

.crm-dropdown-item.danger:hover {
    background: rgba(239, 68, 68, .14);
    color: #fb7185;
}

.crm-dropdown-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--crm-primary) 14%, transparent);
    color: var(--crm-primary-2);
    flex: 0 0 28px;
}

.crm-dropdown-item-icon svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.crm-dropdown-item b {
    margin-left: auto;
    color: var(--crm-success);
}

.crm-profile {
    position: relative;
    padding-right: 13px;
}

.crm-profile .crm-profile-arrow {
    display: grid;
}

.crm-org-select {
    display: none;
}

@media (max-width: 680px) {
    .crm-org-widget {
        width: min(230px, 52vw);
        min-width: min(230px, 52vw);
    }

    .crm-dropdown-current {
        max-width: 150px;
    }

    .crm-dropdown-menu {
        width: 260px;
    }

    .crm-profile {
        padding-right: 5px;
    }

    .crm-profile-arrow {
        display: none !important;
    }
}


/* ===== v6 mobile overflow, form selects, iOS theme switch, org roles ===== */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.crm-app,
.crm-layout,
.crm-topbar,
.crm-main {
    max-width: 100%;
}

.crm-card,
.crm-dashboard-hero,
.crm-stat-card,
.crm-topbar,
.crm-main {
    min-width: 0;
}

.crm-table-wrap {
    max-width: 100%;
}

/* Красивые dropdown/select в формах */
.crm-field select {
    min-height: 48px;
    padding: 0 48px 0 15px;
    border-radius: 16px;
    cursor: pointer;
    color: var(--crm-text);
    background:
        linear-gradient(45deg, transparent 50%, var(--crm-primary-2) 50%) calc(100% - 23px) 50% / 7px 7px no-repeat,
        linear-gradient(135deg, var(--crm-primary-2) 50%, transparent 50%) calc(100% - 16px) 50% / 7px 7px no-repeat,
        linear-gradient(180deg,
            color-mix(in srgb, var(--crm-panel-2) 88%, var(--crm-primary) 12%),
            color-mix(in srgb, var(--crm-panel-2) 96%, #000 4%)
        );
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.05),
        0 8px 18px rgba(15,23,42,.05);
}

.crm-field select:hover {
    border-color: color-mix(in srgb, var(--crm-primary) 58%, var(--crm-border) 42%);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.06),
        0 10px 24px rgba(37,99,235,.10);
}

.crm-field select:focus {
    border-color: var(--crm-primary);
    background:
        linear-gradient(45deg, transparent 50%, var(--crm-primary-2) 50%) calc(100% - 23px) 50% / 7px 7px no-repeat,
        linear-gradient(135deg, var(--crm-primary-2) 50%, transparent 50%) calc(100% - 16px) 50% / 7px 7px no-repeat,
        var(--crm-panel-solid);
}

/* iOS-like theme switch */
.crm-theme-toggle {
    display: none !important;
}

.crm-theme-switch {
    width: 74px;
    height: 42px;
    padding: 0;
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.crm-theme-switch-track {
    position: relative;
    width: 68px;
    height: 36px;
    border-radius: 999px;
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--crm-panel-solid) 72%, #020617 28%),
            color-mix(in srgb, var(--crm-panel-2) 74%, #020617 26%)
        );
    border: 1px solid var(--crm-border);
    box-shadow:
        inset 0 1px 5px rgba(0,0,0,.18),
        var(--crm-shadow-soft);
    transition: background .2s ease, border-color .2s ease;
}

.crm-theme-switch-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 25%, #ffffff, #dbeafe 55%, #93c5fd);
    box-shadow:
        0 8px 16px rgba(0,0,0,.22),
        0 0 0 1px rgba(255,255,255,.32) inset;
    transition: transform .24s cubic-bezier(.2,.8,.2,1), background .2s ease;
    z-index: 2;
}

html[data-theme="light"] .crm-theme-switch-thumb {
    transform: translateX(32px);
    background:
        radial-gradient(circle at 35% 30%, #fff7ed, #fde047 56%, #f59e0b);
}

html[data-theme="light"] .crm-theme-switch-track {
    background:
        linear-gradient(135deg, rgba(96,165,250,.30), rgba(250,204,21,.22)),
        var(--crm-panel);
}

.crm-theme-switch-icon {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    color: var(--crm-soft);
    z-index: 1;
}

.crm-theme-switch-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.crm-theme-switch-moon {
    left: 10px;
}

.crm-theme-switch-sun {
    right: 10px;
}

html[data-theme="dark"] .crm-theme-switch-moon,
html[data-theme="light"] .crm-theme-switch-sun {
    color: transparent;
}

/* Организации: подпись должности и расстояния */
.crm-org-widget {
    height: 56px;
    padding-top: 7px;
    padding-bottom: 7px;
}

.crm-dropdown-current {
    line-height: 1.05;
}

.crm-dropdown-current-sub {
    display: block;
    max-width: 205px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--crm-soft);
    font-size: 11px;
    line-height: 1;
    margin-top: 5px;
    font-style: normal;
    font-weight: 750;
}

.crm-dropdown-menu {
    padding: 10px;
}

.crm-dropdown-item {
    min-height: 50px;
    margin: 4px 0;
    gap: 12px;
}

.crm-dropdown-item:first-child {
    margin-top: 0;
}

.crm-dropdown-item:last-child {
    margin-bottom: 0;
}

.crm-dropdown-item-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.crm-dropdown-item-text strong {
    font-size: 14px;
    line-height: 1;
    font-weight: 850;
}

.crm-dropdown-item-text small {
    color: var(--crm-soft);
    font-size: 12px;
    line-height: 1;
    font-weight: 700;
}

.crm-dropdown-item:hover .crm-dropdown-item-text small,
.crm-dropdown-item.active .crm-dropdown-item-text small {
    color: color-mix(in srgb, var(--crm-primary-2) 56%, var(--crm-soft) 44%);
}

@media (max-width: 920px) {
    .crm-topbar {
        width: 100%;
        max-width: 100vw;
        overflow: visible;
    }

    .crm-topbar-left,
    .crm-topbar-right {
        min-width: 0;
    }

    .crm-topbar-right {
        gap: 8px;
    }
}

@media (max-width: 680px) {
    body {
        overflow-x: hidden;
    }

    .crm-topbar {
        padding-left: 10px;
        padding-right: 10px;
        gap: 8px;
    }

    .crm-topbar-left {
        flex: 1 1 auto;
        min-width: 0;
    }

    .crm-topbar-right {
        flex: 0 0 auto;
    }

    .crm-org-widget {
        width: min(210px, calc(100vw - 178px));
        min-width: 0;
        max-width: min(210px, calc(100vw - 178px));
        padding-left: 11px;
        padding-right: 34px;
    }

    .crm-dropdown-current,
    .crm-dropdown-current-sub {
        max-width: 145px;
    }

    .crm-theme-switch {
        width: 58px;
    }

    .crm-theme-switch-track {
        width: 54px;
        height: 32px;
    }

    .crm-theme-switch-thumb {
        width: 24px;
        height: 24px;
    }

    html[data-theme="light"] .crm-theme-switch-thumb {
        transform: translateX(22px);
    }

    .crm-theme-switch-icon {
        display: none;
    }

    .crm-profile {
        min-width: 42px;
        width: 42px;
        height: 42px;
        padding: 2px;
        flex: 0 0 42px;
    }

    .crm-avatar {
        width: 36px;
        height: 36px;
    }

    .crm-main {
        width: 100%;
        padding-left: 12px;
        padding-right: 12px;
    }

    .crm-dashboard-hero,
    .crm-card,
    .crm-stat-card {
        width: 100%;
    }

    .crm-grid {
        width: 100%;
    }

    .crm-dropdown-menu {
        max-width: calc(100vw - 20px);
    }

    .crm-org-dropdown .crm-dropdown-menu {
        left: 0;
        width: min(280px, calc(100vw - 20px));
    }

    .crm-profile-dropdown .crm-dropdown-menu {
        right: 0;
        width: 210px;
    }
}


/* ===== v7 collapsed org clean + real custom selects ===== */

.crm-org-widget {
    height: 48px;
}

.crm-org-widget .crm-dropdown-current-sub {
    display: none !important;
}

/* Нативный option почти не стилизуется в Chrome/Safari/мобилках.
   Поэтому для красивых выпадашек используй .crm-select ниже. */
.crm-select {
    position: relative;
    width: 100%;
}

.crm-select-btn {
    width: 100%;
    height: 48px;
    border: 1px solid color-mix(in srgb, var(--crm-border) 70%, var(--crm-primary) 30%);
    border-radius: 16px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--crm-panel-2) 88%, var(--crm-primary) 12%),
            color-mix(in srgb, var(--crm-panel-2) 96%, #000 4%)
        );
    color: var(--crm-text);
    padding: 0 14px 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 750;
    text-align: left;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.05),
        0 8px 18px rgba(15,23,42,.05);
    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        background-color .16s ease;
}

.crm-select-btn:hover,
.crm-select.open .crm-select-btn {
    border-color: var(--crm-primary);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.06),
        0 12px 26px rgba(37,99,235,.13);
}

.crm-select-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-select-btn em {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    color: var(--crm-primary-2);
    transition: transform .22s cubic-bezier(.2,.8,.2,1);
    font-style: normal;
    flex: 0 0 22px;
}

.crm-select.open .crm-select-btn em {
    transform: rotate(180deg);
}

.crm-select-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.crm-select-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    padding: 8px;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
    background:
        linear-gradient(180deg,
            color-mix(in srgb, var(--crm-panel-solid) 94%, var(--crm-primary) 6%),
            var(--crm-panel-solid)
        );
    box-shadow: var(--crm-shadow);
    backdrop-filter: blur(22px);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-7px) scale(.98);
    transform-origin: top;
    transition:
        opacity .16s ease,
        visibility .16s ease,
        transform .16s cubic-bezier(.2,.8,.2,1);
}

.crm-select.open .crm-select-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.crm-select-option {
    width: 100%;
    min-height: 42px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: var(--crm-text);
    display: flex;
    align-items: center;
    padding: 9px 11px;
    text-align: left;
    font-weight: 750;
    margin: 3px 0;
    transition:
        background-color .14s ease,
        color .14s ease,
        transform .14s ease;
}

.crm-select-option:hover,
.crm-select-option.active {
    background: color-mix(in srgb, var(--crm-primary) 14%, transparent);
    color: color-mix(in srgb, var(--crm-primary-2) 62%, var(--crm-text) 38%);
}

.crm-select-option:hover {
    transform: translateX(2px);
}

.crm-select-option.active::after {
    content: "✓";
    margin-left: auto;
    color: var(--crm-success);
    font-weight: 900;
}

/* На всякий случай нативные select тоже оставляем приличными, но option браузер всё равно рисует сам */
.crm-field select option {
    padding: 12px 14px;
    min-height: 42px;
    background: var(--crm-panel-solid);
    color: var(--crm-text);
    font-weight: 750;
}

@media (max-width: 680px) {
    .crm-org-widget {
        height: 48px;
    }
}


/* ===== v8 organization height + date/file upload ===== */

.crm-org-widget {
    height: 54px;
    min-height: 54px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.crm-org-widget .crm-dropdown-current {
    line-height: 1.18;
    padding-bottom: 1px;
}

.crm-date-input {
    color-scheme: dark;
}

html[data-theme="light"] .crm-date-input {
    color-scheme: light;
}

.crm-date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: .75;
    filter: invert(70%) sepia(77%) saturate(1163%) hue-rotate(176deg) brightness(99%) contrast(96%);
}

.crm-date-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.crm-file-upload {
    position: relative;
    min-height: 170px;
    border: 1px dashed color-mix(in srgb, var(--crm-primary) 54%, var(--crm-border) 46%);
    border-radius: 20px;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .10), transparent 18rem),
        color-mix(in srgb, var(--crm-panel-2) 88%, transparent);
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition:
        border-color .16s ease,
        background-color .16s ease,
        transform .16s ease,
        box-shadow .16s ease;
}

.crm-file-upload:hover {
    border-color: var(--crm-primary-2);
    transform: translateY(-1px);
    box-shadow: 0 16px 34px rgba(37, 99, 235, .12);
}

.crm-file-upload input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.crm-file-icon {
    width: 58px;
    height: 58px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    color: white;
    box-shadow: 0 14px 30px rgba(37, 99, 235, .28);
}

.crm-file-icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.crm-file-upload strong {
    font-size: 15px;
    font-weight: 850;
}

.crm-file-upload small {
    max-width: 440px;
    color: var(--crm-soft);
    font-size: 13px;
    line-height: 1.45;
}

.crm-file-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.crm-file-item {
    display: grid;
    grid-template-columns: 48px 1fr 44px;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: var(--crm-panel-2);
}

.crm-file-type {
    width: 48px;
    height: 38px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--crm-primary) 18%, transparent);
    color: var(--crm-primary-2);
    font-size: 11px;
    font-weight: 900;
}

.crm-file-item strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.crm-file-item small {
    display: block;
    color: var(--crm-soft);
    font-size: 12px;
    margin-top: 3px;
}

@media (max-width: 680px) {
    .crm-org-widget {
        height: 52px;
        min-height: 52px;
    }

    .crm-file-upload {
        min-height: 150px;
        padding: 18px;
    }

    .crm-file-item {
        grid-template-columns: 44px 1fr 40px;
    }
}


/* v9 compact upload */
.crm-file-upload{
    min-height:90px !important;
    padding:14px 18px !important;
    grid-template-columns:56px 1fr;
    display:grid;
    text-align:left;
    align-items:center;
    justify-content:flex-start;
}

.crm-file-icon{
    width:44px;
    height:44px;
    border-radius:14px;
}

.crm-file-icon svg{
    width:22px;
    height:22px;
}

.crm-file-upload strong{
    margin-bottom:4px;
}

.crm-file-upload small{
    max-width:none;
}

.crm-file-upload.dragover{
    border-color:var(--crm-primary-2);
    background:rgba(56,189,248,.08);
}


/* ===== v11 SAFE: sidebar scrollbar hidden + large submenu height ===== */

/* Не трогаем глобальные скроллы страницы, чтобы ничего не уезжало */
html,
body {
    overflow-x: hidden;
}

/* Скрываем визуальный скролл только у левого меню */
.crm-nav {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 24px;
}

.crm-nav::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* Без grid-хака. Просто большой запас высоты для длинных подменю */
.crm-nav-sub {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        max-height .34s cubic-bezier(.2, .8, .2, 1),
        opacity .20s ease,
        transform .20s ease,
        padding .20s ease;
}

/* 2000px хватит даже на дохрена пунктов, при этом ничего не срезает */
.crm-nav-group.open .crm-nav-sub {
    max-height: 2000px;
    opacity: 1;
    transform: translateY(0);
    padding: 3px 0 12px 48px;
}

.crm-nav-sub a {
    min-height: 36px;
    line-height: 1.25;
    white-space: normal;
    display: flex;
    align-items: center;
}

/* Скрыть горизонтальную прокрутку в таблицах нельзя, там она нужна.
   Но сама страница не должна гулять влево-вправо. */
.crm-layout,
.crm-main,
.crm-card,
.crm-dashboard-hero,
.crm-table-wrap {
    max-width: 100%;
    min-width: 0;
}

@media (max-width: 680px) {
    .crm-table {
        min-width: 720px;
    }
}


/* ===== v12 upload alignment + recipients UI ===== */

.crm-file-upload {
    width: 100%;
    max-width: 520px;
    min-height: 82px !important;
    padding: 12px 16px !important;
    display: grid !important;
    grid-template-columns: 46px 1fr !important;
    grid-template-areas:
        "icon title"
        "icon text" !important;
    column-gap: 13px;
    row-gap: 3px;
    align-items: center;
    justify-content: start;
    place-items: initial !important;
    align-content: center !important;
    text-align: left !important;
}

.crm-file-upload .crm-file-icon {
    grid-area: icon;
    justify-self: center;
    align-self: center;
}

.crm-file-upload strong {
    grid-area: title;
    margin: 0;
    line-height: 1.15;
}

.crm-file-upload small {
    grid-area: text;
    margin: 0;
    line-height: 1.3;
}

.crm-file-list {
    max-width: 520px;
}

.crm-recipient-box {
    border: 1px solid var(--crm-border);
    border-radius: 20px;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .08), transparent 18rem),
        var(--crm-panel-2);
    padding: 14px;
    display: grid;
    gap: 14px;
}

.crm-segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 5px;
    border: 1px solid var(--crm-border);
    border-radius: 17px;
    background: color-mix(in srgb, var(--crm-panel-solid) 74%, transparent);
}

.crm-segmented-item {
    min-height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: var(--crm-soft);
    font-weight: 850;
    cursor: pointer;
    transition:
        background-color .16s ease,
        color .16s ease,
        box-shadow .16s ease,
        transform .16s ease;
}

.crm-segmented-item input {
    display: none;
}

.crm-segmented-item:hover {
    color: var(--crm-text);
    background: color-mix(in srgb, var(--crm-primary) 8%, transparent);
}

.crm-segmented-item.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--crm-primary), #1d4ed8);
    box-shadow: 0 10px 22px rgba(37, 99, 235, .25);
}

.crm-recipient-panel {
    display: none;
    animation: crmFadeUp .16s ease;
}

.crm-recipient-panel.active {
    display: block;
}

@keyframes crmFadeUp {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.crm-info-line {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 12px;
    align-items: center;
    min-height: 70px;
    padding: 12px;
    border: 1px solid var(--crm-border);
    border-radius: 17px;
    background: var(--crm-panel);
}

.crm-info-icon {
    width: 42px;
    height: 42px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--crm-primary) 16%, transparent);
    color: var(--crm-primary-2);
}

.crm-info-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.crm-info-line strong {
    display: block;
    font-size: 14px;
}

.crm-info-line small {
    display: block;
    color: var(--crm-soft);
    font-size: 13px;
    margin-top: 4px;
}

.crm-field-inner {
    margin: 0;
}

.crm-check-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.crm-check-row {
    position: relative;
    min-height: 64px;
    border: 1px solid var(--crm-border);
    border-radius: 17px;
    background: var(--crm-panel);
    padding: 11px 12px;
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 11px;
    align-items: center;
    cursor: pointer;
    transition:
        border-color .16s ease,
        background-color .16s ease,
        transform .16s ease,
        box-shadow .16s ease;
}

.crm-check-row:hover {
    border-color: color-mix(in srgb, var(--crm-primary) 55%, var(--crm-border) 45%);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(37, 99, 235, .10);
}

.crm-check-row input {
    display: none;
}

.crm-check-row > span {
    width: 22px;
    height: 22px;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--crm-border-strong) 78%, var(--crm-primary) 22%);
    background: var(--crm-panel-2);
    display: grid;
    place-items: center;
    transition: .16s ease;
}

.crm-check-row > span::after {
    content: "✓";
    color: white;
    font-size: 13px;
    font-weight: 900;
    opacity: 0;
    transform: scale(.7);
    transition: .16s ease;
}

.crm-check-row input:checked + span {
    border-color: var(--crm-primary);
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    box-shadow: 0 8px 18px rgba(37, 99, 235, .25);
}

.crm-check-row input:checked + span::after {
    opacity: 1;
    transform: scale(1);
}

.crm-check-row:has(input:checked) {
    border-color: color-mix(in srgb, var(--crm-primary) 62%, var(--crm-border) 38%);
    background: color-mix(in srgb, var(--crm-primary) 9%, var(--crm-panel) 91%);
}

.crm-check-row strong {
    display: block;
    font-size: 14px;
    line-height: 1.1;
}

.crm-check-row small {
    display: block;
    color: var(--crm-soft);
    font-size: 12px;
    margin-top: 5px;
}

@media (max-width: 680px) {
    .crm-file-upload {
        max-width: 100%;
        grid-template-columns: 42px 1fr !important;
    }

    .crm-file-list {
        max-width: 100%;
    }

    .crm-segmented {
        grid-template-columns: 1fr;
    }

    .crm-check-list {
        grid-template-columns: 1fr;
    }
}


/* ===== v13 recipients reset + 50 organizations / 4 columns ===== */

.crm-check-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 520px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.crm-check-row {
    min-height: 68px;
}

.crm-check-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-check-row small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1280px) {
    .crm-check-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 920px) {
    .crm-check-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: 460px;
    }
}

@media (max-width: 680px) {
    .crm-check-list {
        grid-template-columns: 1fr;
        max-height: 420px;
    }
}


/* ===== v14 schools list + no hover overlap ===== */

/* Убираем сдвиг карточки при наведении, чтобы не заезжала под соседние элементы */
.crm-check-row:hover {
    transform: none !important;
}

/* Компенсируем отсутствие движения более аккуратным подсветом */
.crm-check-row:hover {
    background: color-mix(in srgb, var(--crm-primary) 8%, var(--crm-panel) 92%);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--crm-primary) 45%, transparent);
}

/* Чуть увеличим зазор между организациями */
.crm-check-list {
    gap: 12px !important;
}


/* ===== v15: no inner scroll in organizations list ===== */

.crm-check-list {
    max-height: none !important;
    overflow: visible !important;
    padding-right: 0 !important;
}

/* Родитель тоже не должен резать список */
.crm-recipient-panel,
.crm-recipient-box {
    overflow: visible !important;
}


/* ===== v16 task view pages ===== */

.crm-task-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 18px;
    align-items: start;
}

.crm-task-main,
.crm-task-side {
    min-width: 0;
}

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

.crm-task-head h2 {
    margin: 0;
    font-size: clamp(22px, 2.5vw, 32px);
    line-height: 1.08;
    letter-spacing: -.055em;
}

.crm-task-text {
    color: var(--crm-soft);
    line-height: 1.55;
    margin-bottom: 18px;
}

.crm-task-text p {
    margin: 0;
}

.crm-task-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.crm-task-status.done {
    background: rgba(34, 197, 94, .16);
    color: #86efac;
}

html[data-theme="light"] .crm-task-status.done {
    color: #166534;
}

.crm-task-status.inwork {
    background: rgba(59, 130, 246, .16);
    color: #93c5fd;
}

html[data-theme="light"] .crm-task-status.inwork {
    color: #1d4ed8;
}

.crm-task-status.wait {
    background: rgba(148, 163, 184, .16);
    color: var(--crm-soft);
}

.crm-task-status.problem {
    background: rgba(239, 68, 68, .16);
    color: #fca5a5;
}

html[data-theme="light"] .crm-task-status.problem {
    color: #991b1b;
}

.crm-task-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.crm-task-meta {
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: var(--crm-panel-2);
    padding: 12px;
    min-width: 0;
}

.crm-task-meta span {
    display: block;
    color: var(--crm-soft);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 6px;
}

.crm-task-meta strong {
    display: block;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-task-section-title {
    display: block;
    color: var(--crm-soft);
    font-size: 13px;
    font-weight: 900;
    margin-bottom: 10px;
}

.crm-task-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.crm-task-file {
    min-width: 220px;
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: var(--crm-panel-2);
    padding: 10px;
    display: grid;
    grid-template-columns: 44px 1fr;
    gap: 10px;
    align-items: center;
    transition: .16s ease;
}

.crm-task-file:hover {
    border-color: var(--crm-primary);
    background: color-mix(in srgb, var(--crm-primary) 7%, var(--crm-panel-2) 93%);
}

.crm-task-file > span {
    width: 44px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: var(--crm-primary-2);
    background: color-mix(in srgb, var(--crm-primary) 15%, transparent);
    font-size: 11px;
    font-weight: 900;
}

.crm-task-file strong {
    display: block;
    font-size: 13px;
}

.crm-task-file small {
    display: block;
    color: var(--crm-soft);
    margin-top: 3px;
    font-size: 12px;
}

.crm-task-progress-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.crm-task-progress {
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: var(--crm-panel-2);
    padding: 13px;
}

.crm-task-progress-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 850;
}

.crm-task-progress-top span {
    color: var(--crm-soft);
}

.crm-progress {
    height: 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--crm-border) 55%, transparent);
    overflow: hidden;
}

.crm-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--crm-primary), var(--crm-primary-2));
}

.crm-progress.success span {
    background: linear-gradient(90deg, var(--crm-success), #86efac);
}

.crm-chat-list {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}

.crm-chat-message {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    align-items: flex-start;
}

.crm-chat-message.incoming {
    opacity: .94;
}

.crm-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    color: white;
    font-weight: 900;
}

.crm-chat-bubble {
    border: 1px solid var(--crm-border);
    border-radius: 18px;
    background: var(--crm-panel-2);
    padding: 12px;
}

.crm-chat-author {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.crm-chat-author strong {
    font-size: 13px;
}

.crm-chat-author time {
    color: var(--crm-soft);
    font-size: 12px;
}

.crm-chat-bubble p {
    margin: 0;
    color: var(--crm-text);
    line-height: 1.45;
}

.crm-chat-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: end;
}

.crm-chat-form textarea {
    width: 100%;
    min-height: 48px;
    resize: vertical;
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: var(--crm-panel-2);
    color: var(--crm-text);
    padding: 12px;
    outline: none;
}

.crm-chat-form textarea:focus {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, .15);
}

.crm-task-mini-stats {
    display: grid;
    gap: 10px;
}

.crm-task-mini-stats div {
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: var(--crm-panel-2);
    padding: 12px;
}

.crm-task-mini-stats strong {
    display: block;
    font-size: 26px;
    line-height: 1;
}

.crm-task-mini-stats span {
    display: block;
    color: var(--crm-soft);
    margin-top: 5px;
}

.crm-executor-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
}

.crm-executor-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    background: var(--crm-panel-solid);
}

.crm-executor-table th,
.crm-executor-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--crm-border);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.crm-executor-table th {
    color: var(--crm-soft);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    background: var(--crm-panel-2);
}

.crm-executor-table tr:hover td {
    background: color-mix(in srgb, var(--crm-primary) 6%, transparent);
}

.crm-executor-table tr:last-child td {
    border-bottom: 0;
}

.crm-executor-org strong {
    display: block;
    font-size: 13px;
    line-height: 1.1;
}

.crm-executor-org small {
    display: block;
    color: var(--crm-soft);
    font-size: 11px;
    margin-top: 3px;
}

.crm-mini-file {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 8px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--crm-primary) 12%, transparent);
    color: var(--crm-primary-2);
    font-size: 12px;
    font-weight: 800;
}

.crm-muted {
    color: var(--crm-soft);
}

.crm-btn-danger {
    background: rgba(239, 68, 68, .14);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, .22);
}

html[data-theme="light"] .crm-btn-danger {
    color: #991b1b;
}

.crm-btn-sm {
    min-height: 30px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 12px;
}

.crm-user-answer {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--crm-border);
    display: grid;
    gap: 14px;
}

.crm-task-my-status {
    display: grid;
    gap: 10px;
}

.crm-task-my-status p {
    margin: 0;
    color: var(--crm-soft);
}

.crm-task-my-status strong {
    color: var(--crm-text);
}

@media (max-width: 1180px) {
    .crm-task-layout {
        grid-template-columns: 1fr;
    }

    .crm-task-side {
        display: none;
    }

    .crm-task-meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .crm-task-head {
        flex-direction: column;
    }

    .crm-task-meta-grid,
    .crm-task-progress-grid {
        grid-template-columns: 1fr;
    }

    .crm-task-file {
        width: 100%;
        min-width: 0;
    }

    .crm-chat-form {
        grid-template-columns: 1fr;
    }

    .crm-executor-table {
        min-width: 900px;
    }
}


/* ===== v17 review status ===== */

.crm-task-status.review {
    background: rgba(245, 158, 11, .18);
    color: #fcd34d;
}

html[data-theme="light"] .crm-task-status.review {
    color: #92400e;
}

.crm-review-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.crm-btn-accept {
    background: rgba(34, 197, 94, .15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, .24);
}

html[data-theme="light"] .crm-btn-accept {
    color: #166534;
}

.crm-btn-reject {
    background: rgba(245, 158, 11, .15);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, .24);
}

html[data-theme="light"] .crm-btn-reject {
    color: #92400e;
}

.crm-btn-accept:hover,
.crm-btn-reject:hover {
    transform: none;
    filter: brightness(1.08);
}


/* ===== v18 chat modal ===== */

.crm-chat-open-card .crm-card-header {
    margin-bottom: 0;
    align-items: center;
}

.crm-chat-modal-window {
    width: min(760px, calc(100vw - 28px));
}

.crm-chat-modal .crm-modal-body {
    padding: 0;
}

.crm-chat-modal-content {
    padding: 18px;
}

.crm-chat-modal-content > .crm-card-header {
    display: none;
}

.crm-chat-modal-content .crm-chat-list {
    max-height: min(58vh, 520px);
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 14px;
}

.crm-chat-modal-content .crm-chat-form {
    position: sticky;
    bottom: 0;
    background: var(--crm-panel-solid);
    padding-top: 12px;
    border-top: 1px solid var(--crm-border);
}

@media (max-width: 680px) {
    .crm-chat-open-card .crm-card-header {
        align-items: stretch;
    }

    .crm-chat-modal-window {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
        border-radius: 20px;
    }

    .crm-chat-modal-content {
        padding: 14px;
    }

    .crm-chat-modal-content .crm-chat-list {
        max-height: 62vh;
    }
}


/* ===== v19 user task redesign ===== */

.crm-task-action-panel {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--crm-border);
}

.crm-task-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.crm-delegate-list {
    display: grid;
    gap: 9px;
}

.crm-delegate-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 11px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid var(--crm-border);
    border-radius: 16px;
    background: var(--crm-panel-2);
}

.crm-delegate-avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--crm-primary) 18%, transparent);
    color: var(--crm-primary-2);
    font-size: 12px;
    font-weight: 900;
}

.crm-delegate-row strong {
    display: block;
    font-size: 14px;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-delegate-row small {
    display: block;
    color: var(--crm-soft);
    font-size: 12px;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-task-timeline {
    position: relative;
    display: grid;
}

.crm-timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 12px;
    padding: 0 0 18px;
}

.crm-timeline-item:last-child {
    padding-bottom: 0;
}

.crm-timeline-item::before {
    content: "";
    position: absolute;
    left: 11px;
    top: 24px;
    bottom: 0;
    width: 2px;
    background: var(--crm-border);
}

.crm-timeline-item:last-child::before {
    display: none;
}

.crm-timeline-item > span {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--crm-panel-2);
    border: 2px solid var(--crm-border-strong);
    z-index: 1;
}

.crm-timeline-item.done > span {
    background: var(--crm-success);
    border-color: var(--crm-success);
    box-shadow: 0 0 0 5px rgba(34, 197, 94, .13);
}

.crm-timeline-item.active > span {
    background: var(--crm-primary);
    border-color: var(--crm-primary-2);
    box-shadow: 0 0 0 5px rgba(37, 99, 235, .16);
}

.crm-timeline-item.wait > span {
    background: var(--crm-panel-2);
    border-color: var(--crm-border-strong);
}

.crm-timeline-item strong {
    display: block;
    font-size: 14px;
    line-height: 1.15;
}

.crm-timeline-item small {
    display: block;
    color: var(--crm-soft);
    font-size: 12px;
    margin-top: 4px;
}

@media (max-width: 680px) {
    .crm-task-action-buttons {
        display: grid;
        grid-template-columns: 1fr;
    }

    .crm-delegate-row {
        grid-template-columns: 36px minmax(0, 1fr);
    }

    .crm-delegate-row .crm-btn {
        grid-column: 1 / -1;
        width: 100%;
    }
}


/* ===== v20 task list page ===== */

.crm-task-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.crm-task-tab {
    position: relative;
    min-height: 116px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-xl);
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .12), transparent 18rem),
        var(--crm-panel);
    box-shadow: var(--crm-shadow-soft);
    padding: 22px 76px 22px 22px;
    display: flex;
    align-items: center;
    overflow: hidden;
    transition: .16s ease;
}

.crm-task-tab:hover {
    border-color: color-mix(in srgb, var(--crm-primary) 52%, var(--crm-border) 48%);
    transform: translateY(-1px);
}

.crm-task-tab.active {
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .18), transparent 18rem),
        linear-gradient(135deg, color-mix(in srgb, var(--crm-primary) 16%, var(--crm-panel) 84%), var(--crm-panel));
    box-shadow: 0 18px 42px rgba(37, 99, 235, .14);
}

.crm-task-tab span {
    display: block;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -.03em;
    margin-bottom: 7px;
}

.crm-task-tab strong {
    display: block;
    color: var(--crm-soft);
    font-size: 14px;
    font-weight: 750;
}

.crm-task-tab b {
    position: absolute;
    top: 14px;
    right: 14px;
    min-width: 42px;
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    color: white;
    font-size: 14px;
    box-shadow: 0 12px 24px rgba(37, 99, 235, .26);
}

.crm-table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
    background: var(--crm-panel-2);
    padding: 12px;
    margin-bottom: 14px;
}

.crm-table-toolbar-left,
.crm-table-toolbar-right,
.crm-bulk-actions,
.crm-rows-select {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-rows-select > span {
    color: var(--crm-soft);
    font-size: 13px;
    font-weight: 850;
}

.crm-select-sm {
    width: 92px;
}

.crm-select-sm .crm-select-btn {
    height: 38px;
    border-radius: 13px;
}

.crm-task-search {
    min-width: 280px;
}

.crm-pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin: 12px 0;
}

.crm-pagination-info {
    color: var(--crm-soft);
    font-size: 13px;
}

.crm-pagination-info strong {
    color: var(--crm-text);
}

.crm-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
}

.crm-pagination button,
.crm-pagination span {
    min-width: 34px;
    height: 34px;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    background: var(--crm-panel-2);
    color: var(--crm-text);
    display: grid;
    place-items: center;
    font-weight: 850;
}

.crm-pagination button.active {
    background: linear-gradient(135deg, var(--crm-primary), #1d4ed8);
    color: white;
    border-color: transparent;
}

.crm-pagination button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.crm-task-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
}

.crm-task-table {
    width: 100%;
    min-width: 1320px;
    border-collapse: collapse;
    background: var(--crm-panel-solid);
}

.crm-task-table th,
.crm-task-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--crm-border);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.crm-task-table th {
    color: var(--crm-soft);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    background: var(--crm-panel-2);
}

.crm-task-table tr:hover td {
    background: color-mix(in srgb, var(--crm-primary) 6%, transparent);
}

.crm-task-table tr:last-child td {
    border-bottom: 0;
}

.crm-check-cell {
    width: 44px;
    text-align: center !important;
}

.crm-table-check {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
}

.crm-table-check input {
    display: none;
}

.crm-table-check span {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    border: 1px solid color-mix(in srgb, var(--crm-border-strong) 78%, var(--crm-primary) 22%);
    background: var(--crm-panel-2);
    display: grid;
    place-items: center;
    transition: .16s ease;
}

.crm-table-check span::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: 900;
    opacity: 0;
    transform: scale(.7);
    transition: .16s ease;
}

.crm-table-check input:checked + span {
    border-color: var(--crm-primary);
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    box-shadow: 0 8px 16px rgba(37, 99, 235, .22);
}

.crm-table-check input:checked + span::after {
    opacity: 1;
    transform: scale(1);
}

.crm-task-title-link {
    display: grid;
    gap: 4px;
    min-width: 360px;
}

.crm-task-title-link strong {
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    line-height: 1.15;
}

.crm-task-title-link small {
    color: var(--crm-soft);
    font-size: 12px;
}

.crm-table-progress {
    width: 96px;
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--crm-border) 55%, transparent);
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.crm-table-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--crm-primary), var(--crm-primary-2));
}

.crm-table-progress.success span {
    background: linear-gradient(90deg, var(--crm-success), #86efac);
}

.crm-table-percent {
    display: inline-block;
    color: var(--crm-soft);
    font-size: 11px;
    font-weight: 800;
    margin-left: 6px;
    vertical-align: middle;
}

@media (max-width: 920px) {
    .crm-task-tabs {
        grid-template-columns: 1fr;
    }

    .crm-table-toolbar,
    .crm-pagination-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-table-toolbar-left,
    .crm-table-toolbar-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .crm-task-search {
        width: 100%;
        min-width: 0;
    }

    .crm-pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 680px) {
    .crm-task-tab {
        min-height: 104px;
        padding: 18px 68px 18px 18px;
    }

    .crm-task-tab span {
        font-size: 18px;
    }

    .crm-bulk-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crm-bulk-actions .crm-btn {
        width: 100%;
    }

    .crm-task-table {
        min-width: 1180px;
    }
}


/* ===== v21 task list + right-side chat/history fixes ===== */

/* На планшете/мобилке правая колонка уходит вниз, а не скрывается */
@media (max-width: 1180px) {
    .crm-task-layout {
        grid-template-columns: 1fr !important;
    }

    .crm-task-side {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 18px !important;
        width: 100% !important;
    }
}

@media (max-width: 680px) {
    .crm-task-side {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .crm-chat-open-card .crm-card-header {
        flex-direction: row !important;
        align-items: center !important;
    }

    .crm-chat-open-card .crm-card-header .crm-btn {
        width: auto !important;
        flex: 0 0 auto !important;
    }
}

/* Страница списка задач */
.crm-task-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.crm-task-tab {
    position: relative;
    min-height: 116px;
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-xl);
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .12), transparent 18rem),
        var(--crm-panel);
    box-shadow: var(--crm-shadow-soft);
    padding: 22px 76px 22px 22px;
    display: flex;
    align-items: center;
    overflow: hidden;
    transition: .16s ease;
}

.crm-task-tab:hover {
    border-color: color-mix(in srgb, var(--crm-primary) 52%, var(--crm-border) 48%);
    transform: translateY(-1px);
}

.crm-task-tab.active {
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .18), transparent 18rem),
        linear-gradient(135deg, color-mix(in srgb, var(--crm-primary) 16%, var(--crm-panel) 84%), var(--crm-panel));
    box-shadow: 0 18px 42px rgba(37, 99, 235, .14);
}

.crm-task-tab span {
    display: block;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: -.03em;
    margin-bottom: 7px;
}

.crm-task-tab strong {
    display: block;
    color: var(--crm-soft);
    font-size: 14px;
    font-weight: 750;
}

.crm-task-tab b {
    position: absolute;
    top: 14px;
    right: 14px;
    min-width: 42px;
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    color: white;
    font-size: 14px;
    box-shadow: 0 12px 24px rgba(37, 99, 235, .26);
}

.crm-table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
    background: var(--crm-panel-2);
    padding: 12px;
    margin-bottom: 14px;
}

.crm-table-toolbar-left,
.crm-table-toolbar-right,
.crm-bulk-actions,
.crm-rows-select {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-rows-select > span {
    color: var(--crm-soft);
    font-size: 13px;
    font-weight: 850;
}

.crm-select-sm {
    width: 92px;
}

.crm-select-sm .crm-select-btn {
    height: 38px;
    border-radius: 13px;
}

.crm-task-search {
    min-width: 280px;
}

.crm-pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin: 12px 0;
}

.crm-pagination-info {
    color: var(--crm-soft);
    font-size: 13px;
}

.crm-pagination-info strong {
    color: var(--crm-text);
}

.crm-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
}

.crm-pagination button,
.crm-pagination span {
    min-width: 34px;
    height: 34px;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    background: var(--crm-panel-2);
    color: var(--crm-text);
    display: grid;
    place-items: center;
    font-weight: 850;
}

.crm-pagination button.active {
    background: linear-gradient(135deg, var(--crm-primary), #1d4ed8);
    color: white;
    border-color: transparent;
}

.crm-pagination button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.crm-task-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
}

.crm-task-table {
    width: 100%;
    min-width: 1320px;
    border-collapse: collapse;
    background: var(--crm-panel-solid);
}

.crm-task-table th,
.crm-task-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--crm-border);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.crm-task-table th {
    color: var(--crm-soft);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    background: var(--crm-panel-2);
}

.crm-task-table tr:hover td {
    background: color-mix(in srgb, var(--crm-primary) 6%, transparent);
}

.crm-task-table tr:last-child td {
    border-bottom: 0;
}

.crm-check-cell {
    width: 44px;
    text-align: center !important;
}

.crm-table-check {
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    cursor: pointer;
}

.crm-table-check input {
    display: none;
}

.crm-table-check span {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    border: 1px solid color-mix(in srgb, var(--crm-border-strong) 78%, var(--crm-primary) 22%);
    background: var(--crm-panel-2);
    display: grid;
    place-items: center;
    transition: .16s ease;
}

.crm-table-check span::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: 900;
    opacity: 0;
    transform: scale(.7);
    transition: .16s ease;
}

.crm-table-check input:checked + span {
    border-color: var(--crm-primary);
    background: linear-gradient(135deg, var(--crm-primary), var(--crm-primary-2));
    box-shadow: 0 8px 16px rgba(37, 99, 235, .22);
}

.crm-table-check input:checked + span::after {
    opacity: 1;
    transform: scale(1);
}

.crm-task-title-link {
    display: grid;
    gap: 4px;
    min-width: 360px;
}

.crm-task-title-link strong {
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    line-height: 1.15;
}

.crm-task-title-link small {
    color: var(--crm-soft);
    font-size: 12px;
}

.crm-table-progress {
    width: 96px;
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--crm-border) 55%, transparent);
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
}

.crm-table-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--crm-primary), var(--crm-primary-2));
}

.crm-table-progress.success span {
    background: linear-gradient(90deg, var(--crm-success), #86efac);
}

.crm-table-percent {
    display: inline-block;
    color: var(--crm-soft);
    font-size: 11px;
    font-weight: 800;
    margin-left: 6px;
    vertical-align: middle;
}

@media (max-width: 920px) {
    .crm-task-tabs {
        grid-template-columns: 1fr;
    }

    .crm-table-toolbar,
    .crm-pagination-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-table-toolbar-left,
    .crm-table-toolbar-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .crm-task-search {
        width: 100%;
        min-width: 0;
    }

    .crm-pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 680px) {
    .crm-task-tab {
        min-height: 104px;
        padding: 18px 68px 18px 18px;
    }

    .crm-task-tab span {
        font-size: 18px;
    }

    .crm-bulk-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crm-bulk-actions .crm-btn {
        width: 100%;
    }

    .crm-task-table {
        min-width: 1180px;
    }
}


/* ===== v22 fixes: forms segmented colors + DataTables task list ===== */

/* 2. Исправление контраста кнопок Всем/Группе/Конкретным */
.crm-segmented-item.active {
    background: linear-gradient(135deg, #0f46d9, #0b2f9f) !important;
    box-shadow:
        0 10px 22px rgba(37, 99, 235, .35),
        inset 0 1px 0 rgba(255,255,255,.18) !important;
}

.crm-segmented-item.active span {
    color: #ffffff !important;
    font-weight: 900 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,.45);
}

html[data-theme="light"] .crm-segmented-item:not(.active) span {
    color: #334155 !important;
}

/* 3. DataTables-friendly task list */
.crm-dt-top,
.crm-dt-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.crm-dt-top {
    border: 1px solid var(--crm-border);
    border-radius: 18px;
    background: var(--crm-panel-2);
    padding: 12px;
    margin-bottom: 12px;
}

.crm-dt-pagination {
    margin: 12px 0;
}

.crm-dt-left,
.crm-dt-right,
.crm-bulk-actions,
.crm-rows-select {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-rows-select > span {
    color: var(--crm-soft);
    font-size: 13px;
    font-weight: 850;
}

.crm-select-sm {
    width: 92px;
}

.crm-select-sm .crm-select-btn {
    height: 38px;
    border-radius: 13px;
}

.crm-task-search {
    min-width: 280px;
}

.crm-datatable-wrap {
    width: 100%;
    overflow-x: visible;
    border: 1px solid var(--crm-border);
    border-radius: 18px;
}

.crm-datatable {
    width: 100%;
    border-collapse: collapse;
    background: var(--crm-panel-solid);
    table-layout: auto;
}

.crm-datatable th,
.crm-datatable td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--crm-border);
    text-align: left;
    vertical-align: middle;
    white-space: normal;
}

.crm-datatable th {
    color: var(--crm-soft);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    background: var(--crm-panel-2);
}

.crm-datatable tr:hover td {
    background: color-mix(in srgb, var(--crm-primary) 6%, transparent);
}

.crm-datatable tr:last-child td {
    border-bottom: 0;
}

.crm-datatable .crm-dt-check,
.crm-datatable td:first-child {
    width: 42px;
    text-align: center;
}

.custom-checkbox-input {
    width: 18px;
    height: 18px;
    accent-color: var(--crm-primary);
    cursor: pointer;
}

.crm-dt-task-link {
    color: var(--crm-text);
    font-weight: 800;
    line-height: 1.25;
}

.crm-dt-task-link:hover {
    color: var(--crm-primary-2);
}

.crm-dt-category {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 9px;
    border-radius: 999px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.crm-dt-category.blue { background: #007bff; }
.crm-dt-category.cyan { background: #0891b2; }
.crm-dt-category.violet { background: #7c3aed; }
.crm-dt-category.green { background: #16a34a; }
.crm-dt-category.orange { background: #ea580c; }

.crm-pagination-info {
    color: var(--crm-soft);
    font-size: 13px;
}

.crm-pagination-info strong {
    color: var(--crm-text);
}

.crm-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
}

.crm-pagination button,
.crm-pagination span {
    min-width: 34px;
    height: 34px;
    border: 1px solid var(--crm-border);
    border-radius: 12px;
    background: var(--crm-panel-2);
    color: var(--crm-text);
    display: grid;
    place-items: center;
    font-weight: 850;
}

.crm-pagination button.active {
    background: linear-gradient(135deg, var(--crm-primary), #1d4ed8);
    color: white;
    border-color: transparent;
}

.crm-pagination button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

@media (max-width: 920px) {
    .crm-dt-top,
    .crm-dt-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .crm-dt-left,
    .crm-dt-right {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .crm-task-search {
        width: 100%;
        min-width: 0;
    }

    .crm-pagination {
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 680px) {
    .crm-datatable-wrap {
        overflow-x: auto;
    }

    .crm-datatable {
        min-width: 920px;
    }

    .crm-bulk-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .crm-bulk-actions .crm-btn {
        width: 100%;
    }
}


/* ===== v23 soft categories + progressbar in task list ===== */

.crm-dt-category {
    min-height: 26px !important;
    padding: 2px 10px !important;
    border-radius: 999px !important;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
    color: var(--crm-text) !important;
    background: var(--crm-panel-2) !important;
}

/* Мягкие категории вместо кислотных цветов */
.crm-dt-category.blue {
    color: #93c5fd !important;
    background: rgba(59, 130, 246, .14) !important;
    border-color: rgba(59, 130, 246, .22);
}

.crm-dt-category.cyan {
    color: #67e8f9 !important;
    background: rgba(6, 182, 212, .13) !important;
    border-color: rgba(6, 182, 212, .22);
}

.crm-dt-category.violet {
    color: #c4b5fd !important;
    background: rgba(124, 58, 237, .14) !important;
    border-color: rgba(124, 58, 237, .22);
}

.crm-dt-category.green {
    color: #86efac !important;
    background: rgba(34, 197, 94, .13) !important;
    border-color: rgba(34, 197, 94, .22);
}

.crm-dt-category.orange {
    color: #fdba74 !important;
    background: rgba(249, 115, 22, .14) !important;
    border-color: rgba(249, 115, 22, .22);
}

html[data-theme="light"] .crm-dt-category.blue {
    color: #1d4ed8 !important;
    background: rgba(59, 130, 246, .11) !important;
}

html[data-theme="light"] .crm-dt-category.cyan {
    color: #0e7490 !important;
    background: rgba(6, 182, 212, .11) !important;
}

html[data-theme="light"] .crm-dt-category.violet {
    color: #6d28d9 !important;
    background: rgba(124, 58, 237, .10) !important;
}

html[data-theme="light"] .crm-dt-category.green {
    color: #166534 !important;
    background: rgba(34, 197, 94, .10) !important;
}

html[data-theme="light"] .crm-dt-category.orange {
    color: #c2410c !important;
    background: rgba(249, 115, 22, .11) !important;
}

.crm-dt-progress-cell {
    min-width: 128px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
}

.crm-dt-progress {
    height: 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--crm-border) 55%, transparent);
    overflow: hidden;
}

.crm-dt-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--crm-primary), var(--crm-primary-2));
}

.crm-dt-progress-cell strong {
    color: var(--crm-soft);
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}


/* ===== v27 auth page ===== */

.crm-auth-body {
    min-height: 100vh;
    overflow-x: hidden;
}

.crm-auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr);
    background:
        radial-gradient(circle at 12% 12%, rgba(37, 99, 235, .28), transparent 30rem),
        radial-gradient(circle at 88% 22%, rgba(6, 182, 212, .16), transparent 28rem),
        linear-gradient(135deg, #050b15, #08111f 42%, #0b1b32);
    color: #e7eefb;
}

.crm-auth-left {
    position: relative;
    min-height: 100vh;
    padding: 44px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.crm-auth-left::before {
    content: "";
    position: absolute;
    inset: 26px;
    border: 1px solid rgba(148, 163, 184, .14);
    border-radius: 34px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
    pointer-events: none;
}

.crm-auth-left::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    right: -120px;
    bottom: -130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56,189,248,.18), transparent 68%);
    pointer-events: none;
}

.crm-auth-logo {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 13px;
    width: fit-content;
}

.crm-auth-logo > span:last-child {
    display: grid;
    gap: 3px;
}

.crm-auth-logo strong {
    color: white;
    font-size: 18px;
    font-weight: 900;
}

.crm-auth-logo small {
    color: #93a4bd;
    font-size: 12px;
    font-weight: 750;
}

.crm-auth-hero {
    position: relative;
    z-index: 1;
    max-width: 720px;
}

.crm-auth-hero h1 {
    margin: 0;
    font-size: clamp(38px, 5vw, 68px);
    line-height: .96;
    letter-spacing: -.04em;
    font-weight: 900;
}

.crm-auth-hero p {
    max-width: 620px;
    margin: 22px 0 0;
    color: #a8b7cc;
    font-size: 17px;
    line-height: 1.55;
}

.crm-auth-benefits {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-width: 680px;
}

.crm-auth-benefits div {
    min-height: 92px;
    border: 1px solid rgba(148, 163, 184, .15);
    border-radius: 22px;
    background: rgba(15, 23, 42, .36);
    backdrop-filter: blur(18px);
    padding: 16px;
    display: grid;
    align-content: center;
    gap: 5px;
}

.crm-auth-benefits b {
    color: #38bdf8;
    font-size: 24px;
    line-height: 1;
}

.crm-auth-benefits span {
    color: #98a9c1;
    font-size: 13px;
    font-weight: 750;
}

.crm-auth-right {
    min-height: 100vh;
    padding: 34px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 18px;
}

.crm-auth-card {
    width: min(460px, 100%);
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 30px;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .10), transparent 18rem),
        rgba(14, 27, 48, .82);
    box-shadow: 0 30px 90px rgba(0,0,0,.36);
    backdrop-filter: blur(24px);
    padding: 28px;
}

.crm-auth-card-head {
    margin-bottom: 22px;
}

.crm-auth-badge {
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    color: #93c5fd;
    background: rgba(59, 130, 246, .14);
    border: 1px solid rgba(59, 130, 246, .22);
    font-size: 12px;
    font-weight: 900;
    margin-bottom: 14px;
}

.crm-auth-card h2 {
    margin: 0;
    color: white;
    font-size: 34px;
    line-height: 1;
    letter-spacing: -.03em;
}

.crm-auth-card p {
    margin: 10px 0 0;
    color: #9babc1;
    line-height: 1.45;
}

.crm-auth-form {
    display: grid;
    gap: 16px;
}

.crm-auth-field {
    display: grid;
    gap: 8px;
}

.crm-auth-field > span {
    color: #9fb0c8;
    font-size: 13px;
    font-weight: 850;
}

.crm-auth-field > div {
    min-height: 52px;
    border: 1px solid rgba(148, 163, 184, .15);
    border-radius: 18px;
    background: rgba(15, 23, 42, .42);
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    transition: .16s ease;
}

.crm-auth-field > div:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, .15);
    background: rgba(15, 23, 42, .62);
}

.crm-auth-field svg {
    width: 20px;
    height: 20px;
    fill: #38bdf8;
}

.crm-auth-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #e7eefb;
    font-weight: 750;
}

.crm-auth-field input::placeholder {
    color: #64748b;
}

.crm-auth-password-toggle {
    border: 0;
    background: transparent;
    color: #38bdf8;
    font-size: 12px;
    font-weight: 900;
}

.crm-auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.crm-auth-check {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
}

.crm-auth-check input {
    display: none;
}

.crm-auth-check span {
    width: 20px;
    height: 20px;
    border-radius: 7px;
    border: 1px solid rgba(148, 163, 184, .28);
    background: rgba(15, 23, 42, .42);
    display: grid;
    place-items: center;
}

.crm-auth-check span::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: 900;
    opacity: 0;
    transform: scale(.7);
    transition: .16s ease;
}

.crm-auth-check input:checked + span {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #2563eb, #38bdf8);
}

.crm-auth-check input:checked + span::after {
    opacity: 1;
    transform: scale(1);
}

.crm-auth-check em {
    color: #9fb0c8;
    font-style: normal;
    font-size: 13px;
    font-weight: 750;
}

.crm-auth-link {
    color: #38bdf8;
    font-size: 13px;
    font-weight: 850;
}

.crm-auth-submit {
    min-height: 52px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: white;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 16px 36px rgba(37, 99, 235, .28);
    transition: .16s ease;
}

.crm-auth-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 20px 42px rgba(37, 99, 235, .34);
}

.crm-auth-submit svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.crm-auth-note {
    border: 1px solid rgba(148, 163, 184, .13);
    border-radius: 18px;
    background: rgba(15, 23, 42, .32);
    padding: 13px;
    display: grid;
    gap: 4px;
}

.crm-auth-note strong {
    color: white;
    font-size: 13px;
}

.crm-auth-note span {
    color: #8fa0b9;
    font-size: 12px;
    line-height: 1.35;
}

.crm-auth-footer {
    width: min(460px, 100%);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #64748b;
    font-size: 12px;
    font-weight: 750;
}

@media (max-width: 980px) {
    .crm-auth-page {
        grid-template-columns: 1fr;
    }

    .crm-auth-left {
        min-height: auto;
        padding: 28px 24px;
        gap: 32px;
    }

    .crm-auth-left::before {
        inset: 14px;
        border-radius: 26px;
    }

    .crm-auth-hero h1 {
        font-size: clamp(32px, 7vw, 48px);
    }

    .crm-auth-benefits {
        grid-template-columns: 1fr;
        max-width: none;
    }

    .crm-auth-benefits div {
        min-height: 70px;
    }

    .crm-auth-right {
        min-height: auto;
        padding: 0 16px 24px;
    }
}

@media (max-width: 520px) {
    .crm-auth-left {
        padding: 22px 16px;
    }

    .crm-auth-hero p {
        font-size: 15px;
    }

    .crm-auth-card {
        border-radius: 24px;
        padding: 20px;
    }

    .crm-auth-card h2 {
        font-size: 30px;
    }

    .crm-auth-row,
    .crm-auth-footer {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* v28 auth phone */

.crm-auth-hero h1{
    letter-spacing:.03em !important;
}

.crm-auth-otp-wrap{
    display:grid;
    gap:8px;
}

.crm-auth-otp-wrap>span{
    color:#9fb0c8;
    font-size:13px;
    font-weight:850;
}

.crm-auth-otp{
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:10px;
}

.crm-auth-otp div{
    height:58px;
    border-radius:18px;
    border:1px solid rgba(148,163,184,.15);
    background:rgba(15,23,42,.42);
    display:grid;
    place-items:center;
    color:#e7eefb;
    font-size:22px;
    font-weight:900;
}


/* ===== v29 phone auth flow ===== */

.crm-auth-hero h1 {
    letter-spacing: .03em !important;
}

.crm-auth-step {
    display: none;
    gap: 16px;
}

.crm-auth-step.active {
    display: grid;
}

.crm-auth-code-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.crm-auth-otp {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.crm-auth-otp button {
    height: 62px;
    border: 1px solid rgba(148,163,184,.16);
    border-radius: 18px;
    background: rgba(15,23,42,.42);
    color: #e7eefb;
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
    transition: .16s ease;
}

.crm-auth-otp button.active {
    border-color: #3b82f6;
    box-shadow:
        0 0 0 4px rgba(59,130,246,.15),
        inset 0 1px 0 rgba(255,255,255,.04);
}

.crm-auth-code-info {
    border: 1px solid rgba(148,163,184,.13);
    border-radius: 16px;
    background: rgba(15,23,42,.32);
    padding: 12px 14px;
    display: grid;
    gap: 4px;
}

.crm-auth-code-info span {
    color: #8fa0b9;
    font-size: 12px;
    font-weight: 750;
}

.crm-auth-code-info strong {
    color: #e7eefb;
    font-size: 14px;
}

.crm-auth-back {
    min-height: 42px;
    border: 1px solid rgba(148,163,184,.16);
    border-radius: 16px;
    background: rgba(15,23,42,.32);
    color: #38bdf8;
    font-weight: 900;
}

@media (max-width: 980px) {
    .crm-auth-page {
        min-height: 100vh;
        display: grid;
        grid-template-columns: 1fr;
        place-items: center;
        padding: 16px;
    }

    .crm-auth-left {
        display: none !important;
    }

    .crm-auth-right {
        width: 100%;
        min-height: auto !important;
        padding: 0 !important;
    }

    .crm-auth-card {
        width: min(460px, 100%);
    }

    .crm-auth-footer {
        width: min(460px, 100%);
    }
}

@media (max-width: 520px) {
    .crm-auth-page {
        padding: 0;
        place-items: stretch;
        align-items: center;
    }

    .crm-auth-right {
        padding: 14px !important;
    }

    .crm-auth-card {
        width: 100%;
    }

    .crm-auth-footer {
        display: none !important;
    }

    .crm-auth-otp button {
        height: 58px;
    }
}


/* ===== v30 auth phone/otp fixes ===== */

#authPhone {
    letter-spacing: .02em;
}

.crm-auth-code-field {
    gap: 10px;
}

/* Один реальный input поверх четырёх крупных ячеек */
.crm-auth-code-box {
    position: relative;
    border: 1px solid rgba(56, 189, 248, .22);
    border-radius: 22px;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .10), transparent 14rem),
        rgba(15, 23, 42, .34);
    padding: 14px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.04),
        0 14px 30px rgba(0,0,0,.16);
}

.crm-auth-code-input {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
    outline: 0 !important;
    opacity: .01 !important;
    color: transparent !important;
    background: transparent !important;
    caret-color: transparent !important;
    z-index: 3 !important;
    cursor: text !important;
}

.crm-auth-otp {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 12px !important;
}

.crm-auth-otp span {
    height: 68px;
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(15,23,42,.62), rgba(15,23,42,.42));
    display: grid;
    place-items: center;
    color: #ffffff;
    font-size: 28px;
    font-weight: 950;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.06),
        0 10px 24px rgba(0,0,0,.18);
    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        transform .16s ease,
        background-color .16s ease;
}

.crm-auth-otp span::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(148,163,184,.34);
    display: block;
}

.crm-auth-otp span.filled::before {
    display: none;
}

.crm-auth-otp span.active {
    border-color: #38bdf8;
    box-shadow:
        0 0 0 4px rgba(56,189,248,.16),
        0 14px 30px rgba(37,99,235,.22),
        inset 0 1px 0 rgba(255,255,255,.08);
    transform: translateY(-1px);
}

.crm-auth-otp span.filled {
    border-color: rgba(56,189,248,.36);
    background:
        radial-gradient(circle at top left, rgba(56,189,248,.22), transparent 120%),
        rgba(15,23,42,.62);
}

/* Информационный блок делаем вторичным, чтобы не путался с OTP */
.crm-auth-code-info {
    margin-top: 2px;
    border-style: dashed !important;
    border-color: rgba(148,163,184,.18) !important;
    background: rgba(15,23,42,.20) !important;
    box-shadow: none !important;
}

.crm-auth-code-info strong {
    color: #93c5fd !important;
}

/* Старые кнопки OTP больше не используются */
.crm-auth-otp button {
    all: unset;
}

@media (max-width: 520px) {
    .crm-auth-code-box {
        padding: 12px;
        border-radius: 20px;
    }

    .crm-auth-otp {
        gap: 9px !important;
    }

    .crm-auth-otp span {
        height: 62px;
        border-radius: 18px;
        font-size: 25px;
    }
}


/* ===== v31 real OTP inputs ===== */

/* Полностью перебиваем старую схему OTP: теперь это 4 настоящих input */
.crm-auth-real-otp {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 12px !important;
}

.crm-auth-real-otp input {
    width: 100% !important;
    height: 68px !important;
    border: 1px solid rgba(148,163,184,.18) !important;
    border-radius: 20px !important;
    background:
        linear-gradient(180deg, rgba(15,23,42,.62), rgba(15,23,42,.42)) !important;
    color: #ffffff !important;
    text-align: center !important;
    font-size: 30px !important;
    line-height: 1 !important;
    font-weight: 950 !important;
    outline: none !important;
    padding: 0 !important;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.06),
        0 10px 24px rgba(0,0,0,.18) !important;
    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        transform .16s ease,
        background-color .16s ease !important;
}

.crm-auth-real-otp input:focus {
    border-color: #38bdf8 !important;
    box-shadow:
        0 0 0 4px rgba(56,189,248,.16),
        0 14px 30px rgba(37,99,235,.22),
        inset 0 1px 0 rgba(255,255,255,.08) !important;
    transform: translateY(-1px);
}

.crm-auth-real-otp input.filled {
    border-color: rgba(56,189,248,.36) !important;
    background:
        radial-gradient(circle at top left, rgba(56,189,248,.22), transparent 120%),
        rgba(15,23,42,.62) !important;
}

.crm-auth-real-otp input::-webkit-outer-spin-button,
.crm-auth-real-otp input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.crm-auth-real-otp input::placeholder {
    color: transparent;
}

/* Старый overlay/input из v30 на всякий случай выключаем */
.crm-auth-code-box,
.crm-auth-code-input,
.crm-auth-code-hidden {
    all: unset;
}

@media (max-width: 520px) {
    .crm-auth-real-otp {
        gap: 9px !important;
    }

    .crm-auth-real-otp input {
        height: 62px !important;
        border-radius: 18px !important;
        font-size: 27px !important;
    }
}


.crm-logo-image {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
}

.crm-logo-image img {
    max-width: 180px;
    max-height: 70px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.crm-sidebar-head {
    justify-content: center;
    position: relative;
}

.crm-sidebar-close {
    position: absolute;
    right: 16px;
    top: 16px;
}