/* ECEDAIA mobile layer. Keep this stylesheet last in the cascade. */

@media (max-width: 980px) {
    html,
    body,
    #app {
        max-width: 100%;
        min-width: 0;
        overflow-x: clip;
    }

    body {
        min-height: 100dvh;
        -webkit-text-size-adjust: 100%;
    }

    body:has(.shell-app:not(.is-sidebar-collapsed)) {
        overflow: hidden;
    }

    img,
    video,
    canvas,
    svg {
        max-width: 100%;
    }

    .shell-app,
    .shell-main,
    .shell-content,
    .shell-section,
    .workspace-shell,
    .workspace-switcher__content,
    .workspace-switcher__panel,
    .workspace-collection,
    .teacher-support-shell,
    .teacher-academic-view,
    .teacher-planner-view,
    .teacher-coordination-shell,
    .teacher-written-tests-shell,
    .teacher-lms-shell,
    .communication-shell,
    .attendance-module,
    .student-life-search,
    .student-life-detail,
    .school-pae-overview {
        max-width: 100%;
        min-width: 0;
    }

    .shell-app {
        display: block;
        min-height: 100dvh;
    }

    .shell-sidebar {
        border: 0;
        border-right: 1px solid rgba(195, 222, 248, 0.24);
        bottom: 0;
        box-shadow: 16px 0 36px rgba(7, 45, 73, 0.24);
        height: 100dvh;
        left: 0;
        max-height: 100dvh;
        max-width: min(86vw, 320px);
        min-width: min(86vw, 320px);
        opacity: 1;
        overflow-x: hidden;
        overflow-y: auto;
        padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        pointer-events: auto;
        position: fixed;
        top: 0;
        transform: translateX(0);
        transition: transform 0.2s ease, opacity 0.2s ease;
        width: min(86vw, 320px);
        z-index: 220;
    }

    .shell-app.is-sidebar-collapsed .shell-sidebar {
        border-right-color: transparent;
        box-shadow: none;
        min-width: min(86vw, 320px);
        opacity: 0;
        padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        pointer-events: none;
        transform: translateX(-105%);
        width: min(86vw, 320px);
    }

    .shell-sidebar-backdrop {
        background: rgba(10, 39, 62, 0.48);
        border: 0;
        display: none;
        inset: 0;
        padding: 0;
        position: fixed;
        z-index: 210;
    }

    .shell-app:not(.is-sidebar-collapsed) .shell-sidebar-backdrop {
        display: block;
    }

    .shell-sidebar__brand {
        border-radius: 8px;
        padding: 0.68rem;
    }

    .shell-sidebar__logo {
        border-radius: 8px;
        height: 124px;
        width: 138px;
    }

    .shell-sidebar__footer {
        display: block;
        font-size: 0.76rem;
        line-height: 1.4;
        padding: 0.72rem;
    }

    .shell-sidebar__platform-brand {
        margin-top: 0.48rem;
        padding: 0.45rem;
    }

    .shell-sidebar__platform-brand img {
        max-height: 46px;
        width: min(146px, 100%);
    }

    .shell-nav {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .shell-nav__group {
        min-width: 0;
    }

    .shell-nav__item {
        border-radius: 8px;
        gap: 0.62rem;
        grid-template-columns: 38px minmax(0, 1fr);
        min-height: 56px;
        padding: 0.55rem 0.62rem;
    }

    .shell-nav__icon {
        border-radius: 7px;
        height: 38px;
        width: 38px;
    }

    .shell-nav__label {
        font-size: 0.88rem;
        line-height: 1.16;
    }

    .shell-nav__meta {
        font-size: 0.71rem;
        line-height: 1.25;
    }

    .shell-main {
        min-height: 100dvh;
        width: 100%;
    }

    .shell-topbar {
        background: rgba(238, 244, 250, 0.94);
        padding: calc(0.38rem + env(safe-area-inset-top, 0px)) 0.5rem 0.32rem;
        position: sticky;
        top: 0;
        z-index: 80;
    }

    .shell-topbar__inner {
        border-radius: 8px;
        gap: 0.42rem;
        padding: 0.45rem;
    }

    .shell-topbar__left {
        align-items: center;
        display: grid;
        flex: 1 1 100%;
        gap: 0.42rem;
        grid-template-columns: 40px minmax(0, 1fr);
        min-width: 0;
        width: 100%;
    }

    .shell-toggle {
        border-radius: 7px;
        height: 40px;
        min-height: 40px;
        width: 40px;
    }

    .shell-breadcrumb {
        border-radius: 7px;
        min-height: 40px;
        min-width: 0;
        overflow: hidden;
        padding: 0.5rem 0.62rem;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: auto;
    }

    .shell-breadcrumb span,
    .shell-breadcrumb strong {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .shell-topbar__right {
        align-items: center;
        display: flex;
        flex: 0 0 auto;
        flex-wrap: nowrap;
        gap: 0.35rem;
        justify-content: flex-start;
        margin: 0;
        max-width: 100%;
        overflow-x: auto;
        padding: 0 0 0.1rem;
        scrollbar-width: none;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    .shell-topbar__right::-webkit-scrollbar,
    .teacher-coordination-nav::-webkit-scrollbar,
    .workspace-switcher__tabs::-webkit-scrollbar,
    .workspace-collection__head-actions::-webkit-scrollbar {
        display: none;
    }

    .shell-topbar__actions,
    .session-tools.is-topbar {
        align-items: center;
        display: flex;
        flex: 0 0 auto;
        flex-direction: row;
        gap: 0.35rem;
        margin: 0;
        width: auto;
    }

    .shell-topbar__help,
    .session-tools.is-topbar .session-tool-button,
    .shell-pill {
        border-radius: 7px;
        flex: 0 0 auto;
        font-size: 0.72rem;
        min-height: 36px;
        padding: 0.42rem 0.58rem;
        white-space: nowrap;
        width: auto;
    }

    .shell-pill {
        min-height: 34px;
    }

    .shell-content {
        padding: 0.62rem 0.55rem calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    .shell-footer {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .shell-hero,
    .shell-card,
    .workspace-shell__panel,
    .workspace-collection,
    .teacher-analytics-panel,
    .teacher-coordination-alert-board,
    .teacher-observer-detail-card,
    .teacher-maturity-panel,
    .portal-panel,
    .portal-student-card,
    .student-life-detail,
    .student-life-search__panel,
    .student-life-block,
    .school-pae-overview,
    .school-pae-overview__metric,
    .school-pae-overview__closure,
    .school-pae-overview__period,
    .school-pae-overview__table-card,
    .school-pae-overview__missing-card {
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(8, 64, 103, 0.055);
    }

    .shell-hero,
    .workspace-shell__panel,
    .teacher-analytics-panel,
    .teacher-coordination-alert-board,
    .teacher-observer-detail-card,
    .teacher-maturity-panel,
    .portal-panel,
    .portal-student-card,
    .student-life-detail,
    .student-life-search__panel,
    .school-pae-overview {
        padding: 0.78rem;
    }

    .shell-hero__title,
    .workspace-shell__title,
    .teacher-maturity-panel__head h3,
    .student-life-search__head h2,
    .school-pae-overview__head h3 {
        font-size: clamp(1.15rem, 5.8vw, 1.45rem);
        line-height: 1.15;
    }

    .shell-hero__copy,
    .workspace-shell__copy,
    .teacher-analytics-panel__head p,
    .student-life-search__head p,
    .school-pae-overview__head p {
        font-size: 0.86rem;
        line-height: 1.42;
    }

    :where(
        .super-admin-kpi-grid,
        .super-admin-panel-grid,
        .super-admin-action-grid,
        .super-admin-form__grid,
        .teacher-coordination-executive,
        .teacher-coordination-report-hub,
        .teacher-coordination-dossier-grid,
        .teacher-report-analysis-grid,
        .teacher-report-executive__grid,
        .teacher-report-executive__split,
        .teacher-written-tests-toolbar,
        .teacher-written-tests-detail-grid,
        .teacher-written-tests-checklists,
        .teacher-written-tests-answer-grid,
        .teacher-written-tests-question__grid,
        .teacher-written-tests-toggle-grid,
        .teacher-planner-form__grid,
        .teacher-planner-text-grid,
        .teacher-planner-week-grid,
        .teacher-planner-component-grid,
        .teacher-curricular-resources__upload,
        .teacher-observer-package-grid,
        .teacher-observer-package-grid--wide,
        .teacher-observer-radiography__cards,
        .teacher-observer-signatures,
        .attendance-kpi-grid,
        .attendance-layout,
        .teacher-analytics-grid,
        .teacher-analytics-chart-specs,
        .portal-dashboard-grid,
        .portal-grid,
        .student-life-tabs,
        .school-pae-overview__head,
        .school-pae-overview__body,
        .communication-layout,
        .teacher-lms-layout,
        .teacher-lms-form,
        .teacher-lms-form__checks,
        .teacher-lms-activity,
        .teacher-lms-material,
        .teacher-lms-submission,
        .teacher-lms-split,
        .teacher-lms-action-board,
        .teacher-lms-seating__toolbar,
        .teacher-lms-linked-activity__grid
    ) {
        grid-template-columns: minmax(0, 1fr);
    }

    .workspace-collection__toolbar,
    .teacher-support-toolbar,
    .teacher-coordination-toolbar,
    .student-photo-workspace__filters,
    .school-schedule-toolbar__filters,
    .communication-recipient-grid,
    .school-calendar-form__grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .teacher-coordination-nav,
    .teacher-coordination-quick-actions,
    .workspace-switcher__tabs,
    .workspace-collection__head-actions,
    .teacher-report-workflow__steps,
    .communication-folder-tabs {
        display: flex;
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 0.18rem;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }

    .teacher-coordination-nav > *,
    .teacher-coordination-quick-actions > *,
    .workspace-switcher__tabs > *,
    .workspace-collection__head-actions > *,
    .teacher-report-workflow__steps > *,
    .communication-folder-tabs > * {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    .workspace-collection__toolbar,
    .workspace-collection__meta,
    .workspace-collection__pager,
    .teacher-coordination-filter-head,
    .teacher-coordination-executive__head,
    .teacher-coordination-report-hub__head,
    .teacher-analytics-panel__head,
    .student-life-search__head,
    .student-photo-workspace__head,
    .school-pae-overview__subhead,
    .communication-detail__head {
        align-items: stretch;
        flex-direction: column;
    }

    .workspace-shell__actions,
    .workspace-collection__empty-actions,
    .teacher-coordination-filter-actions,
    .teacher-coordination-alert-item__actions,
    .teacher-observer-detail-tags,
    .teacher-support-item__meta,
    .student-life-profile__actions,
    .school-pae-overview__actions,
    .communication-detail__actions,
    .communication-reply__actions,
    .teacher-lms-hero-actions {
        align-items: center;
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
        justify-content: flex-start;
        width: 100%;
    }

    :where(
        .workspace-shell__actions,
        .workspace-collection__empty-actions,
        .teacher-coordination-filter-actions,
        .teacher-coordination-alert-item__actions,
        .student-life-profile__actions,
        .school-pae-overview__actions,
        .communication-detail__actions,
        .communication-reply__actions,
        .teacher-lms-hero-actions
    ) > :where(button, a, label) {
        flex: 1 1 9rem;
        min-width: 0;
        width: auto;
    }

    .button-primary,
    .button-secondary,
    .session-tool-button,
    .super-admin-item__action,
    .shell-help-action,
    .attendance-save-button {
        min-height: 42px;
    }

    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
    select,
    textarea {
        font-size: 16px;
        max-width: 100%;
        min-width: 0;
    }

    textarea {
        min-height: 7.5rem;
    }

    .super-admin-search-select__panel,
    .school-schedule-filter .super-admin-search-select__panel {
        max-inline-size: calc(100vw - 1.5rem);
        min-inline-size: 100%;
    }

    .app-dialog-shell {
        align-items: end;
        padding: 0;
    }

    .app-dialog-shell__dialog,
    .app-dialog-shell__dialog--help,
    .app-dialog-shell__dialog--student-photo,
    .teacher-note-modal__dialog,
    .attendance-photo-modal__dialog,
    .pae-operator-camera__dialog {
        border-radius: 8px 8px 0 0;
        max-height: calc(100dvh - env(safe-area-inset-top, 0px));
        max-width: 100%;
        overflow-y: auto;
        width: 100%;
    }

    .app-dialog-shell__actions {
        background: #fff;
        bottom: 0;
        display: grid;
        gap: 0.45rem;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        position: sticky;
        width: 100%;
        z-index: 2;
    }

    .app-dialog-shell__actions > * {
        min-width: 0;
        width: 100%;
    }

    .teacher-academic-sheet__table-wrap,
    .school-schedule-table-wrap,
    .super-admin-schedule-grid__viewport,
    .school-pae-overview__table-scroll,
    .teacher-lms-seating__grid {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-gutter: stable;
        touch-action: pan-x pan-y;
        -webkit-overflow-scrolling: touch;
    }

    .teacher-academic-sheet__scrollbar-shell {
        display: none;
    }

    .attendance-student,
    .teacher-coordination-alert-item,
    .teacher-coordination-priority-item,
    .teacher-report-batch-row,
    .teacher-observer-student-card,
    .workspace-registry__row,
    .workspace-registry__cells,
    .workspace-registry__aside {
        grid-template-columns: minmax(0, 1fr);
    }

    .student-life-result {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .attendance-student > *,
    .teacher-observer-student-card > *,
    .student-life-result > * {
        min-width: 0;
    }

    .student-life-result img {
        height: 48px;
        width: 48px;
    }

    .student-life-result__main {
        grid-column: auto;
    }

    .student-life-result__context,
    .student-life-result .button-secondary {
        grid-column: 1 / -1;
    }

    .student-life-profile {
        align-items: start;
        gap: 0.68rem;
        grid-template-columns: 64px minmax(0, 1fr);
        padding: 0.72rem;
    }

    .student-life-profile__photo-button img {
        height: 64px;
        width: 64px;
    }

    .student-life-profile__actions {
        grid-column: 1 / -1;
    }

    .student-life-tab-list {
        display: flex;
        gap: 0.45rem;
        overflow-x: auto;
        padding-bottom: 0.18rem;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }

    .student-life-tab-card {
        border-radius: 7px;
        flex: 0 0 min(72vw, 220px);
        padding: 0.62rem;
        scroll-snap-align: start;
    }

    .student-photo-workspace__metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .student-photo-capture {
        grid-template-columns: minmax(0, 1fr);
    }

    .student-photo-capture__preview {
        justify-self: center;
        max-width: 230px;
        width: min(100%, 230px);
    }

    .student-photo-capture__actions > * {
        flex: 1 1 9rem;
        min-width: 0;
    }

    .school-pae-overview__metrics,
    .school-pae-overview__closures,
    .school-pae-overview__periods {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .school-pae-overview__metric,
    .school-pae-overview__closure,
    .school-pae-overview__period {
        min-width: 0;
        padding: 0.68rem;
    }

    .school-pae-overview__metric strong {
        font-size: 1.35rem;
    }

    .teacher-maturity-score {
        min-width: 0;
    }

    .teacher-maturity-card li {
        grid-template-columns: 44px minmax(0, 1fr);
    }

    .teacher-maturity-card li em {
        grid-column: 2;
    }

    .communication-thread__preview {
        white-space: nowrap;
    }

    .communication-metrics,
    .communication-notice-strip,
    .communication-recipient-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .communication-panel,
    .communication-thread,
    .communication-message,
    .communication-reply {
        border-radius: 8px;
    }

    .teacher-lms-seat {
        border-radius: 7px;
    }

    .shell-scrolltop {
        bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
        height: 44px;
        right: calc(0.7rem + env(safe-area-inset-right, 0px));
        width: 44px;
    }
}

@media (max-width: 720px) {
    .landing-screen,
    .landing-screen--context {
        padding-left: max(0.55rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.55rem, env(safe-area-inset-right, 0px));
    }

    .landing-card,
    .auth-card,
    .context-selector {
        border-radius: 8px;
    }

    .shell-topbar__inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .shell-topbar__help,
    .session-tools.is-topbar .session-tool-button,
    .shell-pill {
        min-height: 34px;
        padding: 0.38rem 0.52rem;
    }

    .shell-card-grid,
    .teacher-academic-selector-grid,
    .teacher-academic-activity-row,
    .teacher-support-summary,
    .teacher-support-toolbar,
    .teacher-coordination-toolbar,
    .teacher-report-analysis-grid,
    .teacher-written-tests-grid,
    .teacher-written-tests-grid--metrics,
    .teacher-written-tests-answer-grid,
    .teacher-written-tests-context-media__grid,
    .teacher-planner-selector-grid,
    .teacher-planner-usage-list,
    .teacher-observer-detail-evidences,
    .teacher-observer-evidence-preview,
    .teacher-observer-toggle-grid,
    .teacher-analytics-insights,
    .student-life-kpis {
        grid-template-columns: minmax(0, 1fr);
    }

    .attendance-hero__tools,
    .attendance-card__actions--footer,
    .teacher-report-analysis-grid--stacked .teacher-report-analysis-field,
    .teacher-planner-ai-panel__head,
    .teacher-planner-form__assistant,
    .teacher-planner-search-row,
    .teacher-planner-summary-row,
    .school-setup-guide-strip,
    .school-vigilance-layout,
    .school-vigilance-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .workspace-registry__head {
        display: none;
    }

    .workspace-registry__row,
    .super-admin-item,
    .teacher-support-item,
    .teacher-coordination-alert-item,
    .teacher-coordination-priority-item,
    .teacher-analytics-card,
    .teacher-report-analysis-field,
    .teacher-written-tests-response-card,
    .attendance-kpi-card,
    .student-life-result,
    .student-life-tab-card {
        border-radius: 7px;
    }

    .teacher-report-workflow__step {
        min-width: min(78vw, 250px);
    }

    .school-calendar-grid {
        gap: 0.14rem;
        padding: 0.2rem;
    }

    .school-calendar-day {
        min-height: 3.75rem;
        padding: 0.2rem;
    }

    .school-calendar-event-chip {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .school-calendar-modal__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .school-calendar-modal__actions > * {
        min-width: 0;
        width: 100%;
    }

    .teacher-academic-table__student-col {
        max-width: 180px;
        width: 180px;
    }

    .teacher-academic-view .teacher-academic-table--sheet input.teacher-note-input[type="number"] {
        font-size: 12px !important;
    }

    .teacher-lms-submission__student,
    .teacher-lms-material,
    .teacher-lms-activity {
        min-width: 0;
    }
}

@media (max-width: 440px) {
    .shell-content {
        padding-left: 0.42rem;
        padding-right: 0.42rem;
    }

    .shell-topbar {
        padding-left: 0.38rem;
        padding-right: 0.38rem;
    }

    .shell-breadcrumb {
        font-size: 0.78rem;
    }

    .shell-topbar__help {
        font-size: 0;
        width: 36px;
    }

    .shell-topbar__help::before {
        content: "?";
        font-size: 0.82rem;
        font-weight: 700;
    }

    .session-tools.is-topbar .session-tool-button {
        font-size: 0.68rem;
    }

    .shell-pill:nth-of-type(2),
    .shell-pill:nth-of-type(3) {
        display: none;
    }

    .student-photo-workspace__metrics,
    .school-pae-overview__metrics,
    .school-pae-overview__closures,
    .school-pae-overview__periods,
    .communication-metrics,
    .communication-notice-strip,
    .communication-recipient-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .student-life-tab-card {
        flex-basis: min(82vw, 220px);
    }

    .student-life-profile {
        grid-template-columns: 54px minmax(0, 1fr);
    }

    .student-life-profile__photo-button img {
        height: 54px;
        width: 54px;
    }

    .app-dialog-shell__actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .pae-operator__roster {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.42rem;
    }

    .pae-operator-student {
        min-height: 170px;
        padding: 0.42rem;
    }

    .pae-operator-student img {
        height: 96px;
    }
}

@media (hover: none) and (pointer: coarse) {
    button,
    [role="button"],
    a.button-primary,
    a.button-secondary,
    input,
    select,
    textarea {
        touch-action: manipulation;
    }

    button:not(.teacher-note-icon):not(.teacher-academic-table__component-action):not(.teacher-academic-table__activity-action),
    [role="button"],
    a.button-primary,
    a.button-secondary {
        min-height: 42px;
    }

    .shell-card:hover,
    .teacher-support-item--clickable:hover,
    .student-life-result:hover,
    .portal-metric:hover,
    .portal-signal:hover {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
