/* Full-screen category page (replaces overlay) */
.tile-category-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    flex-direction: column;
    background: #1f1f1f;
    color: #f2f2f2;
    overflow: hidden;
    color-scheme: light;
}

.tile-category-screen.active {
    display: flex;
}

@media (min-width: 769px) {
    .tile-category-screen {
        left: 50%;
        transform: translateX(-50%);
        max-width: 960px;
        width: 960px;
    }
}

body.tile-category-open {
    overflow: hidden;
}

.tile-category-screen-box {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.light-theme .tile-category-screen {
    background: #fff;
    color: #1f2937;
}

.tile-category-screen-back {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    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;
    padding: 0;
}

.tile-category-screen-back:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

body.light-theme .tile-category-screen-back {
    color: #64748b;
}

body.light-theme .tile-category-screen-back:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
}

.tile-category-screen-back .material-icons {
    font-size: 24px;
}

.tile-category-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;
}

.tile-category-fab:hover {
    background: #4a7ad4;
    transform: scale(1.05);
}

.tile-category-fab .material-icons {
    font-size: 28px;
}

body.light-theme .tile-category-fab {
    background: #4f7cff;
    box-shadow: 0 4px 14px rgba(79, 124, 255, 0.35);
}

body.light-theme .tile-category-fab:hover {
    background: #3d6ae6;
}

/* Legacy class for keyboard viewport (if still used) */
.tile-overlay-keyboard-open .tile-category-screen-box {
    min-height: 0;
}

.tile-category-screen-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
    background: #1f1f1f;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-theme .tile-category-screen-header {
    background: #fff;
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.tile-category-screen-header-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 8px 0 4px;
}

.tile-category-screen-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f2f2f2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

body.light-theme .tile-category-screen-title {
    color: #1f2937;
}

.tile-category-control {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-theme .tile-category-control {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* Раскладка как на странице «Настроить группы»: 1-я строка — название, 2-я — план, иконка, цвет, обязательное, 3-я — группа. Кнопка удаления категории в хедере экрана. */
.tile-category-card {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    grid-template-rows: auto auto auto;
    gap: 14px 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;
}

.tile-category-card .tile-overlay-field-name {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
}

.tile-category-screen-header-delete {
    margin-left: auto;
    flex-shrink: 0;
}

.tile-category-card .tile-overlay-field-plan {
    grid-column: 1;
    grid-row: 2;
    min-width: 0;
}

.tile-category-card .budget-card-icon-btn {
    grid-column: 2;
    grid-row: 2;
}

.tile-category-card .budget-card-color-swatch {
    grid-column: 3;
    grid-row: 2;
}

/* M3-style outlined text field with floating label */
.tile-overlay-field {
    min-width: 0;
}

.tile-overlay-mdc-outlined {
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 4px;
    background: transparent;
    transition: border-color 0.2s;
}

.tile-overlay-mdc-outlined:hover {
    border-color: rgba(255, 255, 255, 0.6);
}

.tile-overlay-mdc-outlined:focus-within {
    border-color: #5b8def;
    outline: 2px solid #5b8def;
    outline-offset: -2px;
}

body.light-theme .tile-overlay-mdc-outlined {
    border-color: rgba(0, 0, 0, 0.38);
}

body.light-theme .tile-overlay-mdc-outlined:hover {
    border-color: rgba(0, 0, 0, 0.6);
}

body.light-theme .tile-overlay-mdc-outlined:focus-within {
    border-color: #4f7cff;
    outline-color: #4f7cff;
}

/* Outlined style: only the container has border, input is transparent. M3: container 56dp, padding 8dp vertical */
.tile-overlay-mdc-outlined .tile-overlay-mdc-input,
.tile-overlay-mdc-outlined .budget-card-name,
.tile-overlay-mdc-outlined .budget-card-budget {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 14px 12px 6px;
    font-size: 16px;
    font-weight: 400;
    color: #f2f2f2;
    background: transparent !important;
    border: none !important;
    border-radius: 4px;
    outline: none;
}

.tile-overlay-mdc-outlined .tile-overlay-mdc-input::placeholder,
.tile-overlay-mdc-outlined .budget-card-name::placeholder,
.tile-overlay-mdc-outlined .budget-card-budget::placeholder {
    color: transparent;
}

body.light-theme .tile-overlay-mdc-outlined .tile-overlay-mdc-input,
body.light-theme .tile-overlay-mdc-outlined .budget-card-name,
body.light-theme .tile-overlay-mdc-outlined .budget-card-budget {
    color: #1f2937;
}

/* Hide number input spin buttons everywhere */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.tile-overlay-mdc-label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    transition: transform 0.2s, font-size 0.2s, color 0.2s, top 0.2s;
}

body.light-theme .tile-overlay-mdc-label {
    color: rgba(0, 0, 0, 0.6);
}

/* Label embedded in top border (notch) - centered on the border line; opaque bg so border does not show through */
.tile-overlay-mdc-outlined .tile-overlay-mdc-input:focus ~ .tile-overlay-mdc-label,
.tile-overlay-mdc-outlined .tile-overlay-mdc-input:not(:placeholder-shown) ~ .tile-overlay-mdc-label,
.tile-overlay-mdc-outlined.tile-overlay-mdc-filled .tile-overlay-mdc-label {
    top: 0;
    transform: translateY(-50%) scale(0.75);
    transform-origin: left top;
    font-size: 12px;
    color: #94a3b8;
    padding: 0 6px;
    margin-left: -6px;
    z-index: 1;
    background: #252525;
}

body.light-theme .tile-overlay-mdc-outlined .tile-overlay-mdc-input:focus ~ .tile-overlay-mdc-label,
body.light-theme .tile-overlay-mdc-outlined .tile-overlay-mdc-input:not(:placeholder-shown) ~ .tile-overlay-mdc-label,
body.light-theme .tile-overlay-mdc-outlined.tile-overlay-mdc-filled .tile-overlay-mdc-label {
    color: #4f7cff;
    background: #fff;
}

.tile-category-card .budget-card-fixed-btn {
    grid-column: 4;
    grid-row: 2;
    justify-self: end;
}

body.light-theme .tile-category-card {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
}

.tile-category-card .tile-overlay-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-category-card .tile-overlay-icon .tile-overlay-icon-svg {
    font-size: 22px;
}

.tile-overlay-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 52px;
    padding: 12px 12px 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-theme .tile-overlay-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.tile-overlay-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.tile-overlay-header-row-first {
    justify-content: space-between;
}

.tile-overlay-header-row-second {
    justify-content: space-between;
    margin-top: 4px;
}

.tile-overlay-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tile-overlay-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.tile-overlay-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;
    padding: 0;
}

.tile-overlay-icon-btn:hover {
    background: rgba(0, 0, 0, 0.35);
}

body.light-theme .tile-overlay-icon-btn {
    background: #e2e8f0;
}

body.light-theme .tile-overlay-icon-btn:hover {
    background: #cbd5e1;
}

.tile-overlay-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tile-overlay-icon-svg {
    font-size: 28px;
    line-height: 1;
}

.tile-overlay-name-input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    font-size: 18px;
    font-weight: 600;
    color: #f2f2f2;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

.tile-overlay-name-input::placeholder {
    color: #94a3b8;
}

body.light-theme .tile-overlay-name-input {
    color: #1f2937;
    background: #f1f5f9;
    border-color: #e2e8f0;
}

body.light-theme .tile-overlay-name-input::placeholder {
    color: #94a3b8;
}

.tile-overlay-plan-input {
    width: 80px;
    flex-shrink: 0;
    padding: 6px 10px;
    font-size: 16px;
    font-weight: 600;
    color: #f2f2f2;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

body.light-theme .tile-overlay-plan-input {
    color: #1f2937;
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.tile-overlay-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;
    padding: 0;
}

.tile-overlay-fixed-btn .material-icons {
    font-size: 18px;
}

.tile-overlay-fixed-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}

.tile-overlay-fixed-btn.active {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.tile-overlay-fixed-btn.active:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

body.light-theme .tile-overlay-fixed-btn {
    background: rgba(0, 0, 0, 0.06);
    color: #94a3b8;
}

body.light-theme .tile-overlay-fixed-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #64748b;
}

body.light-theme .tile-overlay-fixed-btn.active {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
}

body.light-theme .tile-overlay-fixed-btn.active:hover {
    background: rgba(239, 68, 68, 0.22);
    color: #b91c1c;
}

.tile-overlay-color-swatch {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.2s, transform 0.2s;
}

.tile-overlay-color-swatch:hover {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

body.light-theme .tile-overlay-color-swatch {
    border-color: rgba(0, 0, 0, 0.15);
}

body.light-theme .tile-overlay-color-swatch:hover {
    border-color: rgba(0, 0, 0, 0.3);
}

/* Group selector inside tile overlay card (3rd row, spans all columns) */
.tile-overlay-group-selector {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tile-overlay-group-selector.hidden {
    display: none;
}

.tile-overlay-group-select-wrap.tile-overlay-mdc-outlined {
    min-width: 0;
}

.tile-overlay-group-select-wrap .tile-overlay-group-select {
    padding: 14px 32px 6px 12px;
    border: none;
    background-color: transparent;
}

.tile-overlay-group-select-wrap:hover .tile-overlay-group-select {
    background-color: transparent;
}

/* Group selector: label embedded in top border (notch); opaque bg in dark theme */
.tile-overlay-group-select-wrap .tile-overlay-mdc-label {
    top: 0;
    transform: translateY(-50%) scale(0.75);
    transform-origin: left top;
    font-size: 12px;
    color: #94a3b8;
    z-index: 1;
    background: #252525;
    padding: 0 6px;
    margin-left: -6px;
}

body.light-theme .tile-overlay-group-select-wrap .tile-overlay-mdc-label {
    color: #4f7cff;
    background: #fff;
}

.tile-overlay-group-select {
    width: 100%;
    padding: 7px 32px 7px 10px;
    font-size: 14px;
    font-family: inherit;
    color: #e2e8f0;
    background-color: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 20px;
}

.tile-overlay-group-select option {
    background: #2a2a2a;
    color: #e2e8f0;
}

.tile-overlay-group-select:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.22);
}

.tile-overlay-group-select:focus {
    outline: none;
    border-color: #5b8def;
}

body.light-theme .tile-overlay-group-select {
    color: #1f2937;
    background-color: #f1f5f9;
    border-color: #e2e8f0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24'%3E%3Cpath fill='%2364748b' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

body.light-theme .tile-overlay-group-select option {
    background: #fff;
    color: #1f2937;
}

body.light-theme .tile-overlay-group-select:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
}

body.light-theme .tile-overlay-group-select:focus {
    border-color: #4f7cff;
}

.tile-overlay-header-error {
    font-size: 12px;
    color: #f87171;
}

body.light-theme .tile-overlay-header-error {
    color: #dc2626;
}

.tile-overlay-header-error.hidden {
    display: none;
}

.tile-overlay-header-error:not(.hidden) {
    flex: 1;
    min-width: 0;
}

.tile-overlay-delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 14px;
    color: #f87171;
    background: transparent;
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.tile-overlay-delete-btn:hover {
    background: rgba(248, 113, 113, 0.15);
    color: #fca5a5;
    border-color: rgba(248, 113, 113, 0.5);
}

.tile-overlay-delete-btn .material-icons {
    font-size: 18px;
}

body.light-theme .tile-overlay-delete-btn {
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.4);
}

body.light-theme .tile-overlay-delete-btn:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
    border-color: rgba(220, 38, 38, 0.5);
}

.tile-overlay-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f2f2f2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.light-theme .tile-overlay-title {
    color: #1f2937;
}

.tile-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;
    flex-shrink: 0;
}

.tile-overlay-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

body.light-theme .tile-overlay-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
}

.tile-overlay-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;
    background: #1f1f1f;
    flex-shrink: 0;
}

body.light-theme .tile-overlay-list-header {
    background: #fff;
    color: #64748b;
}

.tile-overlay-list-header-date {
    width: 150px;
    flex-shrink: 0;
}

.tile-overlay-list-header-amount {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.tile-overlay-list-header-actions {
    width: 48px;
    flex-shrink: 0;
}

.tile-overlay-list-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 20px 12px 12px;
}

.tile-overlay-expenses-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tile-overlay-expense-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
}

body.light-theme .tile-overlay-expense-card {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.1);
}

.tile-overlay-expense-date {
    width: 150px;
    flex-shrink: 0;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: 400;
    color: #e2e8f0;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-sizing: border-box;
}

.tile-overlay-expense-date:focus {
    outline: none;
    border-color: #5b8def;
}

body.light-theme .tile-overlay-expense-date {
    color: #1e293b;
    background: #f1f5f9;
    border-color: rgba(0, 0, 0, 0.12);
}

.tile-overlay-expense-amount {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 14px;
    font-weight: 400;
    text-align: right;
    color: #f1f5f9;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    box-sizing: border-box;
}

.tile-overlay-expense-amount:focus {
    outline: none;
    border-color: #5b8def;
}

body.light-theme .tile-overlay-expense-amount {
    color: #1e293b;
    background: #f1f5f9;
}

.tile-overlay-expense-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;
}

.tile-overlay-expense-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.tile-overlay-expense-confirm {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 15;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tile-overlay-expense-confirm.active {
    display: flex;
}

.tile-overlay-expense-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

.tile-overlay-expense-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 .tile-overlay-expense-confirm-box {
    background: #fff;
    color: #1e293b;
    border-color: rgba(0, 0, 0, 0.1);
}

.tile-overlay-expense-confirm-text {
    margin: 0 0 20px;
    font-size: 16px;
}

.tile-overlay-expense-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.tile-overlay-expense-confirm-delete {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    background: #dc2626;
    color: #fff;
    cursor: pointer;
}

.tile-overlay-expense-confirm-delete:hover {
    background: #b91c1c;
}

.tile-overlay-expense-confirm-cancel {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    cursor: pointer;
}

.tile-overlay-expense-confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

body.light-theme .tile-overlay-expense-confirm-cancel {
    background: #f1f5f9;
    color: #64748b;
}

body.light-theme .tile-overlay-expense-confirm-cancel:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Диалог подтверждения удаления категории в tile overlay */
#tileOverlayDeleteConfirm.budget-confirm {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 15;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#tileOverlayDeleteConfirm.budget-confirm.active {
    display: flex;
}

#tileOverlayDeleteConfirm .budget-confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}

#tileOverlayDeleteConfirm .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 #tileOverlayDeleteConfirm .budget-confirm-box {
    background: #fff;
    color: #1e293b;
    border-color: rgba(0, 0, 0, 0.1);
}

#tileOverlayDeleteConfirm .budget-confirm-text {
    margin: 0 0 20px;
    font-size: 16px;
}

#tileOverlayDeleteConfirm .budget-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

#tileOverlayDeleteConfirm .budget-confirm-btn {
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#tileOverlayDeleteConfirm .budget-confirm-delete {
    background: #dc2626;
    color: #fff;
}

#tileOverlayDeleteConfirm .budget-confirm-delete:hover {
    background: #b91c1c;
}

#tileOverlayDeleteConfirm .budget-confirm-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

#tileOverlayDeleteConfirm .budget-confirm-cancel:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
}

body.light-theme #tileOverlayDeleteConfirm .budget-confirm-cancel {
    background: #f1f5f9;
    color: #64748b;
}

body.light-theme #tileOverlayDeleteConfirm .budget-confirm-cancel:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Full-screen auth page (email entry) */
.auth-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    background: #121212;
    color: #f2f2f2;
    box-sizing: border-box;
}

.auth-screen.active {
    display: flex;
    flex-direction: column;
}

body.light-theme .auth-screen {
    background: #f8fafc;
    color: #1f2937;
}

.auth-screen-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1;
    background: #1a1a1a;
    border-bottom: 1px solid #2d2d2d;
}

body.light-theme .auth-screen-header {
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.auth-screen-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 0 12px;
}

.auth-screen-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.auth-lang-select {
    height: 32px;
    padding: 0 6px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    color: #94a3b8;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    min-width: 44px;
    text-align: center;
}

.auth-lang-select:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.08);
}

.auth-lang-select option {
    background: #1e293b;
    color: #e2e8f0;
    font-weight: 400;
}

body.light-theme .auth-lang-select {
    color: #64748b;
}

body.light-theme .auth-lang-select:hover {
    color: #334155;
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme .auth-lang-select option {
    background: #fff;
    color: #1e293b;
}

.auth-screen-title {
    margin: 0 0 0 6px;
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
}

body.light-theme .auth-screen-title {
    color: #1e293b;
}

.auth-screen-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    padding: 16px;
    text-align: center;
    box-sizing: border-box;
}

.auth-screen-message {
    margin: 0 0 28px;
    font-size: 0.95rem;
    line-height: 1.45;
    color: #94a3b8;
}

body.light-theme .auth-screen-message {
    color: #64748b;
}

.auth-screen-message.auth-message-error {
    color: #ef4444;
}

body.light-theme .auth-screen-message.auth-message-error {
    color: #dc2626;
}

/* Form: strict column */
#authScreen .auth-screen-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}
#authScreen .auth-screen-form .auth-screen-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
}
#authScreen .auth-screen-form .auth-screen-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}
#authScreen .auth-screen-form .auth-screen-input {
    margin-bottom: 0;
}

#authScreen .auth-screen-form .auth-pin-fields {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 0;
}
#authScreen .auth-screen-form .auth-pin-fields + .auth-screen-submit {
    margin-top: 20px;
}
#authScreen .auth-screen-form .auth-pin-fields .auth-pin-digit {
    width: 2.5em;
    min-width: 0;
    max-width: 3em;
    flex: 1 1 0;
    text-align: center;
    font-size: 1.25rem;
    margin-bottom: 0;
    padding: 12px 2px;
    box-sizing: border-box;
}
@media (max-width: 380px) {
    #authScreen .auth-screen-form .auth-pin-fields {
        gap: 4px;
    }
    #authScreen .auth-screen-form .auth-pin-fields .auth-pin-digit {
        padding: 10px 0;
        font-size: 1.1rem;
    }
}

.auth-screen-input {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #f2f2f2;
    transition: border-color 0.2s, background 0.2s;
}

.auth-screen-input::placeholder {
    color: #64748b;
}

.auth-screen-input:focus {
    outline: none;
    border-color: #5b8def;
    background: rgba(255, 255, 255, 0.08);
}

body.light-theme .auth-screen-input {
    border-color: #e2e8f0;
    background: #fff;
    color: #1f2937;
}

body.light-theme .auth-screen-input::placeholder {
    color: #94a3b8;
}

body.light-theme .auth-screen-input:focus {
    border-color: #4f7cff;
}

.auth-screen-submit {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: #4a90e2;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.auth-screen-submit-spinner {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-screen-submit-spin 0.65s linear infinite;
}

@keyframes auth-screen-submit-spin {
    to { transform: rotate(360deg); }
}

.auth-screen-submit:hover {
    background: #3a7bc8;
}

.auth-screen-submit:active {
    transform: scale(0.98);
}

.auth-screen-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

body.light-theme .auth-screen-submit {
    background: #2563eb;
}

body.light-theme .auth-screen-submit:hover {
    background: #1d4ed8;
}

.input-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.input-overlay.active {
    display: flex;
}

.input-box {
    background: #1f1f1f;
    color: #f2f2f2;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
    min-width: 300px;
    border: 1px solid #333;
}

.input-box h2 {
    margin-bottom: 10px;
    color: #f2f2f2;
    font-size: 18px;
}

.input-box .category-budget {
    color: #667eea;
    font-size: 14px;
    margin-bottom: 20px;
}

.input-box input {
    width: 100%;
    padding: 15px;
    font-size: 24px;
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 20px;
    background: #121212;
    color: #f2f2f2;
}

.input-box input:focus {
    outline: none;
    border-color: #667eea;
}

.input-box button {
    padding: 12px 30px;
    margin: 5px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-cancel {
    background: #333;
    color: #ddd;
}

.btn-cancel:hover {
    background: #3f3f3f;
}

.voice-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
}

.voice-overlay.active {
    display: flex;
}

@media (min-width: 769px) {
    .voice-overlay-box {
        max-width: 960px;
        margin-left: auto;
        margin-right: auto;
    }
}

.voice-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.voice-overlay-box {
    position: relative;
    width: 100%;
    height: 38vh;
    min-height: 300px;
    max-height: min(38vh, 420px);
    background: #1f1f1f;
    color: #f2f2f2;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
    border: 1px solid #333;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.light-theme .voice-overlay-box {
    background: #fff;
    color: #1f2937;
    border-color: #d4d9e2;
}

.voice-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 12px 12px 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-theme .voice-overlay-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.voice-overlay-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f2f2f2;
}

body.light-theme .voice-overlay-title {
    color: #1f2937;
}

.voice-overlay-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
}

.voice-overlay-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.light-theme .voice-overlay-close {
    color: #64748b;
}

body.light-theme .voice-overlay-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1f2937;
}

.voice-overlay-mic {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0 12px;
}

.voice-overlay-mic-circle {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    padding: 0;
    outline: none;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.voice-overlay-mic-circle.listening {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4);
}

.voice-overlay-mic-circle:hover {
    background: rgba(255, 255, 255, 0.18);
}

.voice-overlay-mic-circle.listening:hover {
    background: rgba(239, 68, 68, 0.35);
}

.voice-overlay-mic-circle:active {
    transform: scale(0.96);
}

.voice-overlay-mic-circle:focus,
.voice-overlay-mic-circle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.voice-overlay-mic-circle.listening:focus,
.voice-overlay-mic-circle.listening:focus-visible {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.4);
}

.voice-overlay-mic-icon {
    font-size: 44px;
}

.voice-overlay-ok-icon {
    display: none;
    font-size: 72px;
    color: #22c55e;
    line-height: 1;
}

.voice-overlay-mic-circle.success .voice-overlay-mic-icon {
    display: none;
}

.voice-overlay-mic-circle.success {
    background: transparent;
    box-shadow: none;
}

.voice-overlay-mic-circle.success .voice-overlay-ok-icon {
    display: block;
}

body.light-theme .voice-overlay-mic-circle {
    background: rgba(51, 65, 85, 0.1);
    color: #64748b;
    box-shadow: 0 0 0 3px rgba(51, 65, 85, 0.15);
}

body.light-theme .voice-overlay-mic-circle.listening {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35);
}

body.light-theme .voice-overlay-mic-circle.success {
    background: transparent;
    box-shadow: none;
}

body.light-theme .voice-overlay-ok-icon {
    color: #16a34a;
}

.voice-overlay-lines {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 0 20px;
    gap: 0;
}

.voice-overlay-line {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.75);
}

.voice-overlay-line.voice-overlay-transcript {
    min-height: 2.7em;
    line-height: 1.35;
    padding: 6px 0 8px;
    font-size: 17px;
    font-weight: 500;
    color: #f2f2f2;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.voice-overlay-line.voice-overlay-transcript:empty {
    color: rgba(255, 255, 255, 0.4);
}

.voice-overlay-line.voice-overlay-message {
    min-height: 1.5em;
    padding: 6px 0 8px;
    font-size: 14px;
    white-space: normal;
    overflow: visible;
    word-break: break-word;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.voice-overlay-message .voice-overlay-icon-err {
    font-size: 22px;
    flex-shrink: 0;
    color: #ef4444;
}

.voice-overlay-err-text {
    font-size: 14px;
    line-height: 1.35;
    color: #ef4444;
}

body.light-theme .voice-overlay-message .voice-overlay-icon-err,
body.light-theme .voice-overlay-err-text {
    color: #dc2626;
}

body.light-theme .voice-overlay-line.voice-overlay-transcript {
    color: #1f2937;
}

body.light-theme .voice-overlay-line.voice-overlay-transcript:empty {
    color: rgba(51, 65, 85, 0.5);
}

body.light-theme .voice-overlay-line {
    color: rgba(51, 65, 85, 0.85);
}

body.light-theme .voice-overlay-line.voice-overlay-message {
    color: #1f2937;
}

.voice-overlay-matches {
    flex: 1;
    min-height: 0;
    padding: 0 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.voice-overlay-match-item {
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f2f2f2;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.voice-overlay-match-item:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
}

.voice-overlay-match-item .voice-overlay-match-name {
    font-weight: 600;
}

.voice-overlay-match-item .voice-overlay-match-amount {
    color: #7ba3d4;
    margin-left: 6px;
}

body.light-theme .voice-overlay-match-item {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
    color: #1f2937;
}

body.light-theme .voice-overlay-match-item:hover {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.12);
}

body.light-theme .voice-overlay-match-item .voice-overlay-match-amount {
    color: #4f7cff;
}
