:root {
    --primary: #25475e;
    --accent: #f0a500;
    --bg: #f7f9fc;
}

* {
    box-sizing: border-box;
}

html {
    max-width: 100vw;
    overflow-x: hidden;
    scroll-behavior: auto;
}

/* Настройка прокрутки для якорей с учетом фиксированного хедера */
#finance {
    scroll-margin-top: 80px;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    font-size: 16px;
    color: #1f2933;
    background-color: var(--bg);
    margin: 0;
    transition: margin 0.3s ease;
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
}

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

a:hover {
    text-decoration: underline;
}

.header {
    background-color: var(--primary);
    color: #fff;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* разрешаем перенос на новую строку */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0; /* для flex-shrink */
    flex: 0 1 auto;
}

.header-left .logo-link {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}

.header-left .logo-link:hover {
    text-decoration: underline;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex: 0 1 auto;
    min-width: 0;
}

.header.nav-collapsed .header-content {
    min-width: auto;
}

/* Состояние инициализации */
.header.nav-initializing .header-nav,
.header.nav-initializing .header-content .logout-form,
.header.nav-initializing .menu-toggle {
    visibility: hidden;
    opacity: 0;
}

/* Скрываем навигацию до инициализации */
.header .header-nav,
.header .header-content .logout-form,
.header .menu-toggle {
    transition: opacity 0.2s ease;
}

.header-content .logout-form {
    margin-left: 16px;
    display: inline;
}

.header-nav {
    display: none; /* Скрыто по умолчанию, покажем через JS */
    flex-wrap: nowrap; /* НЕ переносим элементы навигации внутри */
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.header:not(.nav-initializing) .header-nav {
    display: flex;
}

.header.nav-collapsed .header-nav {
    display: none !important;
}

.header-nav a {
    color: #fff;
    margin-left: 16px;
    font-weight: 500;
    white-space: nowrap;
    font-size: 1rem;
    line-height: 1.5;
    text-decoration: none;
}

.logout-form {
    display: inline;
    margin-left: 16px;
}

.header-content .logout-link {
    background: none;
    border: none;
    color: #fff;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1.5;
    font-family: inherit;
    text-decoration: none;
}

.header-content .logout-link:hover {
    text-decoration: underline;
}

.container {
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    margin-top: 0 !important;
    padding: clamp(16px, 3vw, 40px);
    padding-top: 70px !important;
    box-sizing: border-box;
    overflow-x: hidden;
}

.content-card .filter-wrapper {
    margin-bottom: 12px;
    overflow: visible;
    overflow-y: visible !important;
    overflow-x: visible !important;
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 12px;
    margin-top: 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    width: 100%;
    container-type: inline-size;
    position: relative;
    /* Делаем скроллбар всегда видимым */
    scrollbar-gutter: stable;
    /* Убеждаемся, что скроллбар всегда виден */
    padding-bottom: 0;
}

.table-wrapper::-webkit-scrollbar {
    height: 12px;
    -webkit-appearance: none;
    appearance: none;
}

.table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 12px;
    /* overflow: hidden; - removed to allow sticky columns */
    box-shadow: 0 8px 24px rgba(37, 71, 94, 0.08);
    margin-top: 16px;
    table-layout: auto;
    font-size: 0.95rem;
}

.table th,
.table td {
    padding: 10px 14px;
    border-bottom: 1px solid #edf2f5;
    text-align: left;
}

.table thead {
    background-color: rgba(37, 71, 94, 0.07);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.85rem;
    font-weight: 600;
}

.table thead th {
    white-space: nowrap;
}

.table thead th a {
    white-space: nowrap;
    display: inline-block;
}

.table-amount {
    white-space: nowrap;
    display: inline-block;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.amount-col {
    vertical-align: middle;
}

.actions-col {
    vertical-align: middle;
}

.month-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 140px;
    justify-content: flex-start;
}

.month-actions a,
.month-actions button {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.month-actions form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0;
}

.table td form,
.table td form > * {
    width: 100%;
}

.table td select,
.table td textarea,
.table td input[type="text"],
.table td input[type="number"],
.table td input[type="email"],
.table td input[type="search"],
.table td input[type="tel"],
.table td input[type="url"] {
    width: 100%;
    min-width: 0;
    font-size: 0.85rem;
    padding: 6px 8px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    box-sizing: border-box;
}

.table td select {
    padding-right: 20px;
}

.table td textarea {
    min-height: 50px;
    resize: vertical;
}

.table tbody tr:hover {
    background-color: rgba(240, 165, 0, 0.08);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background-color: #1a3344;
}

.btn-accent {
    background-color: var(--accent);
    color: #1f2933;
}

.btn-danger {
    background-color: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background-color: #d73232;
}

.btn-danger-text {
    color: #d73232 !important;
    padding: 0;
}

.btn-text {
    background: transparent;
    color: var(--primary);
    padding: 0;
}

.month-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 140px;
    justify-content: flex-start;
}

.month-actions a,
.month-actions button {
    display: inline-flex;
    align-items: center;
}

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

.btn-outline-primary:hover {
    background-color: var(--primary);
    color: #fff;
}

.card {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(37, 71, 94, 0.08);
    padding: clamp(16px, 2.4vw, 22px);
    margin-bottom: 20px;
    overflow: visible;
    position: relative;
}

.content-card {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible !important;
    box-sizing: border-box;
    position: relative;
    min-height: auto;
    height: auto;
}

/* Увеличиваем высоту контейнера в ПК версии для дропдаунов */
@media (min-width: 769px) {
    .content-card {
        min-height: 800px;
    }
}

/* Увеличиваем высоту контейнера в мобильной версии, чтобы дропдаун не вылезал внизу */
/* Удалена чрезмерная высота - теперь контролируется естественным содержимым */
@media (max-width: 768px) {
    .content-card {
        min-height: auto;
        padding-bottom: 40px;
    }
    
    /* Стили для кнопок в месяцах проектов */
    .month-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        min-width: 0;
        width: 100%;
    }
    
    .month-actions form {
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }
    
    .month-actions .btn {
        width: 100%;
        justify-content: center;
        font-size: 0.85rem;
        padding: 8px 12px;
    }
}

.messages {
    margin-bottom: 16px;
}

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    font-weight: 500;
}

.flash-success {
    background: rgba(34, 197, 94, 0.12);
    color: #0c7a31;
    border-color: rgba(34, 197, 94, 0.3);
}

.flash-error, .flash-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #b4231a;
    border-color: rgba(239, 68, 68, 0.3);
}

.flash-info, .flash-debug {
    background: rgba(37, 71, 94, 0.08);
    color: #25475e;
    border-color: rgba(37, 71, 94, 0.15);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.filter-form {
    margin-bottom: 16px;
}

.filter-wrapper {
    overflow: visible;
    overflow-y: visible !important;
    overflow-x: visible !important;
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.table-control-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.table-zoom-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #25475e;
}

.table-zoom-control span:first-child {
    font-weight: 600;
}

.table-zoom-control input[type='range'] {
    width: 140px;
    accent-color: var(--primary);
}

.table-zoom-value {
    font-weight: 600;
    min-width: 3ch;
    text-align: right;
}

.column-selector {
    background: rgba(37, 71, 94, 0.03);
    border-radius: 8px;
    padding: 12px;
}

.column-selector summary {
    cursor: pointer;
    font-weight: 600;
    color: #25475e;
    margin-bottom: 8px;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.column-selector summary::after {
    content: '\25BC';
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

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

.column-selector[open] {
    box-shadow: 0 2px 8px rgba(37, 71, 94, 0.08);
}

.column-selector[open] summary::after {
    transform: rotate(-180deg);
}

.column-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.column-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    width: 100%;
}

.assignment-list {
    margin: 0;
    padding-left: 18px;
}

.assignment-list li {
    margin-bottom: 4px;
}

.assignment-formset {
    margin-top: 24px;
    background: rgba(37, 71, 94, 0.02);
    border-radius: 8px;
    padding: 16px;
}

.assignment-title {
    margin-top: 0;
    margin-bottom: 12px;
}

.assignment-formset__list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assignment-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    padding: 12px;
    border: 1px solid rgba(37, 71, 94, 0.08);
    border-radius: 8px;
    margin-bottom: 12px;
    background: #fff;
}

.assignment-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.assignment-field--wide {
    grid-column: span 2;
}

.assignment-field--medium {
    grid-column: span 1;
}

.assignment-field--small {
    max-width: 220px;
}

.assignment-remove {
    display: none;
}

.assignment-remove-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}

.assignment-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 4px;
}

.assignment-field input,
.assignment-field textarea,
.assignment-field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    box-sizing: border-box;
}

.assignment-hint {
    margin: 0;
    font-size: 0.85rem;
    color: #5c6b73;
}

@media (max-width: 640px) {
    .assignment-field--wide,
    .assignment-field--medium,
    .assignment-field--small {
        grid-column: span 1;
        max-width: 100%;
    }
}


.bulk-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 16px;
}

.bulk-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #25475e;
}

.bulk-select input[type='checkbox'] {
    width: 18px;
    height: 18px;
}


.form-grid label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d9e0;
    font-size: 0.95rem;
    box-sizing: border-box;
    max-width: 100%;
}

/* Специальные стили для полей даты и месяца на мобильных устройствах */
input[type="date"],
input[type="month"] {
    box-sizing: border-box !important;
    max-width: 100% !important;
    width: 100% !important;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
}

.form-grid--project {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.form-grid__wide {
    grid-column: span 2;
    min-width: 240px;
}

.form-grid__full {
    grid-column: 1 / -1;
}

/* Ограничиваем ширину multi-filter и searchable-select в form-grid__full в десктопной версии */
.form-grid__full .multi-filter,
.form-grid__full .searchable-select {
    max-width: 400px;
}

/* Ограничиваем ширину select в form-grid в десктопной версии */
@media (min-width: 769px) {
    .form-grid > div select {
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .form-grid--project {
        grid-template-columns: 1fr;
    }
    
    .form-grid__wide {
        grid-column: span 1;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .form-grid__full {
        grid-column: span 1;
        width: 100%;
        max-width: 100%;
    }
    
    .form-grid input,
    .form-grid select,
    .form-grid textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Исправляем переполнение полей даты на iPhone */
    input[type="date"],
    input[type="month"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .form-grid > div {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .form-grid--project {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .form-grid__wide {
        grid-column: span 1;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .form-grid__full {
        grid-column: span 1;
        width: 100%;
        max-width: 100%;
    }
    
    .form-grid input,
    .form-grid select,
    .form-grid textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Исправляем переполнение полей даты на iPhone */
    input[type="date"],
    input[type="month"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .form-grid > div {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
}

.project-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(37, 71, 94, 0.06), rgba(37, 71, 94, 0.02));
    border: 1px solid rgba(37, 71, 94, 0.12);
    border-radius: 12px;
}

.project-meta__item {
    padding: 10px 12px;
    background: #fff;
    border: 1px solid rgba(37, 71, 94, 0.08);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(37, 71, 94, 0.05);
}

.project-meta__label {
    font-size: 0.9rem;
    color: #5c6b73;
    letter-spacing: 0.01em;
}

.project-meta__value {
    margin-top: 6px;
    font-weight: 700;
    font-size: 1.05rem;
    color: #1f2933;
}

.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 4px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    background: linear-gradient(135deg, #25475e, #3a6686);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(37, 71, 94, 0.15);
}

.info-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: 120%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.3;
    white-space: pre-line;
    min-width: 320px;
    max-width: 520px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 10;
}

.info-tooltip:hover::after,
.info-tooltip:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 10%);
}

.searchable-select {
    position: relative;
    width: 100%;
}

.searchable-select__toggle {
    width: 100%;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #d1d9e0;
    background: #fff;
    color: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.searchable-select__toggle:hover,
.searchable-select--open .searchable-select__toggle {
    border-color: rgba(15, 91, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(15, 91, 255, 0.12);
}

.searchable-select__toggle span[data-label] {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.searchable-select__toggle::after {
    content: '';
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease;
}

.searchable-select--open .searchable-select__toggle::after {
    transform: rotate(180deg);
}

.searchable-select__menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #fff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 1100;
}

/* Когда меню открыто как попап (fixed), убираем right: 0 */
.searchable-select__menu[style*="position: fixed"] {
    right: auto !important;
}

.searchable-select--open .searchable-select__menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.searchable-select__search {
    padding: 0 12px 8px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.searchable-select__search input {
    width: 100%;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.searchable-select__search input:focus {
    border-color: rgba(15, 91, 255, 0.5);
    box-shadow: 0 0 0 2px rgba(15, 91, 255, 0.1);
}

.searchable-select__options {
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
}

@media (max-width: 768px) {
    .searchable-select__options {
        max-height: 160px;
    }
}

.searchable-select__option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 10px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.92rem;
    text-align: left;
    gap: 8px;
    color: inherit;
    transition: background-color 0.15s ease;
}

.searchable-select__check {
    width: 16px;
    height: 16px;
    border: 1px solid rgba(37, 71, 94, 0.35);
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: transparent;
    background: transparent;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.searchable-select--multiple .searchable-select__check {
    display: inline-flex;
}

.searchable-select__check.checked {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.searchable-select__label {
    flex: 1;
}

.searchable-select__option:hover,
.searchable-select__option:focus-visible {
    background-color: rgba(15, 91, 255, 0.08);
    outline: none;
}

.searchable-select__option[aria-selected='true'] {
    background-color: rgba(15, 91, 255, 0.14);
    font-weight: 600;
}

.searchable-select__option.hidden {
    display: none;
}

.searchable-select__empty {
    padding: 12px;
    font-size: 0.9rem;
    color: #6b7280;
    text-align: center;
}

.searchable-select__create {
    width: 100%;
    margin: 4px 0 0;
    padding: 8px 10px;
    border: 1px dashed rgba(37, 71, 94, 0.5);
    background: #f0f4f8;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #25475e;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    font-weight: 600;
}

/* Мобильные стили для кнопки создания */
@media (max-width: 768px) {
    .searchable-select__create {
        margin: 2px 0 0;
        padding: 6px 8px;
        font-size: 0.85rem;
    }
}

.searchable-select__create:hover,
.searchable-select__create:focus-visible {
    border-color: var(--primary);
    background: #e3ecf5;
}

.searchable-select__native {
    display: none !important;
}

/* Backdrop для мобильной версии dropdown */
.searchable-select__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.searchable-select__backdrop.visible {
    opacity: 1;
    visibility: visible;
}

.searchable-select__modal-portal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}

.searchable-select__modal-portal.open {
    display: flex;
}

.searchable-select__modal {
    position: relative;
    width: min(420px, 92vw);
    z-index: 1;
}

.searchable-select__modal.open {
    display: block;
}

.searchable-select__modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 1;
}

.searchable-select__modal-dialog {
    position: relative;
    z-index: 2;
    padding: 18px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.5);
    display: grid;
    gap: 10px;
    max-width: 90vw;
    width: 360px;
}

.searchable-select__modal-title {
    font-weight: 700;
    font-size: 1rem;
    color: #111827;
}

.searchable-select__modal-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.16);
    font-size: 0.95rem;
}

.searchable-select__modal-input:focus {
    border-color: rgba(15, 91, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(15, 91, 255, 0.12);
    outline: none;
}

.searchable-select__modal-error {
    color: #b91c1c;
    font-size: 0.85rem;
    min-height: 18px;
}

.searchable-select__modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.searchable-select__modal-submit,
.searchable-select__modal-cancel {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
}

.searchable-select__modal-submit {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.searchable-select__modal-submit:hover {
    background: #1f4d77;
    border-color: #1f4d77;
}

.searchable-select__modal-cancel {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.12);
}

.searchable-select__modal-cancel:hover {
    border-color: rgba(0, 0, 0, 0.3);
}

/* Стили для чекбокса "Требует внимания" */
.attention-checkbox-wrapper {
    display: block;
    margin-top: 4px;
    max-width: 100%;
}

.attention-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin: 0;
    font-weight: 600;
    flex-wrap: nowrap;
}

.attention-checkbox-label input[type="checkbox"] {
    flex-shrink: 0;
    margin: 0;
    width: 18px;
    height: 18px;
}

.attention-star {
    color: #0F5BFF;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.attention-checkbox-label span:last-child {
    flex-shrink: 0;
}

.attention-help-text {
    margin-top: 4px;
    margin-left: 26px;
}

.attention-help-text small {
    display: block;
    color: #6b7280;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-aup {
    background: rgba(37, 71, 94, 0.1);
    color: var(--primary);
}

.badge-pps {
    background: rgba(240, 165, 0, 0.15);
    color: #9c5b00;
}

.executor-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 12px;
    margin-top: 6px;
}

.executor-item {
    border: 1px solid rgba(37, 71, 94, 0.12);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(37, 71, 94, 0.05);
}

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

.executor-meta {
    color: #556b7c;
    font-size: 0.9rem;
    margin-top: 4px;
}

.status {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}

.status-pending {
    background: rgba(240, 165, 0, 0.15);
    color: #9c5b00;
}

.status-approved {
    background: rgba(34, 197, 94, 0.18);
    color: #0c7a31;
}

.status-rejected {
    background: rgba(239, 68, 68, 0.18);
    color: #b4231a;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    background: rgba(239, 68, 68, 0.12);
    color: #b4231a;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

.pagination-compact {
    justify-content: flex-start;
    gap: 8px;
    margin-top: 8px;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #d1d9e0;
}

.pagination .current {
    background-color: var(--primary);
    color: #fff;
}

/* Page header with actions */
.page-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-header-actions h2 {
    margin: 0;
    flex: 0 0 auto;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-buttons .btn,
.page-header-actions .btn,
.page-header-actions a.btn,
.action-buttons a.btn,
.action-buttons button.btn,
.period-close-form .btn,
.period-close-form button,
.content-card > div:first-child > div .btn,
.content-card > div:first-child > .btn,
.content-card > div:first-child > a.btn {
    width: auto;
    flex: 0 0 auto;
}

.btn-success {
    background-color: #10b981;
    color: #fff;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-warning {
    background-color: #f59e0b;
    color: #1f2933;
}

.btn-warning:hover {
    background-color: #d97706;
    color: #1f2933;
}

.btn-info {
    background-color: #3b82f6;
    color: #fff;
}

.btn-info:hover {
    background-color: #2563eb;
}

/* Кнопка бургер-меню */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    width: 36px;
    height: 36px;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.header.nav-collapsed .menu-toggle {
    display: flex;
}

.header.nav-collapsed .header-content .logout-form {
    display: none;
}

.menu-toggle:hover {
    transform: scale(1.1);
}

.menu-toggle:active {
    transform: scale(0.95);
}

/* Класс для collapsed навигации */
.header.nav-collapsed .header-nav {
    display: none !important;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background-color: #fff;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Сайдбар */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background-color: #fff;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
}

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

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: var(--primary);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header strong {
    font-size: 1.1rem;
}

.menu-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
}

.sidebar-nav a {
    padding: 14px 20px;
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid #edf2f5;
    transition: background-color 0.2s ease;
    display: block;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
}

.sidebar-nav .logout-form {
    padding: 0;
    margin: 0;
    border-top: 1px solid #edf2f5;
    border-bottom: none;
    display: block;
}

.sidebar-nav a:hover {
    background-color: rgba(37, 71, 94, 0.05);
    color: var(--primary);
}

.sidebar-nav .logout-link.sidebar-logout,
.sidebar-nav .logout-form .logout-link {
    background: none !important;
    border: none !important;
    color: var(--primary) !important;
    font-weight: 500 !important;
    font-size: 1rem !important;
    padding: 14px 20px !important;
    text-align: left !important;
    width: 100% !important;
    cursor: pointer;
    border-bottom: none !important;
    font-family: inherit !important;
    line-height: 1.5 !important;
    display: block !important;
    margin: 0 !important;
}

.sidebar-nav .logout-link.sidebar-logout:hover,
.sidebar-nav .logout-form .logout-link:hover {
    background-color: rgba(239, 68, 68, 0.05) !important;
    color: #d73232 !important;
    text-decoration: none !important;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Ring Chart Styles */
.ring-chart {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(
        #4caf50 var(--percent),
        #e0e0e0 0
    );
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}
.ring-chart::before {
    content: "";
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
}
.ring-chart-value {
    position: relative;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}

/* Адаптивные стили */

/* Планшеты */
@media (max-width: 1024px) {
    .header {
        padding: 14px 20px;
    }

    .header-nav {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-nav a,
    .header .logout-form {
        margin-left: 12px;
    }

    .card {
        padding: 20px;
    }

    .table th,
    .table td {
        padding: 10px 14px;
    }
}

/* Мобильные устройства */
@media (max-width: 768px) {
    .container {
        padding: 16px !important;
        padding-top: 70px !important;
        max-width: 100vw;
        overflow-x: hidden;
    }

    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Адаптация таблицы штатного расписания для мобильных */
    .table-wrapper {
        overflow-x: auto !important;
        overflow-y: visible !important;
        width: 100% !important;
        max-width: 100% !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .table-wrapper table {
        min-width: 100% !important;
        table-layout: auto !important;
    }
    
    .table-wrapper table th,
    .table-wrapper table td {
        min-width: 80px !important;
        max-width: 200px !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        white-space: normal !important;
        font-size: 0.85rem !important;
        padding: 6px 8px !important;
    }
    
    /* Исправление вылезания кнопок у поля "Отображаемые столбцы" */
    .filter-wrapper form > div:last-child > div[style*="display: flex"] {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .filter-wrapper form > div:last-child > div[style*="display: flex"] > .filter-actions {
        flex: 1 1 100% !important;
        margin-left: 0 !important;
        margin-top: 8px !important;
        justify-content: flex-start !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    
    .filter-wrapper form > div:last-child > div[style*="display: flex"] > .multi-filter[data-multiselect="columns"] {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: calc(100% - 20px) !important;
        width: auto !important;
    }
    
    /* Убираем вертикальный скролл у зоны фильтров */
    .filter-wrapper,
    .filter-wrapper form,
    .filter-wrapper form > div {
        overflow-y: visible !important;
        overflow-x: visible !important;
        max-height: none !important;
        height: auto !important;
    }

    .header {
        padding: 12px 16px;
    }
    
    .container {
        padding-top: 70px !important;
    }
    
    .menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .header .menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .header.nav-collapsed .menu-toggle,
    .header:not(.nav-collapsed) .menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .header-nav {
        display: none !important;
    }
    
    .header-content .logout-form {
        display: none !important;
    }

    .header-left {
        flex: 1;
    }

    .header-left strong {
        font-size: 0.9rem;
    }

    .card {
        padding: 16px;
        margin-bottom: 16px;
    }

    .page-header-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .page-header-actions h2 {
        width: 100%;
    }

    .action-buttons {
        width: auto;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .action-buttons .btn {
        width: auto;
        flex: 0 0 auto;
        justify-content: center;
    }
    
    /* Исключения для кнопок, которые не должны растягиваться в мобильной версии */
    .period-close-form .btn,
    .period-close-form button {
        width: auto !important;
        flex: 0 0 auto !important;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-grid--project {
        grid-template-columns: 1fr;
    }
    
    .form-grid__wide {
        grid-column: span 1;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .form-grid__full {
        grid-column: span 1;
        width: 100%;
        max-width: 100%;
    }
    
    .form-grid input,
    .form-grid select,
    .form-grid textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Исправляем переполнение полей даты на iPhone */
    input[type="date"],
    input[type="month"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .form-grid > div {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .table {
        font-size: 0.85rem;
    }

    .table thead {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 10px 12px;
    }

    /* Исправляем наложение элементов фильтров на мобильных */
    .matrix-filter-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .matrix-filter-group--period {
        grid-column: span 1 !important;
    }

    .matrix-filter-group--period .matrix-period-controls {
        flex-direction: column;
        gap: 10px;
    }

    .matrix-filter-group--period .matrix-period-range {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        min-width: 100% !important;
    }

    .matrix-period-range input {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
    }

    .matrix-presets {
        width: 100%;
    }

    .matrix-filter-group {
        width: 100%;
        max-width: 100%;
    }

    /* Уменьшаем шрифт и ширину столбцов для matrix-table на мобильных */
    .matrix-table table {
        font-size: 0.75rem;
        min-width: 700px;
    }

    .matrix-table table th,
    .matrix-table table td {
        padding: 6px 6px;
        min-width: 85px;
    }

    .matrix-table thead {
        font-size: 0.75rem;
    }

    .matrix-cell {
        font-size: 0.8rem;
    }

    .matrix-chip {
        font-size: 10px;
        padding: 3px 6px;
    }

    .matrix-chip__label,
    .matrix-chip__value {
        font-size: 10px;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.9rem;
    }

    .filter-form {
        overflow-x: auto;
    }

    .table-control-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .table-zoom-control {
        justify-content: space-between;
    }

    .table-zoom-control input[type='range'] {
        width: 100%;
    }

    .table-zoom-value {
        text-align: left;
    }

    .bulk-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .bulk-select {
        width: 100%;
    }

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

    .pagination a,
    .pagination span {
        padding: 5px 10px;
        font-size: 0.9rem;
    }

    /* Главная страница - мобильные исправления */
    .home-hero {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .finance-breakdown {
        grid-template-columns: 1fr;
    }

    .finance-stack {
        grid-template-columns: 1fr;
    }

    .month-row {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    .month-row__label {
        flex: 0 0 auto;
        font-size: 0.9rem;
        font-weight: 600;
        min-width: 0;
    }

    .month-bar {
        flex: 1 1 auto;
        min-width: 0;
        position: relative;
        background: #eef2f7;
        border-radius: 10px;
        padding: 8px;
        display: flex;
        align-items: center;
        gap: 10px;
        box-sizing: border-box;
    }

    .month-value {
        position: relative;
        z-index: 1;
        font-weight: 700;
        color: #0f172a;
        white-space: nowrap;
        flex-shrink: 0;
        margin-left: auto;
    }

    .year-switcher {
        flex-wrap: wrap;
        justify-content: center;
    }

    .home-subsection__head {
        flex-direction: column;
        align-items: flex-start;
        min-width: 0;
        max-width: 100%;
    }

    .home-subsection__head h4 {
        font-size: 0.9rem;
        line-height: 1.3;
        margin: 0;
        padding: 0;
        min-width: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .recurring-list {
        overflow-x: visible;
    }

    .recurring-list li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        min-width: 0;
        overflow: visible;
    }

    .recurring-name {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.9rem;
    }

    .recurring-dates {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.85rem;
    }

    .recurring-amount {
        flex: 0 0 auto;
        font-size: 0.9rem;
        white-space: nowrap;
        flex-shrink: 0;
        min-width: fit-content;
    }

    .month-table {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .month-row {
        flex-wrap: wrap;
        gap: 6px;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .month-row__label {
        flex: 0 0 auto;
        font-size: 0.65rem;
        font-weight: 600;
        min-width: 0;
        flex-shrink: 1;
        max-width: 28%;
        padding-right: 1px;
    }

    .month-bar {
        flex: 1 1 0;
        min-width: 0;
        position: relative;
        background: #eef2f7;
        border-radius: 3px;
        padding: 2px 1px 2px 3px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0;
        box-sizing: border-box;
        overflow: hidden;
    }

    .month-value {
        position: relative;
        z-index: 2;
        font-weight: 700;
        color: #0f172a;
        font-size: 0.6rem;
        white-space: nowrap;
        flex-shrink: 1;
        flex-grow: 0;
        min-width: 0;
        padding: 0;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 100%;
        line-height: 1.2;
    }
}

/* Маленькие мобильные устройства */
@media (max-width: 480px) {
    .container {
        padding: 12px !important;
        padding-top: 70px !important;
        max-width: 100vw;
        overflow-x: hidden;
    }

    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .header .menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .header.nav-collapsed .menu-toggle,
    .header:not(.nav-collapsed) .menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .header-nav {
        display: none !important;
    }
    
    .header-content .logout-form {
        display: none !important;
    }

    .header-left strong {
        font-size: 0.85rem;
    }

    .page-header-actions {
        gap: 8px;
    }

    .page-header-actions h2 {
        font-size: 1.25rem;
    }

    .action-buttons .btn {
        font-size: 0.85rem;
        padding: 8px 12px;
        width: auto !important;
        flex: 0 0 auto !important;
    }
    
    /* Исключения для кнопок, которые не должны растягиваться в маленьких мобильных */
    .action-buttons .btn,
    .page-header-actions .btn,
    .content-card > div:first-child > div .btn,
    .period-close-form .btn,
    .period-close-form button,
    .page-header-actions a.btn,
    .action-buttons a.btn,
    .action-buttons button.btn,
    a.btn-primary,
    a.btn-success,
    a.btn-info,
    a.btn-text,
    a.btn-outline-primary,
    .btn-primary:not(.bulk-actions .btn),
    .btn-success:not(.bulk-actions .btn),
    .btn-info:not(.bulk-actions .btn),
    .btn-text:not(.bulk-actions .btn),
    .btn-outline-primary:not(.bulk-actions .btn) {
        width: auto !important;
        flex: 0 0 auto !important;
    }

    .card {
        padding: 12px;
        border-radius: 8px;
    }

    .content-card {
        overflow-x: hidden;
        overflow-y: visible;
        min-height: auto;
        padding-bottom: 30px;
    }
    
    /* Стили для кнопок в месяцах проектов на маленьких экранах */
    .month-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        min-width: 0;
        width: 100%;
    }
    
    .month-actions form {
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }
    
    .month-actions .btn {
        width: 100%;
        justify-content: center;
        font-size: 0.8rem;
        padding: 7px 10px;
    }

    .table {
        font-size: 0.8rem;
    }

    .table thead {
        font-size: 0.7rem;
    }

    .table th,
    .table td {
        padding: 8px 10px;
    }

    /* Уменьшаем шрифт и ширину столбцов для matrix-table на маленьких мобильных */
    .matrix-table table {
        font-size: 0.7rem;
        min-width: 550px;
    }

    .matrix-table table th,
    .matrix-table table td {
        padding: 5px 5px;
        min-width: 70px;
    }

    .matrix-table thead {
        font-size: 0.7rem;
    }

    .matrix-cell {
        font-size: 0.75rem;
    }

    .matrix-chip {
        font-size: 9px;
        padding: 2px 5px;
        gap: 4px;
    }

    .matrix-chip__label {
        font-size: 9px;
    }

    .matrix-chip__value {
        font-size: 9px;
    }

    .matrix-details {
        font-size: 9px;
    }

    .matrix-details summary {
        font-size: 9px;
    }

    .btn {
        padding: 7px 12px;
        font-size: 0.85rem;
    }
    
    /* Исключения для кнопок, которые не должны растягиваться */
    .action-buttons .btn,
    .page-header-actions .btn,
    .content-card > div:first-child > div .btn,
    .period-close-form .btn,
    .period-close-form button,
    .page-header-actions a.btn,
    .action-buttons a.btn,
    .action-buttons button.btn,
    a.btn-primary,
    a.btn-success,
    a.btn-info,
    a.btn-text,
    a.btn-outline-primary {
        width: auto !important;
        flex: 0 0 auto !important;
    }

    /* Исправляем наложение элементов фильтров в ландшафтном режиме */
    @media (max-width: 1024px) and (orientation: landscape) {
        .matrix-filter-grid {
            grid-template-columns: 1fr !important;
            gap: 16px !important;
        }

        .matrix-filter-group--period {
            grid-column: span 1 !important;
        }

        .matrix-filter-group--period .matrix-period-controls {
            flex-direction: column;
            gap: 10px;
        }

        .matrix-filter-group--period .matrix-period-range {
            flex-direction: column;
            align-items: stretch;
            width: 100%;
            min-width: 100% !important;
            max-width: 100% !important;
        }

        .matrix-period-range input {
            width: 100% !important;
            min-width: 100% !important;
            max-width: 100% !important;
        }

        .matrix-presets {
            width: 100%;
        }

        .matrix-filter-group {
            width: 100%;
            max-width: 100%;
        }
    }

    .btn-primary {
        width: auto;
    }

    .form-grid input,
    .form-grid select,
    .form-grid textarea {
        padding: 8px 10px;
        font-size: 0.9rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Исправляем переполнение полей даты на iPhone */
    input[type="date"],
    input[type="month"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        -webkit-appearance: none;
        appearance: none;
    }
    
    .form-grid > div {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    
    .form-grid--project {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .form-grid__wide {
        grid-column: span 1;
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
    
    .form-grid__full {
        grid-column: span 1;
        width: 100%;
        max-width: 100%;
    }

    .bulk-actions button {
        width: 100%;
    }

    .assignment-row {
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .filter-wrapper {
        margin-left: -12px;
        margin-right: -12px;
        padding: 0 12px;
        overflow: visible !important;
    }

    .multi-filter {
        overflow: visible !important;
    }

    .multi-filter__toggle {
        overflow: visible !important;
        overflow-y: visible !important;
        overflow-x: visible !important;
        -webkit-overflow-scrolling: auto !important;
        scroll-behavior: auto !important;
        max-height: none !important;
        height: auto !important;
    }

    .multi-filter__menu {
        /* Ширина управляется через JavaScript в мобильной версии */
        box-sizing: border-box;
    }
    
    .multi-filter.open .multi-filter__menu {
        display: flex !important;
        flex-direction: column !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .card {
        overflow: visible !important;
    }

    .content-card {
        overflow-y: visible !important;
    }
    
    .filter-wrapper {
        overflow: visible !important;
    }

    /* Главная страница - мобильные исправления */
    .home-hero {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
        max-width: 100%;
        overflow: hidden;
    }

    .home-hero__text {
        gap: 12px;
        min-width: 0;
        max-width: 100%;
    }

    .home-hero__text h1 {
        font-size: 1.5rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .home-subtitle {
        font-size: 0.9rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .hero-total__number {
        font-size: 1.75rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .finance-breakdown {
        grid-template-columns: 1fr;
        gap: 10px;
        max-width: 100%;
        overflow: hidden;
    }

    .finance-card {
        padding: 12px;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-wrap: break-word;
        word-wrap: break-word;
        overflow: hidden;
    }

    .finance-card__amount {
        font-size: 1.1rem;
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        overflow: hidden;
        line-height: 1.3;
    }

    .finance-card__head {
        flex-wrap: wrap;
        gap: 6px;
        min-width: 0;
        max-width: 100%;
    }

    .finance-card__share {
        flex-shrink: 0;
    }

    .finance-stack {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 10px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
        min-width: 0;
    }

    .finance-block {
        padding: 8px;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .finance-block .home-subsection__head {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .finance-block * {
        max-width: 100%;
        box-sizing: border-box;
    }

    .month-row {
        display: flex;
        align-items: center;
        gap: 1px;
        width: 100%;
        box-sizing: border-box;
        min-width: 0;
        overflow: hidden;
    }

    .month-row__label {
        flex: 0 0 auto;
        font-size: 0.55rem;
        font-weight: 600;
        min-width: 0;
        flex-shrink: 1;
        max-width: 24%;
        padding-right: 0;
    }

    .month-bar {
        flex: 1 1 0;
        min-width: 0;
        position: relative;
        background: #eef2f7;
        border-radius: 2px;
        padding: 2px 1px 2px 1px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0;
        box-sizing: border-box;
        overflow: hidden;
    }

    .month-bar__fill {
        overflow: hidden;
    }

    .month-value {
        position: relative;
        z-index: 2;
        font-weight: 700;
        color: #0f172a;
        font-size: 0.55rem;
        white-space: nowrap;
        flex-shrink: 1;
        flex-grow: 0;
        min-width: 0;
        padding: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        line-height: 1.1;
    }

    .year-switcher {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        justify-content: center;
        align-items: center;
        min-width: 0;
        box-sizing: border-box;
        overflow: visible;
    }

    .year-switcher__label {
        flex: 0 0 auto;
        text-align: center;
        font-size: 0.9rem;
        min-width: 0;
        max-width: none;
        white-space: nowrap;
        overflow-wrap: normal;
        word-wrap: normal;
    }

    .year-switcher__btn {
        flex-shrink: 0 !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-width: 32px;
        width: auto;
    }
    
    /* Исправляем перенос текста в "Актуальные суммы" */
    .month-switcher {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 10px;
        align-items: center;
        justify-content: center;
    }
    
    .month-switcher h3 {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        margin: 0;
        text-align: center;
        flex: 0 0 auto;
        line-height: 1.3;
        max-width: 200px;
        hyphens: none !important;
        -webkit-hyphens: none !important;
    }
    
    .month-switcher__prefix {
        white-space: nowrap !important;
    }
    
    .month-switcher__month {
        white-space: nowrap !important;
    }
    
    .month-switcher__btn {
        flex-shrink: 0 !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-width: 32px;
        width: auto !important;
    }
    
    .month-switcher a {
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .home-subsection__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    .home-subsection__head > div {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .home-subsection__head h4 {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: break-word;
        max-width: 100%;
        min-width: 0;
        font-size: 0.85rem;
        line-height: 1.2;
        margin: 0;
        padding: 0;
        overflow: hidden;
        hyphens: auto;
        -webkit-hyphens: auto;
        -ms-hyphens: auto;
    }

    .recurring-list {
        max-width: 100%;
        overflow: hidden;
    }

    .recurring-list li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 2px;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        flex-wrap: nowrap;
    }

    .recurring-list li > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 1px;
    }

    .recurring-name {
        flex: 0 0 auto;
        font-size: 0.7rem;
        font-weight: 700;
        min-width: 0;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .recurring-dates {
        flex: 0 0 auto;
        font-size: 0.65rem;
        color: #475569;
        min-width: 0;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .recurring-amount {
        flex: 0 0 auto;
        font-size: 0.6rem;
        font-weight: 800;
        color: #0f172a;
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 0;
        margin-left: 1px;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .home-actions {
        grid-template-columns: 1fr;
        max-width: 100%;
        overflow: hidden;
    }

    .home-action-card {
        min-width: 0;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .notice-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    .notice-item .btn {
        width: 100%;
        max-width: 100%;
        justify-content: center;
    }

    .card {
        max-width: 100%;
        overflow-x: hidden;
    }

    .home-finance {
        max-width: 100%;
        overflow-x: hidden;
    }

    .finance-layout {
        max-width: 100%;
        overflow-x: hidden;
    }
}

/* Очень маленькие экраны (375px и меньше) */
@media (max-width: 375px) {
    .container {
        padding: 6px !important;
        padding-top: 70px !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .card {
        padding: 8px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin-left: 0;
        margin-right: 0;
    }

    .home-finance {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .finance-layout {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .finance-stack {
        display: grid;
        grid-template-columns: 1fr !important;
        gap: 6px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .finance-block {
        padding: 4px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .home-subsection__head {
        gap: 4px;
        margin-bottom: 6px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .home-subsection__head h4 {
        font-size: 0.75rem;
        line-height: 1.15;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .home-subsection__head > div {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .year-switcher {
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        font-size: 0.85rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        justify-content: center;
        align-items: center;
        overflow: visible;
    }

    .year-switcher__label {
        flex: 0 0 auto;
        font-size: 0.8rem;
        max-width: 100%;
        box-sizing: border-box;
        white-space: nowrap;
    }
    
    .year-switcher__btn {
        flex-shrink: 0 !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-width: 32px;
        width: auto;
    }
    
    /* Исправляем перенос текста в "Актуальные суммы" - разрешаем 2 строки */
    .month-switcher {
        display: flex !important;
        flex-wrap: nowrap !important;
        gap: 8px;
        align-items: center;
        justify-content: center;
    }
    
    .month-switcher h3 {
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        word-break: normal !important;
        margin: 0;
        text-align: center;
        flex: 0 0 auto;
        font-size: 0.95rem;
        line-height: 1.3;
        max-width: 180px;
        hyphens: none !important;
        -webkit-hyphens: none !important;
    }
    
    .month-switcher__prefix {
        white-space: nowrap !important;
    }
    
    .month-switcher__month {
        white-space: nowrap !important;
    }
    
    .month-switcher__btn,
    .month-switcher a {
        flex-shrink: 0 !important;
        display: inline-flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        min-width: 32px;
        width: auto !important;
    }
    
    .month-table {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .month-row {
        gap: 2px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .month-row__label {
        font-size: 0.5rem;
        max-width: 22%;
        box-sizing: border-box;
    }

    .month-bar {
        max-width: 100%;
        box-sizing: border-box;
    }

    .month-value {
        font-size: 0.5rem;
        max-width: 100%;
        box-sizing: border-box;
    }

    .recurring-list {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .recurring-list li {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .multi-filter {
        overflow: visible !important;
    }

    .multi-filter__toggle {
        overflow: visible !important;
        overflow-y: visible !important;
        overflow-x: visible !important;
        -webkit-overflow-scrolling: auto !important;
        scroll-behavior: auto !important;
        max-height: none !important;
        height: auto !important;
    }

    .multi-filter__menu {
        width: 100%;
        box-sizing: border-box;
        max-height: 200px;
    }
    
    .multi-filter.open .multi-filter__menu {
        display: flex !important;
        flex-direction: column !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    .card {
        overflow: visible !important;
    }

    .content-card {
        overflow-y: visible !important;
        min-height: auto !important;
        padding-bottom: 20px !important;
    }

    .filter-wrapper {
        overflow: visible !important;
    }
    
    /* Стили для кнопок в месяцах проектов на очень маленьких экранах */
    .month-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        min-width: 0;
        width: 100%;
    }
    
    .month-actions form {
        flex-direction: column;
        width: 100%;
        gap: 6px;
    }
    
    .month-actions .btn {
        width: 100%;
        justify-content: center;
        font-size: 0.75rem;
        padding: 6px 8px;
    }
}

/* Большие экраны */
@media (min-width: 1400px) {
    .container {
        padding: 40px;
        padding-top: 70px !important;
    }
}

/* Autocomplete styles */
.autocomplete {
    position: relative;
    width: 100%;
}

.autocomplete input {
    width: 100%;
}

.autocomplete__menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #fff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
    padding: 8px 0;
    max-height: 260px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 1100;
    display: none;
}

.autocomplete--open .autocomplete__menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.autocomplete__suggestion {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 8px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.92rem;
    text-align: left;
    color: inherit;
    transition: background-color 0.15s ease;
}

.autocomplete__suggestion:hover,
.autocomplete__suggestion:focus-visible {
    background-color: rgba(15, 91, 255, 0.08);
    outline: none;
}

.autocomplete__suggestion--selected {
    background-color: rgba(15, 91, 255, 0.14);
    font-weight: 600;
}

/* Multi-filter styles */
.multi-filter {
    position: relative;
    width: 100%;
    overflow: visible;
}

.multi-filter__toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    background: #fff;
    color: inherit;
    cursor: pointer;
    gap: 8px;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    overflow: visible !important;
    overflow-y: visible !important;
    overflow-x: visible !important;
    -webkit-overflow-scrolling: auto !important;
    scroll-behavior: auto !important;
}

.multi-filter__toggle:hover,
.multi-filter.open .multi-filter__toggle {
    border-color: rgba(15, 91, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(15, 91, 255, 0.12);
}

.multi-filter__toggle span[data-label] {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
    flex: 1;
}

.multi-filter__toggle::after {
    content: '';
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease;
}

.multi-filter.open .multi-filter__toggle::after {
    transform: rotate(180deg);
}

.multi-filter__menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-width: 400px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 270px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: 10px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
    z-index: 1000;
    min-width: 0;
}

.multi-filter.open .multi-filter__menu {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
    display: flex !important;
}

.multi-filter__search {
    padding: 8px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    margin-bottom: 4px;
}

.multi-filter__search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.multi-filter__search input:focus {
    border-color: rgba(15, 91, 255, 0.5);
    box-shadow: 0 0 0 2px rgba(15, 91, 255, 0.1);
}

.multi-filter__menu label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px !important;
    line-height: 1.4;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background-color 0.15s ease;
    white-space: nowrap;
    min-width: 0;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.multi-filter__menu label:hover {
    background-color: rgba(15, 91, 255, 0.08);
}

.multi-filter__menu label.hidden {
    display: none;
}

.multi-filter__menu input[type="checkbox"] {
    margin: 0;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

/* Utility classes */
.bg-light {
    background-color: #f5f5f5 !important;
}

/* Sticky first column for employee table */
.table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    background-color: #eff2f4; /* Matches rgba(37, 71, 94, 0.07) on white */
    border-right: 1px solid rgba(37, 71, 94, 0.1);
}

.table tbody td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background-color: #fff;
    border-right: 1px solid #edf2f5;
    box-shadow: 2px 0 5px rgba(0,0,0,0.02);
}

.table tbody tr:nth-child(even) td:first-child {
    background-color: #fff; /* Keep white to avoid transparency issues, or match row color */
}

/* Ensure hover row color covers sticky column correctly */
.table tbody tr:hover td:first-child {
    background-color: #f0f7ff !important; /* Light blue tint for hover, opaque */
    z-index: 3;
}

/* Ensure non-hover rows have opaque background too */
.table tbody tr td:first-child {
    background-color: #fff;
    z-index: 2;
}

.table tbody tr:nth-child(even) td:first-child {
    background-color: #fafafa;
}

.table .sticky-col-right {
    position: sticky;
    right: 0;
    z-index: 3;
    background-color: #fff;
    box-shadow: -4px 0 8px rgba(0, 0, 0, 0.04);
}

.table thead .sticky-col-right {
    z-index: 5;
    background-color: #eff2f4;
    border-left: 1px solid rgba(37, 71, 94, 0.1);
}

.table tbody tr:nth-child(even) .sticky-col-right {
    background-color: #fafafa;
}

.table tbody tr:hover .sticky-col-right {
    background-color: #f0f7ff !important;
}

/* Уменьшаем ширину столбца "Управление" в портретном режиме мобильных */
@media (max-width: 768px) and (orientation: portrait) {
    .table .sticky-col-right {
        width: 140px !important;
        min-width: 140px !important;
        max-width: 140px !important;
    }
    
    .table thead .sticky-col-right,
    .table tbody .sticky-col-right {
        width: 140px !important;
        min-width: 140px !important;
        max-width: 140px !important;
    }
    
    /* Уменьшаем размер кнопок в столбце управления */
    .table .sticky-col-right .btn {
        font-size: 0.8rem;
        padding: 6px 8px;
        white-space: nowrap;
    }
    
    .table .sticky-col-right form {
        gap: 4px !important;
    }
    
    .table .sticky-col-right select {
        font-size: 0.8rem;
        padding: 4px 6px;
    }
}

/* Custom scrollbar for tables - всегда видимый внизу */
.table-wrapper {
    position: relative;
    padding-bottom: 0;
    margin-bottom: 0;
}

.custom-scrollbar-container {
    position: fixed !important;
    bottom: 0 !important;
    height: 14px !important;
    z-index: 9999 !important;
    pointer-events: none;
    background: rgba(247, 249, 252, 0.98) !important;
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(37, 71, 94, 0.1) !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05) !important;
    display: none;
    visibility: hidden;
    opacity: 0;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    /* left, right, width, display, visibility, opacity управляются через JavaScript */
}

.custom-scrollbar-track {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: rgba(37, 71, 94, 0.08);
    border-radius: 6px;
    pointer-events: auto;
    cursor: pointer;
}

.custom-scrollbar-thumb {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    min-width: 40px;
    background-color: rgba(37, 71, 94, 0.4);
    border-radius: 6px;
    cursor: grab;
    transition: background-color 0.2s ease, height 0.2s ease;
    pointer-events: auto;
}

.custom-scrollbar-thumb:hover {
    background-color: rgba(37, 71, 94, 0.55);
    height: 10px;
    top: 1px;
}

.custom-scrollbar-thumb.dragging {
    background-color: rgba(37, 71, 94, 0.65);
    cursor: grabbing;
    height: 10px;
    top: 1px;
}

/* Показываем нативный скроллбар и делаем его всегда видимым */
/* Нативный скроллбар всегда виден */
.table-wrapper {
    scrollbar-width: thin; /* Firefox */
    -ms-overflow-style: auto; /* IE и Edge */
}

/* Home page */
.home-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    background: linear-gradient(135deg, #1f3b57, #2f607e);
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-top: 0 !important;
}

.home-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 35%),
                radial-gradient(circle at 80% 0%, rgba(240, 165, 0, 0.15), transparent 30%);
    pointer-events: none;
}

.home-hero > * {
    position: relative;
    z-index: 1;
}

.home-hero__text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.home-hero__meta {
    margin-top: 10px;
}

.home-hello {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    opacity: 0.85;
    margin: 0 0 6px 0;
}

.home-hero__text h1 {
    margin: 0 0 10px 0;
}

.home-subtitle {
    margin: 0 0 12px 0;
    color: inherit;
    opacity: 0.9;
}

.home-hero__cta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 4px;
}

.animation-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(6px);
    width: 100%;
    max-width: 520px;
}

.animation-toggle__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.animation-toggle--footer {
    margin-top: 10px;
}

.home-hero__toggle {
    align-self: flex-start;
    margin-top: auto;
    max-width: 100%;
}

body.animations-off *,
body.animations-off *::before,
body.animations-off *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    animation-delay: 0s !important;
}

.animation-toggle__title {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.animation-toggle__desc {
    font-size: 0.95rem;
    opacity: 0.9;
}

.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(31, 59, 87, 0.45);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    min-width: 96px;
}

.toggle-switch:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.toggle-switch.is-off {
    background: rgba(15, 23, 42, 0.35);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.85);
}

.toggle-switch__glow {
    position: absolute;
    inset: 3px;
    background: radial-gradient(circle at 20% 50%, rgba(240, 165, 0, 0.45), transparent 50%);
    filter: blur(10px);
    opacity: 1;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.toggle-switch.is-off .toggle-switch__glow {
    opacity: 0;
}

.toggle-switch__thumb {
    position: relative;
    z-index: 1;
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f0a500, #ffd479);
    box-shadow: 0 8px 16px rgba(240, 165, 0, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.toggle-switch.is-off .toggle-switch__thumb {
    transform: translateX(-4px);
    background: linear-gradient(135deg, #475569, #1f2937);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

.toggle-switch__text {
    position: relative;
    z-index: 1;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.home-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: inherit;
    font-weight: 600;
    width: fit-content;
}

.hero-year-select {
    margin: 0;
}

.home-chip--select {
    gap: 8px;
}

.home-chip--select select {
    border: none;
    background: transparent;
    color: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 4px 6px;
    border-radius: 8px;
    appearance: none;
    cursor: pointer;
}

.home-chip--select select:focus {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 2px;
}

.hero-total {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hero-total__number {
    font-size: clamp(24px, 4vw, 32px);
    font-weight: 800;
}

.hero-total__hint {
    font-size: 0.95rem;
    opacity: 0.8;
}

.home-hero__chart {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.hero-bar {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
}

.hero-bar__label {
    font-weight: 600;
    margin-bottom: 6px;
}

.hero-bar__track {
    background: rgba(255, 255, 255, 0.12);
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
}

.hero-bar__fill {
    display: block;
    height: 8px;
    width: 0;
    background: linear-gradient(90deg, #f0a500, #ffd479);
    border-radius: 999px;
    transition: width 0.6s ease;
}

.hero-bar__fill.is-filled {
    width: var(--target-fill, 0%);
}

.hero-bar__value {
    margin-top: 6px;
    font-weight: 700;
}

.home-section-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.month-switcher {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.month-switcher h3 {
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: normal !important;
    margin: 0;
    text-align: center;
    line-height: 1.3;
    max-width: 250px;
    hyphens: none !important;
    -webkit-hyphens: none !important;
}

/* "Актуальные суммы за" остается на одной строке, перенос происходит после */
.month-switcher__prefix {
    white-space: nowrap;
}

.month-switcher__month {
    white-space: nowrap;
}

.month-switcher__btn,
.month-switcher a {
    padding: 6px 10px;
    font-size: 1.2rem;
    color: #25475e;
    flex-shrink: 0;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 32px;
}

.home-eyebrow {
    margin: 0;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7280;
}

.home-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    justify-content: flex-start;
}

.home-action-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border-radius: 14px;
    color: #0b1726;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    background: #f7f9fc;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(15, 23, 42, 0.06);
    width: 100%;
}

.home-action-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.15);
    text-decoration: none;
}

.home-action-card h4 {
    margin: 0;
}

.home-action-card__arrow {
    font-weight: 700;
    color: #0f172a;
}

.home-action-card__top {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    width: 100%;
    margin: 0;
    padding: 0;
}

.home-actions .home-chip {
    margin-left: -10px; /* компенсируем внутренний отступ, чтобы текст чипа начинался вровень с контентом карточки */
}

.home-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.25);
    color: inherit;
    font-weight: 700;
    margin-left: auto;
}

.home-action-card.tone-blue {
    background: linear-gradient(135deg, #e5edf7, #dae9ff);
    color: #0b2a45;
}

.home-action-card.tone-amber {
    background: linear-gradient(135deg, #fff4d8, #fde9c0);
    color: #7a4a00;
}

.home-action-card.tone-teal {
    background: linear-gradient(135deg, #e4fbf6, #ccf0e6);
    color: #0f3f36;
}

.home-action-card.tone-slate {
    background: linear-gradient(135deg, #eef2f6, #e2e8f0);
    color: #111827;
}

.home-action-card.tone-green {
    background: linear-gradient(135deg, #e9f7ec, #d4f3dd);
    color: #0f3323;
}

.home-action-card.tone-dark {
    background: linear-gradient(135deg, #e6ebff, #d5dcff);
    color: #1c2f6a;
}

.home-notifications .notice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notice-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #f9fbff;
}

.notice-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.notice-meta {
    color: #4b5563;
    font-size: 0.95rem;
}

.notice-deadline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(37, 71, 94, 0.1);
    color: #25475e;
    font-weight: 600;
}

.notice-deadline.is-hot {
    background: rgba(239, 68, 68, 0.14);
    color: #b91c1c;
}

.btn-compact {
    padding: 8px 12px;
    font-size: 0.95rem;
}

.home-finance .finance-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(620px, 1fr);
    gap: 16px;
    align-items: start;
}

@media (max-width: 1024px) {
    .home-finance .finance-layout {
        grid-template-columns: 1fr;
    }
}

.finance-breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
}

@media (max-width: 900px) {
    .finance-breakdown {
        grid-template-columns: 1fr;
    }
}

.finance-card {
    padding: 14px;
    border-radius: 12px;
    background: #f7f9fc;
    border: 1px solid rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finance-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.finance-card__share {
    font-weight: 700;
    color: #1f3b57;
}

.finance-card__amount {
    font-size: 1.4rem;
    font-weight: 800;
    color: #0f172a;
}

.finance-progress {
    background: #e8edf3;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.finance-progress__fill {
    display: block;
    height: 8px;
    width: 0;
    background: linear-gradient(90deg, #25475e, #0ea5e9);
    border-radius: 999px;
    transition: width 0.6s ease;
}

.finance-progress__fill.is-filled {
    width: var(--target-fill, 0%);
}

.finance-card__note {
    margin: 0;
    color: #475569;
    font-size: 0.95rem;
}

.finance-stack {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 12px;
}

.finance-block {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.year-switcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.year-switcher__btn {
    padding: 6px 10px;
    font-size: 1rem;
    color: #25475e;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-width: 32px;
}

.year-switcher__label {
    font-size: 0.95rem;
    color: #475569;
}

#one-time-year-label {
    font-weight: 700;
    color: #0f172a;
}

.home-subsection__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    min-width: 0;
}

.home-subsection__head h4 {
    margin: 0;
    padding: 0;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.recurring-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.recurring-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(15, 23, 42, 0.1);
    min-width: 0;
}

.recurring-list li > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recurring-list li:last-child {
    border-bottom: none;
}

.recurring-name {
    font-weight: 700;
    min-width: 0;
}

.recurring-dates {
    font-size: 0.95rem;
    color: #475569;
    min-width: 0;
}

.recurring-amount {
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: fit-content;
}

.month-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.month-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.month-row__label {
    flex: 0 0 170px;
    font-weight: 600;
}

.month-bar {
    position: relative;
    flex: 1;
    min-width: 0;
    background: #eef2f7;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
}

.month-bar__fill {
    position: absolute;
    inset: 0;
    height: 100%;
    width: 0;
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(37, 71, 94, 0.18), rgba(240, 165, 0, 0.3));
    transition: width 0.6s ease;
}

.month-bar__fill.is-filled {
    width: var(--target-fill, 0%);
}

body.animations-off .hero-bar__fill,
body.animations-off .finance-progress__fill,
body.animations-off .month-bar__fill {
    transition: none !important;
}

.month-value {
    position: relative;
    z-index: 1;
    font-weight: 700;
    color: #0f172a;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

.finance-number {
    font-variant-numeric: tabular-nums;
}

.empty-state {
    padding: 16px;
    border-radius: 12px;
    background: #f7f9fc;
    border: 1px dashed rgba(15, 23, 42, 0.15);
    color: #475569;
}

.empty-state.muted {
    background: #f9fafb;
    color: #6b7280;
}

/* Исправление выхода кнопок за границы контейнера в "Заявки на стимулирование" */
.content-card > div:first-child {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 16px !important;
    gap: 16px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.content-card > div:first-child h2 {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
}

.content-card > div:first-child > div {
    display: flex !important;
    gap: 12px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.content-card > div:first-child > div .btn,
.content-card > div:first-child > .btn,
.content-card > div:first-child > a.btn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
}

@media (max-width: 768px) {
    .content-card > div:first-child {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    
    .content-card > div:first-child h2 {
        flex: 1 1 auto !important;
        margin-bottom: 0 !important;
        width: 100% !important;
    }
    
    .content-card > div:first-child > div {
        flex-direction: row !important;
        width: auto !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    .content-card > div:first-child > div .btn,
    .content-card > div:first-child > .btn,
    .content-card > div:first-child > a.btn {
        width: auto !important;
        flex: 0 0 auto !important;
        align-self: flex-start !important;
        text-align: center !important;
    }
}

@media (max-width: 480px) {
    .content-card > div:first-child {
        gap: 10px !important;
    }
    
    .content-card > div:first-child > div {
        gap: 6px !important;
    }
}
