/* Shared sizing for the workspace and page-specific controls. */
.app-body {
    --sidebar-width: 196px;
    --rail-width: 49px;
    --topbar-height: 43px;
    --control-height: 31px;
    font-size: .8125rem;
}
.app-body .sidebar {
    --bs-offcanvas-width: min(240px, 82vw);
    min-height: 0;
}
.sidebar-head { min-height: var(--topbar-height); padding: .35rem .65rem; }
.sidebar-brand { gap: .4rem; font-size: .98rem; }
.sidebar-brand img { border-radius: 6px; }
.sidebar-nav { padding: .4rem .3rem; }
.sidebar-nav .side-link { min-height: 34px; padding: .25rem .5rem; gap: .38rem; font-size: .78rem; margin-bottom: .15rem; }
.sidebar-nav .side-link.selected { background: var(--nav-active); box-shadow: inset 2px 0 var(--teal); }
.sidebar-nav .side-link i { flex: 0 0 1.15rem; }
.sidebar-section > summary {
    list-style: none;
    cursor: pointer;
}
.sidebar-section > summary::-webkit-details-marker { display: none; }
.sidebar-section > summary::marker { content: ''; }
.side-link.section-active { color: #fff; background: var(--nav-hover); }
.sidebar-nav .side-chevron {
    flex: 0 0 auto;
    margin-left: auto;
    width: auto;
    font-size: .65rem;
    opacity: .78;
}
.sidebar-section[open] .side-chevron { transform: rotate(90deg); }
.sidebar-sublinks {
    list-style: none;
    margin: .1rem .1rem .38rem .95rem;
    padding: 0 0 0 .45rem;
    border-left: 1px solid var(--nav-edge);
}
.side-sublink {
    display: block;
    min-height: 29px;
    padding: .32rem .43rem;
    border-radius: 5px;
    color: var(--nav-muted);
    font-size: .77rem;
    line-height: 1.2;
    text-decoration: none;
}
.side-sublink:hover, .side-sublink[aria-current="page"] { color: #fff; background: var(--nav-active); }
.sidebar-account { margin-top: .38rem; }
.sidebar-nav :is(a, summary):focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }
.topbar {
    min-height: var(--topbar-height);
    padding: .15rem .65rem;
    box-shadow: 0 1px 2px #1928450b;
}
.topbar-page { font-size: .8rem; }
.topbar .icon-btn { align-items: center; justify-content: center; height: 32px; width: 33px; font-size: 1.05rem; padding: 0; }
.topbar .avatar { width: 26px; height: 26px; border-radius: 6px; }
.topbar .account-button { padding: .12rem .2rem; }
.account-name small { margin-top: 0; font-size: .65rem; }
.content { padding: .62rem .75rem; }
.app-body .page-heading { margin-bottom: .55rem; gap: .45rem; }
.app-body .page-heading h1 { margin-block: 0 .15rem !important; font-size: clamp(1.24rem, 2vw, 1.62rem); letter-spacing: -.034em; }
.page-heading p { font-size: .78rem; }
.page-heading > div > a.small { display: inline-block; margin-bottom: .16rem; }
.app-body .h4, .app-body .h5 { font-size: .99rem; }
.app-body .h6 { font-size: .85rem; }
.app-body .dashboard-panel { padding: .65rem .7rem; }
.app-body .surface { border-radius: 8px; box-shadow: 0 1px 3px #182c5110; }
.app-body .section-heading { margin-bottom: .45rem; gap: .45rem; }
.app-body .section-heading h2 { font-size: .94rem; }
.app-body .section-heading a { font-size: .74rem; }
.app-body .btn {
    --bs-btn-font-size: .76rem;
    --bs-btn-padding-y: .3rem;
    --bs-btn-padding-x: .63rem;
    border-radius: 6px;
    min-height: var(--control-height);
}
.app-body .btn-sm { --bs-btn-font-size: .72rem; --bs-btn-padding-x: .45rem; --bs-btn-padding-y: .18rem; min-height: 27px; }
.app-body .form-label { display: block; margin: 0 0 .16rem; font-size: .755rem; line-height: 1.22; }
.app-body .form-control, .app-body .form-select {
    min-height: var(--control-height);
    border-radius: 5px;
    font-size: .8rem;
    padding-block: .26rem;
}
.app-body .form-control { padding-inline: .5rem; }
.app-body .form-select { padding-inline-start: .5rem; }
.app-body textarea.form-control { min-height: 56px; }
.app-body .form-text { display: block; margin-top: .15rem; font-size: .685rem; line-height: 1.25; }
.app-body :is(.form-control, .form-select, .guardian-step-title, .form-error-summary, .signature-pad, #admissions-trend) {
    scroll-margin-block: calc(var(--topbar-height) + 10px) .5rem;
}
.app-body form .row { --bs-gutter-x: .65rem; --bs-gutter-y: .52rem; }
.app-body .row.g-3 { --bs-gutter-x: .65rem; --bs-gutter-y: .55rem; }
.app-body :is(.dashboard-panel, .modal-body) .mb-3 { margin-bottom: .55rem !important; }
.app-body .modal-header, .app-body .modal-body, .app-body .modal-footer { padding: .6rem .72rem; }
.app-body .modal-footer > * { margin: .14rem; }
.directory-filters { padding: .5rem .65rem; gap: .45rem; }
.app-body .directory-filters > .btn { min-height: var(--control-height); }
.directory-table th, .directory-table td { padding: .4rem .65rem; }
.directory-table td { font-size: .78rem; }
.directory-footer { padding: .45rem .65rem; }
.activity-row { padding-block: .3rem; font-size: .78rem; }
.app-body .status-pill { padding: .16rem .4rem; font-size: .68rem; }
.student-heading-info { margin-top: .22rem; gap: .48rem; }
.student-portrait { flex-basis: 40px; width: 40px; height: 40px; border-radius: 8px; font-size: 1.05rem; }
.guardian-portrait { flex-basis: 43px; width: 43px; height: 43px; border-radius: 8px; }
.app-body :is(.intake-steps, .student-tabs) {
    gap: .23rem;
    padding: .22rem;
    margin-bottom: .45rem;
    border-radius: 7px;
}
.app-body .intake-steps > :is(a, button, span),
.app-body .student-tabs a {
    min-height: 30px;
    border-radius: 5px;
    padding: .2rem .32rem;
    gap: .28rem;
    font-size: .745rem;
    white-space: normal;
}
.app-body .intake-steps > :is(a, button, span) > span {
    flex-basis: 16px;
    width: 16px;
    height: 16px;
    font-size: .66rem;
}
.app-body .intake-navigation > summary {
    padding: .35rem .55rem;
    border-radius: 6px;
}
.app-body .intake-navigation { margin-bottom: .45rem; }
.intake-section-header, .intake-repeat-heading, .intake-row-head {
    gap: .35rem;
    margin-bottom: .48rem;
    padding-bottom: .34rem;
}
.intake-section-header p { margin-bottom: .18rem !important; }
.intake-grid { gap: .48rem .66rem; }
.intake-repeat h3 { font-size: .86rem; }
.intake-repeat, .intake-row, .intake-review-section, .student-optional {
    padding: .48rem .55rem;
    border-radius: 7px;
}
.intake-row { margin-block: .35rem; }
.intake-review-section { margin-bottom: .36rem; }
.intake-review-list { gap: .25rem .6rem; margin-block: .36rem; }
.intake-choices, .intake-results, .intake-selected { gap: .27rem; }
.intake-choice, .intake-chip { min-height: 27px; gap: .28rem; padding: .17rem .38rem; border-radius: 5px; font-size: .75rem; }
.intake-choice input { margin: 0; }
.intake-check { padding: .06rem 0 .06rem 1.4rem; min-height: 1rem; }
.app-body .intake-age { margin-bottom: .45rem; padding: .26rem .4rem; font-size: .75rem; }
.intake-actions, .guardian-actions { margin-top: .55rem; padding-top: .4rem; gap: .35rem; }
.guardian-section { margin-bottom: .35rem; }
.guardian-section > summary { padding: .45rem .6rem; }
.guardian-section-body { padding: .63rem .7rem; }
.guardian-step-title { font-size: .98rem; margin-bottom: .5rem; padding-bottom: .35rem; }
.guardian-form > p.small { margin-bottom: .3rem; }
.student-optional, .student-save { margin-top: .5rem; }
.student-document {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .15rem .4rem;
    padding: .34rem 0;
    border-top: 1px solid var(--stroke);
}
.student-document > p { grid-column: 1 / -1; }
.student-document > details { align-self: center; margin-top: 0 !important; }
.student-document .saved-file { margin: 0; }

.file-preview { margin-top: .27rem; padding: .24rem .33rem; gap: .37rem; border-radius: 6px; }
.saved-file { margin-block: .15rem .33rem; }
.file-preview img, .file-thumb, .file-preview-icon { width: 41px; height: 35px; flex: 0 0 41px; border-radius: 4px; }
.file-preview img { display: block; object-fit: contain; }
.file-preview-details strong { font-size: .72rem; line-height: 1.24; }
.file-preview-details small { font-size: .655rem; }
.file-preview-actions { display: flex; flex-wrap: wrap; gap: .2rem; }
.image-preview-body { text-align: center; }
.image-preview-body img { display: block; max-width: 100%; max-height: 74vh; margin-inline: auto; object-fit: contain; }
.app-toasts { top: 3.1rem; }

.intake-signing {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(0, 2fr);
    gap: .65rem;
    margin-top: .6rem;
    align-items: start;
}
.signature-pad { max-width: 550px; }
.signature-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .45rem; margin-bottom: .25rem; }
.signature-pad canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 10/3;
    border: 1px solid var(--blue-edge);
    border-radius: 6px;
    background: linear-gradient(transparent 77%, var(--stroke) 77%, var(--stroke) 78%, transparent 78%), var(--blue-wash);
    cursor: crosshair;
    touch-action: none;
}
.saved-signature {
    display: block;
    width: 170px;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--stroke);
    border-radius: 5px;
    background: var(--blue-wash);
    margin-top: .2rem;
}
.admission-signature-review { margin-top: .4rem; }

/* Management overview */
.management-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .52rem; margin-bottom: .58rem; }
.management-metric {
    min-height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .3rem;
    padding: .47rem .56rem;
    color: var(--ink);
    text-decoration: none;
}
.management-metric:hover { border-color: var(--focus-blue); color: var(--blue); }
.metric-copy { min-width: 0; }
.management-metric .metric-label { display: block; font-size: .72rem; font-weight: 550; line-height: 1.22; }
.management-metric .metric-number { display: block; margin-top: .12rem; font-size: 1.35rem; line-height: 1.1; }
.management-metric .metric-icon { width: 29px; height: 29px; font-size: .88rem; border-radius: 7px; }
.metric-icon.navy-tint { background: var(--blue-wash); color: var(--navy); }
.management-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .55rem; align-items: stretch; }
.trend-panel { grid-column: span 2; }
.trend-panel .section-heading p { font-size: .7rem; }
.chart-period { display: flex; gap: .11rem; padding: .14rem; background: var(--blue-soft); border-radius: 6px; }
.chart-period a { padding: .24rem .4rem; border-radius: 4px; }
.chart-period [aria-current] { background: #fff; color: var(--blue); box-shadow: 0 1px 3px #17233b18; }
.admissions-graph {
    --plot-height: 112px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: .35rem;
    margin-top: .7rem;
}
.graph-axis { display: flex; flex-direction: column; justify-content: space-between; height: calc(var(--plot-height) + .55rem); transform: translateY(-.27rem); text-align: right; }
.graph-axis span, .graph-label { color: var(--muted); font-size: .65rem; line-height: .8rem; }
.graph-months {
    display: grid;
    grid-template-columns: repeat(var(--month-count), minmax(0, 1fr));
    background: repeating-linear-gradient(to bottom, var(--stroke) 0 1px, transparent 1px 25%) top / 100% var(--plot-height) no-repeat;
}
.graph-month { text-align: center; min-width: 0; }
.graph-track { display: flex; align-items: flex-end; justify-content: center; height: var(--plot-height); border-bottom: 1px solid var(--stroke); }
.graph-bar { width: 60%; max-width: 35px; height: var(--bar-height); border-radius: 4px 4px 0 0; background: var(--blue); }
.graph-month:hover .graph-bar { background: var(--blue-hover); }
.graph-label { display: block; margin-top: .2rem; }
.dashboard-bar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .15rem .35rem;
    padding: .27rem 0;
    color: var(--ink);
    text-decoration: none;
    font-size: .74rem;
}
.dashboard-bar-row strong { font-variant-numeric: tabular-nums; }
.dashboard-bar-track { grid-column: 1 / -1; height: 5px; border-radius: 4px; background: var(--blue-soft); }
.dashboard-bar-track span { display: block; width: clamp(0%, var(--value), 100%); height: 100%; border-radius: inherit; background: var(--blue); }
.classroom-panel .dashboard-bar-track span { background: var(--teal-chart); }
.classroom-roll { max-height: 165px; overflow: auto; }
.dashboard-record {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .35rem;
    min-height: 34px;
    padding: .23rem 0;
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--stroke);
}
.dashboard-record:last-child { border: 0; }
.dashboard-record small, .dashboard-record time { color: var(--muted); font-size: .67rem; }
.dashboard-record small { display: block; }
.dashboard-record time { white-space: nowrap; }

.staff-activity { margin-top: .55rem; }
.staff-activity > summary { font-weight: 630; cursor: pointer; }

@media (min-width: 768px) {
    .app-body .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); background: var(--navy) !important; }
    .app-main { margin-left: var(--sidebar-width); }
    .app-body.navigation-collapsed { --sidebar-width: var(--rail-width); }
    .navigation-collapsed :is(.sidebar-brand, .sidebar-nav .side-link) { justify-content: center; }
    .navigation-collapsed :is(.sidebar-brand span, .side-link span, .side-link .side-chevron, .sidebar-sublinks) { display: none; }
    .navigation-collapsed .sidebar-head { justify-content: center; padding-inline: 0; }
    .intake-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .app-body .intake-steps { grid-template-columns: repeat(8, minmax(0, 1fr)); }
    .app-body .guardian-steps { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

@media (min-width: 768px) and (max-width: 899.98px) {
    .app-body .intake-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1450px) {
    .intake-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1023.98px) {
    .management-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .content { padding: .5rem; }
    .app-body .sidebar-nav :is(.side-link, .side-sublink) { min-height: 39px; }
    .management-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-body .intake-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .app-body .intake-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .student-directory .directory-table tr { padding: .45rem .6rem; gap: .25rem .4rem; }
    .student-directory .student-list-action a { min-height: 30px; }
    .app-body .intake-actions button { flex: 0 1 auto; }
}

@media (max-width: 500px) {
    .management-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .management-grid, .app-body .intake-grid, .intake-signing { grid-template-columns: 1fr; }
    .trend-panel { grid-column: auto; }
    .app-body .intake-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-body .page-heading { align-items: flex-start; }
    .app-body .directory-filters { align-items: flex-end; }
    .student-document { grid-template-columns: 1fr; }
}

@media (pointer: coarse) {
    .app-body { --control-height: 35px; }
    .app-body .btn-sm { min-height: 32px; }
    .app-body .intake-choice { min-height: 34px; }
}
