html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5I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I2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ─── Budget / Calendar styles ────────────────────────────────────────────── */

.budget-nav {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
}

.budget-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 900px) {
    .budget-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    .calendar-panel {
        flex: 1 1 0;
        min-width: 0;
    }
    .snapshot-side-panel {
        width: 340px;
        flex-shrink: 0;
    }
}

/* State badge */
.badge {
    display: inline-block;
    padding: .2em .55em;
    font-size: .75rem;
    font-weight: 600;
    border-radius: .35em;
    vertical-align: middle;
}
.badge-draft  { background: #e0f0ff; color: #0055aa; border: 1px solid #99ccff; }
.badge-frozen { background: #ddd;    color: #555;    border: 1px solid #bbb; }
.badge-past   { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ── Calendar grid ── */
.month-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: #e5e7eb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

/* Mid-month divider spans full grid width */
.mid-month-divider {
    grid-column: 1 / -1;
    background: #f3f4f6;
    padding: .25rem .5rem;
    text-align: center;
    font-size: .78rem;
    color: #6b7280;
    border-top: 1px dashed #d1d5db;
    border-bottom: 1px dashed #d1d5db;
}

.divider-label { font-style: italic; }

/* ── Day cell ── */
.day-cell {
    background: #fff;
    min-height: 80px;
    padding: 4px;
    font-size: .75rem;
    position: relative;
    overflow: hidden;
}

.day-cell.readonly { background: #fafafa; }

.day-number {
    font-weight: 700;
    font-size: .8rem;
    color: #374151;
    margin-bottom: 2px;
}

/* ── Entries ── */
.entry {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    border-radius: 3px;
    padding: 1px 3px;
    margin-bottom: 2px;
    line-height: 1.2;
}

.income-entry { background: #ecfdf5; border-left: 2px solid #10b981; }
.cost-entry   { background: #fef2f2; border-left: 2px solid #ef4444; }
.entry-clickable { cursor: pointer; }
.entry-clickable:hover { filter: brightness(0.95); }

.entry-icon   { font-size: .7rem; color: inherit; }
.entry-amount { font-weight: 600; }
.entry-desc   { color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.recurring-icon { color: #9ca3af; }

/* ── Add-entry buttons ── */
.add-entry-buttons {
    display: flex;
    gap: 2px;
    margin-top: 4px;
}

.add-btn {
    font-size: .7rem;
    padding: 1px 5px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    background: #f9fafb;
    cursor: pointer;
    line-height: 1.4;
}

.add-income-btn:hover { background: #ecfdf5; border-color: #10b981; }
.add-cost-btn:hover   { background: #fef2f2; border-color: #ef4444; }

/* ── Entry form (inline in day cell) ── */
.entry-form {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: #fff;
    border: 1px solid #6366f1;
    border-radius: 4px;
    padding: 8px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    min-width: 200px;
}

.entry-form h4 {
    margin: 0 0 6px;
    font-size: .85rem;
    color: #1f2937;
}

.entry-form label {
    display: block;
    font-size: .75rem;
    color: #374151;
    margin-bottom: 4px;
}

.entry-form input[type="number"],
.entry-form input[type="text"],
.entry-form select {
    display: block;
    width: 100%;
    padding: 2px 4px;
    font-size: .75rem;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    box-sizing: border-box;
    margin-top: 1px;
}

.entry-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
}

.entry-form .form-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.entry-form button {
    padding: 2px 8px;
    font-size: .75rem;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    cursor: pointer;
    background: #f3f4f6;
}

.entry-form button:first-child {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}

.entry-form button:disabled { opacity: .5; cursor: not-allowed; }

.form-error  { color: #b91c1c; font-size: .72rem; margin-top: 4px; }
.picker-hint { font-size: .72rem; color: #6b7280; }

/* ── Snapshot panel ── */
.snapshot-columns {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.snapshot-col {
    flex: 1 1 200px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: .75rem;
    background: #fafafa;
}

.snapshot-col h4 {
    margin: 0 0 .5rem;
    font-size: .9rem;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: .35rem;
}

.snapshot-column-data p { font-size: .85rem; margin-bottom: .5rem; }
.snapshot-column-data h5 { font-size: .8rem; margin: .5rem 0 .25rem; color: #374151; }

.account-snapshot-row {
    margin-bottom: .75rem;
    font-size: .82rem;
}

.snapshot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    margin-top: .25rem;
}

.snapshot-table td { padding: 2px 4px; border-bottom: 1px solid #f3f4f6; }
.snapshot-table td:last-child { text-align: right; font-weight: 500; }

.shortfall-row td { background: #fef2f2; }
.shortfall-row strong { color: #b91c1c; }

/* ─── ErrorDisplay component ─────────────────────────────────────────────── */

.error-display {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: .5rem .75rem;
    margin-bottom: .75rem;
    font-size: .82rem;
    color: #991b1b;
}

.error-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.error-text { flex: 1; }
.error-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: #991b1b;
    font-size: 1rem;
    padding: 0 .25rem;
    line-height: 1;
    flex-shrink: 0;
}
.error-dismiss:hover { opacity: .7; }

/* ─── EntryPopup <dialog> ─────────────────────────────────────────────────── */

dialog.entry-popup {
    border: none;
    border-radius: 10px;
    padding: 0;
    width: min(480px, 95vw);
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
    overflow: visible;
}

dialog.entry-popup::backdrop {
    background: rgba(0, 0, 0, .5);
}

.popup-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

.popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1.25rem .75rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 10px 10px 0 0;
}

.popup-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
}

.popup-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0 .25rem;
    line-height: 1;
    border-radius: 4px;
}
.popup-close:hover { background: #f3f4f6; color: #111827; }

.popup-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.popup-body label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: .75rem;
}

.popup-body input[type="number"],
.popup-body input[type="text"],
.popup-body select {
    display: block;
    width: 100%;
    padding: .45rem .6rem;
    font-size: .85rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    box-sizing: border-box;
    margin-top: .2rem;
    background: #fff;
}

.popup-body input:focus,
.popup-body select:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 1px;
    border-color: #4f46e5;
}

.popup-body input:disabled,
.popup-body select:disabled {
    background: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.popup-body .checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 400;
}

.popup-body .checkbox-label input[type="checkbox"] {
    width: auto;
    display: inline;
    margin: 0;
}

.popup-confirm-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 5px;
    padding: .6rem .75rem;
    margin-top: .75rem;
    font-size: .83rem;
    color: #92400e;
}

.popup-confirm-row span { flex: 1; font-weight: 500; }

.popup-warning-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 5px;
    padding: .6rem .75rem;
    margin-top: .75rem;
    font-size: .8rem;
    color: #92400e;
}

.popup-info-row {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    border-radius: 5px;
    padding: .6rem .75rem;
    margin-top: .75rem;
    font-size: .83rem;
    color: #065f46;
}

.budget-toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    color: #065f46;
    border-radius: 6px;
    padding: .6rem .9rem;
    margin-bottom: .75rem;
    font-size: .88rem;
}

.budget-toast button {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.popup-footer {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 10px 10px;
}

.btn-primary-sm {
    padding: .4rem 1rem;
    font-size: .83rem;
    background: #4f46e5;
    color: #fff;
    border: 1px solid #4338ca;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
}
.btn-primary-sm:hover:not(:disabled) { background: #4338ca; }
.btn-primary-sm:disabled { opacity: .5; cursor: not-allowed; }

.btn-danger-sm {
    padding: .4rem .9rem;
    font-size: .83rem;
    background: #dc2626;
    color: #fff;
    border: 1px solid #b91c1c;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
}
.btn-danger-sm:hover:not(:disabled) { background: #b91c1c; }
.btn-danger-sm:disabled { opacity: .5; cursor: not-allowed; }

.popup-footer > button:not(.btn-primary-sm):not(.btn-danger-sm) {
    padding: .4rem .9rem;
    font-size: .83rem;
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    cursor: pointer;
}
.popup-footer > button:not(.btn-primary-sm):not(.btn-danger-sm):hover {
    background: #f3f4f6;
}

.popup-footer .spacer { flex: 1; }

/* ─── Entry list scroll cap (US3) ────────────────────────────────────────── */

.entry-list {
    max-height: calc(5 * 2rem);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ─── Mobile popup (bottom sheet) ─────────────────────────────────────────── */

@media (max-width: 640px) {
    dialog.entry-popup {
        width: 100%;
        margin: auto auto 0;
        border-radius: 12px 12px 0 0;
    }
    .popup-header { border-radius: 12px 12px 0 0; }
    .popup-footer { border-radius: 0; }
}

/* ─── Account & Category page layouts ───────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-header h2 { margin: 0; }

.text-muted { color: #6b7280; }

.card {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    background: #fff;
}

.mb-3 { margin-bottom: 1rem; }

.inline-form label,
.inline-edit label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: .5rem;
}

.inline-form input[type="text"],
.inline-form input[type="number"],
.inline-edit input[type="text"],
.inline-edit input[type="number"] {
    display: block;
    width: 100%;
    padding: .4rem .6rem;
    font-size: .85rem;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    box-sizing: border-box;
    margin-top: .2rem;
}

.inline-form h4,
.inline-edit h4 { margin: 0 0 .75rem; font-size: .95rem; }

/* Data table */
.data-table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.data-table th {
    text-align: left;
    padding: .5rem .75rem;
    background: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    color: #374151;
    font-weight: 600;
    white-space: nowrap;
}

.data-table td {
    padding: .5rem .75rem;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: top;
}

.data-table tr:hover td { background: #f9fafb; }
.data-table tr.row-pending-deletion td { background: #fefce8; }

.iban-cell {
    font-family: monospace;
    font-size: .8rem;
    color: #4b5563;
}

/* Action buttons in table */
.action-btns { display: flex; gap: .35rem; flex-wrap: wrap; }

.act-btn {
    padding: .25rem .65rem;
    font-size: .78rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #f9fafb;
    cursor: pointer;
    white-space: nowrap;
}
.act-btn:hover { background: #f3f4f6; }
.act-btn.act-danger { border-color: #fca5a5; color: #b91c1c; }
.act-btn.act-danger:hover { background: #fef2f2; }

/* Confirm dialog (uses same popup classes as EntryPopup) */
dialog.confirm-dialog {
    border: none;
    border-radius: 8px;
    padding: 0;
    width: min(420px, 95vw);
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog.confirm-dialog::backdrop { background: rgba(0,0,0,.5); }

/* Reassignment inline dialog in CategoryList */
.reassign-row td { background: #f0f9ff; }

.reassign-dialog {
    padding: .75rem;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    background: #f0f9ff;
}

.reassign-dialog p { margin: 0 0 .5rem; font-size: .85rem; }

.radio-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    margin-bottom: .35rem;
    cursor: pointer;
}

.radio-label input[type="radio"] { margin: 0; }

/* ─── Auth pages (Login / Register) ─────────────────────────────────────────── */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.auth-card {
    width: min(420px, 95vw);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
}

.auth-card h2 { margin: 0 0 .25rem; font-size: 1.5rem; color: #111827; }
.auth-subtitle { color: #6b7280; font-size: .875rem; margin-bottom: 1.5rem; }
.auth-hint-inline { font-size: .75rem; color: #6b7280; font-weight: 400; }

.auth-card label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: .75rem;
}

.auth-card input[type="email"],
.auth-card input[type="password"] {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    font-size: .875rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
    margin-top: .25rem;
}

.auth-card input:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 1px;
    border-color: #4f46e5;
}

.auth-btn { width: 100%; margin-top: .5rem; padding: .6rem; font-size: .9rem; }

.auth-footer {
    text-align: center;
    margin-top: .75rem;
    font-size: .83rem;
    color: #6b7280;
}

/* ─── Nav logout button ───────────────────────────────────────────────────────── */

.nav-logout { margin-top: auto; }

.nav-logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    width: 100%;
    padding: 0;
}

/* ─── Saving account allocation indicator ────────────────────────────────────── */

.allocation-total {
    font-size: .82rem;
    color: #374151;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: .2rem .6rem;
}

.allocation-warning {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

.allocation-success {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
    font-weight: 600;
}

/* ─── Snapshot deficit (negative net surplus) ────────────────────────────────── */

.snapshot-deficit-row strong { color: #b91c1c; }