/* ============================================================
   Мобильный редизайн приложения "Семейный бюджет"
   Mobile-first UI в стиле нативного iOS/Android приложения
   ============================================================ */

:root {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f9f9fb;
    --text: #1c1c1e;
    --text-muted: #6e6e73;
    --text-soft: #8e8e93;
    --border: #e5e5ea;
    --border-strong: #d1d1d6;

    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.12);
    --success: #30b854;
    --success-soft: rgba(48, 184, 84, 0.14);
    --danger: #ff3b30;
    --danger-soft: rgba(255, 59, 48, 0.12);
    --warning: #ff9500;

    --grad-primary: linear-gradient(135deg, #5b8def 0%, #8a70ff 100%);
    --grad-success: linear-gradient(135deg, #30b854 0%, #1ea048 100%);
    --grad-danger: linear-gradient(135deg, #ff6258 0%, #ff3b30 100%);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.16);

    --radius-xs: 8px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --surface: #1c1c1e;
        --surface-2: #2c2c2e;
        --text: #ffffff;
        --text-muted: #aeaeb2;
        --text-soft: #8e8e93;
        --border: #38383a;
        --border-strong: #48484a;

        --accent-soft: rgba(10, 132, 255, 0.24);
        --success-soft: rgba(48, 184, 84, 0.22);
        --danger-soft: rgba(255, 59, 48, 0.22);

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
        --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.55);
        --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.7);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(96px + var(--safe-bottom));
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

/* =======================
   Верхняя панель (app bar)
   ======================= */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--border);
    padding: calc(var(--safe-top) + 10px) 12px 10px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
}

.app-bar-title {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    text-align: center;
    color: var(--text);
}

.app-bar-link,
.app-bar-btn {
    background: transparent;
    border: 0;
    color: var(--accent);
    font-size: 22px;
    padding: 6px;
    cursor: pointer;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    line-height: 1;
    text-decoration: none;
}
.app-bar-link:active,
.app-bar-btn:active { opacity: 0.55; }
.app-bar-link[aria-current="page"] { color: var(--text); pointer-events: none; }

/* =======================
   Основной контейнер
   ======================= */
.screen { padding: 0 0 8px; }
.section { padding: 0 16px; }
.section + .section { margin-top: 18px; }

.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 16px;
    margin: 22px 0 10px;
}
.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}
.section-action {
    font-size: 14px;
    color: var(--accent);
    background: transparent;
    border: 0;
    padding: 4px 6px;
    cursor: pointer;
    font-weight: 500;
}
.section-action:active { opacity: 0.55; }

/* =======================
   Hero — карточка баланса
   ======================= */
.hero {
    margin: 16px;
    padding: 22px 22px 20px;
    border-radius: var(--radius-xl);
    background: var(--grad-primary);
    color: #fff;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: "";
    position: absolute;
    right: -40px;
    top: -40px;
    width: 160px;
    height: 160px;
    background: radial-gradient(circle, rgba(255,255,255,0.18), transparent 70%);
    pointer-events: none;
}

.hero-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 6px;
}
.hero-amount {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
    word-break: break-all;
}
.hero-amount.negative { color: #ffc2bc; }

.hero-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.22);
}
.hero-chip { display: flex; align-items: center; gap: 10px; }
.hero-chip-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}
.hero-chip-text { min-width: 0; }
.hero-chip-label {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.78;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.hero-chip-amount {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =======================
   Segmented control
   ======================= */
.segmented {
    display: flex;
    margin: 0 16px 12px;
    padding: 4px;
    background: var(--surface-2);
    border-radius: 12px;
    gap: 4px;
    border: 1px solid var(--border);
}
.segmented-item {
    flex: 1;
    background: transparent;
    border: 0;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.segmented-item.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    font-weight: 600;
}
.segmented-item:active { opacity: 0.8; }

/* =======================
   Список транзакций
   ======================= */
.tx-list { list-style: none; margin: 0 16px; padding: 0; }
.tx-item {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 12px;
    row-gap: 8px;
    align-items: center;
    box-shadow: var(--shadow-xs);
    transition: transform 0.15s ease;
    cursor: pointer;
}
.tx-item:active { transform: scale(0.985); }

.tx-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.tx-icon.income { background: var(--success-soft); color: var(--success); }
.tx-icon.expense { background: var(--danger-soft); color: var(--danger); }

.tx-meta { min-width: 0; }
.tx-category {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-sub {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
}
.tx-sub .sep {
    width: 3px; height: 3px; border-radius: 50%;
    background: var(--border-strong); flex-shrink: 0;
}
.tx-sub .desc {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-amount {
    font-weight: 600;
    font-size: 16px;
    text-align: right;
    white-space: nowrap;
    letter-spacing: -0.01em;
}
.tx-amount.income { color: var(--success); }
.tx-amount.expense { color: var(--danger); }

.tx-actions {
    grid-column: 1 / -1;
    display: none;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.tx-item.expanded .tx-actions { display: flex; }

.tx-action-btn {
    flex: 1;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.tx-action-btn.danger { background: var(--danger-soft); color: var(--danger); }
.tx-action-btn:active { opacity: 0.65; }

/* Пустое состояние */
.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 44px;
    opacity: 0.4;
    margin-bottom: 10px;
    display: block;
}
.empty-title { font-size: 16px; font-weight: 500; margin: 0 0 4px; color: var(--text); }
.empty-hint { font-size: 14px; margin: 0; }

/* =======================
   FAB — плавающая кнопка
   ======================= */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(24px + var(--safe-bottom));
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    color: #fff;
    font-size: 28px;
    line-height: 1;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.fab:active { transform: scale(0.92); }
.fab.fab-income { background: var(--grad-success); }
.fab.fab-expense { background: var(--grad-danger); }
.fab.fab-neutral { background: var(--accent); }

/* =======================
   Категории — списки
   ======================= */
.cat-group {
    margin: 0 16px 20px;
    background: var(--surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.cat-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.cat-group-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.cat-group-header .dot {
    width: 10px; height: 10px; border-radius: 50%;
}
.cat-group.income .dot { background: var(--success); }
.cat-group.expense .dot { background: var(--danger); }
.cat-add {
    background: transparent;
    border: 0;
    color: var(--accent);
    font-size: 22px;
    padding: 4px 8px;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    border-radius: 8px;
}
.cat-add:active { opacity: 0.55; }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    gap: 10px;
}
.cat-item:first-child { border-top: 0; }
.cat-name { font-size: 15px; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 0;
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn.primary { color: var(--accent); background: var(--accent-soft); }
.icon-btn.danger { color: var(--danger); background: var(--danger-soft); }
.icon-btn:active { opacity: 0.6; }
.cat-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* =======================
   Модалки как bottom sheet
   ======================= */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 9999 !important;
    display: none !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* keyboard-aware on mobile */
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}
.modal.show {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
}
.modal-backdrop {
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    z-index: 9998 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: #000 !important;
}
.modal-backdrop.show { opacity: 0.45 !important; }

.modal-dialog {
    position: relative !important;
    width: 100% !important;
    max-width: 520px !important;
    margin: 0 !important;
    pointer-events: none !important;
    transform: translateY(100%) !important;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1) !important;
}
.modal.show .modal-dialog { transform: translateY(0) !important; }

.modal-content {
    position: relative !important;
    pointer-events: auto !important;
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 0 !important;
    border-radius: 22px 22px 0 0 !important;
    max-height: 90vh !important;
    max-height: 90dvh !important; /* keyboard-aware on mobile */
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.22) !important;
}
.modal-content::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 5px;
    background: var(--border-strong);
    border-radius: 3px;
    opacity: 0.9;
}

.modal-header {
    position: relative !important;
    padding: 22px 20px 12px !important;
    border-bottom: 1px solid var(--border) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: transparent !important;
}
.modal-title {
    font-size: 17px !important;
    font-weight: 600 !important;
    margin: 0 !important;
    color: var(--text) !important;
}
.modal-header .btn-close {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--surface-2) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="%236e6e73"><path d="M2.293 2.293a1 1 0 011.414 0L8 6.586l4.293-4.293a1 1 0 111.414 1.414L9.414 8l4.293 4.293a1 1 0 01-1.414 1.414L8 9.414l-4.293 4.293a1 1 0 01-1.414-1.414L6.586 8 2.293 3.707a1 1 0 010-1.414z"/></svg>') center / 14px no-repeat;
    border: 0;
    opacity: 1;
}

.modal-body {
    padding: 16px 20px !important;
    overflow-y: auto !important;
    flex: 1 1 auto !important;
}

.modal-footer {
    padding: 12px 20px calc(16px + var(--safe-bottom)) !important;
    border-top: 1px solid var(--border) !important;
    display: flex !important;
    gap: 10px !important;
    background: var(--surface) !important;
}
.modal-footer .btn { flex: 1; }

body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

/* =======================
   Формы
   ======================= */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.form-control,
.form-select,
input[type="text"].form-control,
input[type="number"].form-control,
input[type="date"].form-control,
textarea.form-control,
select.form-select {
    display: block !important;
    width: 100% !important;
    padding: 13px 14px !important;
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    font-size: 16px !important; /* 16px чтобы iOS не зумил */
    line-height: 1.3 !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-select {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="%236e6e73"><path d="M4 6l4 4 4-4" stroke="%236e6e73" stroke-width="1.5" fill="none" stroke-linecap="round"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 14px center !important;
    background-size: 14px !important;
    padding-right: 36px !important;
}
.form-control:focus,
.form-select:focus {
    outline: none !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 4px var(--accent-soft) !important;
}
textarea.form-control { min-height: 84px; resize: vertical; }

/* =======================
   Кнопки
   ======================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border: 0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
}
.btn:active { opacity: 0.75; transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-block { display: flex; width: 100%; }

/* =======================
   Toast
   ======================= */
.toast-container {
    position: fixed;
    top: calc(var(--safe-top) + 16px);
    left: 16px;
    right: 16px;
    z-index: 10000;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    border-radius: 12px !important;
    padding: 0 !important;
    margin-bottom: 8px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    border: 0 !important;
    color: #fff !important;
}
.toast.bg-success { background: var(--success) !important; }
.toast.bg-danger  { background: var(--danger)  !important; }
.toast.bg-warning { background: var(--warning) !important; color: #1c1c1e !important; }
.toast .toast-body { padding: 12px 14px !important; }
.toast .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

/* =======================
   Бюджеты — переключатель месяца
   ======================= */
.month-switcher {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 6px;
    margin: 14px 16px 4px;
    padding: 6px 6px;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: var(--shadow-xs);
}
.month-nav {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    text-decoration: none;
}
.month-nav:active { opacity: 0.55; }
.month-current {
    text-align: center;
    line-height: 1.2;
}
.month-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
}
.month-today-link {
    display: inline-block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--accent);
}

/* Hero для бюджета: компактнее, поддержка трёх чипов */
.hero.hero-budget { padding: 18px 18px 16px; }
.hero-split.hero-split-3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hero-split.hero-split-3 .hero-chip { gap: 8px; }
.hero-split.hero-split-3 .hero-chip-icon { width: 28px; height: 28px; font-size: 14px; }
.hero-split.hero-split-3 .hero-chip-amount { font-size: 13px; }

/* =======================
   Бюджеты — карточки
   ======================= */
.budget-list { list-style: none; margin: 0 16px; padding: 0; }
.budget-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 14px 16px 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-xs);
    border-left: 4px solid var(--border-strong);
}
.budget-card.ok { border-left-color: var(--success); }
.budget-card.over { border-left-color: var(--danger); }
.budget-card.other { border-left-color: var(--text-soft); }

.budget-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.budget-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.budget-edit-btn {
    width: 32px; height: 32px;
    border-radius: 8px;
    border: 0;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.budget-edit-btn:active { opacity: 0.6; }

.budget-figures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}
.budget-card.other .budget-figures { grid-template-columns: 1fr; }
.budget-figure { min-width: 0; }
.budget-figure-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-soft);
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.budget-figure-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.budget-figure-value.actual { color: var(--text-muted); }
.budget-figure-value.balance.positive { color: var(--success); }
.budget-figure-value.balance.negative { color: var(--danger); }

.budget-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.budget-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
}
.budget-progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width 0.4s ease;
}
.budget-progress-fill.over { background: var(--danger); }
.budget-progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
}

.budget-no-limit {
    font-size: 12px;
    color: var(--text-soft);
    font-style: italic;
    margin-bottom: 8px;
}

.budget-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}
.budget-tag {
    font-size: 12px;
    padding: 3px 8px;
    background: var(--surface-2);
    color: var(--text-muted);
    border-radius: 999px;
    border: 1px solid var(--border);
    white-space: nowrap;
}
.budget-empty-tags {
    font-size: 12px;
    color: var(--text-soft);
    font-style: italic;
    margin-top: 4px;
}

.budget-detail-link {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
}
.budget-detail-link:active { opacity: 0.6; }
.budget-detail-link i { font-size: 12px; }

/* =======================
   Категории бюджета — список настройки
   ======================= */
.bcat-list { list-style: none; margin: 0 16px; padding: 0; }
.bcat-item {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-xs);
}
.bcat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.bcat-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bcat-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* плоский список «orphan»-категорий */
.cat-list-flat { list-style: none; margin: 0 16px; padding: 0; }
.cat-item-flat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: 10px;
    margin-bottom: 6px;
    box-shadow: var(--shadow-xs);
    gap: 8px;
}
.cat-item-flat .cat-name {
    font-size: 14px;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cat-item-flat .cat-hint {
    font-size: 12px;
    color: var(--text-soft);
    font-style: italic;
    flex-shrink: 0;
}

/* =======================
   Список чекбоксов в модалке
   ======================= */
.checkbox-list {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    max-height: 38vh;
    overflow-y: auto;
}
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.checkbox-row:last-child { border-bottom: 0; }
.checkbox-row input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--accent);
    flex-shrink: 0;
    cursor: pointer;
}
.checkbox-label {
    font-size: 14px;
    color: var(--text);
    flex: 1;
    min-width: 0;
}
.checkbox-hint {
    font-size: 12px;
    color: var(--text-soft);
    font-style: italic;
    margin-left: 6px;
}
.checkbox-empty {
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}
.form-hint {
    font-size: 12px;
    color: var(--text-soft);
    margin-top: 6px;
}

/* =======================
   Тонкая настройка по ширине
   ======================= */
@media (min-width: 640px) {
    .hero, .segmented, .tx-list, .cat-group, .budget-list,
    .month-switcher, .bcat-list, .cat-list-flat {
        margin-left: auto; margin-right: auto; max-width: 560px;
    }
    body { padding-bottom: 120px; }
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         