/* Application layout. Colours and type come from brand.css. Works from 320 px wide. */

body.app {
    background: var(--page);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.5;
}

.app h1, .app h2, .app h3, .app .btn, .money {
    font-family: var(--font-display);
}

.app h1 { font-size: 1.75rem; margin: 0 0 1rem; }
.app h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }

/* Visible focus everywhere (WCAG 2.4.7, 2.4.11). */
.app :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    box-shadow: none;
}

.skip-link {
    position: absolute;
    left: .5rem;
    top: -4rem;
    z-index: 1000;
    padding: .5rem 1rem;
    background: var(--brand);
    color: var(--on-brand);
    border-radius: var(--radius-control);
}

.skip-link:focus {
    top: .5rem;
}

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.app-header__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: .5rem 1rem;
}

.app-header__logo img { height: 28px; width: auto; display: block; }
.app-header__spacer { flex: 1 1 auto; }

.dossier-switch { position: relative; }

.dossier-switch__menu, .new-menu__menu {
    position: absolute;
    right: 0;
    z-index: 50;
    min-width: 16rem;
    max-width: calc(100vw - 2rem);
    margin-top: .25rem;
    padding: .5rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.dossier-switch__menu a, .new-menu__menu a, .new-menu__menu span {
    display: block;
    padding: .5rem 1rem;
    color: var(--text);
    text-decoration: none;
}

.dossier-switch__menu a:hover, .new-menu__menu a:hover { background: var(--mist); }
.dossier-switch__menu [aria-current="true"] { font-weight: 700; }
.new-menu { position: relative; }

.app-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.app-nav ul {
    display: flex;
    gap: .25rem;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 1rem;
    list-style: none;
    overflow-x: auto;
}

.app-nav a {
    display: block;
    padding: .75rem .9rem;
    color: var(--text-soft);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
}

.app-nav a[aria-current="page"] {
    color: var(--text);
    border-bottom-color: var(--brand);
    font-weight: 700;
}

.app-main {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 1.5rem 1rem 6rem;
}

.app-footer {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 1rem;
    color: var(--text-soft);
    font-size: .875rem;
}

/* Mobile: main navigation as a bottom bar. */
@media (max-width: 767.98px) {
    .app-nav {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 40;
        border-top: 1px solid var(--line);
        border-bottom: 0;
    }

    .app-nav ul { justify-content: space-between; padding: 0; }
    .app-nav a { padding: .6rem .5rem; font-size: .875rem; border-bottom: 0; border-top: 3px solid transparent; }
    .app-nav a[aria-current="page"] { border-top-color: var(--brand); }
    .app-header__wide { display: none; }
}

.btn-brand {
    background: var(--brand);
    color: var(--on-brand);
    border-radius: var(--radius-control);
    border: 0;
    padding: .55rem 1rem;
}

.btn-brand:hover, .btn-brand:focus { background: var(--ink-deep); color: #fff; }

.sheet {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sheet);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .1rem .55rem;
    border-radius: 999px;
    font-size: .875rem;
    border: 1px solid currentColor;
    white-space: nowrap;
}

.badge-status--neutral { color: var(--text-soft); }
.badge-status--info { color: var(--ink); }
.badge-status--success { color: var(--paid); }
.badge-status--warning { color: #7a4b00; background: #fff4d6; }
.badge-status--danger { color: var(--alert); }

@media (prefers-color-scheme: dark) {
    .badge-status--info { color: var(--sky); }
    .badge-status--success { color: #6fd3a3; }
    .badge-status--warning { color: #ffd77a; background: transparent; }
    .badge-status--danger { color: #ff9c94; }
}

.money {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Tables become stacked cards on narrow screens, without horizontal scrolling. */
.table-responsive-stack { width: 100%; border-collapse: collapse; }
.table-responsive-stack th, .table-responsive-stack td { padding: .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }

@media (max-width: 575.98px) {
    .table-responsive-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table-responsive-stack tr { display: block; padding: .5rem 0; border-bottom: 1px solid var(--line); }
    .table-responsive-stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem 0; }
    .table-responsive-stack td::before { content: attr(data-label); font-weight: 700; color: var(--text-soft); }
}

/* Forms: label above the field, error under the field and in a summary at the top. */
.app .form-label { font-weight: 700; }
.app .invalid-feedback { display: block; color: var(--alert); }
.error-summary { border-left: 4px solid var(--alert); background: var(--mist); padding: .75rem 1rem; margin-bottom: 1rem; }
.status-region:empty { display: none; }

.visually-hidden-focusable:not(:focus):not(:focus-within) { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; }

.form-inline-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-inline-actions form { margin: 0; }

[x-cloak] { display: none !important; }
