.tile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
}

.tile-overlay.active {
    display: flex;
}

.tile-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.tile-overlay-box {
    position: relative;
    width: 100%;
    max-height: 85vh;
    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;
    color-scheme: light;
}

.tile-overlay-keyboard-open .tile-overlay-box {
    max-height: var(--tile-overlay-vh, 85vh);
}

body.light-theme .tile-overlay-box {
    background: #fff;
    color: #1f2937;
    border-color: #d4d9e2;
}

.tile-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 .tile-overlay-header {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

.tile-overlay-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.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-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;
    margin-right: 8px;
    padding: 8px 10px;
    font-size: 14px;
    color: #1e293b;
    background: #e2e8f0;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.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;
    text-align: right;
    color: #f1f5f9;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid transparent;
    border-radius: 8px;
}

.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-actions {
    display: flex;
    gap: 12px;
    padding: 12px 20px 16px;
    flex-shrink: 0;
}

.tile-overlay-add-btn {
    flex: 1;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    background: transparent;
    color: #e2e8f0;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.tile-overlay-add-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.35);
}

.tile-overlay-save-btn {
    flex: 1;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    border-radius: 12px;
    background: #5b8def;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.tile-overlay-save-btn:hover {
    background: #4a7ad4;
}

body.light-theme .tile-overlay-add-btn {
    border-color: rgba(0, 0, 0, 0.2);
    color: #334155;
}

body.light-theme .tile-overlay-add-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
}

body.light-theme .tile-overlay-save-btn {
    background: #4f7cff;
}

body.light-theme .tile-overlay-save-btn:hover {
    background: #3d6ae6;
}

.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;
}

.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;
}

.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;
}

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);
}

.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;
}

.voice-overlay-message .voice-overlay-icon-ok,
.voice-overlay-message .voice-overlay-icon-err {
    font-size: 22px;
    vertical-align: middle;
}

.voice-overlay-message .voice-overlay-icon-ok {
    color: #22c55e;
}

.voice-overlay-message .voice-overlay-icon-err {
    color: #ef4444;
}

.voice-overlay-err-text {
    margin-top: 4px;
    font-size: 14px;
    line-height: 1.35;
    color: #ef4444;
}

body.light-theme .voice-overlay-message .voice-overlay-icon-ok {
    color: #16a34a;
}

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;
}
