:root {
    --fin-bg: #12141D;
    --fin-surface: #232733;
    --fin-gold: #E2B15B;
    --fin-ice: #7FA9C3;
    --fin-text: #E0E0E0;

    /* Маппинг на Bootstrap */
    --bs-blue: var(--fin-ice);
    --bs-primary: var(--fin-gold);
    --bs-primary-rgb: 226, 177, 91; /* Для прозрачности в Bootstrap */

    --bs-body-bg: var(--fin-bg);
    --bs-body-color: var(--fin-text);

    --bs-emphasis-color: var(--fin-text);
    --bs-secondary-color: var(--fin-ice);

    --bs-border-color: rgba(127, 169, 195, 0.2); /* Тонкие ледяные границы */
}

.sidebar {
    background: var(--fin-bg);
    border-right: 1px solid var(--bs-border-color);
    padding: 1.5rem 0.8rem;
    z-index: 100;
    position: sticky;
}

.wt-filter-form-container .form-label {
    font-size: 0.75rem;
    color: var(--fin-ice);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.25rem;
}

.wt-filter-form-container .form-select,
.wt-filter-form-container .form-control {
    background-color: var(--fin-surface);
    border: 1px solid var(--bs-border-color);
    color: var(--fin-text);
    font-size: 0.9rem;
}

.wt-filter-form-container .form-select:focus,
.wt-filter-form-container .form-control:focus {
    border-color: var(--fin-gold);
    box-shadow: 0 0 0 0.25rem rgba(226, 177, 91, 0.25);
}

.wt-filter-form-container.htmx-request {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s;
}

.wt-filter-form-container .invalid-feedback {
    display: block !important;
    font-size: 0.75rem;
    color: #ff6b6b;
    margin-top: 0.25rem;
}

.wt-filter-form-container .is-invalid {
    border-color: #ff6b6b !important;
    background-image: none !important;
}

.wt-header-compact {
    background: var(--fin-surface);
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
}

.wt-balance-label {
    font-size: 0.75rem;
    color: var(--fin-ice);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.wt-balance-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fin-gold);
}

.wt-account-card-sm {
    flex: 0 0 auto;
    background: rgba(127, 169, 195, 0.05);
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--fin-text);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
}

.wt-account-card-sm:hover {
    background: rgba(127, 169, 195, 0.1);
    border-color: var(--fin-ice);
    color: var(--fin-text);
}

.wt-account-card-sm.active {
    background: var(--fin-gold);
    border-color: var(--fin-gold);
    color: var(--fin-bg);
}

.main-column {
    background: var(--fin-bg);
    height: calc(100vh - 120px);
    overflow: hidden;
    padding: 1.5rem 0.8rem 0.25rem;
}

.list-scroll {
    padding: 0 0.5rem;
    height: 100%;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.list-scroll::-webkit-scrollbar {
    display: none;
}

.wt-accounts-scroll {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.25rem 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.wt-accounts-scroll::-webkit-scrollbar {
    display: none;
}

.wt-search-container {
    position: relative;
}

.wt-search-input {
    width: 100%;
    background: var(--fin-surface);
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    color: var(--fin-text);
    font-size: 0.9rem;
}

.wt-search-input:focus {
    outline: none;
    border-color: var(--fin-gold);
    box-shadow: 0 0 0 2px rgba(226, 177, 91, 0.2);
}

.wt-search-icon {
    position: absolute;
    left: 1.5rem;
    top: 38%;
    transform: translateY(-50%);
    color: var(--fin-ice);
    pointer-events: none;
}

.clear-button,
.clear-button:hover,
.clear-button:focus,
.clear-button:active {
    padding: 0.375rem 0;
    color: var(--fin-ice) !important;
    transition: none !important;
}

/* Карусель счетов */
.wt-accounts-carousel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(127, 169, 195, 0.2);
    border-radius: 12px;
    padding: 0 2rem;
    position: relative;
    overflow: hidden;
}

.wt-accounts-carousel .object-card {
    background: transparent;
    border: none;
    height: 54px;
    border-radius: 0;
}

.object-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(127, 169, 195, 0.2);
    border-radius: 12px;
    text-align: center;
    padding: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 54px;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.object-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(127, 169, 195, 0.4);
}

.object-card-label {
    color: var(--fin-ice);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.object-card-info {
    color: var(--fin-gold);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.1;
}

.currency-symbol {
    font-size: 0.8rem;
    opacity: 0.7;
}

.wt-ba-plus {
    font-size: 1.5rem;
    line-height: 1;
    display: inline-block;
}

.object-card-new .object-card-label {
    opacity: 0.7;
}

.wt-accounts-carousel .carousel-control-prev,
.wt-accounts-carousel .carousel-control-next {
    width: 32px;
    opacity: 0.8;
    background: rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.wt-accounts-carousel:hover .carousel-control-prev,
.wt-accounts-carousel:hover .carousel-control-next {
    opacity: 1;
    background: rgba(0, 0, 0, 0.2);
}

.wt-accounts-carousel .carousel-control-prev {
    left: 0;
    border-radius: 12px 0 0 12px;
}

.wt-accounts-carousel .carousel-control-next {
    right: 0;
    border-radius: 0 12px 12px 0;
}

.wt-accounts-carousel .carousel-control-prev-icon,
.wt-accounts-carousel .carousel-control-next-icon {
    width: 16px;
    height: 16px;
    filter: sepia(100%) saturate(300%) brightness(90%) hue-rotate(10deg); /* Под золото */
}

/* Группировка по дням */

.wt-day-group {
    margin-bottom: 1rem;
}

.wt-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0;
    border-bottom: 1px solid var(--bs-border-color);
    margin-bottom: 0.5rem;
}

.wt-day-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--fin-ice);
}

.wt-day-totals {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.wt-day-totals div {
    white-space: nowrap;
}

.wt-trans-item {
    background: var(--fin-surface);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--fin-text);
    display: block;
}

.wt-trans-item:hover {
    border-color: var(--bs-border-color);
    background: rgba(127, 169, 195, 0.03);
    transform: translateX(4px);
    color: var(--fin-text);
}

.wt-trans-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wt-trans-icon.exp {
    background: rgba(220, 53, 69, 0.1);
    color: #ff6b6b;
}

.wt-trans-icon.rev {
    background: rgba(40, 167, 69, 0.1);
    color: #51cf66;
}

.wt-trans-details {
    flex: 1;
    min-width: 0;
}

.wt-trans-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.15rem;
}

.wt-trans-group {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wt-trans-amount {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
}

.wt-trans-sub {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--fin-ice);
}

.wt-trans-comment {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.wt-trans-list-container {
    height: auto;
}

body {
    background-color: var(--fin-bg);
    color: var(--fin-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding: 60px 0 0;
}

.navbar {
    background-color: rgba(18, 20, 29, 0.9) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--bs-border-color);
    height: 60px; /* Фиксированная высота для удобства расчетов */
}

.min-vh-100-nav {
    min-height: calc(100vh - 60px);
}

.navbar-brand {
    font-weight: 700;
    color: var(--fin-gold) !important;
    letter-spacing: 1px;
}

.btn-primary {
    background-color: var(--fin-gold);
    border-color: var(--fin-gold);
    color: var(--fin-bg);
    font-weight: 600;
}

.btn-primary:hover, .btn-outline-primary:hover {
    background-color: #c99640;
    border-color: #c99640;
    color: var(--fin-bg);
}

.btn-primary:active, .btn-primary:focus,
.btn-outline-primary:active, .btn-outline-primary:focus {
    background-color: #b38539 !important;
    border-color: #b38539 !important;
    color: var(--fin-bg) !important;
    box-shadow: 0 0 0 0.25rem rgba(226, 177, 91, 0.25) !important;
}

.btn-danger {
    background-color: transparent;
    border-color: rgba(127, 169, 195, 0.4); /* Полупрозрачный ледяной */
    color: var(--fin-ice);
    font-weight: 500;
}

.btn-danger:hover {
    background-color: rgba(127, 169, 195, 0.1);
    border-color: var(--fin-ice);
    color: #fff;
}

.btn-danger:active, .btn-danger:focus {
    background-color: rgba(127, 169, 195, 0.2) !important;
    border-color: var(--fin-ice) !important;
    box-shadow: 0 0 0 0.25rem rgba(127, 169, 195, 0.25) !important;
}

.btn-outline-primary {
    color: var(--fin-gold);
    border-color: var(--fin-gold);
}

.card, .offcanvas, .dropdown-menu {
    background-color: var(--fin-surface) !important;
    border: 1px solid var(--bs-border-color);
    color: var(--fin-text);
}

.dropdown-item {
    color: var(--fin-text);
}

.dropdown-item:hover {
    background-color: rgba(226, 177, 91, 0.1);
    color: var(--fin-gold);
}

.text-muted {
    color: var(--fin-ice) !important;
}

.accordion {
    --bs-accordion-btn-bg: rgba(var(--bs-emphasis-color-rgb), 0.05);
    --bs-accordion-active-color: var(--bs-body-bg); /* Цвет текста активного заголовка */
    --bs-accordion-active-bg: var(--bs-body-color); /* Фон активного заголовка */
    --bs-accordion-btn-focus-box-shadow: 0 0 2px 1px var(--bs-body-color);
    --bs-accordion-btn-padding-y: 0.5rem;
    --bs-accordion-body-padding-y: 0.5rem;
}

.accordion-button::after {
    display: none;
}

.comment {
    font-size: 80%;
}

.col-minimum {
    min-width: 40px !important;
}

.clickable {
    cursor: pointer;
}

/* Плавное исчезновение старого контента */
.htmx-swapping {
    opacity: 0;
    transition: opacity 300ms ease-out;
}

/* Плавное появление нового контента */
.htmx-added {
    opacity: 0;
}

/* Универсальный класс для элементов, которые должны обновляться плавно */
.smooth-fade {
    opacity: 1;
    transition: opacity 300ms ease-in;
}

.min-height-0 {
    min-height: 0;
}

.wt-trans-height {
    height: 38vh;
}

.scroll-block {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Опционально: делаем скроллбар более аккуратным */
.scroll-block::-webkit-scrollbar {
    width: 6px;
}

.scroll-block::-webkit-scrollbar-thumb {
    background-color: var(--bs-body-color);
    border-radius: 3px;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background-color: var(--fin-surface);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--bs-border-color);
    z-index: 1030;
    padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--fin-ice);
    text-decoration: none;
    font-size: 0.75rem;
    background: none;
    border: none;
    padding: 5px;
    width: 100%;
}

.bottom-nav-link i {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

.bottom-nav-link.active {
    color: var(--fin-gold);
}

.bottom-nav-link:hover {
    color: var(--fin-gold);
}

.footer {
    background-color: var(--fin-bg);
    border-color: var(--bs-border-color) !important;
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0 0.25rem;
}

.footer-links span {
    transition: opacity 0.2s;
}

.main-container {
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.mobile-nav-top {
    height: 56px;
    display: flex;
    align-items: center;
}

#mobileMenu.offcanvas-bottom {
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

/* ДНИ НЕДЕЛИ */
/* Обертки каждого чекбокса внутри поля выбора */
.custom-days-checkboxes .form-check {
    display: flex;
    flex-direction: column-reverse; /* Разворачиваем: Label сверху, Input снизу */
    align-items: center;
    margin-right: 10px;
    padding-left: 0;
}

/* Стилизуем сам чекбокс, чтобы он был по центру под текстом */
.custom-days-checkboxes .form-check-input {
    margin-left: 0;
    margin-top: 5px;
}

/* Убираем лишние отступы у лейбла */
.custom-days-checkboxes .form-check-label {
    padding-left: 0;
    font-size: 0.85rem;
    font-weight: bold;
}

/* ДНИ МЕСЯЦА */
/* Сетка для чисел месяца */
.days-of-month-grid {
    display: flex;
    flex-wrap: wrap;
    max-width: 210px; /* Ограничиваем ширину, чтобы они выстроились в 7 колонок как календарь */
}

.days-of-month-grid .form-check {
    padding: 0;
    margin: 2px;
}

/* Скрываем стандартный квадрат чекбокса */
.days-of-month-grid .form-check-input {
    display: none;
}

/* Стилизуем Label как кнопку */
.days-of-month-grid .form-check-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

/* Стиль для ВЫБРАННОГО числа */
.days-of-month-grid .form-check-input:checked + .form-check-label {
    background-color: var(--fin-gold);
    color: #12141D;
    border-color: var(--fin-gold);
    font-weight: bold;
}

/* Стилизация Flatpickr для произвольных дат */
.custom-dates-picker {
    background-color: var(--bs-body-bg) !important;
    border: 1px dashed #dee2e6;
    min-height: 38px;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 4px;
    width: 100%;
    white-space: nowrap;
    overflow-x: auto;
    text-overflow: ellipsis;
}

.custom-dates-picker:focus {
    border-color: var(--fin-gold);
    outline: none;
}

/* Стили для отрисовки спиннера загрузки и контента */
.sc-wrap {
    position: relative;
    isolation: isolate; /* Для изоляции z-index от всей страницы */
}

.sc-content {
    position: relative;
    z-index: 1;
}

.sc-spinner {
    position: absolute;
    inset: 0; /* Растянуть поверх всего блока */
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;

    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.sc-spinner-card {
    min-width: 220px;
    max-width: 320px;
    padding: 1rem 1.5rem;
    border-radius: 1rem;

    background: var(--bs-body-color);
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    transform: translateY(0);
    animation: spinner-card-pop 180ms ease-out;
}

.sc-spinner-icon svg {
    color: var(--bs-body-bg);
    width: 48px;
    height: 48px;
}

.sc-spinner-text {
    color: var(--bs-body-bg);
    font-weight: 500;
}

@keyframes spinner-card-pop {
    from {
        transform: translateY(4px) scale(0.70);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.wt-trans-item-focus {
    border-color: var(--fin-gold) !important;
    background: rgba(226, 177, 91, 0.1) !important;
    box-shadow: 0 0 15px rgba(226, 177, 91, 0.2);
    transform: scale(1.02);
    z-index: 10;
}

.text-fin-gold {
    color: var(--fin-gold) !important;
}

.text-fin-ice {
    color: var(--fin-ice) !important;
}

.text-fin-white {
    color: var(--bs-body-color) !important;
}

.fin-cards-row {
    margin: 0 0.5rem 1rem;
}

.fin-card-feature {
    background: var(--fin-surface);
    border: 1px solid rgba(127, 169, 195, 0.1);
    height: 100%;
}

.offcanvas-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wt-sidebar-filters-container.show {
    display: block;
}

.home-logo {
    max-width: 200px;
    max-height: 200px;
    width: 100%;
    height: auto;
}

#div_id_start_date, #div_id_end_date {
    margin-bottom: 4px !important;
}

#div_id_start_date input, #div_id_end_date input {
    padding-right: 3px;
}

/* АДАПТАЦИЯ ВЕРСТКИ ЧЕРЕЗ МЕДИА ЗАПРОСЫ */

/* Адаптивность на мобильных устройствах */
@media (max-width: 767.99px) {
    body {
        padding-bottom: 53px; /* Пространство для навигационного меню снизу на мобильной версии */
    }

    .home-page {
        padding-top: 0 !important;
    }

    .worktable-panel {
        padding-bottom: 165px !important;
    }

    .oneline-panel {
        padding-bottom: 105px !important;
    }

    .sidebar {
        position: fixed;
        bottom: 50px; /* Высота .bottom-nav */
        left: 0;
        right: 0;
        height: auto;
        border-right: none;
        border-top: 1px solid var(--bs-border-color);
        padding: 0.5rem 1rem;
        background: var(--fin-bg);
        z-index: 1030;
    }

    .main-column {
        left: 0;
        right: 0;
        height: auto;
    }

    .wt-actions-sidebar {
        margin-top: 0.5rem !important;
    }

    .wt-trans-list-container {
        height: auto;
        padding-bottom: 20px;
    }

    /* Мобильный контейнер фильтров */
    .wt-sidebar-filters-container {
        display: none;
        position: fixed;
        bottom: 160px; /* Над bottom-nav */
        top: auto;
        left: 0;
        right: 0;
        background: var(--fin-bg);
        padding: 0.5rem 1.5rem;
        border-top: 1px solid var(--bs-border-color);
        border-bottom: none;
        box-shadow: 0 -10px 15px rgba(0, 0, 0, 0.3);
        z-index: 2000;
    }

    /* Эффект затемнения для списка транзакций при открытых фильтрах +++ */
    .main-column.dimmed {
        position: relative;
        pointer-events: none;
    }

    .main-column.dimmed::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.7);
        z-index: 1025;
        transition: background 0.3s ease;
    }

    /* Эффект затемнения для списка транзакций при открытых фильтрах --- */
    /* Стилизация offcanvas-details как bottom sheet на мобильных +++ */
    #offcanvas-details.offcanvas-end {
        top: auto !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-height: 85% !important;
        border-left: none !important;
        border-top: 1px solid var(--bs-border-color) !important;
        border-top-left-radius: 20px !important;
        border-top-right-radius: 20px !important;
        transform: translateY(100%) !important;
        transition: transform 0.3s ease-in-out !important;
        visibility: visible !important;
    }

    #offcanvas-details.offcanvas-end.show {
        transform: translateY(0) !important;
    }

    /* Добавляем индикатор "ручки" для bottom sheet */
    #offcanvas-details.offcanvas-end::before {
        content: "";
        display: block;
        width: 40px;
        height: 4px;
        background-color: var(--bs-border-color);
        border-radius: 2px;
        margin: 10px auto 0;
    }

    /* Стилизация offcanvas-details как bottom sheet на мобильных --- */
}


/* Адаптивность для средних экранов (планшеты) */
@media (min-width: 768px) {
    body {
        padding-top: 60px;
    }

    .home-logo {
        max-width: 250px;
        max-height: 250px;
    }

    .display-3 {
        font-size: calc(1.525rem + 2.5vw);
    }

    .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    .content-wrapper.justify-content-center {
        display: flex !important;
    }

    .min-vh-100-nav {
        height: calc(100vh - 60px);
    }

    .footer {
        height: 60px;
        display: flex;
        align-items: center;
    }
}

/* Адаптивность для больших экранов (desktop) */
@media (min-width: 992px) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    .offcanvas-end {
        width: 400px !important;
    }
}
