/* Страница плана / бюджет: контент выше футера, футер остаётся видимым */
.budget-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 64px;
    width: 100%;
    background: #121212;
    z-index: 1500;
    overflow: hidden;
    flex-direction: column;
}

.budget-screen.active {
    display: flex;
}

body.budget-open {
    overflow: hidden;
}

body.light-theme .budget-screen {
    background: #f8fafc;
}

/* Шапка: План | галочка, под ней КАТЕГОРИЯ БЮДЖЕТ */
.budget-screen-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    background: #121212;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.light-theme .budget-screen-header {
    background: #f8fafc;
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

.budget-screen-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 0 8px 0 20px;
    gap: 8px;
}

.budget-header-row-left {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
}

.budget-screen-title.hidden {
    display: none;
}

.budget-header-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.budget-header-search-wrap.hidden {
    display: none;
}

.budget-header-search-input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    font-size: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    outline: none;
}

.budget-header-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.budget-header-search-input:focus {
    border-color: #5b8def;
    background: rgba(255, 255, 255, 0.1);
}

.budget-header-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.budget-header-search-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.budget-header-search-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.budget-header-search-btn.is-active {
    background: rgba(91, 141, 239, 0.2);
    color: #93c5fd;
}

body.light-theme .budget-header-search-input {
    border-color: rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.04);
    color: #1e293b;
}

body.light-theme .budget-header-search-input::placeholder {
    color: #94a3b8;
}

body.light-theme .budget-header-search-input:focus {
    border-color: #5b8def;
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme .budget-header-search-btn {
    background: transparent;
    color: #64748b;
}

body.light-theme .budget-header-search-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
}

body.light-theme .budget-header-search-btn:focus,
body.light-theme .budget-header-search-btn:focus-visible {
    outline: none;
    background: transparent;
    color: #64748b;
}

body.light-theme .budget-header-search-btn.is-active {
    background: rgba(79, 124, 255, 0.15);
    color: #4f7cff;
}

.budget-screen-save {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.budget-screen-save:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

body.light-theme .budget-screen-save {
    color: #64748b;
}

body.light-theme .budget-screen-save:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
}

.budget-screen-save .material-icons {
    color: #94a3b8;
}

body.light-theme .budget-screen-save .material-icons {
    color: #64748b;
}

.budget-screen-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
}

body.light-theme .budget-screen-title {
    color: #1e293b;
}

/* Контейнер страницы, скролл только внутри — не под футер */
.budget-screen-phone {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: auto;
}

.budget-screen-phone-inner {
    padding: 20px;
    padding-bottom: 96px;
    min-height: 100%;
    color: #e2e8f0;
}

body.light-theme .budget-screen-phone-inner {
    color: #1e293b;
}

.budget-header-errors {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: rgba(239, 68, 68, 0.15);
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
    font-size: 13px;
    color: #fca5a5;
}

.budget-header-errors.hidden {
    display: none;
}

.budget-header-errors-icon {
    font-size: 18px;
    color: #f87171;
}

body.light-theme .budget-header-errors {
    background: rgba(220, 38, 38, 0.1);
    border-bottom-color: rgba(220, 38, 38, 0.2);
    color: #b91c1c;
}

body.light-theme .budget-header-errors-icon {
    color: #dc2626;
}

/* Строка КАТЕГОРИЯ БЮДЖЕТ внутри шапки */
.budget-list-header {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 36px;
    padding: 0 20px 8px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

body.light-theme .budget-list-header {
    color: #64748b;
}

.budget-list-header-total {
    flex: 1;
    min-width: 0;
}

.budget-unsaved-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.12);
    border-bottom: 1px solid rgba(239, 68, 68, 0.2);
}

.budget-unsaved-bar.hidden {
    display: none;
}

.budget-unsaved-text {
    font-size: 13px;
    color: #fca5a5;
}

.budget-unsaved-reset {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
    border: none;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.25);
    color: #fecaca;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.budget-unsaved-reset:hover {
    background: rgba(239, 68, 68, 0.4);
    color: #fff;
}

body.light-theme .budget-unsaved-bar {
    background: rgba(220, 38, 38, 0.08);
    border-bottom-color: rgba(220, 38, 38, 0.15);
}

body.light-theme .budget-unsaved-text {
    color: #b91c1c;
}

body.light-theme .budget-unsaved-reset {
    background: rgba(220, 38, 38, 0.15);
    color: #991b1b;
}

body.light-theme .budget-unsaved-reset:hover {
    background: rgba(220, 38, 38, 0.25);
    color: #7f1d1d;
}

/* Список плашек категорий */
.budget-categories-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.budget-footer-link-wrap {
    margin: 16px 0 24px;
    padding: 0 4px;
}

.budget-colorize-link {
    font-size: 14px;
    color: #93c5fd;
    text-decoration: none;
    cursor: pointer;
}

.budget-colorize-link:hover {
    text-decoration: underline;
    color: #bfdbfe;
}

body.light-theme .budget-colorize-link {
    color: #4f7cff;
}

body.light-theme .budget-colorize-link:hover {
    color: #3d6ae6;
}

.budget-fab {
    position: absolute;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: #5b8def;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(91, 141, 239, 0.4);
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
}

.budget-fab:hover {
    background: #4a7ad4;
    transform: scale(1.05);
}

.budget-fab .material-icons {
    font-size: 28px;
}

body.light-theme .budget-fab {
    background: #4f7cff;
    box-shadow: 0 4px 14px rgba(79, 124, 255, 0.35);
}

body.light-theme .budget-fab:hover {
    background: #3d6ae6;
}

.budget-card {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: auto auto;
    gap: 8px 12px;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

body.light-theme .budget-card {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
}

.budget-card-search-hidden {
    display: none;
}

.budget-card .budget-card-name,
.budget-card .budget-card-budget {
    min-width: 0;
    width: 100%;
}

.budget-card-icon-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background 0.2s;
}

.budget-card-icon-btn:hover {
    background: rgba(0, 0, 0, 0.35);
}

body.light-theme .budget-card-icon-btn {
    background: #e2e8f0;
}

body.light-theme .budget-card-icon-btn:hover {
    background: #cbd5e1;
}

.budget-card-icon-btn .material-icons {
    font-size: 22px;
}

.budget-card-color-swatch {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.budget-card-color-swatch:hover {
    border-color: rgba(255, 255, 255, 0.5);
}

body.light-theme .budget-card-color-swatch {
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .budget-card-color-swatch:hover {
    border-color: rgba(0, 0, 0, 0.35);
}

/* Диалог выбора цвета из палитры */
.budget-color-picker-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.budget-color-picker-overlay.active {
    display: flex;
}

.budget-color-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.budget-color-picker-box {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    padding: 16px;
}

body.light-theme .budget-color-picker-box {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.budget-color-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.budget-color-picker-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
}

body.light-theme .budget-color-picker-title {
    color: #1e293b;
}

.budget-color-picker-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.budget-color-picker-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

body.light-theme .budget-color-picker-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
}

.budget-color-picker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.budget-color-picker-swatch {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.2s;
}

.budget-color-picker-swatch:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.6);
}

body.light-theme .budget-color-picker-swatch {
    border-color: rgba(0, 0, 0, 0.15);
}

body.light-theme .budget-color-picker-swatch:hover {
    border-color: rgba(0, 0, 0, 0.4);
}

.budget-card-fixed-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #64748b;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.budget-card-fixed-btn .material-icons {
    font-size: 18px;
}

.budget-card-fixed-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}

.budget-card-fixed-btn.active {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.budget-card-fixed-btn.active:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

body.light-theme .budget-card-fixed-btn {
    background: rgba(0, 0, 0, 0.06);
    color: #94a3b8;
}

body.light-theme .budget-card-fixed-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #64748b;
}

body.light-theme .budget-card-fixed-btn.active {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

body.light-theme .budget-card-fixed-btn.active:hover {
    background: rgba(239, 68, 68, 0.22);
    color: #b91c1c;
}


.budget-card-name {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 14px;
    color: #f1f5f9;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 8px;
}

.budget-card-name:focus {
    outline: none;
    border-color: #5b8def;
}

body.light-theme .budget-card-name {
    color: #1e293b;
    background: #f1f5f9;
}

body.light-theme .budget-card-name:focus {
    border-color: #4f7cff;
}

.budget-card-budget {
    width: 72px;
    padding: 8px 10px;
    font-size: 14px;
    text-align: right;
    color: #f1f5f9;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 8px;
}

.budget-card-budget:focus {
    outline: none;
    border-color: #5b8def;
}

body.light-theme .budget-card-budget {
    color: #1e293b;
    background: #f1f5f9;
}

body.light-theme .budget-card-budget:focus {
    border-color: #4f7cff;
}

.budget-card-move {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.budget-card-move:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.budget-card-move:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}


body.light-theme .budget-card-move:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.08);
    color: #475569;
}

.budget-card-delete {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.budget-card-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Полноэкранный оверлей выбора иконки */
.icon-picker-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.icon-picker-overlay.active {
    display: flex;
}

.icon-picker-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.icon-picker-overlay-box {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 360px;
    height: 85vh;
    min-height: 400px;
    max-height: 85vh;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

body.light-theme .icon-picker-overlay-box {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.icon-picker-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    padding: 16px 16px 0;
    padding-bottom: 12px;
}

.icon-picker-overlay-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
}

body.light-theme .icon-picker-overlay-title {
    color: #1e293b;
}

.icon-picker-overlay-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.icon-picker-overlay-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

body.light-theme .icon-picker-overlay-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
}

.icon-picker-overlay-search {
    flex-shrink: 0;
    margin: 0 16px 12px;
    padding: 10px 14px;
    font-size: 15px;
    color: #f1f5f9;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.icon-picker-overlay-search::placeholder {
    color: #94a3b8;
}

.icon-picker-overlay-search:focus {
    outline: none;
    border-color: #5b8def;
}

body.light-theme .icon-picker-overlay-search {
    color: #1e293b;
    background: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.12);
}

body.light-theme .icon-picker-overlay-search::placeholder {
    color: #64748b;
}

body.light-theme .icon-picker-overlay-search:focus {
    border-color: #4f7cff;
}

.icon-picker-overlay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 8px;
    padding: 0 16px 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    align-content: start;
}

.icon-picker-overlay-item {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.icon-picker-overlay-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.icon-picker-overlay-item .material-icons {
    font-size: 24px;
}

body.light-theme .icon-picker-overlay-item {
    color: #475569;
}

body.light-theme .icon-picker-overlay-item:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* Диалог подтверждения сохранения */
.budget-confirm {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 10;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.budget-confirm.active {
    display: flex;
}

.budget-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.budget-confirm-box {
    position: relative;
    background: #1f1f1f;
    color: #f1f5f9;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 260px;
}

body.light-theme .budget-confirm-box {
    background: #fff;
    color: #1e293b;
    border-color: rgba(0, 0, 0, 0.1);
}

.budget-confirm-text {
    margin: 0 0 20px;
    font-size: 16px;
}

.budget-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.budget-confirm-btn {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.budget-confirm-save {
    background: #5b8def;
    color: #fff;
}

.budget-confirm-save:hover {
    background: #4a7ad4;
}

.budget-confirm-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

.budget-confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

body.light-theme .budget-confirm-save {
    background: #4f7cff;
}

body.light-theme .budget-confirm-save:hover {
    background: #3d6ae6;
}

body.light-theme .budget-confirm-cancel {
    background: #f1f5f9;
    color: #64748b;
}

body.light-theme .budget-confirm-cancel:hover {
    background: #e2e8f0;
    color: #334155;
}

.budget-confirm-delete {
    background: #dc2626;
    color: #fff;
}

.budget-confirm-delete:hover {
    background: #b91c1c;
}

body.light-theme .budget-confirm-delete {
    background: #dc2626;
}

body.light-theme .budget-confirm-delete:hover {
    background: #b91c1c;
}
