html, body {
    margin: 0;
    min-height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    overflow-wrap: anywhere;
}

.app-startup {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
        max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    place-items: center;
    overflow: auto;
    color: #161d1d;
    background: #f5fafa;
}

.app-startup-card {
    width: min(100%, 360px);
    text-align: center;
}

.app-startup-card img {
    display: block;
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    border-radius: 16px;
}

.app-startup-brand {
    margin-bottom: 22px;
    font-size: 1.25rem;
    font-weight: 750;
}

.app-startup-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 14px;
    border: 3px solid #b8cecc;
    border-top-color: #006a6a;
    border-radius: 50%;
    animation: app-startup-spin .8s linear infinite;
}

.app-startup p {
    margin: 0;
    line-height: 1.5;
}

.app-startup .app-startup-diagnostic {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #b8cecc;
    border-radius: 8px;
    overflow-wrap: anywhere;
    color: #52605f;
    background: #fff;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: .75rem;
    text-align: left;
    user-select: all;
}

.app-startup button {
    min-height: 44px;
    margin-top: 18px;
    padding: 10px 20px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: #006a6a;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.app-startup button:focus-visible {
    outline: 3px solid #006a6a;
    outline-offset: 3px;
}

@keyframes app-startup-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-color-scheme: dark) {
    .app-startup {
        color: #e0e3e2;
        background: #0f1414;
    }

    .app-startup-spinner {
        border-color: #41504f;
        border-top-color: #6edbd5;
    }

    .app-startup .app-startup-diagnostic {
        border-color: #41504f;
        color: #bfc9c8;
        background: #171d1d;
    }
}

img, svg, video, canvas {
    max-width: 100%;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid var(--mud-palette-primary);
    outline-offset: 3px;
}

.page-error-state {
    max-width: 680px;
    margin: clamp(24px, 8vh, 80px) auto;
    text-align: center;
}

.amount { font-variant-numeric: tabular-nums; font-weight: 650; }
.receives { color: var(--mud-palette-success); }
.owes { color: var(--mud-palette-error); }
.neutral { color: var(--mud-palette-text-secondary); }

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-header > * {
    min-width: 0;
}

.project-grid {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 32px;
    align-items: start;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--mud-palette-divider);
}

.sticky-mobile-action { display: none; }

.receipt-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0;
    cursor: pointer;
}

.receipt-capture-retained {
    display: none;
}

.receipt-library-action {
    position: relative;
    display: flex;
    width: fit-content;
    min-height: 44px;
    margin: 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--mud-palette-primary);
    border-radius: 4px;
    color: var(--mud-palette-primary);
    cursor: pointer;
}

.receipt-library-action.is-disabled {
    opacity: .56;
    cursor: not-allowed;
}

.receipt-library-action.is-disabled .receipt-file-input {
    cursor: not-allowed;
}

.receipt-library-action:focus-within {
    outline: 3px solid color-mix(in srgb, var(--mud-palette-primary) 35%, transparent);
    outline-offset: 2px;
}

.receipt-preview {
    display: block;
    width: 100%;
    max-height: 60vh;
    margin-top: 16px;
    border-radius: 12px;
    object-fit: contain;
    background: var(--mud-palette-background-gray);
}

.receipt-preview-frame {
    display: block;
    width: 100%;
    height: min(72vh, 760px);
    min-height: 420px;
    border: 0;
    border-radius: 8px;
    background: var(--mud-palette-background-gray);
}

@media (max-width: 959px) {
    .project-grid { grid-template-columns: 1fr; }
    .balances { order: 0; }
    .workspace { order: 1; }
}

@media (max-width: 599px) {
    .page-header { flex-direction: column; gap: 12px; }

    html.virtual-keyboard-open .project-bottom-navigation {
        display: none;
    }

    html.virtual-keyboard-open .page-shell {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }

    .sticky-mobile-action {
        display: block;
        position: fixed;
        right: 16px;
        bottom: 20px;
        z-index: 5;
    }

    .mud-dialog.receipt-preview-dialog {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        margin: 0;
        border-radius: 0;
    }

    .receipt-preview-frame {
        height: calc(100dvh - 152px);
        min-height: 0;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
    .app-startup-spinner { animation: none; }
}
