html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

/* Blazor root — full viewport */
#app {
    height: 100%;
}

/* ── App-shell container: sidebar + main side by side ─────── */
.app-shell {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: 220px;
    min-width: 220px;        /* never shrinks */
    background: #1b2a4a;
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 10;
}

.sidebar-brand {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    letter-spacing: .02em;
    flex-shrink: 0;
}

.sidebar-tenant {
    padding: 0.55rem 1.25rem 0.75rem;
    color: rgba(255,255,255,0.82);
    font-size: 0.82rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.72);
    padding: 0.55rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar .nav-link svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.13);
}

.sidebar .nav-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    text-align: center;
    flex-shrink: 0;
}

/* ── Main column: top-bar + scrollable content ─────────────── */
.main-content {
    flex: 1;
    min-width: 0;            /* prevent flex blowout */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    flex-shrink: 0;          /* always visible */
    background: #fff;
    min-height: 52px;
    border-bottom: 1px solid #e9ecef;
}

.content-area {
    flex: 1;
    min-height: 0;           /* critical for flex overflow */
    overflow-y: auto;        /* only this scrolls */
    background: #f8f9fa;
}

/* ── User avatar ────────────────────────────────────────────── */
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #1b6ec2;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Auth pages ────────────────────────────────────────────── */
.auth-card {
    background: #fff;
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    color: #6c757d;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

h1:focus {
    outline: none;
}

/* ── Document upload dropzone ──────────────────────────────── */
.upload-dropzone {
    position: relative;
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    background: #f8f9fa;
    transition: border-color 0.2s, background 0.2s;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}

.upload-dropzone:hover,
.upload-dropzone:focus-within {
    border-color: #1b6ec2;
    background: #f0f6ff;
}

.upload-dropzone--selected {
    border-color: #198754;
    border-style: solid;
    background: #f0faf5;
}

.upload-dropzone__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-dropzone__placeholder {
    text-align: center;
    padding: 1.5rem 1rem;
    pointer-events: none;
    z-index: 1;
}

.upload-dropzone__preview {
    width: 100%;
    padding: 1rem 1.25rem;
    pointer-events: none;
    z-index: 1;
}

.upload-dropzone__preview .btn {
    pointer-events: all;
    position: relative;
    z-index: 3;
}

.upload-dropzone__file-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 0.5rem;
    border: 1px solid #dee2e6;
    flex-shrink: 0;
}

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+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYy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gODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) 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;
}

/* ── Toast animations ──────────────────────────────────────── */
@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-slide-in {
    animation: toast-slide-in 0.3s ease-out;
}

.toast-container .toast {
    min-width: 280px;
    max-width: 400px;
}

/* ── Skeleton loaders ──────────────────────────────────────── */
@keyframes skeleton-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #e9ecef 25%,
        #f8f9fa 50%,
        #e9ecef 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}

.skeleton-card {
    width: 100%;
    border-radius: 0.5rem;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-table {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 1rem;
}

.skeleton-table-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 16px;
    align-items: center;
}

.skeleton-table-row .skeleton {
    height: 20px;
    margin: 0;
}

/* ── Transitions and animations ────────────────────────────── */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in {
    animation: fade-in 0.4s ease-out;
}

.slide-in-right {
    animation: slide-in-right 0.4s ease-out;
}

/* Apply fade-in to main content areas */
.content-area > * {
    animation: fade-in 0.3s ease-out;
}

/* Smooth transitions on interactive elements */
.card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn {
    transition: all 0.15s ease-in-out;
}

table tbody tr {
    transition: background-color 0.15s ease;
}

.form-control, .form-select {
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Stagger animation for list items */
@keyframes stagger-fade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table tbody tr {
    animation: stagger-fade 0.3s ease-out;
    animation-fill-mode: both;
}

.table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.table tbody tr:nth-child(2) { animation-delay: 0.1s; }
.table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.table tbody tr:nth-child(4) { animation-delay: 0.2s; }
.table tbody tr:nth-child(5) { animation-delay: 0.25s; }
.table tbody tr:nth-child(n+6) { animation-delay: 0.3s; }

/* Summary cards stagger */
.row .col-md-3:nth-child(1) .card { animation-delay: 0.05s; }
.row .col-md-3:nth-child(2) .card { animation-delay: 0.1s; }
.row .col-md-3:nth-child(3) .card { animation-delay: 0.15s; }
.row .col-md-3:nth-child(4) .card { animation-delay: 0.2s; }

/* ── Empty states ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state-icon {
    color: #dee2e6;
    display: inline-block;
}

.empty-state-title {
    color: #495057;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state-description {
    color: #6c757d;
    max-width: 400px;
    margin: 0 auto;
}

/* ── Responsive: hamburger button (hidden on desktop) ───────── */
.btn-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
    color: #495057;
    flex-shrink: 0;
    border-radius: 0.375rem;
}

.btn-hamburger:hover {
    background: rgba(0,0,0,0.06);
}

/* Sidebar backdrop (mobile overlay behind open sidebar) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1039;
}

/* ── Mobile breakpoint (< 768 px) ───────────────────────────── */
@media (max-width: 767.98px) {
    .btn-hamburger {
        display: flex;
    }

    /* Sidebar slides in from left as a fixed overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 0.25s ease-in-out;
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* Tighten top-bar padding on mobile */
    .top-bar {
        padding-left: 0.5rem !important;
        padding-right: 0.75rem !important;
    }

    /* Reduce page-body padding on small screens */
    .content-area {
        padding: 0.875rem !important;
    }

    /* Auth card: full-width on very small screens */
    .auth-card {
        padding: 1.5rem 1.25rem;
    }

    /* Toasts stretch to fill the screen width */
    .toast-container {
        left: 0.5rem !important;
        right: 0.5rem !important;
        bottom: 0.5rem !important;
        width: auto !important;
    }

    .toast-container .toast {
        min-width: unset;
        max-width: 100%;
    }
}