:root {
    /* Мягкая пастельная палитра */
    --primary-color: #8B7EC8;
    --primary-hover: #7A6BB8;
    --primary-light: #B8ADE8;
    --secondary-color: #A8D5BA;
    --accent-color: #F5B8C4;
    --text-color: #2D3748;
    --text-muted: #718096;
    --text-light: #A0AEC0;
    --border-color: #E2E8F0;
    --bg-light: #F7FAFC;
    --bg-white: #FFFFFF;
    --bg-gradient: linear-gradient(135deg, #F7FAFC 0%, #EDF2F7 100%);
    
    /* Мягкие тени */
    --shadow-sm: 0 2px 8px rgba(139, 126, 200, 0.08);
    --shadow-md: 0 4px 16px rgba(139, 126, 200, 0.12);
    --shadow-lg: 0 8px 24px rgba(139, 126, 200, 0.16);
    
    /* Скругления */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    background: var(--bg-gradient);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Навигация */
.navbar {
    background: var(--bg-white) !important;
    border-bottom: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-sm);
    padding: 1rem 0;
    backdrop-filter: blur(10px);
}

.navbar-brand {
    color: var(--primary-color) !important;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    transition: all 0.3s ease;
}

.navbar-brand:hover {
    color: var(--primary-hover) !important;
    transform: translateY(-1px);
}

.nav-link {
    color: var(--text-color) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    margin: 0 0.25rem;
}

.nav-link:hover {
    color: var(--primary-color) !important;
    background-color: rgba(139, 126, 200, 0.08);
    transform: translateY(-1px);
}

.nav-link.active {
    color: var(--primary-color) !important;
    background-color: rgba(139, 126, 200, 0.12);
}

/* Кнопки */
.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    padding: 0.625rem 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 126, 200, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 126, 200, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(139, 126, 200, 0.3);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-white);
    border-color: var(--primary-light);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background-color: transparent;
}

.btn-outline-primary:hover {
    color: var(--bg-white);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary.active,
.btn-outline-primary:active {
    color: var(--bg-white);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-secondary {
    border: 1.5px solid var(--border-color);
    color: var(--text-color);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--bg-light);
    border-color: var(--primary-light);
    color: var(--primary-color);
}

/* Карточки */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    background: var(--bg-white);
    overflow: hidden;
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.05) 0%, rgba(184, 173, 232, 0.05) 100%);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--text-color);
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
}

.card-body {
    padding: 1.5rem;
}

/* Формы */
.form-control, .form-select {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: var(--bg-white);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(139, 126, 200, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-control.is-invalid {
    border-color: #FC8181;
    box-shadow: 0 0 0 4px rgba(252, 129, 129, 0.1);
}

.form-control.is-valid {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(168, 213, 186, 0.1);
}

/* Таблицы */
.table {
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table thead th {
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.08) 0%, rgba(184, 173, 232, 0.08) 100%);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-color);
    padding: 1rem;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: rgba(139, 126, 200, 0.05);
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Алерты */
.alert {
    border-radius: var(--radius-md);
    border: none;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.alert-info {
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.1) 0%, rgba(184, 173, 232, 0.1) 100%);
    color: var(--primary-hover);
    border-left: 4px solid var(--primary-color);
}

.alert-success {
    background: linear-gradient(135deg, rgba(168, 213, 186, 0.15) 0%, rgba(139, 200, 160, 0.15) 100%);
    color: #2F855A;
    border-left: 4px solid var(--secondary-color);
}

.alert-danger {
    background: linear-gradient(135deg, rgba(252, 129, 129, 0.15) 0%, rgba(245, 184, 196, 0.15) 100%);
    color: #C53030;
    border-left: 4px solid #FC8181;
}

.alert-warning {
    background: linear-gradient(135deg, rgba(251, 211, 141, 0.15) 0%, rgba(246, 173, 85, 0.15) 100%);
    color: #C05621;
    border-left: 4px solid #FBD38D;
}

/* Бейджи */
.badge {
    padding: 0.5em 0.75em;
    font-weight: 500;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.badge.bg-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%) !important;
}

.badge.bg-success {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #7FC8A0 100%) !important;
}

/* Футер */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    padding: 2rem 0;
    color: var(--text-muted);
}

/* Заголовки страниц */
.page-header {
    margin-bottom: 2.5rem;
    padding: 2rem 0;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 400;
}

/* Контейнер */
.container {
    padding: 2rem 1rem;
}

.container-fluid {
    padding: 0;
}

/* Улучшенные инпуты */
.input-group .btn {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-group .form-control:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

/* Кастомные чекбоксы и радио */
.form-check-input {
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    width: 1.25rem;
    height: 1.25rem;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:focus {
    box-shadow: 0 0 0 4px rgba(139, 126, 200, 0.1);
}

/* Модальные окна */
.modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.05) 0%, rgba(184, 173, 232, 0.05) 100%);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
}

/* Улучшенная типографика */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.3;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.75rem;
}

/* Плавные переходы для всех интерактивных элементов */
a, button, .btn, .card, .nav-link {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Улучшенный скроллбар */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card, .alert {
    animation: fadeIn 0.4s ease-out;
}

/* Улучшенные ссылки */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Дополнительные утилиты */
.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

/* Адаптивность */
@media (max-width: 768px) {
    .page-title {
        font-size: 2rem;
    }
    
    .card {
        border-radius: var(--radius-md);
    }
    
    .btn {
        padding: 0.5rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .container {
        padding: 1rem 0.5rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table thead th {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .table tbody td {
        padding: 0.75rem 0.5rem;
    }
    
    .form-control, .form-select {
        font-size: 16px; /* Предотвращает зум на iOS */
    }
    
    .input-group {
        flex-wrap: wrap;
    }
    
    .input-group .btn {
        flex: 1 1 100%;
        margin-top: 0.5rem;
        border-radius: var(--radius-md);
    }
    
    .input-group .form-control:first-child {
        border-radius: var(--radius-md);
    }
}

@media (max-width: 576px) {
    .page-title {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .navbar-brand {
        font-size: 1.5rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
}

/* Боковая навигация (Sidebar) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .user-name {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.05) 0%, rgba(184, 173, 232, 0.05) 100%);
    flex-shrink: 0;
    min-height: 56px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.25rem;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
}

.brand-text {
    transition: opacity 0.3s ease;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: rgba(139, 126, 200, 0.1);
    color: var(--primary-color);
}

.sidebar-toggle i {
    transition: transform 0.3s ease;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-nav .nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-item {
    margin: 0.25rem 0.75rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    margin: 0;
    white-space: nowrap;
}

.sidebar-nav .nav-link:hover {
    background: rgba(139, 126, 200, 0.1);
    color: var(--primary-color);
    transform: translateX(4px);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(139, 126, 200, 0.15) 0%, rgba(184, 173, 232, 0.15) 100%);
    color: var(--primary-color);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

.sidebar-nav .nav-link i {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.nav-text {
    transition: opacity 0.3s ease, width 0.3s ease;
    white-space: nowrap;
}

.nav-divider {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.sidebar.collapsed .nav-divider {
    display: none;
}

/* В свёрнутом сайдбаре — только иконки, кнопка «Выйти» без текста */
.sidebar.collapsed .sidebar-footer .btn span {
    display: none;
}

.sidebar.collapsed .sidebar-footer .btn .me-2 {
    margin-right: 0;
}

.sidebar.collapsed .sidebar-footer .btn {
    padding: 0.75rem;
    justify-content: center;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-light);
}

.user-info {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-white);
}

.user-info i {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-right: 0.75rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-color);
    transition: opacity 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .btn-link {
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.sidebar-footer .btn-link:hover {
    background: rgba(252, 129, 129, 0.1);
    color: #C53030;
}

.sidebar-footer .btn-link i {
    margin-right: 0.75rem;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Основной контент с учетом сайдбара */
.main-content {
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    padding: 2rem;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.main-content.with-sidebar {
    margin-left: 260px;
}

body.sidebar-collapsed .main-content.with-sidebar {
    margin-left: 70px;
}

/* Кнопка для мобильных устройств */
.sidebar-mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    width: 48px;
    height: 48px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sidebar-mobile-toggle:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.sidebar-mobile-toggle i {
    font-size: 1.5rem;
}

/* Overlay для мобильных */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Адаптивность для сайдбара */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content.with-sidebar {
        margin-left: 0;
    }

    .sidebar-mobile-toggle {
        display: flex;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .sidebar {
        width: 280px;
    }

    .sidebar.collapsed {
        width: 70px;
    }
}

/* Средние экраны (~1440×724): меньше отступы, календарь не вылезает */
@media (max-width: 1440px) {
    .main-content {
        padding: 1rem 1.25rem;
    }
}

/* Контейнер календаря — скролл внутри, верстка не плывёт */
.calendar-viewport {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Панель календаря: выравнивание кнопок «День / Неделя / Месяц» по одной линии */
.calendar-controls-row .btn-group .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    line-height: 1.2;
}

/* На малых экранах блоки календаря (режим, дата, специалист) не внахлёст — колонки в ряд по 2 или стопкой */
@media (max-width: 767px) {
    .calendar-controls-row .col-12.col-sm-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Отчёты: одинаковый размер плиток и прокрутка при переполнении */
.reports-page .reports-metric-row .reports-metric-card {
    min-height: 115px;
}

.reports-page .reports-card-scroll {
    display: flex;
    flex-direction: column;
}

.reports-page .reports-card-charts {
    height: 360px;
}

.reports-page .reports-card-tables {
    height: 400px;
}

.reports-page .reports-card-body-scroll {
    overflow-y: auto;
    min-height: 0;
    flex: 1 1 auto;
}

/* Пагинация */
.pagination {
    margin: 0;
}

.page-link {
    color: var(--primary-color);
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
}

.page-link:hover {
    color: var(--bg-white);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(139, 126, 200, 0.2);
}

.page-item.active .page-link {
    color: var(--bg-white);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(139, 126, 200, 0.3);
}

.page-item.disabled .page-link {
    color: var(--text-light);
    background-color: var(--bg-light);
    border-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.page-item.disabled .page-link:hover {
    transform: none;
    box-shadow: none;
}

/* Кнопка справки (база знаний) */
.help-fab {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    z-index: 1000;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: var(--primary-color);
    color: white !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, background-color 0.2s ease;
}
.help-fab:hover {
    background: var(--primary-hover);
    color: white !important;
    transform: scale(1.08);
    box-shadow: var(--shadow-lg);
}

/* База знаний: оглавление и статьи */
.help-toc a {
    color: var(--primary-color);
    text-decoration: none;
}
.help-toc a:hover {
    text-decoration: underline;
}
.help-article {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}
.help-article:last-of-type {
    border-bottom: none;
}
.help-article h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
    scroll-margin-top: 1rem;
}
.help-article ol {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}
.help-article li {
    margin-bottom: 0.35rem;
}
.help-article p {
    margin-bottom: 0.5rem;
}

/* Поле суммы депозита без стрелок у числа */
.no-spinners::-webkit-outer-spin-button,
.no-spinners::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.no-spinners {
    -moz-appearance: textfield;
}
