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

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    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+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) 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: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem 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;
}

:root {
    color-scheme: light;
    --bg: rgba(37, 99, 235, 0.08);
    --surface: #ffffff;
    --border: #e6e9f2;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    --unreaded-bg: #f5f7fb;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Inter", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-row {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.top-row.app-header {
    padding: 0 1.5em;
}

.top-row .app-title-link {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    background: none;
    border: none;
    transition: background-color 0.15s ease-in-out;
    width: auto;
    max-width: 100%;
    justify-content: flex-start;
}

.top-row .app-title-link:hover,
.top-row .app-title-link:focus {
    background-color: rgba(31, 42, 68, 0.08);
    outline: none;
}

.top-row .app-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.top-row .user-info {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.top-row .user-name {
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.top-row .user-email {
    font-size: 0.85rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.top-row .icon-btn {
    padding: 0;
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    color: var(--text);
    background: transparent;
    border: none;
}

.top-row .icon-btn:hover {
    background-color: rgba(31, 42, 68, 0.08);
}

.top-row .menu-container {
    position: relative;
}

.top-row .user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    min-width: 180px;
    padding: 0.35rem;
    z-index: 10;
}

.top-row .user-menu-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.4rem;
    color: var(--text);
}

.top-row .user-menu-item:hover {
    background-color: rgba(31, 42, 68, 0.08);
}

.top-row .bi-gear-fill-header {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    background-size: cover;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='currentColor' class='bi bi-gear-fill' viewBox='0 0 16 16'%3E%3Cpath d='M9.405 1.05c-.413-1.4-2.397-1.4-2.81 0l-.1.34a1.464 1.464 0 0 1-2.105.872l-.31-.17c-1.283-.698-2.686.705-1.987 1.987l.169.311c.446.82.023 1.841-.872 2.105l-.34.1c-1.4.413-1.4 2.397 0 2.81l.34.1a1.464 1.464 0 0 1 .872 2.105l-.17.31c-.698 1.283.705 2.686 1.987 1.987l.311-.169a1.464 1.464 0 0 1 2.105.872l.1.34c.413 1.4 2.397 1.4 2.81 0l.1-.34a1.464 1.464 0 0 1 2.105-.872l.31.17c1.283.698 2.686-.705 1.987-1.987l-.169-.311a1.464 1.464 0 0 1 .872-2.105l.34-.1c1.4-.413 1.4-2.397 0-2.81l-.34-.1a1.464 1.464 0 0 1-.872-2.105l.17-.31c.698-1.283-.705-2.686-1.987-1.987l-.311.169a1.464 1.464 0 0 1-2.105-.872zM8 10.93a2.929 2.929 0 1 1 0-5.86 2.929 2.929 0 0 1 0 5.858z'/%3E%3C/svg%3E");
}

.app-content {
    padding: 2rem;
    flex: 1 1 auto;
    min-height: 0;
    height: calc(100vh - 3.5rem);
    overflow: hidden;
}

@media (max-width: 640.98px) {
    .top-row {
        justify-content: space-between;
    }

    .top-row .app-actions {
        gap: 0.75rem;
    }

    .top-row .app-title-link {
        font-size: 0.95rem;
    }
}

.page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    min-height: 0;
}

.toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 180px;
}

.field-grow {
    flex: 1 1 320px;
}

.field-label {
    font-size: 0.85rem;
    color: var(--muted);
}

.field-input {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
    background: #fff;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0.65rem 1.4rem;
    font-weight: 600;
    cursor: pointer;
    height: fit-content;
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 0.75rem 1rem;
    border-radius: 12px;
}

.mail-view {
    height: 100%;
    flex: 1 1 auto;
    min-height: 0;
    box-sizing: border-box;
}

.mail-list,
.mail-details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    height: calc(100% - 3.5rem);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
    box-sizing: border-box;
}

.list-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-columns {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) minmax(140px, 1fr) minmax(120px, 0.8fr) minmax(90px, 0.6fr);
    gap: 1rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.list-meta {
    color: var(--muted);
    font-size: 0.85rem;
}

.list-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.list-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
}

.list-item {
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.list-item.unread {
    background: var(--unreaded-bg);
}

.list-item.read {
    background: white;
}

.list-item:hover {
    background: rgba(31, 42, 68, 0.08);
}

.list-item:last-child {
    border-bottom: none;
}

.list-row {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) minmax(140px, 1fr) minmax(120px, 0.8fr) minmax(90px, 0.6fr);
    gap: 1rem;
    align-items: center;
}

.row-subject {
    font-weight: 600;
}

.row-from,
.row-date {
    color: var(--muted);
    font-size: 0.9rem;
}

.row-status {
    display: flex;
    justify-content: flex-start;
}

.dot {
    font-size: 0.6rem;
}

.list-placeholder,
.details-placeholder {
    padding: 2rem;
    text-align: center;
    color: var(--muted);
}

.mail-details {
    padding: 1.25rem;
}

.details-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-top: 1rem;
    min-height: 0;
}

.details-actions {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.details-meta {
    color: var(--muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.details-section {
    padding-top: 1rem;
}

.details-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.details-message {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    white-space: pre-wrap;
}

.debts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}

.debt-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    background: #f9fafb;
}

.debt-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.debt-title {
    font-weight: 600;
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

.status-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    white-space: nowrap;
}

.status-success {
    background: #dcfce7;
    color: var(--success);
}

.status-warning {
    background: #fef3c7;
    color: var(--warning);
}

.status-danger {
    background: #fee2e2;
    color: var(--danger);
}

.status-info {
    background: #e0f2fe;
    color: var(--info);
}

.status-pending {
    background: #e0e7ff;
    color: #4338ca;
}

.status-muted {
    background: #f3f4f6;
    color: var(--muted);
}

@media (max-width: 1024px) {
    .list-columns,
    .list-row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
}

.login-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(circle at top, #eef2ff, #f5f7fb 60%);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem 2.5rem;
    width: min(420px, 100%);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

.login-header h3 {
    margin: 0 0 0.25rem 0;
}

.login-header p {
    margin: 0 0 1.5rem 0;
    color: var(--muted);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.form-control {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    font-size: 0.95rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: 12px;
    padding: 0.65rem 1.4rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.alert {
    border-radius: 12px;
    padding: 0.75rem 1rem;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
