/* ==================== ПОЛЯ ФОРМ: floating-label ==================== */
/* Универсальный паттерн «как в банк-приложениях»: подпись внутри инпута,
   при фокусе/наличии значения — поднимается и уменьшается. Никаких отдельных <label> снаружи. */

.field {
    position: relative;
    margin-bottom: 10px;
    padding-top: 8px; /* зона для поднятого лейбла над инпутом */
}

.field__input,
.field__select,
.field__textarea {
    width: 100%;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    border-radius: var(--r-sm);
    /* font-size: 16px — критично для iOS, иначе при фокусе страница зумится */
    font-size: 16px;
    font-family: inherit;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow .15s, background .15s;
    outline: none;
}
.field__input:focus,
.field__select:focus,
.field__textarea:focus {
    background: var(--surface);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
.field__input:disabled,
.field__select:disabled,
.field__textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Размеры — БЕЗ места под лейбл внутри (лейбл живёт снаружи, поверх верха) */
.field__input,
.field__select {
    padding: 0 12px;
    height: 44px;
}
.field__textarea {
    padding: 10px 12px;
    min-height: 60px;
    resize: vertical;
}

/* Native &lt;select&gt; — скрыт. Видимая часть — .field__select-display + .field__dropdown.
   Native остаётся в DOM для сабмита формы и для value-based JS-логики. */
.field--select select.field__select,
.cs-shell select.filter-control {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    left: 0;
    top: 0;
}

/* Обёртка для кастомного select вне модалок (фильтры, тулбары) */
.cs-shell {
    position: relative;
    display: block;
}
/* В фильтрах display ведёт себя как .filter-control (38px высота, текст под 16px) */
.cs-shell .field__select-display {
    height: 38px;
    padding: 0 28px 0 10px;
    font-size: 15px;            /* визуально согласован с .filter-control 16px (отступ — это не настоящий input, iOS zoom не вызывает) */
    border-radius: var(--r-sm);
}
.cs-shell .field__select-chevron { right: 8px; width: 14px; height: 14px; }

/* Видимое отображение select */
.field__select-display {
    width: 100%;
    height: 44px;
    padding: 0 36px 0 12px;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    border-radius: var(--r-sm);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow .15s, background .15s;
    user-select: none;
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.field--select.field--open .field__select-display,
.field__select-display:focus {
    background: var(--surface);
    box-shadow: inset 0 0 0 1.5px var(--accent);
    outline: none;
}
.field__select-display--placeholder { color: var(--ink-3); }
.field__select-chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-3);
    pointer-events: none;
    width: 16px;
    height: 16px;
    transition: transform .15s;
}
.field--select.field--open .field__select-chevron {
    transform: translateY(-50%) rotate(180deg);
}

/* Dropdown — открывается под .field */
.field__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-3);
    z-index: 1100;
    padding: 4px;
}
.field__dropdown[hidden] { display: none; }
.field__option {
    padding: 9px 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--ink-1);
    font-size: 0.9rem;
    transition: background .1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.field__option:hover         { background: var(--neutral-soft); }
.field__option.is-selected   { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.field__option--placeholder  { color: var(--ink-3); }

/* Лейбл — по центру инпута, когда пусто.
   Когда поле в фокусе/непустое — лейбл «сидит» поверх верхней границы инпута. */
.field__label {
    position: absolute;
    left: 12px;
    top: 30px; /* центр инпута: 8 (padding-top .field) + 44/2 */
    transform: translateY(-50%);
    font-size: 0.92rem;
    color: var(--ink-3);
    pointer-events: none;
    transition: color .15s ease;
    background: transparent;
    padding: 0 4px;
    white-space: nowrap;
    overflow: hidden;
    max-width: calc(100% - 24px);
    text-overflow: ellipsis;
    z-index: 1;
}

/* Поднятый лейбл — выше верхней границы инпута, на фоне родителя (модалка/страница).
   Изменение позиции/размера моментальное (без transition), чтобы не было «дрожания». */
.field__input:focus ~ .field__label,
.field__input:not(:placeholder-shown) ~ .field__label,
.field__textarea:focus ~ .field__label,
.field__textarea:not(:placeholder-shown) ~ .field__label,
.field--filled .field__label,
.field--select .field__label,
.field--open .field__label {
    top: 8px; /* верхняя граница инпута (равно .field padding-top) */
    transform: translateY(-50%);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--ink-3);
    background: var(--surface); /* перекрыть верхнюю кромку инпута */
}
/* Акцентный цвет лейбла при открытом dropdown */
.field--open .field__label { color: var(--accent); }

/* Для textarea — лейбл по верхней строке (textarea не имеет фиксированной высоты) */
.field__textarea ~ .field__label { top: 26px; }
.field__textarea:focus ~ .field__label,
.field__textarea:not(:placeholder-shown) ~ .field__label { top: 8px; }

/* При фокусе цвет акцент */
.field__input:focus ~ .field__label,
.field__textarea:focus ~ .field__label,
.field__select:focus ~ .field__label,
.field--focused .field__label {
    color: var(--accent);
}

/* Кнопка-сосед поля в .field-row (например, «Вчера 23:59» в модалке статистики).
   .field имеет padding-top: 8px (под floating-label), значит инпут начинается с y=8px.
   Чтобы кнопка совпадала с инпутом — прижимаем её к низу .field-row через align-self. */
.field-row .yesterday-btn,
.yesterday-btn {
    align-self: flex-end;
    flex: 0 0 auto;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-2);
    border-radius: var(--r-sm);
    padding: 0 14px;
    height: 44px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, color .12s;
    font-family: inherit;
}
.yesterday-btn:hover { background: var(--neutral-soft); color: var(--ink-1); }

/* Группа полей в один ряд: сумма + валюта или комиссия + кошелёк */
.field-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.field-row .field { flex: 1; margin-bottom: 0; }
.field-row .field--narrow { flex: 0 0 130px; }

/* Подпись-помощник под полем */
.field__hint {
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--ink-3);
    padding-left: 12px;
}
.field__error {
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--expense);
    padding-left: 12px;
}

/* ==================== DATETIME PICKER (AdmDateTimePicker) ==================== */
.adm-dtp {
    width: 380px;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-3);
    color: var(--ink-1);
    font-family: inherit;
    font-size: 0.85rem;
    z-index: 2000;
    padding: 12px;
    user-select: none;
    border: 0;
}
/* Тело: календарь слева + часы справа */
.adm-dtp-body {
    display: flex;
    gap: 10px;
}
.adm-dtp-cal { flex: 1; min-width: 0; }

/* Шапка */
.adm-dtp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 8px;
}
.adm-dtp-nav {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-2);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
}
.adm-dtp-nav:hover { background: var(--neutral-soft); color: var(--ink-1); }
.adm-dtp-label,
.adm-dtp-label-static {
    flex: 1;
    text-align: center;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink-1);
    background: transparent;
    border: 0;
    padding: 6px 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .12s;
}
.adm-dtp-label-static { cursor: default; }
.adm-dtp-label:hover { background: var(--neutral-soft); }

/* Дни недели */
.adm-dtp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.68rem;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}
.adm-dtp-weekdays span { padding: 4px 0; }

/* Сетка дней */
.adm-dtp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.adm-dtp-day {
    aspect-ratio: 1 / 1;
    border: 0;
    background: transparent;
    color: var(--ink-1);
    font: inherit;
    font-size: 0.85rem;
    border-radius: var(--r-sm);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
}
.adm-dtp-day:hover:not(:disabled) { background: var(--neutral-soft); }
.adm-dtp-day.is-other { color: var(--ink-3); }
.adm-dtp-day.is-today {
    color: var(--accent);
    font-weight: 700;
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
.adm-dtp-day.is-selected {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: none;
}
.adm-dtp-day.is-selected:hover { background: var(--accent-ink); }
.adm-dtp-day.is-disabled,
.adm-dtp-day:disabled {
    color: var(--ink-3);
    opacity: 0.45;
    cursor: not-allowed;
}

/* Часы — вертикальный scroll-список справа от календаря */
.adm-dtp-times {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 78px;
    flex-shrink: 0;
    max-height: 230px;
    overflow-y: auto;
    padding: 2px 4px 2px 10px;
    border-left: 1px solid var(--neutral-soft);
    scrollbar-width: thin;
    scrollbar-color: var(--ink-4) transparent;
    /* iOS: разрешаем вертикальный touch-скролл внутри списка.
       Иначе body.modal-open (touch-action: none) блокирует прокрутку часов. */
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.adm-dtp-times::-webkit-scrollbar { width: 5px; }
.adm-dtp-times::-webkit-scrollbar-thumb { background: var(--ink-4); border-radius: 3px; }
.adm-dtp-times::-webkit-scrollbar-track { background: transparent; }
.adm-dtp-time {
    border: 0;
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--r-sm);
    padding: 6px 0;
    cursor: pointer;
    transition: background .12s, color .12s;
    flex-shrink: 0;
}
.adm-dtp-time:hover { background: var(--neutral-soft); color: var(--ink-1); }
.adm-dtp-time.is-selected {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

/* Подвал */
.adm-dtp-foot {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--neutral-soft);
}
.adm-dtp-action {
    flex: 1;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--r-sm);
    padding: 8px 0;
    cursor: pointer;
    transition: background .12s, filter .12s;
}
.adm-dtp-action:hover { background: var(--neutral-soft); }
.adm-dtp-action-primary {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}
.adm-dtp-action-primary:hover {
    background: var(--accent);
    filter: brightness(0.95);
}

/* Сетка годов */
.adm-dtp-years {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.adm-dtp-year {
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    font: inherit;
    font-size: 0.9rem;
    border-radius: var(--r-sm);
    padding: 12px 0;
    cursor: pointer;
    transition: background .12s;
}
.adm-dtp-year:hover { background: var(--neutral-soft); }
.adm-dtp-year.is-selected {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* Инпут с пикером — добавим иконку календаря и убираем нативный спиннер */
input[data-admdtp] {
    cursor: pointer;
    caret-color: transparent;
}

/* ==================== МОДАЛКИ (без Bootstrap) ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1055;
    overflow-x: hidden;
    overflow-y: auto;
    opacity: 0;
    /* Закрытие — быстрое (0.2s) */
    transition: opacity .2s ease;
}
.modal.show { display: block; }
.modal.fade.show {
    opacity: 1;
    /* Появление — чуть медленнее, мягче */
    transition: opacity .35s ease;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    transition: opacity .2s ease;
}
.modal-backdrop.show { opacity: 1; transition: opacity .35s ease; }

.modal-dialog {
    max-width: 500px;
    margin: 1.75rem auto;
    pointer-events: none;
}
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100vh - 3.5rem);
}
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-3);
    pointer-events: auto;
    outline: 0;
    /* overflow: visible — чтобы кастомные dropdown'ы (например выбор кошелька/категории)
       могли выходить за границы модалки. Скролл длинного контента происходит на .modal */
    overflow: visible;
}
/* Анимация контента: лёгкое поднятие + scale → нормальная позиция.
   Появление — мягче и чуть длиннее; закрытие — быстрое. */
.modal.fade .modal-dialog {
    transform: translateY(-20px) scale(0.97);
    transition: transform .2s ease;
}
.modal.fade.show .modal-dialog {
    transform: none;
    transition: transform .35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--neutral-soft);
}
.modal-header.border-0 { border-bottom: 0; }
.modal-header.pb-0 { padding-bottom: 0; }
.modal-title { margin: 0; font-size: 1.05rem; line-height: 1.3; color: var(--ink-1); }

/* Крестик закрытия */
.btn-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
    flex-shrink: 0;
}
.btn-close::before {
    content: '';
    width: 16px; height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}
.btn-close:hover { background: var(--neutral-soft); color: var(--ink-1); }

.modal-body { padding: 18px; flex: 1 1 auto; }
.modal-footer {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--neutral-soft);
}
.modal-footer.border-0 { border-top: 0; }
.modal-footer.pt-0 { padding-top: 0; }
/* Кнопки в футере модалок растягиваются равными долями:
   1 кнопка → 100%, 2 → 50/50, 3 → 33/33/33 и т.д. */
.modal-footer > .btn {
    flex: 1 1 0;
    min-width: 0;
}

/* Кнопки внутри модалок (минимум для совместимости) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: var(--r-sm);
    padding: 8px 14px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: filter .12s, background .12s;
    font-family: inherit;
    line-height: 1.3;
}
.btn-sm { padding: 6px 10px; font-size: 0.82rem; }
.btn-light { background: var(--surface-alt); color: var(--ink-1); }
.btn-light:hover { background: var(--neutral-soft); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--income); color: #fff; }
.btn-danger  { background: var(--expense); color: #fff; }
.btn-warning { background: var(--warn); color: #fff; }
.btn-info    { background: #64748b; color: #fff; }
.btn-secondary { background: var(--ink-2); color: #fff; }
.btn-repay   { background: #259a8f; color: #fff; }   /* совпадает с .action--repay */
.btn-repay:hover { background: #1f7f76; color: #fff; }
.btn-dark    { background: var(--ink-1); color: #fff; }
.btn-outline-secondary { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.btn-outline-secondary:hover { background: var(--neutral-soft); }
.btn-outline-primary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn-outline-primary:hover { background: var(--accent-soft); }
.btn-outline-danger { background: transparent; color: var(--expense); box-shadow: inset 0 0 0 1.5px var(--expense-soft); }
.btn-outline-danger:hover { background: var(--expense-soft); }
.btn-primary:hover, .btn-success:hover, .btn-danger:hover,
.btn-warning:hover, .btn-info:hover, .btn-secondary:hover, .btn-dark:hover { filter: brightness(0.94); }

/* Старые формы (form-control/form-select/form-label) — компактный fallback */
.form-control, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    border-radius: var(--r-sm);
    /* font-size: 16px — критично для iOS, иначе zoom при фокусе */
    font-size: 16px;
    font-family: inherit;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow .15s, background .15s;
    outline: none;
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
.form-control-sm, .form-select-sm { padding: 5px 10px; font-size: 16px; }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px 14px;
    padding-right: 32px;
}
.form-label { display: block; font-size: 0.78rem; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; }
.form-floating { position: relative; }
.form-floating > .form-control { height: 56px; padding: 22px 12px 8px; }
.form-floating > label {
    position: absolute;
    inset: 0 auto auto 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.92rem;
    color: var(--ink-3);
    pointer-events: none;
    transition: top .15s, font-size .15s, transform .15s;
}
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
    top: 12px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
}

.input-group { display: flex; align-items: stretch; }
.input-group > .form-control,
.input-group > .form-select { flex: 1; }
.input-group > .form-control:not(:last-child),
.input-group > .form-select:not(:last-child) { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

/* ==================== FAQ ==================== */
/* Бейдж «админ» — приглушённый (а не яркий рыжий) */
.faq-tabs-wrapper .badge.bg-warning,
.nav-link .badge.bg-warning {
    background: var(--neutral-soft) !important;
    color: var(--ink-2) !important;
    font-weight: 600;
}
.nav-link.active .badge.bg-warning {
    background: rgba(255,255,255,0.25) !important;
    color: #fff !important;
}

/* Карточки FAQ (общие) */
.card {
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-1);
    overflow: hidden;
    margin-bottom: 12px;
}
.card.shadow-sm { box-shadow: var(--sh-1); }
.card.border-warning { box-shadow: var(--sh-1); }
.card-header {
    padding: 12px 16px;
    font-weight: 600;
    color: var(--ink-1);
    font-size: 0.92rem;
    border-bottom: 1px solid var(--neutral-soft);
}
.card-header.bg-light { background: var(--surface-alt); }
.card-header.bg-warning,
.card-header.bg-warning.bg-opacity-25 {
    background: var(--warn-soft);
    color: var(--warn-ink);
    border-bottom-color: rgba(217, 119, 6, 0.18);
}
.card-body { padding: 16px; color: var(--ink-1); }

/* Заголовки внутри FAQ */
.card-body h5,
.card-body h6 {
    font-weight: 700;
    color: var(--ink-1);
    margin: 18px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--neutral-soft);
}
.card-body h5:first-child,
.card-body h6:first-child { margin-top: 0; }
.card-body h5 { font-size: 1rem; }
.card-body h6 { font-size: 0.92rem; }

.card-body p { margin: 0 0 10px; line-height: 1.5; }
.card-body ol, .card-body ul { margin: 0 0 10px; padding-left: 22px; line-height: 1.55; }
.card-body li { margin-bottom: 4px; }
.card-body code {
    background: var(--surface-alt);
    color: var(--accent-ink);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Бейджи (Bootstrap fallback) — для FAQ и старых страниц.
   Современные бейджи — это .pill. */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 5px;
    color: #fff;
    white-space: nowrap;
}
.badge.bg-success    { background: var(--income-soft);  color: var(--income-ink); }
.badge.bg-danger     { background: var(--expense-soft); color: var(--expense-ink); }
.badge.bg-primary    { background: var(--accent-soft);  color: var(--accent-ink); }
.badge.bg-warning    { background: var(--warn-soft);    color: var(--warn-ink); }
.badge.bg-info       { background: var(--neutral-soft); color: var(--ink-2); }
.badge.bg-secondary  { background: var(--neutral-soft); color: var(--ink-2); }
.badge.bg-dark       { background: var(--ink-1);        color: #fff; }
.badge.bg-light      { background: var(--neutral-soft); color: var(--ink-2); }

/* Alert (старый Bootstrap fallback) */
.alert {
    padding: 12px 14px;
    border-radius: var(--r-sm);
    margin-bottom: 12px;
    font-size: 0.88rem;
}
.alert-danger  { background: var(--expense-soft); color: var(--expense-ink); }
.alert-success { background: var(--income-soft);  color: var(--income-ink); }
.alert-warning { background: var(--warn-soft);    color: var(--warn-ink); }
.alert-info    { background: var(--accent-soft);  color: var(--accent-ink); }

/* Tab панели (FAQ) */
.nav-pills, .nav-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding-left: 0; list-style: none; margin-bottom: 12px; }
.nav-item { display: inline-flex; }
.nav-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; font-size: 0.88rem; font-weight: 500;
    color: var(--ink-2); background: transparent; border: 0;
    border-radius: var(--r-sm); cursor: pointer; text-decoration: none;
    transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--neutral-soft); color: var(--ink-1); }
.nav-link.active { background: var(--accent); color: #fff; }
.tab-content > .tab-pane { display: none; }
.tab-content > .tab-pane.active { display: block; }
.tab-content > .tab-pane.fade { opacity: 0; transition: opacity .15s; }
.tab-content > .tab-pane.fade.show { opacity: 1; }
.tab-content > .tab-pane.active.show { display: block; opacity: 1; }

/* Collapse — общий механизм скрытия/показа.
   Используется в Settings, FAQ-accordion. Управляется bootstrap-mini.js (Collapse). */
.collapse:not(.show) { display: none; }
.collapsing {
    height: 0;
    overflow: hidden;
    transition: height .25s ease;
}

/* Аккордеоны (FAQ) */
.accordion { display: flex; flex-direction: column; gap: 4px; }
.accordion-item { background: var(--surface); border-radius: var(--r-sm); overflow: hidden; box-shadow: var(--sh-1); }
.accordion-header { margin: 0; }
.accordion-button {
    display: flex; width: 100%; align-items: center; gap: 8px;
    padding: 12px 16px; background: var(--surface);
    color: var(--ink-1); font-weight: 500; font-size: 0.92rem;
    border: 0; cursor: pointer; text-align: left;
    transition: background .12s;
}
.accordion-button:hover { background: var(--surface-alt); }
.accordion-button::after {
    content: '';
    margin-left: auto;
    width: 16px; height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    transition: transform .2s;
}
.accordion-button:not(.collapsed)::after { transform: rotate(180deg); }
.accordion-button:not(.collapsed) { background: var(--accent-soft); color: var(--accent-ink); }
.accordion-body { padding: 12px 16px; font-size: 0.88rem; color: var(--ink-1); }
.accordion-collapse.collapse { display: none; }
.accordion-collapse.collapse.show { display: block; }
.accordion-collapse.collapsing { display: block; height: 0; overflow: hidden; transition: height .25s ease; }

/* Dropdown (общие) */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 200px;
    margin: 4px 0 0 0;
    padding: 6px;
    list-style: none;            /* убираем буллеты у ul */
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-3);
}
.dropdown-menu.show { display: block; }
.dropdown-menu-end { left: auto; right: 0; }
.dropdown-menu li { list-style: none; }
.dropdown-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    font-size: 0.88rem;
    color: var(--ink-1);
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
    border-radius: var(--r-sm);
    text-decoration: none;       /* ссылки не подчёркиваются */
    transition: background .12s, color .12s;
    font-family: inherit;
}
.dropdown-item:hover { background: var(--neutral-soft); color: var(--ink-1); }
.dropdown-item.text-danger { color: var(--expense); }
.dropdown-item.text-danger:hover { background: var(--expense-soft); color: var(--expense-ink); }
/* Разделитель внутри dropdown — заменяем native <hr> styling */
hr.dropdown-divider, .dropdown-divider {
    height: 1px;
    margin: 4px 0;
    padding: 0;
    border: 0;
    background: var(--neutral-soft);
    list-style: none;
}

/* Tooltip (для bootstrap-mini) */
.tooltip {
    position: absolute;
    z-index: 1070;
    padding: 4px;
    pointer-events: none;
}
.tooltip-inner {
    /* Тёмный фон + светлый текст. На light --ink-1=#0b1220 (тёмный) → норма.
       На dark --ink-1 — светлый, поэтому фиксированный #0f172a через переменную не работал.
       Делаем явно: на light ink-1, на dark — surface-alt (тёмный для dark). */
    background: #0f172a;
    color: #fff;
    padding: 6px 10px;
    font-size: 0.78rem;
    border-radius: var(--r-sm);
    max-width: 250px;
    text-align: center;
    box-shadow: var(--sh-2);
}
[data-theme="dark"] .tooltip-inner {
    background: #1e2937;
    color: #e6edf3;
}
.tooltip-arrow { display: none; }

/* ============================================================
   TOAST — уведомления в стиле сайта.
   Положение: top-right на десктопе, top-center на мобилке.
   Slide-in справа + opacity. Цветной левый бордер + soft фон.
   ============================================================ */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    bottom: auto;
    left: auto;
    z-index: 2200;            /* выше модалок (1055) и dropdown (1100) */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;     /* контейнер прозрачен для кликов, тосты сами активны */
    max-width: calc(100vw - 32px);
}
.toast {
    display: none;
    min-width: 280px;
    max-width: 380px;
    padding: 12px 16px;
    background: var(--ink-1);   /* дефолт — тёмный (если тип не указан) */
    color: #fff;
    border-radius: var(--r-sm);
    box-shadow: var(--sh-3);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    pointer-events: auto;
    position: relative;
    /* Slide-in справа */
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.toast.show {
    display: block;
}
.toast.show.is-in {
    transform: translateX(0);
    opacity: 1;
}
.toast.is-leaving {
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

/* Цвета по типу — сплошной фон, белый текст */
.toast.bg-success { background: var(--income);  color: #fff; }
.toast.bg-danger  { background: var(--expense); color: #fff; }
.toast.bg-warning { background: var(--warn);    color: #fff; }
.toast.bg-info,
.toast.bg-primary { background: var(--accent);  color: #fff; }

/* Внутренняя разметка тоста */
.toast .d-flex { align-items: center; gap: 10px; }
.toast .toast-body {
    flex: 1;
    min-width: 0;
    word-wrap: break-word;
}
.toast .btn-close,
.toast .btn-close-white {
    width: 26px; height: 26px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity .15s, background .12s;
    color: #fff;
    filter: none !important;
}
.toast .btn-close::before {
    content: '✕';
    font-size: 14px;
    font-weight: 700;
    display: block;
    width: 100%; text-align: center;
    background-image: none;
    color: #fff;
}
.toast .btn-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.18);
}

/* На мобилке — top-center, компактнее */
@media (max-width: 600px) {
    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        align-items: stretch;
    }
    .toast {
        min-width: 0;
        max-width: none;
        font-size: 0.85rem;
    }
}

/* Bootstrap row/col fallback */
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row > [class^="col"] { padding: 0 8px; flex: 1; }
.row.g-2 { margin: -4px; }
.row.g-2 > [class^="col"] { padding: 4px; }
.row.g-3 { margin: -8px; }
.row.g-3 > [class^="col"] { padding: 8px; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-5 { flex: 0 0 41.66%; max-width: 41.66%; }
.col-7 { flex: 0 0 58.33%; max-width: 58.33%; }
.col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-12 { flex: 0 0 100%; max-width: 100%; }
@media (min-width: 768px) {
    .col-md-3  { flex: 0 0 25%;    max-width: 25%; }
    .col-md-4  { flex: 0 0 33.33%; max-width: 33.33%; }
    .col-md-5  { flex: 0 0 41.66%; max-width: 41.66%; }
    .col-md-6  { flex: 0 0 50%;    max-width: 50%; }
    .col-md-7  { flex: 0 0 58.33%; max-width: 58.33%; }
    .col-md-8  { flex: 0 0 66.66%; max-width: 66.66%; }
    .col-md-12 { flex: 0 0 100%;   max-width: 100%; }
}
.col-auto { flex: 0 0 auto; width: auto; }
.col { flex: 1 1 0; min-width: 0; }

/* Bootstrap-таблицы fallback (для FAQ) */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--neutral-soft); }
.table-light { background: var(--surface-alt); }
.table-bordered th, .table-bordered td { border: 1px solid var(--neutral-soft); }
.table-hover tbody tr:hover { background: var(--surface-alt); }
.table-sm th, .table-sm td { padding: 4px 6px; font-size: 0.85rem; }

/* form-floating (если используется в шапках) */
.form-floating > .form-control:not(:placeholder-shown),
.form-floating > .form-control:focus { padding-top: 22px; padding-bottom: 8px; }

/* Auth (login/register) */
.auth-shell { background: var(--bg); min-height: 100vh; padding: 40px 16px; }
.auth-card {
    max-width: 420px;
    margin: 60px auto;
    padding: 32px;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-3);
}
.auth-title {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--ink-1);
    margin: 0 0 20px;
}
.auth-submit { width: 100%; min-height: 44px; font-size: 0.95rem; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 0.88rem; }
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ==================== БАЗОВЫЙ RESET ==================== */
*, *::before, *::after { box-sizing: border-box; }

/* ==================== УТИЛИТЫ (замена Bootstrap) ==================== */
/* Дисплей */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-grid { display: grid !important; }
@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-inline { display: inline !important; }
    .d-md-inline-block { display: inline-block !important; }
    .d-md-flex { display: flex !important; }
    .d-md-inline-flex { display: inline-flex !important; }
}
@media (max-width: 767px) {
    .d-md-none { display: initial; }
}

/* Flex */
.flex-row { flex-direction: row; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
@media (min-width: 768px) {
    .flex-md-row { flex-direction: row; }
    .flex-md-column { flex-direction: column; }
    .align-items-md-center { align-items: center; }
}
@media (max-width: 767px) {
    .flex-md-column { flex-direction: column; }
    .align-items-md-start, .align-items-start { align-items: flex-start; }
}
.flex-grow-1 { flex-grow: 1; }
.flex-grow-0 { flex-grow: 0; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-fill { flex: 1 1 auto; }
.justify-content-start { justify-content: flex-start; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-around { justify-content: space-around; }
.justify-content-evenly { justify-content: space-evenly; }
.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-items-center { align-items: center; }
.align-items-baseline { align-items: baseline; }
.align-items-stretch { align-items: stretch; }
.align-self-center { align-self: center; }
@media (min-width: 768px) {
    .justify-content-md-end { justify-content: flex-end; }
    .flex-md-row { flex-direction: row; }
}

/* Gap */
.gap-0 { gap: 0; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }

/* Margin / Padding */
.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }
.mb-5 { margin-bottom: 32px !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; }
.mt-4 { margin-top: 24px !important; }
.mt-5 { margin-top: 32px !important; }
.ms-1 { margin-left: 4px; }
.ms-2 { margin-left: 8px; }
.ms-3 { margin-left: 16px; }
.ms-4 { margin-left: 24px; }
.ms-auto { margin-left: auto; }
.me-1 { margin-right: 4px; }
.me-2 { margin-right: 8px; }
.me-3 { margin-right: 16px; }
.me-auto { margin-right: auto; }
.my-1 { margin-top: 4px; margin-bottom: 4px; }
.my-2 { margin-top: 8px; margin-bottom: 8px; }
.my-3 { margin-top: 16px; margin-bottom: 16px; }
.p-0 { padding: 0 !important; }
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }
.p-5 { padding: 32px; }
.px-1 { padding-left: 4px; padding-right: 4px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 16px; padding-right: 16px; }
.px-4 { padding-left: 24px; padding-right: 24px; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 16px; padding-bottom: 16px; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }
.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 4px; }
.pt-2 { padding-top: 8px; }
.pt-3 { padding-top: 16px; }
.pt-4 { padding-top: 24px; }
.pt-5 { padding-top: 32px; }
.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 4px; }
.pb-2 { padding-bottom: 8px; }
.pb-3 { padding-bottom: 16px; }
.pb-4 { padding-bottom: 24px; }

/* Text */
.text-start { text-align: left; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-nowrap { white-space: nowrap; }
.text-muted { color: var(--ink-3); }
.text-danger { color: var(--expense); }
.text-success { color: var(--income); }
.text-primary { color: var(--accent); }
.text-warning { color: var(--warn-ink); }
.text-info { color: var(--accent); }
.text-white { color: #fff; }
.text-dark { color: var(--ink-1); }
.text-decoration-none { text-decoration: none; }
.text-uppercase { text-transform: uppercase; }
.small { font-size: 0.85rem; }
.fw-normal { font-weight: 400; }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.fs-1 { font-size: 2.5rem; }
.fs-2 { font-size: 2rem; }
.fs-3 { font-size: 1.75rem; }
.fs-4 { font-size: 1.5rem; }
.fs-5 { font-size: 1.25rem; }
.fs-6 { font-size: 1rem; }
.lh-1 { line-height: 1; }
.opacity-75 { opacity: 0.75; }

/* Width / Height */
.w-100 { width: 100%; }
.w-auto { width: auto; }
.h-100 { height: 100%; }

/* Position */
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }
.position-sticky { position: sticky; }

/* Border / Background utility */
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid var(--neutral-soft); }
.border-bottom { border-bottom: 1px solid var(--neutral-soft); }
.rounded-3 { border-radius: var(--r-lg); }
.bg-light { background: var(--surface-alt-bg); }
.bg-white { background: var(--surface); }

/* Visually-hidden */
.visually-hidden, .visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* Спиннер (loading) */
.spinner-border {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--neutral-soft);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spinner-rot 0.65s linear infinite;
}
.spinner-border-sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spinner-rot { to { transform: rotate(360deg); } }

/* ==================== ИКОНКИ (inline SVG) ==================== */
/* Размер по умолчанию = 1em → наследует font-size родителя,
   благодаря этому fs-1…fs-6 и любое явное font-size работают.
   Цвет берётся от currentColor → красится через text-*. */
.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    flex-shrink: 0;
    overflow: visible;
    transition: transform .2s;
}
.icon.rotated {
    transform: rotate(180deg);
}

/* ==================== ТЕМА: ФИНТЕХ ==================== */
:root {
    /* Поверхности */
    --bg:           	#f4f6f9;
    --surface:      	#ffffff;
    --surface-alt:  	#f6f6f6;
    --surface-alt2:  	#f0f0f0;
    --surface-alt-bg:	#f9fafc;
    --btn-budget:		#f0f0f0;
    --clr-budget:		#475569;
    

    /* Текст (cool slate) */
    --ink-1:  #0b1220;
    --ink-2:  #475569;
    --ink-3:  #94a3b8;
    --ink-4:  #cbd5e1;

    /* Семантика — приглушённые финтех-тона */
    --income:        #15a366;
    --income-soft:   rgba(21, 163, 102, 0.10);
    --income-ink:    #0d7a4a;

    --expense:       #e2453d;
    --expense-soft:  rgba(226, 69, 61, 0.10);
    --expense-ink:   #b9342c;

    --accent:        #3257d4;
    --accent-soft:   rgba(50, 87, 212, 0.10);
    --accent-ink:    #2244ad;

    --warn:          #d97706;
    --warn-soft:     rgba(217, 119, 6, 0.12);
    --warn-ink:      #a35606;

    --neutral-soft:  rgba(15, 23, 42, 0.06);

    /* Геометрия — строгий набор:
       --r-sm  = кнопки, чипы, бейджи-прямоугольники, иконочные кнопки
       --r-lg  = секции (карточки кошельков, итогов, контейнер транзакций)
       --r-pill = только круглые элементы (бейджи-капсулы, мини-значки) */
    --r-sm:   8px;
    --r-lg:   13px;
    --r-pill: 999px;

    /* Тени — мягкие, без бордеров */
    --sh-1: 0 1px 2px rgba(15, 23, 42, 0.04);
    --sh-2: 0 1px 3px rgba(15, 23, 42, 0.05), 0 6px 16px rgba(15, 23, 42, 0.04);
    --sh-3: 0 4px 8px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(15, 23, 42, 0.06);

    /* Типографика */
    --num-font-feat: "tnum" 1, "lnum" 1;
}

/* ============================================================
   ТЁМНАЯ ТЕМА — приглушённая, спокойная глазам, не контрастная.
   Применяется при <html data-theme="dark">. Включается JS-toggle
   в шапке, сохраняется в localStorage. Anti-flash скрипт в <head>.
   ============================================================ */
[data-theme="dark"] {
    /* Поверхности — глубокий сине-серый (не чёрный), уровни как GitHub Dark */
    --bg:           #0e1117;
    --surface:      #161b22;
    --surface-alt:  #1c2128;
    --surface-alt2: #21272f;
    --btn-budget:	#21272f;
    --clr-budget:	#bfc7cf;

    /* Текст — мягкие приглушённые тона. ink-1 чуть светлее меню (--ink-2),
       без вырвиглазного контраста. */
    --ink-1:  #c9d1d9;
    --ink-2:  #8b949e;
    --ink-3:  #6e7681;
    --ink-4:  #484f58;

    /* Семантика — приглушённые, читаемые на тёмном */
    --income:        #3fb984;
    --income-soft:   rgba(63, 185, 132, 0.15);
    --income-ink:    #6ee7b7;

    --expense:       #ef6961;
    --expense-soft:  rgba(239, 105, 97, 0.15);
    --expense-ink:   #fca5a5;

    --accent:        #6c8eef;
    --accent-soft:   rgba(108, 142, 239, 0.15);
    --accent-ink:    #a4b8f5;

    --warn:          #e9a23b;
    --warn-soft:     rgba(233, 162, 59, 0.15);
    --warn-ink:      #fbcd75;

    --neutral-soft:  rgba(255, 255, 255, 0.06);

    /* Тени — глубже, тёмная подложка не «гасит» свет */
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.25);
    --sh-2: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 16px rgba(0, 0, 0, 0.2);
    --sh-3: 0 4px 8px rgba(0, 0, 0, 0.35), 0 16px 32px rgba(0, 0, 0, 0.3);
}

/* ─── Hardcoded цвета — точечные правки для тёмной темы ─── */
[data-theme="dark"] body { background: var(--bg); color: var(--ink-1); }
[data-theme="dark"] body.bg-light { background: var(--bg) !important; }

/* Hardcoded #fff / #f0f0f0 / #f5f6f8 в mobile-menu и др. */
[data-theme="dark"] .mobile-menu { background: var(--surface); }
[data-theme="dark"] .mobile-menu-toggle { background: var(--surface-alt); color: var(--ink-1); }
[data-theme="dark"] .mobile-menu-toggle:hover { background: var(--neutral-soft); }
[data-theme="dark"] .mobile-menu-content .btn:hover { background: var(--neutral-soft); }
[data-theme="dark"] .mobile-menu-content .btn.active { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .mobile-menu-close { background: var(--surface-alt); color: var(--ink-2); }
[data-theme="dark"] .mobile-menu-close:hover { background: var(--neutral-soft); color: var(--ink-1); }
[data-theme="dark"] .mobile-menu-logo .logo-text { color: var(--ink-1); }

/* Header / brand */
[data-theme="dark"] .app-header { background: var(--surface); }
[data-theme="dark"] .app-header-brand { color: var(--ink-1); }
[data-theme="dark"] .app-header-brand:hover { background: var(--surface-alt); color: var(--ink-1); }
[data-theme="dark"] .app-nav-link { color: var(--ink-2); }
[data-theme="dark"] .app-nav-link:hover { background: var(--surface-alt); color: var(--ink-1); }
[data-theme="dark"] .app-nav-link.active { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .app-user-btn { color: var(--ink-1); background: var(--surface-alt); }
[data-theme="dark"] .app-user-btn:hover { background: var(--neutral-soft); }
[data-theme="dark"] .app-header-divider { background: var(--neutral-soft); }

/* Заголовки секций (имели hardcoded #e3e5e9) */
[data-theme="dark"] .tx-section__title,
[data-theme="dark"] .settings-head,
[data-theme="dark"] .rpt-section-head { background: var(--surface-alt2); color: var(--ink-2); }

/* Скроллбары графиков (имели hardcoded #f1f1f1) */
[data-theme="dark"] .chart-wrapper-scrollable::-webkit-scrollbar-track,
[data-theme="dark"] .chart-wrapper::-webkit-scrollbar-track { background: var(--neutral-soft); }
[data-theme="dark"] .chart-wrapper-scrollable::-webkit-scrollbar-thumb,
[data-theme="dark"] .chart-wrapper::-webkit-scrollbar-thumb { background: var(--ink-3); }
[data-theme="dark"] .chart-wrapper-scrollable,
[data-theme="dark"] .chart-container,
[data-theme="dark"] .chart-wrapper { background: var(--surface); }
[data-theme="dark"] .chart-container-scrollable canvas,
[data-theme="dark"] .chart-container canvas { filter: brightness(0.95); }

/* Тосты — на тёмной убираем тёмный дефолт чтобы не сливался */
[data-theme="dark"] .toast { background: var(--surface-alt); color: var(--ink-1); }
[data-theme="dark"] .toast.bg-success,
[data-theme="dark"] .toast.bg-danger,
[data-theme="dark"] .toast.bg-warning,
[data-theme="dark"] .toast.bg-info,
[data-theme="dark"] .toast.bg-primary { color: #fff; }

/* Карточки настроек / общая поверхность — теперь surface уже dark, всё работает */

/* Datetime picker, dropdown, modal-* — наследуют от переменных */

/* Period pills (Reports) — на dark активный должен быть accent, не светлый ink */
[data-theme="dark"] .period-pill.active { background: var(--accent); color: #fff; }
[data-theme="dark"] .period-pill:hover:not(.active) { background: rgba(255,255,255,0.08); }

/* tx-row hover (зебра) */
[data-theme="dark"] .tx-table tbody tr.tx-row:hover td { background: var(--accent-soft); color: var(--ink-1); }

/* Feedback chip активный — был тёмный ink-1, на dark текст #fff на светлом не виден */
[data-theme="dark"] .fb-chip--active { background: var(--accent); color: #fff; }
[data-theme="dark"] .fb-chip--active.fb-chip--new    { background: var(--expense); }
[data-theme="dark"] .fb-chip--active.fb-chip--seen   { background: var(--warn-ink); }
[data-theme="dark"] .fb-chip--active.fb-chip--closed { background: var(--income); }

/* Modal backdrop — затемнение тёмное даже на тёмном фоне */
[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.75); }

/* Старые .alert fallbacks */
[data-theme="dark"] .alert-info    { background: var(--accent-soft); color: var(--accent-ink); }
[data-theme="dark"] .alert-success { background: var(--income-soft); color: var(--income-ink); }
[data-theme="dark"] .alert-warning { background: var(--warn-soft);   color: var(--warn-ink); }
[data-theme="dark"] .alert-danger  { background: var(--expense-soft); color: var(--expense-ink); }

/* h1, h2, h3, h4, h5, h6 — наследуют ink-1, на тёмной должны быть светлыми */
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 { color: var(--ink-1); }

/* Card / card-body / card-header (FAQ) */
[data-theme="dark"] .card { background: var(--surface); color: var(--ink-1); }
[data-theme="dark"] .card-header { background: var(--surface-alt); color: var(--ink-1); border-bottom-color: var(--neutral-soft); }
[data-theme="dark"] .card-header.bg-warning { background: var(--warn-soft); color: var(--warn-ink); }
[data-theme="dark"] .card-body code { background: var(--surface-alt); color: var(--accent-ink); }

/* code в общем */
[data-theme="dark"] code { background: var(--surface-alt); color: var(--accent-ink); }

/* Активные чипы «Все» (страница транзакций) — на dark надо инверсию:
   var(--ink-1) на тёмной = светлый цвет → активный чип «терялся» на тёмном.
   Делаем активный фон синим (accent) — заметно и согласовано с другими кнопками. */
[data-theme="dark"] .type-btn[data-type="all"].active,
[data-theme="dark"] .cat-chip.active,
[data-theme="dark"] .month-btn.active {
    background: var(--accent);
    color: #fff;
}
/* Hover у тех же чипов — на dark тёмная rgba(15,23,42,0.1) еле видна,
   меняем на светлую rgba(255,255,255,0.08). */
[data-theme="dark"] .type-btn:hover:not(.active),
[data-theme="dark"] .cat-chip:hover,
[data-theme="dark"] .month-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.08);
}

/* Прочерк-заглушка «—» в таблицах: приглушённый цвет в обеих темах,
   на тёмной особенно важно, иначе обычный ink-1 слишком ярко. */
.td-empty {
    color: var(--ink-4);
    opacity: 0.6;
}

/* color-scheme говорит браузеру рендерить системные элементы (spinner-стрелки,
   календарь, scrollbar) в стиле тёмной темы. Это правильный способ —
   filter:invert на pseudo-elements ненадёжен. */
[data-theme="dark"] {
    color-scheme: dark;
}
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="month"],
[data-theme="dark"] input[type="week"] {
    color-scheme: dark;
}

/* Иконка фавикона/SVG в шапке — emerald-маркер остаётся как есть */

/* ──────────────── Theme switcher (slider sun/moon) ──────────────── */
/* Размер/форма — ТОЧНО как у .app-user-btn:
   font-size: 0.8rem, padding: 0.25rem 0.7rem, border: 1.5px solid, border-radius: 8px.
   Контент внутри — два значка, между ними thumb переезжает. */
.theme-switcher {
    position: relative;
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    height: 30px;                       /* строго совпадает с .app-user-btn */
    padding: 2px;
    background: var(--surface-alt);
    border: 1.5px solid var(--neutral-soft);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
    gap: 0;
}
.theme-switcher:hover { border-color: var(--ink-4); }

/* Каждая иконка-опция — фиксированная высота, занимает половину */
.theme-switcher__option {
    position: relative;
    z-index: 1;
    width: 26px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-3);
    transition: color .2s;
    pointer-events: none;
    border-radius: 5px;
}
.theme-switcher__option .icon { width: 13px; height: 13px; }

/* Thumb — переезжающий «пузырёк» */
.theme-switcher__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 26px;
    height: calc(100% - 4px);           /* минус padding 2*2 */
    background: var(--surface);
    border-radius: 5px;
    box-shadow: var(--sh-1);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 0;
}
/* В dark — thumb уезжает к луне */
[data-theme="dark"] .theme-switcher__thumb { transform: translateX(26px); }

/* Цвета иконок: подсвечена та, над которой стоит thumb */
.theme-switcher__option--sun  { color: var(--warn); }
[data-theme="dark"] .theme-switcher__option--sun  { color: var(--ink-4); }
.theme-switcher__option--moon { color: var(--ink-4); }
[data-theme="dark"] .theme-switcher__option--moon { color: var(--accent); }

/* ===== Мобильная шапка: пирог / переключатель темы / выход — одна высота 30px ===== */
.app-mbtn {
    box-sizing: border-box;
    height: 30px;
    min-width: 30px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-alt);
    color: var(--ink-1);
    border: 1.5px solid var(--neutral-soft);
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}
.app-mbtn:hover { border-color: var(--ink-4); }
.app-mbtn .icon { width: 16px; height: 16px; }
/* Пирог — крупнее */
.app-mbtn--burger .icon { width: 22px; height: 22px; }
/* Бургер-кнопка переопределяет дефолтные 40×40 у .mobile-menu-toggle */
.mobile-menu-toggle.app-mbtn { width: auto; height: 30px; }

/* Заголовок мобильной шапки — выравниваем по центру вертикально (h1 имеет
   собственный line-height, из-за чего визуально съезжает ниже иконок) */
.app-mbar h1 {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    margin: 0;
}
.app-mbar h1 a { line-height: 1; }

/* ==================== КОМПОНЕНТЫ ГЛАВНОЙ ==================== */

/* — общая обёртка секций (без бордеров, мягкая тень) */
.surface {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
}
.surface__title {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink-1);
    letter-spacing: -0.005em;
}
.surface__subtitle {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--ink-3);
}
/* Заголовок с двумя элементами: текст слева, значение/бейдж справа */
.surface__title.surface__title--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* ---------- Hobbi: итоговая карточка ---------- */
.hobbi-summary {
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background:
        linear-gradient(135deg, var(--surface-alt) 0%, var(--surface) 100%);
}
.hobbi-summary__label {
    font-size: 0.72rem;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.hobbi-summary__value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--ink-1);
}
.hobbi-summary__value.is-income  { color: var(--income); }
.hobbi-summary__value.is-expense { color: var(--expense); }
.hobbi-summary__cur { font-size: 1.3rem; font-weight: 600; margin-left: 2px; }
.hobbi-summary__rub {
    font-size: 0.95rem;
    color: var(--ink-3);
    font-weight: 500;
}
@media (max-width: 767px) {
    .hobbi-summary { padding: 18px 16px; }
    .hobbi-summary__value { font-size: 1.6rem; }
    .hobbi-summary__cur { font-size: 1.1rem; }
    .hobbi-summary__rub { font-size: 0.88rem; }
}

/* Цифры всегда табличные, чтобы суммы выравнивались */
.num { font-feature-settings: var(--num-font-feat); font-variant-numeric: tabular-nums; }

/* ---------- Пилюли (бейджи) ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 10px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 5px;
    color: var(--ink-2);
    background: var(--neutral-soft);
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.pill--income    { color: var(--income-ink);  background: var(--income-soft); }
.pill--expense   { color: var(--expense-ink); background: var(--expense-soft); }
.pill--exchange  { color: var(--accent-ink);  background: var(--accent-soft); }
.pill--transfer  { color: var(--ink-1);       background: rgba(15,23,42,0.08); }
.pill--repayment { color: var(--warn-ink);    background: var(--warn-soft); }
/* Большой вариант — для заметных меток (например, «текущий курс» в графиках) */
.pill--lg {
    height: 30px;
    padding: 0 14px;
    font-size: 0.92rem;
    font-weight: 700;
    border-radius: 6px;
}

/* ---------- Курсы валют ---------- */
.rates-strip {
    display: grid;
    /* Кол-во колонок задаётся через CSS-переменную --rates-count из HTML
       (на странице Currency) или дефолт 5 (на Main). */
    grid-template-columns: repeat(var(--rates-count, 5), 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.rate-chip {
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-1);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    text-align: center;
}
.rate-chip__label {
    font-size: 0.74rem;
    color: var(--ink-3);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.rate-chip__row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.rate-chip__value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ink-1);
    letter-spacing: -0.01em;
}
.rate-chip__delta { font-size: 0.8rem; font-weight: 600; }
.rate-chip__delta.is-up   { color: var(--income); }
.rate-chip__delta.is-down { color: var(--expense); }
.rate-chip__delta.is-flat { color: var(--ink-3); }
.rate-chip__na { font-size: 0.78rem; color: var(--expense); font-weight: 500; }
@media (max-width: 767px) {
    /* 2 в ряд независимо от значения переменной --rates-count.
       Последняя карточка, если нечётная — на всю ширину. */
    .rates-strip { grid-template-columns: repeat(2, 1fr); }
    .rates-strip > .rate-chip:last-child:nth-child(odd) { grid-column: 1 / -1; }
    /* Меньший шрифт, чтобы пара «USD → RUB» помещалась без переноса */
    .rate-chip { padding: 10px 8px; gap: 4px; }
    .rate-chip__label  { font-size: 0.7rem; white-space: nowrap; }
    .rate-chip__value  { font-size: 1rem; }
    .rate-chip__delta  { font-size: 0.72rem; }
    .rate-chip__row    { gap: 5px; flex-wrap: nowrap; }
}

/* ---------- Кошельки ---------- */
.wallets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.wallet {
    position: relative;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-2);
    padding: 16px 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 124px;
}
.wallet__bg {
    position: absolute;
    right: -18px;
    bottom: -18px;
    width: 124px;
    height: 124px;
    opacity: 0.07;
    pointer-events: none;
    user-select: none;
}
.wallet__name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.wallet__label {
    font-size: 0.7rem;
    color: var(--ink-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.wallet__balance {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink-1);
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.wallet__balance.is-debt   { color: var(--expense); }
.wallet__balance.is-credit { color: var(--income); }
.wallet__sub {
    font-size: 0.72rem;
    color: var(--ink-3);
    margin-top: 2px;
}
.wallet__equivalents {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--ink-3);
    line-height: 1.5;
}
.wallet__equivalents > span { display: inline-block; margin-right: 8px; }
.wallet__type-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--warn-soft);
    color: var(--warn-ink);
}
.wallet__type-mark .icon { width: 14px; height: 14px; }
@media (max-width: 767px) {
    .wallets { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .wallet { min-height: auto; padding: 12px 14px; }
    .wallet__balance { font-size: 1.05rem; }
    .wallet:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ---------- Скрытие балансов ---------- */
/* Объекты, которые блюрятся: суммы, эквиваленты, названия кошельков
   и подписи блоков (Долг / Капитал / Баланс / Доступно и т.д.). */
.balance-value,
.wallet__name,
.wallet__label,
.stat__label {
    transition: filter 0.25s ease;
}
.balances-hidden .balance-value,
.balances-hidden .wallet__name,
.balances-hidden .wallet__label,
.balances-hidden .wallet__bg,
.balances-hidden .stat__label {
    filter: blur(8px);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    pointer-events: none;
    cursor: default;
}

/* ---------- Кнопка toggle балансов ---------- */
.balance-bar {
    display: flex;
    margin: 4px 0 10px;
}
.balance-toggle {
    width: 100%;
    background: var(--surface);
    color: var(--ink-2);
    border: 0;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    box-shadow: var(--sh-1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background .15s, color .15s, box-shadow .15s;
}
.balance-toggle:hover {
    background: var(--surface-alt);
    color: var(--ink-1);
    box-shadow: var(--sh-2);
}
.balance-toggle .icon { font-size: 16px; }
.balance-toggle .balance-toggle__icon--hide { display: inline-flex; }
.balance-toggle .balance-toggle__icon--show { display: none; }
.balance-toggle.is-hidden .balance-toggle__icon--hide { display: none; }
.balance-toggle.is-hidden .balance-toggle__icon--show { display: inline-flex; }

/* ---------- Stat-карточки (итоги) ---------- */
.stats {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}
.stats--1 { grid-template-columns: 1fr; }
.stats--2 { grid-template-columns: repeat(2, 1fr); }
.stats--3 { grid-template-columns: repeat(3, 1fr); }
.stats--4 { grid-template-columns: repeat(4, 1fr); }
.stat {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
    padding: 12px 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 80px;
}
.stat__label {
    font-size: 0.68rem;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}
.stat__value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink-1);
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.stat__value.is-income  { color: var(--income); }
.stat__value.is-expense { color: var(--expense); }
.stat__value.is-accent  { color: var(--accent); }
.stat__value.is-warn    { color: var(--warn-ink); }
.stat__sub {
    font-size: 0.95rem;
    color: var(--ink-3);
    line-height: 1.4;
}
.stat__sub > span { display: inline-block; margin-right: 6px; }

/* Вариант .stat--left: текст слева, многострочные данные (для /projects/) */
.stat--left {
    text-align: left;
    padding: 16px 18px;
    gap: 6px;
    align-items: stretch;
    justify-content: flex-start; /* заголовок прижат к верху, не центрируется */
}
.stat--left .stat__label {
    font-size: 1rem;
    color: var(--ink-1);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 10px;
}
.stat__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.stat__val {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
    gap: 1px;
}
/* $-цифры — основные, крупные, зелёные. Только прямые дочерние .num
   (НЕ затрагивает вложенный .stat__val-rub). */
.stat__val > .num {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--income);
    letter-spacing: -0.01em;
}
.stat__val > .num.is-expense { color: var(--expense); }
/* ₽-эквивалент — видимый, но серый и чуть мельче (перебивает .num по специфичности) */
.stat__val > .stat__val-rub {
    font-size: 1rem;
    color: var(--ink-3);
    font-weight: 500;
}
.stat__divider {
    height: 1px;
    background: var(--neutral-soft);
    margin: 4px 0;
}
.stat__hint {
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--ink-3);
    line-height: 1.4;
}

@media (max-width: 767px) {
    /* На мобилке отключаем grid-template-columns — grid по умолчанию
       создаст одну колонку, каждый блок займёт полную ширину. */
    .stats.stats--2,
    .stats.stats--3,
    .stats.stats--4 {
        grid-template-columns: none;
    }
    .stats > .stat { grid-column: auto; }
}

/* ---------- Кнопки действий ---------- */
.actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 8px;
    margin-bottom: 20px;
}
.action {
    border: 0;
    border-radius: var(--r-sm);
    padding: 12px 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--clr-budget);
    background: var(--btn-budget);
    box-shadow: var(--sh-1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
    white-space: nowrap;
    min-height: 44px;
}
.action:hover {
    box-shadow: var(--sh-2);
    transform: translateY(-1px);
    filter: brightness(0.96);
}
.action:active { transform: translateY(0); filter: brightness(0.92); }
.action .icon {
    width: 1.05em;
    height: 1.05em;
    stroke-width: 2;
}

/* Цвета — приглушённый финтех в одной гамме */
.action--expense  { background: var(--expense); color: #fff; }
.action--income   { background: var(--income);  color: #fff; }
.action--exchange { background: var(--accent);  color: #fff; }
.action--transfer { background: #64748b;        color: #fff; }   /* slate-grey, нейтральный */
.action--repay    { background: #259a8f;        color: #fff; }   /* тёплый taupe, в гамме */
.action--stat     { background: var(--warn);    color: #fff; }
@media (max-width: 767px) {
    .actions {
        grid-auto-flow: row;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .action { font-size: 0.82rem; padding: 10px 6px; min-height: 42px; }
    .actions > .action:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ---------- Секция транзакций ---------- */
.tx-section {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-2);
    overflow: hidden;
    margin-top: 20px;
}
.tx-section__title {
    text-align: center;
    padding: 12px 16px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-2);
    background: var(--surface-alt2);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
/* Двухстолбцовый заголовок: текст слева, значение справа (для /projects/) */
.tx-section__title--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.88rem;
    color: var(--ink-1);
}
.tx-section__title--split .num {
    font-size: 1rem;
    font-weight: 700;
}
.tx-section__title--split .num.is-income { color: var(--income); }

/* Плитки проектов (день → проекты) */
.day-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    padding: 12px;
}
.day-card {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    font: inherit;
    text-align: left;
    background: var(--surface-alt);
    border-radius: var(--r-sm);
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background .12s, transform .12s, box-shadow .12s;
}
.day-card:hover {
    background: var(--surface);
    box-shadow: var(--sh-2);
    transform: translateY(-1px);
}
.day-card:active { transform: translateY(0); }
.day-card__project {
    font-size: 0.82rem;
    color: var(--ink-2);
    font-weight: 500;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.day-card__amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--income);
    letter-spacing: -0.01em;
}
@media (max-width: 767px) {
    .day-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
    .day-card { padding: 10px 8px; }
    .day-card__amount { font-size: 0.95rem; }
}
/* iPhone 13: 3 в ряд, но текст внутри ещё компактнее чтобы помещалось */
@media (max-width: 480px) {
    .day-grid { gap: 6px; padding: 8px; }
    .day-card { padding: 8px 6px; }
    .day-card__day { font-size: 0.72rem; }
    .day-card__project { font-size: 0.72rem; }
    .day-card__amount { font-size: 0.85rem; }
}

/* Десктоп-таблица */
.tx-table { display: block; overflow-x: auto; }
.tx-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.tx-table thead th {
    text-align: center;
    font-weight: 600;
    color: var(--ink-2);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 11px 8px;
    background: var(--surface-alt);
    white-space: nowrap;
}
.tx-table tbody td {
    text-align: center;
    padding: 12px 8px;
    color: var(--ink-1);
    vertical-align: middle;
}
.tx-table tbody tr:nth-child(odd) td  { background: var(--surface); }
.tx-table tbody tr:nth-child(even) td { background: var(--surface-alt); }
.tx-table tbody tr.tx-row             { cursor: pointer; transition: background .12s ease; }
.tx-table tbody tr.tx-row:hover td    { background: var(--accent-soft); }
.tx-table .tx-comm { color: var(--expense); font-size: 0.74rem; }
.tx-table .tx-empty {
    color: var(--ink-3);
    padding: 24px 12px;
    font-size: 0.85rem;
}

/* Иконочная кнопка действий в строке */
.icon-btn {
    border: 0;
    background: transparent;
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--ink-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--neutral-soft); color: var(--ink-1); }
.icon-btn--danger:hover { background: var(--expense-soft); color: var(--expense); }

/* Мобильный список (показывается ≤767px) */
.tx-list { display: none; padding: 10px; flex-direction: column; gap: 6px; }
.tx-card {
    background: var(--surface-alt);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    transition: background .12s ease, transform .12s ease;
}
.tx-card:active { transform: scale(0.99); }
.tx-card:hover  { background: var(--accent-soft); }
.tx-card__r1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.tx-card__r2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.tx-card__context {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    color: var(--ink-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-card__date {
    font-size: 0.7rem;
    color: var(--ink-3);
    white-space: nowrap;
    flex-shrink: 0;
}
.tx-card__amount {
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink-1);
    white-space: nowrap;
    flex-shrink: 0;
}
.tx-card__amount.is-income  { color: var(--income); }
.tx-card__amount.is-expense { color: var(--expense); }
.tx-card__comm {
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--expense);
}
.tx-card__empty {
    text-align: center;
    color: var(--ink-3);
    padding: 18px;
    font-size: 0.85rem;
}
@media (max-width: 767px) {
    .tx-table { display: none; }
    .tx-list { display: flex; }
}

/* ==================== БАЗОВЫЕ СТИЛИ ==================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink-1);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    touch-action: pan-y;
}

html, body {
    width: 100%;
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
}

html {
    scrollbar-gutter: stable;
}

/* Когда открыта модалка — блокируем прокрутку фона.
   overflow:hidden на html+body — самый надёжный способ для desktop и iOS. */
html.modal-open,
body.modal-open {
    overflow: hidden !important;
    /* На iOS дополнительно фиксируем body чтобы скролл не «протекал» через свайп */
    touch-action: none;
    padding-right: 0 !important;
}

h1, h2, h3, h4, h5 {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.container {
    width: 100%;
    max-width: 1920px;
    margin-right: auto;
    margin-left: auto;
    padding-left: 12px;
    padding-right: 12px;
}

.card {
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    overflow: hidden;
}

.card-header {
    font-weight: 600;
    background: var(--surface-alt);
    border-bottom: 1px solid #dee2e6;
}

.card-body p {
    margin: 0;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink-1);
}

.btn {
    border-radius: 8px;
    font-size: 1rem;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.9rem;
}

.btn.active {
    color: #fff !important;
    background-color: #6c757d !important;
    border-color: #aaa !important;
    font-weight: 600;
}

.form-control,
.form-select {
    border-radius: 8px;
    font-size: 1rem;
    padding: .375rem .75rem;
}

textarea.form-control {
    resize: vertical;
}

/* ==================== МОБИЛЬНЫЙ САЙДБАР ==================== */

/* Кнопка-бургер */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    place-items: center;
    color: var(--ink-1);
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}
.mobile-menu-toggle:hover { background: var(--neutral-soft); }
.mobile-menu-toggle i { font-size: 1.4rem; }

/* Затемнение */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
    opacity: 0;
    /* Закрытие — быстро (0.2s), как у модалок */
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}
.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
    /* Открытие — плавнее (0.35s) */
    transition: opacity 0.35s ease;
}

/* Сайдбар */
.mobile-menu {
    position: fixed;
    top: 0;
    left: -290px;
    width: 270px;
    height: 100%;
    background: var(--surface);
    z-index: 1050;
    /* Закрытие — быстрое (0.2s) */
    transition: left 0.2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.mobile-menu.active {
    left: 0;
    /* Открытие — мягче, дольше (0.35s с пружинкой как у модалок) */
    transition: left 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Шапка: логотип + закрытие */
.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--neutral-soft);
    flex-shrink: 0;
}
.mobile-menu-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.mobile-menu-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #10b981, #047857);  /* emerald — как в шапке лендинга и иконке PWA */
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.mobile-menu-logo .logo-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--ink-1);
    letter-spacing: -0.2px;
}
.mobile-menu-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--surface-alt);
    border: none;
    cursor: pointer;
    color: var(--ink-3);
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.mobile-menu-close:hover { background: var(--neutral-soft); color: var(--ink-1); }

/* Навигация */
.mobile-menu-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px 0 12px;        /* убран боковой padding — пункты прижаты к краям */
}
.mobile-menu-content .btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;   /* прижать содержимое к левому краю (базовый .btn центрирует) */
    gap: 12px;
    padding: 12px 16px;            /* внутренний отступ — текст начинается от 16px от левого края */
    border-radius: 0;              /* без округлых углов чтобы строки шли впритык */
    border: none;
    background: transparent;
    color: var(--ink-2);
    font-size: 0.93rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    margin-bottom: 0;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.mobile-menu-content .btn i {
    font-size: 1.1rem;
    width: 22px;
    flex-shrink: 0;
    opacity: 0.7;
    text-align: center;
}
.mobile-menu-content .btn:hover {
    background: var(--surface-alt);
    color: var(--ink-1);
}
.mobile-menu-content .btn.active {
    background: var(--accent-soft);
    color: #0d6efd;
    font-weight: 600;
}
.mobile-menu-content .btn.active i { opacity: 1; }

body.mobile-menu-open {
    overflow: hidden;
    touch-action: none;
}

/* ==================== DESKTOP APP HEADER ==================== */

.app-header {
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
    padding: 5px 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.app-header-brand {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e293b;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}
.app-header-brand:hover { background: #f1f5f9; color: #1e293b; }

.app-header-divider {
    width: 1px;
    height: 18px;
    background: var(--neutral-soft);
    flex-shrink: 0;
    margin: 0 4px;
}

.app-nav-link {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    padding: 0.25rem 0.7rem;
    border-radius: 8px;
    border: 1.5px solid transparent;
    white-space: nowrap;
    transition: all .15s;
    flex-shrink: 0;
}
.app-nav-link:hover { background: #f1f5f9; color: #1e293b; }
.app-nav-link.active {
    background: var(--ink-2);
    color: #fff;
    border-color: var(--ink-2);
}

.app-user-btn {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-2);
    background: var(--surface-alt);
    border: 1.5px solid var(--neutral-soft);
    border-radius: 8px;
    height: 30px;                /* фиксированная высота — для соседних кнопок (theme-switcher) */
    padding: 0 0.7rem;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all .15s;
    white-space: nowrap;
}
.app-user-btn:hover { background: var(--neutral-soft); border-color: var(--ink-4); }
.app-user-btn.show { background: var(--neutral-soft); border-color: var(--ink-4); }

/* ========== ЕДИНАЯ МОБИЛЬНАЯ КАРТОЧКА ТРАНЗАКЦИИ (Projects, Transactions) ========== */
/* На главной используется .tx-card, эта секция — для остальных страниц. */

.tx-mobile-list { display: flex; flex-direction: column; gap: 6px; }

.tx-mobile-card {
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid #eef0f3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 9px 12px;
}

/* Строка 1: бейдж + контекст + дата */
.tx-mobile-card .tx-r1 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.tx-mobile-card .tx-context {
    flex: 1;
    font-size: 0.78rem;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-mobile-card .tx-date {
    font-size: 0.72rem;
    color: var(--ink-4);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Строка 2: сумма + кнопки */
.tx-mobile-card .tx-r2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.tx-mobile-card .tx-amount-wrap { flex: 1; min-width: 0; }
.tx-mobile-card .tx-amount {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
}
.tx-mobile-card .tx-amount.income  { color: #198754; }
.tx-mobile-card .tx-amount.expense { color: var(--expense); }
.tx-mobile-card .tx-amount.neutral { color: var(--ink-2); }
.tx-mobile-card .tx-comm {
    font-size: 0.72rem;
    color: var(--expense);
    display: block;
    margin-top: 1px;
}
.tx-mobile-card .tx-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}

/* ==================== ОБЩИЕ GRID-УТИЛИТЫ ==================== */

.grid-2-cols { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-auto-fit { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.grid-auto-fill { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

/* ==================== ГРАФИКИ: ОБЩИЕ ОБЁРТКИ ==================== */

/* Скроллируемые обёртки (Budget, Currency, Hobbi, Incomes) */
.chart-wrapper-scrollable {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    background-color: white;
}

.chart-wrapper-scrollable::-webkit-scrollbar { height: 6px; }
.chart-wrapper-scrollable::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.chart-wrapper-scrollable::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; }
.chart-wrapper-scrollable::-webkit-scrollbar-thumb:hover { background: #555; }

.chart-container-scrollable {
    width: 100%;
    position: relative;
}

.chart-container-scrollable canvas { display: block; }

/* Нескроллируемые обёртки (Projects) */
.chart-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.chart-wrapper::-webkit-scrollbar { height: 6px; }
.chart-wrapper::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.chart-wrapper::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; }
.chart-wrapper::-webkit-scrollbar-thumb:hover { background: #555; }

.chart-container {
    width: 100%;
    position: relative;
}

.chart-container canvas { display: block; }

@media (max-width: 767px) {
    .chart-container-scrollable { height: 350px; }
    .chart-container { height: 300px; }
    .chart-wrapper-scrollable { margin: 0; padding: 1rem; }
    .chart-wrapper { margin: 0 -1rem; padding: 0 1rem; }
}

@media (min-width: 768px) {
    .chart-container-scrollable { height: 400px; }
    .chart-container { height: 400px; }
    .chart-wrapper-scrollable { padding: 1.5rem; }
}

/* ==================== ОБЩИЕ КОМПОНЕНТЫ: ФИЛЬТРЫ ==================== */

/* Чипы-фильтры категорий (Transactions, Fixedexpenses) */
.cat-chip {
    display: inline-block;
    border: 0;
    border-radius: var(--r-sm);
    padding: 5px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background .15s, color .15s;
    user-select: none;
    background: var(--neutral-soft);
    color: var(--ink-2);
    font-weight: 500;
}
.cat-chip:hover { background: rgba(15,23,42,0.1); }
.cat-chip.active { background: var(--ink-1); color: #fff; }

/* Чипы-фильтры групп — акцентный цвет */
.group-chip {
    display: inline-block;
    border: 0;
    border-radius: var(--r-sm);
    padding: 5px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background .15s, color .15s;
    user-select: none;
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
}
.group-chip:hover { background: rgba(50,87,212,0.18); }
.group-chip.active { background: var(--accent); color: #fff; }

/* Чип-кнопка «Комиссии» — янтарный, независимый тоггл */
.commission-chip {
    display: inline-block;
    border: 0;
    border-radius: var(--r-sm);
    padding: 5px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background .15s, color .15s;
    user-select: none;
    background: var(--warn-soft);
    color: var(--warn-ink);
    font-weight: 600;
}
.commission-chip:hover { background: rgba(217,119,6,0.2); }
.commission-chip.active { background: var(--warn); color: #fff; }

/* Сброс фильтров (Transactions, Fixedexpenses, Reports) */
.reset-filters {
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--expense);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    margin-left: auto;
    transition: background .12s;
}
.reset-filters:hover { background: var(--expense-soft); }

/* Сброс на отдельной строке (Fixedexpenses, Incomes) */
.filter-reset-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}
@media (max-width: 767px) {
    .filter-reset-row .filter-reset {
        width: 100%;
        justify-content: center;
    }
}

/* Управляющие чипы верхнего уровня (Все / Сбросить) */
.master-chip {
    display: inline-block;
    border: 1.5px solid;
    border-radius: 8px;
    padding: 0.2rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.master-chip--all {
    border-color: var(--ink-2);
    background: #f1f5f9;
    color: var(--ink-2);
}
.master-chip--all:hover { background: var(--neutral-soft); }
.master-chip--all.active { background: var(--ink-2); color: #fff; border-color: var(--ink-2); }
.master-chip--reset {
    border-color: var(--expense);
    background: var(--expense-soft);
    color: var(--expense);
}
.master-chip--reset:hover { background: var(--expense-soft); filter: brightness(0.95); }

/* Единый border-radius 8px для bootstrap-карточек на ещё не переоформленных страницах */
.card { border-radius: 8px !important; }
.card > .card-header:first-child { border-radius: 7px 7px 0 0 !important; }
.card > .card-footer:last-child  { border-radius: 0 0 7px 7px !important; }
.card > .card-img-top { border-top-left-radius: 7px !important; border-top-right-radius: 7px !important; }

/* ==================== RUNWAY ЧИПЫ ==================== */
/* Палитровый стиль: серый = выключена, акцентный soft = включена.
   Без рамок, без зачёркивания, без псевдо-галочек. */
.runway-cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    font-weight: 500;
    border: 0;
    background: var(--neutral-soft);
    color: var(--ink-3);
    cursor: pointer;
    transition: background .12s, color .12s;
    user-select: none;
}
.runway-cat-chip small {
    font-size: 0.72rem;
    opacity: 0.75;
}
.runway-cat-chip:not(.active):hover { background: rgba(15,23,42,0.1); color: var(--ink-2); }
.runway-cat-chip.active {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
}
.runway-cat-chip.active small { color: var(--accent-ink); opacity: 0.7; }

/* Старые стили reports перенесены в саму страницу Reports/index.php (inline <style>).
   Здесь сохранено только для совместимости — но всё перекрыто новыми. */

/* ==================== АДАПТАЦИЯ МОБИЛЬНАЯ ==================== */

@media (max-width: 768px) {
    .mobile-menu-toggle { display: grid; }

    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .row.g-2.mb-3 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .row.g-2.mb-3 .card { border-radius: 8px; }
    .row.g-2.mb-3 .card-body { padding: 8px !important; }
    .row.g-2.mb-3 small { font-size: 0.75rem; }
    .row.g-2.mb-3 strong { font-size: 0.9rem; }

    .row.g-3.mb-4 { grid-template-columns: 1fr; gap: 12px; }
    .row.g-3.mb-4 .card-body { padding: 12px !important; }
    .row.g-3.mb-4 h6 { font-size: 0.9rem; margin-bottom: 8px !important; }
    .row.g-3.mb-4 p { font-size: 0.85rem; margin-bottom: 4px !important; }
    .row.g-3.mb-4 .fs-4 { font-size: 1.2rem !important; }

    .d-flex.gap-3.mb-4 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 0 4px;
    }

    .d-flex.gap-3.mb-4 .btn { font-size: 0.9rem; padding: 10px 12px; white-space: nowrap; }

    .form-control,
    .form-select { font-size: 1rem; padding: 12px 14px; }

    .modal-dialog { margin: 10px; }
    .modal-body input,
    .modal-body select,
    .modal-body textarea { font-size: 1rem; padding: 12px; }
    /* Footer остаётся flex (определён выше): кнопки растягиваются по числу детей */
    .modal-footer .btn { font-size: 1rem; padding: 12px; }

    .card { border-radius: 10px; }
    .card-header { font-size: 1rem; padding: 10px; }

    form.row.g-2 { display: grid; gap: 8px; }
    form.row.g-2 .col-auto { width: 100%; }
    form.row.g-2 select,
    form.row.g-2 button { width: 100%; font-size: 1rem; padding: 12px; }

    .row.mb-4 .col-md-4,
    .row.mb-4 .col-md-6 { width: 100%; }

    .grid-2-cols,
    .grid-3-cols,
    .grid-4-cols { grid-template-columns: 1fr; }
}

/* ==================== ДЕСКТОП ==================== */

@media (min-width: 769px) {
    .mobile-menu-toggle { display: none; }
}

/* ==================== МОДАЛКИ ==================== */

.modal-backdrop.show {
    opacity: 0.75;
}

.modal-header {
    padding: 0.6rem 1rem;
}

.modal-header .modal-title {
    font-size: 1rem;
}

.modal-body {
    padding: 0.75rem 1rem;
}

.modal-body .mb-3 {
    margin-bottom: 0.5rem !important;
}

.modal-footer {
    padding: 0.5rem 1rem;
    gap: 0.5rem;
}

/* ==================== АНИМАЦИИ / ACCESSIBILITY ==================== */

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.mobile-menu.active { animation: slideIn 0.3s ease; }

@media (prefers-reduced-motion: reduce) {
    .mobile-menu,
    .mobile-menu-overlay { transition: none; }
    .mobile-menu.active { animation: none; }
}

/* ==================== СТРАНИЦА: TRANSACTIONS ==================== */

/* Кнопки типа транзакции */
/* ==================== СТРАНИЦА: TRANSACTIONS ==================== */

/* Кнопки типов транзакций */
.type-btn {
    border-radius: var(--r-sm);
    font-size: 0.8rem;
    padding: 6px 12px;
    border: 0;
    background: var(--neutral-soft);
    color: var(--ink-2);
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.type-btn .icon { width: 1em; height: 1em; }
.type-btn.active .icon { color: #fff; }
.type-btn:hover:not(.active) { background: rgba(15,23,42,0.1); }
.type-btn[data-type="all"].active     { background: var(--ink-1);  color: #fff; }
.type-btn[data-type="income"].active  { background: var(--income); color: #fff; }
.type-btn[data-type="expense"].active { background: var(--expense);color: #fff; }
.type-btn[data-type="exchange"].active{ background: var(--accent); color: #fff; }
.type-btn[data-type="transfer"].active{ background: #64748b;       color: #fff; }
.type-btn[data-type="repayment"].active{background: var(--warn);   color: #fff; }

/* Ряд кнопок типов */
.filter-types-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

/* Лейбл-заголовок секции фильтра */
.filter-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-3);
    margin-bottom: 6px;
}
.filter-section { margin-bottom: 10px; }
.filter-section--last { margin-bottom: 0; }

/* Лейбл-заголовок как кнопка-toggle (для collapse-секций) */
.filter-label--toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
    color: var(--ink-3);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 6px;
    -webkit-tap-highlight-color: transparent;
}
.filter-label--toggle:hover { color: var(--ink-1); }
.filter-label__caret {
    display: inline-flex;
    transition: transform .18s ease;
}
.filter-label__caret .icon { width: 12px; height: 12px; }
.filter-label--toggle.is-open .filter-label__caret { transform: rotate(180deg); }

/* Свёрнутое состояние блока чипов */
.chips-collapse.is-collapsed { display: none; }

/* Кнопки месяца */
.months-scroll {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.months-scroll::-webkit-scrollbar { display: none; }
.month-btn {
    border-radius: var(--r-sm);
    font-size: 0.75rem;
    padding: 5px 11px;
    border: 0;
    background: var(--neutral-soft);
    color: var(--ink-2);
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 500;
}
.month-btn:hover:not(.active) { background: rgba(15,23,42,0.1); }
.month-btn.active { background: var(--ink-1); color: #fff; }

/* Чипы-ряд */
.chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

/* Контролы фильтра — плоские компактные поля */
.filter-control {
    height: 38px;
    padding: 0 10px;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    border-radius: var(--r-sm);
    /* font-size: 16px — критично для iOS, иначе при фокусе страница зумит */
    font-size: 16px;
    font-family: inherit;
    outline: none;
    min-width: 0;           /* чтобы инпут мог ужиматься в grid-ячейке (даты на транзакциях) */
    max-width: 100%;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow .15s, background .15s;
}
.filter-control:focus {
    background: var(--surface);
    box-shadow: inset 0 0 0 1.5px var(--accent);
}
select.filter-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px 14px;
    padding-right: 28px;
}
.filter-control--narrow { width: 72px; flex-shrink: 0; }

/* Ряды фильтров */
.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.filter-row--desktop { display: none; }
.filter-row--mobile  { display: grid; gap: 8px; }
.filter-sep { color: var(--ink-3); font-size: 0.85rem; flex-shrink: 0; }
.filter-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
/* input[type="date"] на iOS имеет внутренний min-width — принудительно ограничиваем */
.filter-grid-2 > .filter-control,
.filter-grid > .filter-control { width: 100%; min-width: 0; }
.filter-grid--wlt { display: grid; grid-template-columns: 1fr 72px 38px; gap: 8px; }

/* Мобильные строки фильтра транзакций.
   Двойной селектор (.filter-row--mobile .filter-grid--xxx) — чтобы не были
   перекрыты общим правилом .filter-grid { repeat(3, 1fr) } из другой секции. */
.filter-row--mobile .filter-grid--wlt-limit {
    display: grid;
    grid-template-columns: 7fr 3fr;
    gap: 8px;
    align-items: stretch;
}
.filter-row--mobile .filter-grid--search-reset {
    display: grid;
    grid-template-columns: 1fr 38px;
    gap: 8px;
    align-items: center;
}
.filter-row--mobile .filter-grid--search-reset .filter-reset--icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-alt);
    border: 0;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .12s;
    flex-shrink: 0;
}
.filter-row--mobile .filter-grid--search-reset .filter-reset--icon:hover { background: var(--neutral-soft); }
.filter-row--mobile .filter-grid--search-reset .filter-reset--icon .icon { width: 18px; height: 18px; }

/* На мобиле плейсхолдер поиска длинный — уменьшаем шрифт, чтобы влезал в ширину экрана */
.filter-row--mobile #filterSearchM::placeholder { font-size: 0.78rem; }
.filter-row--mobile #filterSearchM::-webkit-input-placeholder { font-size: 0.78rem; }

@media (min-width: 768px) {
    .filter-row--desktop { display: flex; }
    .filter-row--mobile  { display: none; }
}

/* Кнопка сброса фильтров */
.filter-reset {
    height: 34px;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    border-radius: var(--r-sm);
    padding: 0 12px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .12s, color .12s;
    flex-shrink: 0;
    white-space: nowrap;
}
.filter-reset:hover { background: var(--expense-soft); color: var(--expense); }
.filter-reset--icon { width: 34px; padding: 0; justify-content: center; }

/* Inline-сброс внутри строк чипов (типы / группы) — прижимается вправо */
.filter-types-row .filter-reset--inline,
.chips-row .filter-reset--inline {
    margin-left: auto;
    height: auto;
    align-self: stretch;
}
@media (max-width: 767px) {
    .filter-types-row .filter-reset--inline,
    .chips-row .filter-reset--inline {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        margin-top: 4px;
        padding: 5px 10px;
    }
}

/* Счётчик результатов */
.results-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 4px;
}
.results-count { font-size: 0.78rem; color: var(--ink-3); }
.results-count strong { color: var(--ink-1); }

/* Итоги месяца под таблицей */
.tx-totals {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface-alt);
    font-size: 0.82rem;
    border-top: 1px solid var(--neutral-soft);
}
.tx-total__label { color: var(--ink-3); font-weight: 600; }
.tx-total__cur { color: var(--ink-2); font-weight: 500; }
.tx-total__sep { color: var(--ink-3); padding: 0 2px; }
.tx-total__rub { font-weight: 700; }
.tx-total__rub.is-income  { color: var(--income); }
.tx-total__rub.is-expense { color: var(--expense); }

/* Спиннер загрузки */
.transactions-container.loading { opacity: 0.4; pointer-events: none; }
.spinner-overlay { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10; }
.transactions-container.loading .spinner-overlay { display: block; }

@media (max-width: 767px) {
    .type-btn { font-size: 0.74rem; padding: 5px 10px; }
    .month-btn { font-size: 0.72rem; padding: 4px 9px; }
}

/* ==================== СТРАНИЦА: FIXEDEXPENSES ==================== */

/* Тулбар в шапке (Excel + год) */
.fe-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.fe-btn--excel {
    background: var(--income);
    color: #fff;
    border: 0;
    border-radius: var(--r-sm);
    padding: 0 12px;
    height: 34px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: filter .12s;
}
.fe-btn--excel:hover { filter: brightness(0.94); }
.fe-btn--excel .icon { width: 1em; height: 1em; }

/* Результаты-счётчик */
.fe-results { font-size: 0.78rem; color: var(--ink-3); font-weight: 500; text-transform: none; letter-spacing: 0; }
.fe-results strong { color: var(--ink-1); font-weight: 700; }

/* Контейнер таблицы (для прозрачности при loading) */
.fe-table-container { transition: opacity 0.25s; }
.fe-table-container.loading { opacity: 0.4; pointer-events: none; }

/* Сама таблица расходов */
.fe-table { display: block; overflow-x: auto; }
.fe-table table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
    min-width: 700px;
    border-top: 1px solid var(--neutral-soft);
}
/* Мягкая сетка как в Excel — тонкие разделители между ячейками */
.fe-table th,
.fe-table td {
    border-right: 1px solid var(--neutral-soft);
    border-bottom: 1px solid var(--neutral-soft);
}
.fe-table th:last-child,
.fe-table td:last-child { border-right: 0; }
.fe-table tbody tr:last-child td { border-bottom: 0; }

.fe-table thead th {
    text-align: center;
    font-weight: 600;
    color: var(--ink-2);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 11px 8px;
    background: var(--surface-alt);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}
.fe-table thead th.fe-th-comm { background: var(--warn-soft); color: var(--warn-ink); }
.fe-table tbody td {
    text-align: center;
    padding: 10px 8px;
    color: var(--ink-1);
    vertical-align: middle;
    white-space: nowrap;
    background: var(--surface);
}
.fe-table tbody tr:nth-child(even) td { background: var(--surface-alt); }

/* Подсветка строк: оплачено / частично */
.fe-table tbody tr.is-paid    td { background: var(--income-soft); }
.fe-table tbody tr.is-partial td { background: var(--warn-soft); }
/* В частично оплаченных — выделить ячейки с фактической оплатой (фоном, текст остаётся чёрным) */
.fe-table tbody tr.is-partial td.fe-cell-paid { background: var(--income-soft); font-weight: 600; }

/* На тёмной теме «soft»-фон + ink-1 = плохо читаемо.
   Делаем цвет текста соответствующим тонкому фону (income-ink / warn-ink). */
[data-theme="dark"] .fe-table tbody tr.is-paid    td { color: var(--income-ink); }
[data-theme="dark"] .fe-table tbody tr.is-partial td { color: var(--warn-ink); }
[data-theme="dark"] .fe-table tbody tr.is-partial td.fe-cell-paid { color: var(--income-ink); }
/* Sticky-колонка тоже должна совпадать с фоном строки на тёмной теме */
/* На dark var(--income-soft) и var(--warn-soft) — rgba с alpha 0.15,
   через них при горизонтальном скролле просвечивают данные справа.
   Используем SOLID цвета (тёмные оттенки accent). */
[data-theme="dark"] .fe-table tbody tr.is-paid    td.fe-th-sticky { background-color: #1f3a2d !important; color: var(--income-ink); }
[data-theme="dark"] .fe-table tbody tr.is-partial td.fe-th-sticky { background-color: #3a2f1a !important; color: var(--warn-ink); }
/* Также строки целиком (фон ячеек) — на dark soft rgba даёт просвечивание sticky;
   но это уже видно только на скролле, для самих ячеек оставляем soft. */

/* Footer таблицы */
.fe-table tfoot td {
    background: var(--surface-alt);
    padding: 12px 8px;
    font-weight: 700;
    color: var(--ink-1);
    border-top: 1px solid var(--neutral-soft);
    text-align: center;
}

/* Sticky-колонка с названием месяца (первый столбец).
   Chrome-specific fix: для корректного перекрытия sticky-ячейки над соседними
   при горизонтальном скролле — принудительный stacking context через will-change. */
.fe-table .fe-th-sticky {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 10;
    background-color: var(--surface) !important;
    background-clip: padding-box;
    will-change: transform;
    border-right: 1px solid var(--neutral-soft);
}
/* Тень-разделитель — добавляем через ::after, чтобы не путать с border-collapse */
.fe-table .fe-th-sticky::after {
    content: '';
    position: absolute;
    top: 0;
    right: -6px;
    bottom: 0;
    width: 6px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(15,23,42,0.08), rgba(15,23,42,0));
}
.fe-table thead .fe-th-sticky                        { z-index: 11; background-color: var(--surface-alt) !important; }
.fe-table tfoot .fe-th-sticky                        { background-color: var(--surface-alt) !important; }
.fe-table tbody tr:nth-child(even) .fe-th-sticky     { background-color: var(--surface-alt) !important; }
/* SOLID цвета (без alpha) — иначе через sticky-ячейку просвечивают данные справа */
.fe-table tbody tr.is-paid    .fe-th-sticky          { background-color: #e6f4ec !important; }
.fe-table tbody tr.is-partial .fe-th-sticky          { background-color: #fdf1e0 !important; }

.fe-mnum { color: var(--ink-3); font-weight: 400; font-size: 0.78em; margin-left: 2px; }

/* Empty-state когда нет выбранных категорий */
.fe-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--ink-3);
}
.fe-empty__icon { width: 48px; height: 48px; color: var(--ink-3); margin-bottom: 12px; }
.fe-empty__title { font-size: 1rem; margin-bottom: 4px; color: var(--ink-2); }
.fe-empty__text  { font-size: 0.85rem; color: var(--ink-3); margin: 0; }

@media (max-width: 767px) {
    .fe-table thead th,
    .fe-table tbody td,
    .fe-table tfoot td { padding: 8px 6px; font-size: 0.78rem; }
    .fe-toolbar { gap: 6px; }
    .fe-btn--excel { padding: 0 10px; font-size: 0.8rem; }
}

/* ==================== СТРАНИЦА: REPORTS ==================== */

/* Стили reports перенесены в Reports/index.php (inline). */

/* ==================== СТРАНИЦА: SETTINGS ==================== */

.section-header {
    background: var(--surface-alt);
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    color: var(--ink-2);
}
.section-header:hover { background: #e9ecef; }

.group-title { font-weight: 600; color: var(--ink-1); }
.badge-count { font-weight: 500; }

/* ==================== СТРАНИЦА: BUDGET ==================== */

.budget-controls-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* ==================== СТРАНИЦА: BUDGET ==================== */

/* Уведомление-баннер */
.notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-lg);
    box-shadow: var(--sh-1);
}
.notice__icon { flex-shrink: 0; width: 20px; height: 20px; }
.notice__body { flex: 1; font-size: 0.88rem; color: var(--ink-1); }
.notice__hint { color: var(--ink-3); font-size: 0.78rem; margin-left: 4px; }
.notice--warn    { background: var(--warn-soft);    color: var(--warn-ink); }
.notice--warn .notice__icon { color: var(--warn-ink); }
.notice--success { background: var(--income-soft); color: var(--income-ink); }
.notice--success .notice__icon { color: var(--income-ink); }

/* На узких экранах action-кнопка переносится под текст и занимает всю ширину */
@media (max-width: 560px) {
    .notice {
        flex-wrap: wrap;
        align-items: flex-start;
        row-gap: 10px;
    }
    .notice__body { flex: 1 1 100%; }
    .notice > .action {
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* Контролы бюджета */
.budget-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.budget-controls__filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.budget-controls__filters--mobile { display: none; width: 100%; }
.budget-filter { width: 110px; }
.budget-filter--wide { width: 170px; }
.budget-filter-spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--neutral-soft);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: bspin 0.6s linear infinite;
}
@keyframes bspin { to { transform: rotate(360deg); } }
.budget-autofill { margin: 0 0 0 auto; flex-shrink: 0; } /* прижать к правому краю */
.budget-autofill--mobile { display: none; width: 100%; margin: 0; }

@media (max-width: 767px) {
    .budget-controls__filters:not(.budget-controls__filters--mobile) { display: none; }
    .budget-controls__filters--mobile { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .budget-controls__filters--mobile .budget-filter { width: auto; }
    .budget-autofill--desktop { display: none; }
    .budget-autofill--mobile  { display: block; }
}

/* Split-кнопка (основное действие + dropdown с альтернативами) */
.split-btn {
    position: relative;
    display: inline-flex;
}
.split-btn__main,
.split-btn__caret {
    border: 0;
    background: var(--btn-budget);
    color: var(--clr-budget);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: filter .12s;
    min-height: 36px;
}
.split-btn__main {
    padding: 0 14px;
    border-radius: var(--r-sm) 0 0 var(--r-sm);
    font-size: 0.85rem;
    gap: 6px;
}
.split-btn__caret {
    padding: 0 10px;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    border-left: 1px solid rgba(255,255,255,0.2);
    width: 36px;
}
.split-btn__main:hover,
.split-btn__caret:hover { filter: brightness(0.94); }
.budget-autofill--mobile .split-btn { width: 100%; }
.budget-autofill--mobile .split-btn__main { flex: 1; }

/* Меню split-кнопки */
.split-btn .dropdown-menu,
.split-btn__menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 260px;
    background: var(--surface);
    border-radius: var(--r-sm);
    box-shadow: var(--sh-3);
    padding: 6px;
    z-index: 1100;
    display: none;
}
.split-btn .dropdown-menu.show,
.split-btn__menu.show { display: block; }
.split-btn__item {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    text-align: left;
    color: var(--ink-1);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background .12s;
}
.split-btn__item:hover { background: var(--neutral-soft); }
.split-btn__item-sub { font-size: 0.72rem; color: var(--ink-3); margin-top: 2px; margin-left: 26px; font-weight: 400; }
.split-btn__divider { height: 1px; background: var(--neutral-soft); margin: 4px 0; }
.split-btn .icon { width: 1em; height: 1em; }

/* Прогресс-бар */
.bar {
    height: 18px;
    background: var(--neutral-soft);
    border-radius: var(--r-sm);
    overflow: hidden;
    position: relative;
}
.bar__fill {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    transition: width .25s ease;
    white-space: nowrap;
    min-width: 28px;
}
.bar__fill.is-good   { background: var(--income); }
.bar__fill.is-warn   { background: var(--warn); }
.bar__fill.is-danger { background: var(--expense); }

/* Подсветка значений в таблице (без модификаторов pill) */
/* Утилитарные цвета — !important, чтобы перебивать color у .tfoot/.thead/.cell */
.is-income-text  { color: var(--income) !important; }
.is-expense-text { color: var(--expense) !important; }

/* Таблица бюджета — расширение .tx-table */
.budget-table table { table-layout: fixed; }
.budget-table thead th {
    text-align: center;
    font-weight: 600;
    color: var(--ink-2);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 11px 8px;
    background: var(--surface-alt);
    white-space: nowrap;
}
.budget-table th .th-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 3px;
    border-radius: 50%;
    background: var(--neutral-soft);
    color: var(--ink-3);
    font-size: 9px;
    font-weight: 700;
    cursor: help;
    text-transform: none;
    letter-spacing: 0;
}
.budget-table tbody td {
    text-align: center;
    padding: 10px 8px;
    color: var(--ink-1);
    vertical-align: middle;
}
.budget-table tbody tr:nth-child(odd) td  { background: var(--surface); }
.budget-table tbody tr:nth-child(even) td { background: var(--surface-alt); }
.budget-table tfoot td {
    background: var(--surface-alt) !important;
    padding: 12px 8px;
    font-weight: 700;
    color: var(--ink-1);
    border-top: 1px solid var(--neutral-soft);
    text-align: center;
}

/* Инпут лимита внутри таблицы (десктоп) — центр + нативные стрелки number */
.budget-input {
    width: 100%;
    padding: 6px 6px 6px 10px;
    border: 0;
    background: var(--surface-alt2);
    color: var(--ink-1);
    border-radius: var(--r-sm);
    /* font-size: 16px — фикс iOS-zoom при фокусе на input */
    font-size: 16px;
    font-family: inherit;
    text-align: center;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow .15s, background .15s;
    outline: none;
}
.budget-input:focus    { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent); }
.budget-input.is-valid   { box-shadow: inset 0 0 0 1.5px var(--income); }
.budget-input.is-invalid { box-shadow: inset 0 0 0 1.5px var(--expense); }
/* Нативные стрелки number-инпута — оставляем видимыми всегда (а не только при hover) */
.budget-input[type="number"]::-webkit-inner-spin-button,
.budget-input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    height: 28px;
}

.mobile-filters-grid {
    display: grid;
    grid-template-columns: 4fr 8fr;
    gap: 8px;
    width: 100%;
}
.mobile-filters-grid .mobile-filter-btn { grid-column: 1 / -1; }

.mobile-filter-select {
    background-color: var(--surface-alt);
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    padding: 8px 12px;
    transition: all 0.2s ease;
}
.mobile-filter-select:focus {
    background-color: var(--surface);
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.mobile-filter-btn {
    border-radius: 6px;
    padding: 10px;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.mobile-autofill-btn {
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
}
.mobile-autofill-btn:hover { background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); }

.mobile-budget-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

.mobile-budget-table {
    width: 100%;
    min-width: 500px;
    font-size: 13px;
    border-collapse: collapse;
}

.mobile-budget-table thead {
    background: var(--surface-alt);
    position: sticky;
    top: 0;
    z-index: 10;
}

.mobile-budget-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--ink-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.mobile-budget-table td {
    padding: 10px 8px;
    vertical-align: middle;
    font-size: 0.85rem;
    color: var(--ink-1);
}
.mobile-budget-table tbody tr:nth-child(odd) td  { background: var(--surface); }
.mobile-budget-table tbody tr:nth-child(even) td { background: var(--surface-alt); }

.mobile-budget-table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 5;
    box-shadow: 2px 0 4px rgba(15,23,42,0.04);
    min-width: 110px;
    max-width: 150px;
}
.mobile-budget-table tbody tr:nth-child(odd)  .sticky-col { background: var(--surface); }
.mobile-budget-table tbody tr:nth-child(even) .sticky-col { background: var(--surface-alt); }
.mobile-budget-table thead .sticky-col { background: var(--surface-alt); z-index: 15; }

.mobile-budget-table .category-name { font-weight: 500; word-wrap: break-word; }

.mobile-budget-input {
    width: 80px;
    padding: 6px 8px;
    border: 0;
    background: var(--surface-alt);
    color: var(--ink-1);
    border-radius: var(--r-sm);
    font-size: 0.85rem;
    text-align: right;
    box-shadow: inset 0 0 0 1px transparent;
    transition: box-shadow .15s, background .15s;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}
.mobile-budget-input::-webkit-outer-spin-button,
.mobile-budget-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mobile-budget-input:focus    { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--accent); }
.mobile-budget-input.is-valid   { box-shadow: inset 0 0 0 1.5px var(--income); }
.mobile-budget-input.is-invalid { box-shadow: inset 0 0 0 1.5px var(--expense); }

.mobile-budget-table .total-row td { background: var(--surface-alt) !important; font-weight: 700; text-align: center; }
.mobile-budget-table .total-row .sticky-col { background: var(--surface-alt) !important; text-align: left; }

.mobile-budget-table-wrapper::-webkit-scrollbar { height: 6px; }
.mobile-budget-table-wrapper::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.mobile-budget-table-wrapper::-webkit-scrollbar-thumb { background: #888; border-radius: 10px; }
.mobile-budget-table-wrapper::-webkit-scrollbar-thumb:hover { background: #555; }

@media (max-width: 767px) {
    .budget-controls-container { display: block; }
}

@media (min-width: 768px) {
    .budget-controls-container { margin-bottom: 0; }
}

/* ==================== СТРАНИЦА: CURRENCY ==================== */

.grid-pairs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    align-items: end;
}

@media (max-width: 767px) {
    .grid-pairs { grid-template-columns: repeat(2, 1fr); }
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-submit { grid-column: 1 / -1; }

    /* Высота графика на странице Currency */
    .chart-container-scrollable { height: 300px; }
}

@media (min-width: 768px) {
    /* Высота графика на странице Currency */
    .chart-container-scrollable { height: 350px; }
}

/* ==================== СТРАНИЦА: PROJECTS ==================== */
/* Итоговая строка дня — без hover (аналогично month-total-row) */
.table-hover .day-total-row:hover > td { background-color: var(--bs-table-striped-bg, #e9ecef) !important; cursor: default; }

/* ==================== СТРАНИЦА: INCOMES ==================== */

/* Hobbi использует те же классы — chart-wrapper-scrollable с высотами из общего блока */

/* ==================== МОДАЛКА ЗАМЕТОК (.n-*) ==================== */

:root {
    --n-bg: #f2f2f7;
    --n-card: #fff;
    --n-card-hover: #ebebf0;
    --n-tx: #1c1c1e;
    --n-tx3: #636366;
    --n-tx4: #8e8e93;
    --n-sep: #e5e5ea;
    --n-blue: #6c757d;
    --n-red: #ff3b30;
    --n-green: #34c759;
    --n-placeholder: #c7c7cc;
    --n-fmtbar-bg: rgba(255, 255, 255, 0.97);
    --n-code-bg: #f3f4f6;
    --n-code-tx: #1f2937;
    --n-code-border: #d1d5db;
    --n-r: 12px;
    --n-f: -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
}
/* Notes — переопределение под тёмную тему */
[data-theme="dark"] {
    --n-bg: var(--bg);
    --n-card: var(--surface);
    --n-card-hover: var(--surface-alt);
    --n-tx: var(--ink-1);
    --n-tx3: var(--ink-2);
    --n-tx4: var(--ink-3);
    --n-sep: var(--neutral-soft);
    --n-blue: var(--accent);
    --n-red: var(--expense);
    --n-green: var(--income);
    --n-placeholder: var(--ink-4);
    --n-fmtbar-bg: rgba(22, 27, 34, 0.97);  /* tinted surface */
    --n-code-bg: var(--surface-alt);
    --n-code-tx: var(--ink-1);
    --n-code-border: var(--neutral-soft);
}

.n-wrap { font-family: var(--n-f); padding-bottom: 60px; }
.n-topbar { display: flex; justify-content: flex-end; align-items: center; padding: 8px 4px 12px; }
.n-count { font-size: 13px; color: var(--n-tx4); margin-right: auto; }

.n-new-btn { color: var(--ink-1); background-color: var(--surface); border: 2px solid var(--neutral-soft); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; cursor: pointer; transition: all 0.2s ease; }
.n-new-btn:hover { background-color: var(--accent); border-color: var(--accent); color: #fff; }
.n-new-btn svg { display: block; }

.n-section-lbl { font-size: 13px; font-weight: 600; color: var(--n-tx4); text-transform: uppercase; letter-spacing: .5px; padding: 8px 4px 6px; }
.n-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
@media (min-width: 768px) {
    .n-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 12px; align-items: start; }
}

.n-card { background: var(--n-card); border-radius: var(--n-r); padding: 14px 15px 12px; cursor: pointer; border: none; width: 100%; text-align: left; font-family: var(--n-f); transition: background .12s, transform .1s, box-shadow .12s; box-shadow: 0 1px 3px rgba(0,0,0,.07); display: block; }
.n-card:hover { background: var(--n-card-hover); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.n-card:active { transform: scale(.98); }
@media (min-width: 768px) {
    .n-card { min-height: 165px; display: flex; flex-direction: column; }
}

.n-card-title { font-size: 15px; font-weight: 600; color: var(--n-tx); margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
@media (min-width: 768px) { .n-card-title { font-size: 14px; } }

.n-card-row { display: flex; gap: 8px; align-items: baseline; }
@media (min-width: 768px) { .n-card-row { flex-direction: column; gap: 3px; flex: 1; } }
.n-card-date { font-size: 13px; color: var(--n-tx4); white-space: nowrap; flex-shrink: 0; }
.n-card-prev { font-size: 13px; color: var(--n-tx4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
@media (min-width: 768px) {
    .n-card-prev { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; }
}

.n-todo-badge { font-size: 11px; font-weight: 500; color: var(--n-blue); background: var(--accent-soft); border-radius: 4px; padding: 1px 5px; flex-shrink: 0; }
.n-todo-prev { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.n-todo-prev-row { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--n-tx4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n-tdot { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--n-placeholder); flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.n-tdot.dn { border-color: var(--n-green); background: var(--n-green); }
.n-tdot.dn::after { content: ''; width: 7px; height: 4px; border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff; transform: rotate(-45deg) translateY(-1px); display: block; }
.n-tdot-txt.dn { text-decoration: line-through; color: var(--n-placeholder); }

.n-empty { text-align: center; padding: 80px 20px; color: var(--n-tx4); }
.n-empty svg { opacity: .25; display: block; margin: 0 auto 12px; }
.n-empty h3 { font-size: 18px; font-weight: 600; color: var(--n-tx3); }
.n-empty p { font-size: 15px; margin: 4px 0 0; }

.n-overlay { display: none; position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,0); transition: background .3s; }
.n-overlay.vis {
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(8px);
}

.n-modal { display: none; position: fixed; inset: 0; z-index: 1001; background: var(--surface); flex-direction: column; font-family: var(--n-f); overflow: hidden; transform: translateY(102%); transition: transform .3s cubic-bezier(.4,0,.2,1); }
.n-modal.vis { display: flex; }
.n-modal.open { transform: translateY(0); }
@media (min-width: 768px) {
    .n-modal { top: 50%; left: 50%; right: auto; bottom: auto; width: min(780px,94vw); height: min(88vh,860px); transform: translate(-50%,calc(-50% + 40px)); opacity: 0; border-radius: 16px; box-shadow: 0 24px 80px rgba(0,0,0,.35); transition: transform .26s cubic-bezier(.4,0,.2,1), opacity .26s; }
    .n-modal.open { transform: translate(-50%,-50%); opacity: 1; }
}

.n-toolbar { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--n-sep); background: var(--surface); min-height: 52px; gap: 8px; }
.n-btn-back { display: flex; align-items: center; gap: 4px; background: none; border: none; color: var(--n-blue); font-size: 16px; font-family: var(--n-f); cursor: pointer; padding: 6px 8px; border-radius: 8px; transition: background .15s; white-space: nowrap; }
.n-btn-back:hover { background: rgba(125,125,125,0.8); color: #fff; }
.n-toolbar-right { display: flex; align-items: center; gap: 8px; }
.n-btn-save { background: var(--n-blue); color: #fff; border: none; border-radius: 8px; font-size: 15px; font-weight: 600; font-family: var(--n-f); padding: 7px 18px; cursor: pointer; transition: background .15s; white-space: nowrap; }
.n-btn-save:hover { background: rgba(125,125,125,0.8); color: #fff; }
.n-btn-save:active { background: #0055b3; }
.n-btn-del { background: none; background-color: var(--expense-soft); border: none; color: var(--n-red); cursor: pointer; padding: 6px; border-radius: 8px; display: flex; align-items: center; transition: background .15s; }
.n-btn-del:hover { background: var(--expense-soft); filter: brightness(0.95); }

.n-body { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; position: relative; }
.n-body-top { padding: 20px 20px 0; }
.n-title-inp { width: 100%; border: none; outline: none; font-size: 26px; font-weight: 700; color: var(--n-tx); font-family: var(--n-f); letter-spacing: -.3px; background: transparent; padding: 0; margin-bottom: 4px; display: block; resize: none; overflow: hidden; line-height: 1.3; }
.n-title-inp::placeholder { color: var(--n-placeholder); }
@media (max-width: 480px) { .n-title-inp { font-size: 20px; } }
.n-date { font-size: 13px; color: var(--n-tx4); margin-bottom: 10px; }

.n-fmtbar { position: sticky; top: 0; z-index: 10; background: var(--n-fmtbar-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--n-sep); border-top: 1px solid var(--n-sep); }
.n-fmtscroll { display: flex; align-items: center; padding: 5px 10px; gap: 1px; overflow-x: auto; scrollbar-width: none; }
.n-fmtscroll::-webkit-scrollbar { display: none; }
.n-fmt { background: none; border: none; cursor: pointer; color: var(--n-tx3); padding: 7px 10px; border-radius: 8px; display: flex; align-items: center; justify-content: center; min-width: 36px; font-family: var(--n-f); transition: background .1s, color .1s; flex-shrink: 0; line-height: 1; -webkit-user-select: none; user-select: none; position: relative; }
.n-fmt:hover { background: var(--neutral-soft); }
.n-fmt.on { background: var(--n-blue); color: #fff; }
.n-tip { position: fixed; background: rgba(30,30,30,.88); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 5px; pointer-events: none; z-index: 9999; white-space: nowrap; display: none; font-family: var(--n-f); }
.fl { font-size: 14px; line-height: 1; }
.n-sep { width: 1px; height: 20px; background: var(--n-sep); margin: 0 3px; flex-shrink: 0; }

.n-editor { padding: 14px 20px 80px; outline: none; font-size: 16px; line-height: 1.7; color: var(--n-tx); caret-color: var(--n-blue); font-family: var(--n-f); min-height: 200px; word-break: break-word; }
.n-editor:empty:before { content: attr(data-placeholder); color: var(--n-placeholder); pointer-events: none; display: block; }
.n-editor h1 { font-size: 24px; font-weight: 700; margin: 12px 0 6px; }
.n-editor h2 { font-size: 20px; font-weight: 700; margin: 10px 0 5px; }
.n-editor h3 { font-size: 17px; font-weight: 600; margin: 8px 0 4px; }
.n-editor p, .n-editor div { margin: 0 0 2px; }
.n-editor ul, .n-editor ol { margin: 4px 0; padding-left: 22px; }
.n-editor li { margin: 2px 0; }
.n-editor a { color: var(--n-blue); }

.n-editor ul.tdl { list-style: none; padding-left: 0; margin: 4px 0; }
.n-editor ul.tdl > li { position: relative; padding: 2px 0 2px 28px; min-height: 1.7em; word-break: break-word; }
.n-editor ul.tdl > li::before { content: ''; position: absolute; left: 0; top: 4px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--n-placeholder); cursor: pointer; box-sizing: border-box; transition: background .18s, border-color .18s; }
.n-editor ul.tdl > li.dn::before { background: var(--n-green); border-color: var(--n-green); }
.n-editor ul.tdl > li.dn::after { content: ''; position: absolute; left: 4px; top: 8px; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg); pointer-events: none; display: block; }
.n-editor ul.tdl > li.dn { text-decoration: line-through; color: var(--n-tx4); }
/* Скрываем .tdc из старых заметок — кружок теперь через ::before */
.n-editor ul.tdl > li > .tdc { display: none; }

/* ── Обёртка блока кода (кнопка снаружи <pre>) ── */
.n-code-wrap {
    position: relative;
    margin: 8px 0;
}

/* ── Блоки кода в заметках ── */
.n-editor pre.n-code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    background: var(--n-code-bg);
    color: var(--n-code-tx);
    border-radius: 10px;
    padding: 14px 40px 14px 16px;
    margin: 0;
    overflow-x: auto;
    white-space: pre;
    -webkit-text-size-adjust: 100%;
    tab-size: 4;
    outline: none;
    border: 1.5px solid var(--n-code-border);
    transition: border-color .15s;
    min-height: 2.5em;
}
.n-editor pre.n-code:focus,
.n-editor pre.n-code:focus-within {
    border-color: var(--accent);
    background: var(--n-code-bg);
}
/* Иконка </> в заголовке карточки */
.n-card-code-badge {
    display: inline-flex;
    align-items: center;
    font-family: 'SF Mono', monospace;
    font-size: 10px;
    color: var(--n-tx4);
    background: var(--surface-alt);
    border-radius: 4px;
    padding: 1px 5px;
    flex-shrink: 0;
}
/* Кнопка копирования кода внутри блока */
.n-code-copy-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    background: var(--neutral-soft);
    color: var(--ink-3);
    border: none;
    border-radius: 6px;
    padding: 5px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    user-select: none;
    line-height: 1;
}
.n-code-copy-btn:hover { background: var(--ink-4); color: var(--surface); }
.n-code-copy-btn.copied { background: var(--income-soft); color: var(--income-ink); }

/* Мини-превью кода в карточке */
.n-code-preview {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    line-height: 1.5;
    background: var(--n-code-bg);
    color: var(--n-tx);
    border: 1px solid var(--n-code-border);
    border-radius: 6px;
    padding: 6px 9px;
    margin-top: 5px;
    overflow: hidden;
    white-space: pre;
    max-height: 84px;
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0;
}
/* Точка-индикатор на кнопке user-dropdown (есть непрочитанные обращения) */
.app-user-btn { position: relative; }
.user-btn-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--expense);
    border-radius: 50%;
    margin-left: 4px;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* Бейдж в пункте dropdown'а (число непрочитанного) */
.dropdown-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    margin-left: auto;
    background: var(--expense);
    color: #fff;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
}
.dropdown-item { display: flex; align-items: center; }

/* Фикс overflow в карточках заметок */
.n-card-prev { overflow-wrap: break-word; word-break: break-word; }
@media (min-width: 768px) {
    .n-card-prev { overflow-wrap: break-word; word-break: break-word; }
}

/* ============================================================
   iPhone 13 / узкие экраны (≤ 480px) — компактная вёрстка
   ============================================================ */
@media (max-width: 480px) {
    /* Контейнер — меньше padding */
    .container { padding-left: 12px; padding-right: 12px; }

    /* Шапка приложения */
    .app-header-brand { font-size: 0.95rem; }

    /* Мобильная шапка (☰ ... [logout]) */
    .mobile-menu-toggle { padding: 4px 8px; }

    /* Кошельки на главной — 2 в ряд → если очень узко, оставляем 2 но компактнее */
    .wallets { gap: 8px; }
    .wallet { padding: 12px; }
    .wallet__name { font-size: 0.82rem; }
    .wallet__balance { font-size: 1rem; }

    /* Сводные итоги — 2 в ряд */
    .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat { padding: 10px 12px; }
    .stat__label { font-size: 0.72rem; }
    .stat__value { font-size: 1rem; }

    /* Кнопки действий (Доход/Расход/Перевод/Обмен/Погашение) */
    .actions { gap: 6px; }
    .action {
        font-size: 0.82rem;
        padding: 10px 8px;
        min-height: 44px;
    }
    .action .icon { width: 18px; height: 18px; }

    /* Курсы валют — стили уже заданы в media (max-width: 767px),
       здесь только финальное уменьшение gap для самых узких экранов */
    .rates-strip { gap: 6px; }

    /* Бейджи / пилюли в карточках транзакций */
    .pill { font-size: 0.7rem; padding: 3px 7px; }
    .pill--lg { font-size: 0.78rem; }

    /* Мобильные карточки транзакций */
    .tx-mobile-card { padding: 10px 12px; }
    .tx-mobile-card__amount { font-size: 0.95rem; }

    /* Таблицы — на узких экранах разрешаем горизонтальный скролл */
    .tx-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .fe-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    /* Заголовки секций — меньше padding */
    .tx-section__title { padding: 10px 12px; font-size: 0.72rem; }

    /* Фильтры — фильтры/чипы wrap на новые строки.
       font-size у .filter-control НЕ меняем (16px — фикс iOS-zoom). */
    .chips-row { gap: 5px; }
    .filter-control { padding: 0 10px; }

    /* Модалки — почти на весь экран */
    .modal-dialog { margin: 0.5rem; max-width: calc(100vw - 1rem); }
    .modal-body { padding: 14px; }
    .modal-header { padding: 12px 14px; }
    .modal-footer { padding: 12px 14px; }
    .modal-title { font-size: 1rem; }

    /* Поля ввода — font-size не трогаем (16px фикс iOS-zoom).
       Только подпись floating-label можно уменьшить. */
    .field__label { font-size: 0.78rem; }

    /* Demo-баннер — компактнее */
    .demo-banner { padding: 8px 10px; gap: 8px; font-size: 0.82rem; }
    .demo-banner__cta { padding: 4px 10px; font-size: 0.78rem; }

    /* Notice (плашки) */
    .notice { padding: 10px 12px; font-size: 0.88rem; }

    /* Datetime picker — компактнее */
    .adm-dtp { width: 340px; padding: 10px; }
    .adm-dtp-day { padding: 6px 0; font-size: 0.85rem; }
    .adm-dtp-times { width: 68px; }
}

/* ================= Опасная зона (Настройки) ================= */
.danger-zone {
    border: 1px solid var(--expense-soft);
}
.danger-title {
    color: var(--expense);
}
.danger-body {
    padding: 14px 16px;
}
.danger-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.danger-row__text { min-width: 0; flex: 1 1 220px; }
.danger-row__title {
    font-weight: 600;
    color: var(--ink-1);
    font-size: 0.95rem;
}
.danger-row__sub {
    font-size: 0.82rem;
    color: var(--ink-3);
    margin-top: 4px;
    line-height: 1.4;
}
.danger-warn {
    background: var(--expense-soft);
    color: var(--expense-ink);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: 0.86rem;
    line-height: 1.45;
    margin-bottom: 14px;
}
