html, body {
    font-family: 'Inter', 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---- Brand app bar ------------------------------------------------------ */
.me-appbar {
    background: linear-gradient(100deg, #0B3322 0%, #15694B 58%, #1E7E5B 100%) !important;
    border-bottom: 2px solid rgba(200, 160, 40, 0.55);
}

.me-brandmark {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: linear-gradient(135deg, #E0B83A 0%, #C8A028 100%);
    color: #2A2300;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
    flex: 0 0 auto;
}

.me-nav {
    text-transform: none;
    font-weight: 500;
    opacity: 0.92;
}

.me-nav-active {
    text-transform: none;
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.16) !important;
    color: #fff !important;
}

/* ---- Page surface ------------------------------------------------------- */
.me-main {
    min-height: 100vh;
}

.me-hero {
    border-radius: 18px;
    background: linear-gradient(120deg, #0E3B2A 0%, #15694B 55%, #237E5C 100%);
    color: #fff;
    overflow: hidden;
    position: relative;
}

.me-hero::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -60px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(224, 184, 58, 0.32) 0%, rgba(224, 184, 58, 0) 70%);
    pointer-events: none;
}

.me-stat-card {
    border-radius: 14px;
    transition: transform .15s ease, box-shadow .15s ease;
    height: 100%;
}

.me-stat-card:hover {
    transform: translateY(-3px);
}

/* Print: show only the report sheet */
@media print {
    .me-appbar,
    .mud-appbar,
    .me-no-print,
    #blazor-error-ui,
    .mud-snackbar-container {
        display: none !important;
    }

    .mud-main-content {
        padding-top: 0 !important;
    }

    .me-print-area {
        box-shadow: none !important;
        border: none !important;
    }

    body {
        background: #fff !important;
    }
}

/* Inter-company loan matrix */
.me-matrix-wrap {
    overflow: auto;
    max-height: 72vh;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 10px;
}

.me-matrix {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.74rem;
    width: max-content;
}

.me-matrix th,
.me-matrix td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    border-right: 1px solid var(--mud-palette-lines-default);
    white-space: nowrap;
}

.me-matrix thead th {
    position: sticky;
    top: 0;
    background: var(--mud-palette-background-grey);
    z-index: 2;
    font-weight: 600;
    max-width: 130px;
    white-space: normal;
    vertical-align: bottom;
}

.me-matrix .num {
    text-align: right;
}

.me-matrix .rowhead,
.me-matrix thead th.corner {
    position: sticky;
    left: 0;
    background: var(--mud-palette-surface);
    z-index: 1;
    font-weight: 600;
    text-align: left;
    max-width: 220px;
    white-space: normal;
}

.me-matrix thead th.corner {
    z-index: 3;
    background: var(--mud-palette-background-grey);
}

.me-matrix .neg {
    color: #c8443b;
}

.me-neg {
    color: #c8443b;
}

/* ---- Auth (login / register) ------------------------------------------- */
.me-auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0B3322 0%, #15694B 55%, #1E7E5B 100%);
    padding: 24px;
}

.me-auth-card {
    width: 100%;
    max-width: 430px;
    background: #fff;
    border-radius: 18px;
    padding: 36px 34px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
    border-top: 4px solid #C8A028;
}

.me-auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }

.me-auth-mark {
    width: 46px; height: 46px; border-radius: 13px;
    background: linear-gradient(135deg, #E0B83A, #C8A028);
    color: #2A2300; font-weight: 800; font-size: 1rem; letter-spacing: .5px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.me-auth-title { font-weight: 700; font-size: 1.1rem; color: #15321F; line-height: 1; }
.me-auth-sub { font-size: .7rem; letter-spacing: 3px; color: #C8A028; font-weight: 600; }
.me-auth-h1 { font-size: 1.5rem; font-weight: 700; color: #15321F; margin: 0 0 4px; }
.me-auth-lead { color: #5B6B63; font-size: .9rem; margin: 0 0 18px; }
.me-auth-label { display: block; font-size: .8rem; font-weight: 600; color: #3a4a42; margin: 12px 0 4px; }

.me-auth-input {
    width: 100%; box-sizing: border-box; padding: 11px 13px;
    border: 1px solid #cdd6d1; border-radius: 10px;
    font-size: .95rem; font-family: inherit; background: #fff; color: #16241d;
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.me-auth-input:focus { border-color: #15694B; box-shadow: 0 0 0 3px rgba(21, 105, 75, 0.15); }

.me-auth-row { display: flex; gap: 12px; }
.me-auth-row > div { flex: 1; }

.me-auth-btn {
    width: 100%; margin-top: 20px; padding: 12px; border: none; border-radius: 10px; cursor: pointer;
    background: linear-gradient(100deg, #0E3B2A, #15694B); color: #fff;
    font-weight: 600; font-size: .95rem; font-family: inherit;
    transition: filter .15s, transform .05s;
}
.me-auth-btn:hover { filter: brightness(1.08); }
.me-auth-btn:active { transform: translateY(1px); }

.me-auth-error {
    background: #fdecea; border: 1px solid #f5c2c0; color: #8a2c25;
    border-radius: 10px; padding: 10px 12px; font-size: .86rem; margin-bottom: 6px;
}
.me-auth-val { color: #c8443b; font-size: .78rem; display: block; margin-top: 3px; }
.me-auth-foot { margin-top: 18px; font-size: .86rem; color: #5B6B63; text-align: center; }
.me-auth-foot a { color: #15694B; font-weight: 600; text-decoration: none; }
.me-auth-foot a:hover { text-decoration: underline; }
.me-auth-foot-note { color: rgba(255, 255, 255, 0.75); font-size: .78rem; margin-top: 18px; }

/* Logout item (a plain form button styled like a menu item) */
.me-logout-item {
    display: flex; align-items: center; width: 100%; border: none; background: none; cursor: pointer;
    font: inherit; color: inherit; padding: 8px 16px; text-align: left;
}
.me-logout-item:hover { background: rgba(0, 0, 0, 0.06); }

.me-matrix tfoot td {
    position: sticky;
    bottom: 0;
    background: var(--mud-palette-background-grey);
    font-weight: 700;
}

.me-matrix tfoot td.rowhead {
    z-index: 2;
}

@media print {
    @page { size: landscape; }
    .me-matrix-wrap { max-height: none; overflow: visible; }
}

/* Clickable / selected table rows */
.me-clickable-rows tbody tr {
    cursor: pointer;
}

.me-row-selected td {
    background-color: var(--mud-palette-primary-hover) !important;
}

.me-row-unmatched td {
    background-color: rgba(200, 68, 59, 0.09) !important;
}

.me-row-partial td {
    background-color: rgba(217, 138, 0, 0.09) !important;
}

/* ---- Blazor error UI ---------------------------------------------------- */
#blazor-error-ui {
    color-scheme: light only;
    background: #ffeded;
    border-top: 1px solid #f5c2c2;
    bottom: 0;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.9rem 1.5rem 0.9rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1100;
    color: #842029;
    font-family: 'Inter', 'Roboto', sans-serif;
}

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

#blazor-error-ui .reload {
    color: #842029;
    font-weight: 600;
}
