/* Split layout: fixed page chrome + scrollable body (tables, dashboard, etc.). */

.main:has(.page-layout) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.main:has(.page-layout)>.page-layout {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
}

.page-layout {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Stacked list + record pages: full content width. */
.page-layout:has(.stacked-page) {
    align-items: stretch;
}

.stacked-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
}

.stacked-page>.page-chrome {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

/* List/table pages — frozen gap under search bar matches dashboard title spacing. */
.stacked-page:not(.stacked-page--record)>.page-chrome {
    padding-bottom: var(--content-gutter);
}

.stacked-page>.page-body {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: auto;
}

.stacked-page .page-header,
.stacked-page .table-toolbar {
    width: 100%;
    box-sizing: border-box;
}

.page-chrome {
    flex-shrink: 0;
    background: var(--surface-page-chrome);
    --page-chrome-stack-gap: 0.625rem;
    padding: var(--content-gutter) var(--content-gutter) var(--page-chrome-stack-gap);
    z-index: 5;
}

.page-chrome .page-header {
    margin-bottom: var(--page-chrome-stack-gap);
}

.page-layout--title-only .page-chrome {
    padding: var(--content-gutter);
}

.page-layout--title-only .page-chrome .page-header {
    margin-bottom: 0;
}

.page-chrome .table-toolbar {
    margin-bottom: 0;
}

.page-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0;
    box-sizing: border-box;
    background: var(--content-bg);
}

/* Dashboard, detail, profile, etc. — inset white sections like page-chrome gutter.
   Top/side spacing under the title lives on .page-chrome (frozen), not here. */
.page-layout--title-only .page-body {
    padding: 0 var(--content-gutter) var(--content-gutter);
    display: flex;
    flex-direction: column;
    gap: var(--content-gutter);
}

.page-layout--title-only .page-body>.record-form {
    display: flex;
    flex-direction: column;
    gap: var(--content-gutter);
}