/**
 * Global mobile & tablet responsiveness
 * Loaded after app.css — fixes headers, toolbars, filters across modules.
 */

/* ── Tablet: stack section headers, icon-only toolbar buttons ── */
@media (max-width: 900px) {
    .section-head {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 10px;
    }

    .section-head > div:first-child {
        flex: 1 1 100%;
        min-width: 0;
    }

    /* OL edit/composer — keep title + back on one row (override stack above) */
    .section-head.oex-composer-head,
    .section-head.ohw-composer-head,
    .section-head.cm-bots-compose-head {
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .section-head.oex-composer-head > div:first-child,
    .section-head.ohw-composer-head > div:first-child,
    .section-head.cm-bots-compose-head > div:first-child {
        flex: 1 1 auto;
    }

    .section-head.oex-composer-head h2,
    .section-head.ohw-composer-head h2,
    .section-head.cm-bots-compose-head h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 15px;
    }

    .section-head.oex-composer-head p,
    .section-head.ohw-composer-head p,
    .section-head.cm-bots-compose-head p {
        display: none;
    }

    .section-head.cm-bots-compose-head .cm-bots-selected-badge {
        flex: 0 0 auto;
        order: 2;
    }

    .section-head.oex-composer-head .oex-back-btn,
    .section-head.ohw-composer-head .ohw-back-btn {
        flex: 0 0 auto;
        order: 2;
        width: auto !important;
        padding: 6px 8px;
    }

    .section-head.oex-composer-head .oex-back-copy,
    .section-head.ohw-composer-head .ohw-back-copy {
        display: none;
    }

    .section-head:not(.oex-composer-head):not(.ohw-composer-head):not(.cm-bots-compose-head) h2 {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Icon-only labeled action buttons (keep title/aria-label for accessibility) */
    .header-actions .app-action-btn,
    .header-actions .secondary-btn.app-action-btn,
    .header-actions .primary-btn.app-action-btn,
    .header-actions .secondary-btn:has(> i),
    .header-actions .primary-btn:has(> i),
    .section-head > .app-action-btn,
    .section-head > .secondary-btn:has(> i),
    .section-head > .primary-btn:has(> i),
    .section-head > a.app-action-btn,
    .section-head > a.secondary-btn:has(> i),
    .section-head > a.primary-btn:has(> i),
    .section-head > button.primary-btn:has(> i),
    .section-head > button.secondary-btn:has(> i),
    .student-more-menu > button.app-action-btn,
    .student-more-menu > button.secondary-btn {
        min-width: 0 !important;
        width: 40px !important;
        flex: 0 0 40px !important;
        padding: 0 !important;
        font-size: 0 !important;
        justify-content: center;
        gap: 0;
        white-space: nowrap;
    }

    .header-actions .app-action-btn i,
    .header-actions .secondary-btn i,
    .header-actions .primary-btn i,
    .section-head > .app-action-btn i,
    .section-head > .secondary-btn i,
    .section-head > .primary-btn i,
    .section-head > a i,
    .student-more-menu > button i {
        font-size: 14px !important;
        margin: 0;
        line-height: 1;
    }

    .student-more-menu > button {
        min-width: 40px !important;
    }

    /* Override full-width secondary-btn rule from module blocks */
    .section-head .header-actions .secondary-btn,
    .section-head .header-actions .primary-btn {
        width: 40px !important;
        flex: 0 0 40px !important;
        margin-top: 0 !important;
    }

    /* Advanced search — keep all filters inside the panel */
    .advanced-search {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        flex-wrap: unset !important;
        overflow-x: visible !important;
        overflow: visible !important;
        align-items: end;
        gap: 10px;
        padding-bottom: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .advanced-search > label,
    .advanced-search > label:first-child {
        flex: unset;
        min-width: 0;
        max-width: 100%;
    }

    .advanced-search > label:first-child {
        grid-column: 1 / -1;
    }

    .advanced-search > .search-submit-btn,
    .advanced-search > .filter-reset-btn {
        flex: unset;
        width: 100%;
        min-width: 0;
    }

    /* Role hierarchy toolbar */
    .rh-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .rh-toolbar-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .rh-toolbar-actions .rh-tool-btn {
        min-width: 0;
        flex: 1 1 auto;
        justify-content: center;
        font-size: 10px;
        padding: 8px 10px;
    }

    /* Accounting / admin hero action rows */
    .aa-page-hero-actions,
    .aa-hero-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .acc-hero-actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
        gap: 8px;
        max-width: 100%;
        min-width: 0;
    }

    .form-actions {
        flex-wrap: wrap;
        justify-content: stretch;
    }

    .form-actions .primary-btn,
    .form-actions .secondary-btn {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
    }

    /* Bulk toolbar on tablet */
    .bulk-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bulk-toolbar .danger-outline-btn {
        grid-column: 1 / -1;
        justify-content: center;
    }
}

/* ── Phone ── */
@media (max-width: 680px) {
    .header-actions > *:not(.student-more-menu) {
        flex: 0 0 auto;
    }

    .header-actions .student-more-menu {
        flex: 0 0 auto;
    }

    /* Prevent stretched icon buttons */
    .header-actions .app-action-btn,
    .header-actions .secondary-btn.app-action-btn,
    .header-actions .primary-btn.app-action-btn {
        width: 40px !important;
        flex: 0 0 40px !important;
        font-size: 0 !important;
    }

    .advanced-search {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .advanced-search > label:first-child {
        grid-column: 1 / -1;
    }

    .advanced-search > .search-submit-btn,
    .advanced-search > .filter-reset-btn {
        width: 100%;
        justify-content: center;
    }

    .bulk-toolbar,
    .bulk-toolbar.page-size-only {
        grid-template-columns: 1fr;
    }

    .bulk-toolbar .danger-outline-btn,
    .bulk-toolbar .list-page-size {
        width: 100%;
    }

    .bulk-toolbar .check-label {
        grid-column: 1 / -1;
    }

    .compact-upload,
    .upload-row {
        grid-template-columns: 1fr !important;
    }

    .compact-upload .primary-btn,
    .upload-row .primary-btn {
        width: 100%;
        justify-content: center;
        font-size: 10.8px !important;
        min-height: 40px;
    }

    .rh-toolbar-actions .rh-tool-btn {
        flex: 1 1 calc(50% - 4px);
        font-size: 9.5px;
    }

    .page-heading p {
        display: none;
    }

    .page-heading h1,
    .topbar h1 {
        font-size: 15px;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        line-height: 1.35;
    }

    .responsive-table {
        margin-inline: -4px;
        border-radius: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .data-table {
        min-width: 640px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .header-actions {
        gap: 6px;
    }

    .header-actions .app-action-btn,
    .header-actions .secondary-btn.app-action-btn,
    .header-actions .primary-btn.app-action-btn,
    .student-more-menu > button {
        width: 38px !important;
        flex: 0 0 38px !important;
        height: 38px !important;
    }

    .rh-toolbar-actions {
        flex-direction: column;
    }

    .rh-toolbar-actions .rh-tool-btn {
        width: 100%;
        flex: 1 1 auto;
    }
}

/* ── Academic Unit: hub, report cards, lists, process notebook ── */
@media (max-width: 900px) {
    .settings-layout > .settings-page,
    .settings-layout > .au-dashboard,
    [data-report-cards-page],
    .class-lists-page,
    .process-notebook-page {
        min-width: 0;
    }

    /* Report cards */
    [data-report-cards-page] .report-card-workspace {
        border-radius: 18px;
    }

    [data-report-cards-page] .report-card-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 18px;
        gap: 12px;
    }

    [data-report-cards-page] .report-card-hero-icon {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        font-size: 18px;
        border-radius: 14px;
    }

    [data-report-cards-page] .report-card-workspace .grades-form {
        padding: 14px 16px 18px;
    }

    [data-report-cards-page] .report-card-board {
        border-radius: 18px;
        overflow: visible;
    }

    [data-report-cards-page] .report-card-board > header {
        padding: 14px 16px;
    }

    [data-report-cards-page] .report-card-search {
        min-width: 0;
        width: 100%;
    }

    [data-report-cards-page] .report-subject-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
        gap: 10px;
    }

    [data-report-cards-page] .report-subject-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    [data-report-cards-page] .report-subject-chip {
        flex: 0 0 auto;
    }

    [data-report-cards-page] .report-subject-add {
        min-width: 0;
        width: 100%;
    }

    [data-report-cards-page] .report-card-table-wrap {
        max-height: min(58vh, 520px);
        margin: 0 -1px;
        border-top: 1px solid #e8eef7;
        border-bottom: 1px solid #e8eef7;
        border-radius: 0;
    }

    [data-report-cards-page] .report-print-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
        gap: 12px;
    }

    [data-report-cards-page] .report-print-bar-controls {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    [data-report-cards-page] .report-print-mode-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        padding-bottom: 4px;
    }

    [data-report-cards-page] .report-print-mode-pill {
        flex: 0 0 auto;
    }

    [data-report-cards-page] .report-print-bar .primary-btn.report-print-btn {
        width: 100%;
        justify-content: center;
    }

    [data-report-cards-page] .report-card-period-bar {
        padding: 12px 14px;
    }

    [data-report-cards-page] .report-card-period-fields {
        grid-template-columns: 1fr;
    }

    [data-report-cards-page] .report-card-period-head {
        flex-wrap: wrap;
        gap: 10px;
    }

    [data-report-cards-page] .report-card-period-head .secondary-btn.compact {
        margin-right: 0;
        width: 100%;
        justify-content: center;
    }

    [data-report-cards-page] .form-actions[data-report-actions] {
        position: sticky;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        z-index: 4;
        margin: 0 -16px -18px;
        padding: 12px 16px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), #fff);
        border-top: 1px solid #e8eef7;
        backdrop-filter: blur(8px);
    }

    [data-report-cards-page] .form-actions[data-report-actions] .primary-btn {
        width: 100%;
        justify-content: center;
    }

    /* Report cards — term tabs horizontal scroll */
    [data-report-cards-page] .stage-tabs-wrap.report-card-tabs-multi,
    [data-report-cards-page] .report-card-term-scroller {
        min-width: 0;
        max-width: 100%;
    }

    [data-report-cards-page] .report-card-tabs-multi .stage-tabs button {
        min-width: 100px;
    }

    /* Grades toolbar */
    [data-class-grades-page] .grades-toolbar .section-head {
        flex-direction: column;
        align-items: stretch;
    }

    [data-class-grades-page] .grades-toolbar-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    [data-class-grades-page] .grades-toolbar-actions .secondary-btn,
    [data-class-grades-page] .grades-toolbar-actions .primary-btn {
        width: 100% !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        min-height: 44px;
        font-size: 12px !important;
        padding: 10px 12px !important;
        justify-content: center;
        gap: 8px;
        white-space: nowrap;
    }

    [data-class-grades-page] .grades-toolbar-actions .secondary-btn i,
    [data-class-grades-page] .grades-toolbar-actions .primary-btn i {
        font-size: 13px !important;
        margin: 0;
    }

    [data-class-grades-page] .grades-toolbar-actions .count-badge {
        margin-right: auto;
    }

    /* Attendance — report & notices */
    [data-attendance-page] .att-report-body {
        padding: 14px 16px 20px;
    }

    [data-attendance-page] .att-rep-filter-bar {
        padding: 12px 16px;
    }

    [data-attendance-page] .att-rep-pager {
        padding: 12px 16px;
    }

    [data-attendance-page] .att-notice-status-tabs {
        margin: 0 14px 12px;
    }

    [data-attendance-page] [data-att-panel="notices"] .learner-grade-list {
        padding: 0 14px 16px;
    }

    [data-attendance-page] .objection-review .row-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    [data-attendance-page] .objection-review .row-actions .primary-btn,
    [data-attendance-page] .objection-review .row-actions .danger-outline-btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    /* Class lists */
    .class-lists-page .lst-studio {
        padding: 16px;
        border-radius: 18px;
        gap: 14px;
    }

    .class-lists-page .lst-studio-top {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .class-lists-page .lst-type-pills {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 6px;
        padding: 6px;
        width: 100%;
        scrollbar-width: none;
    }

    .class-lists-page .lst-type-pills::-webkit-scrollbar {
        display: none;
    }

    .class-lists-page .lst-pill,
    .class-lists-page .lst-pill-link {
        flex: 0 0 auto;
        min-width: max-content;
        scroll-snap-align: start;
        padding: 10px 14px;
        font-size: 12px;
    }

    .class-lists-page .lst-print-btn {
        width: 100%;
        justify-content: center;
    }

    .class-lists-page .lst-studio-filters {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .class-lists-page .lst-studio-options {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .class-lists-page .lst-mode-group,
    .class-lists-page .lst-blank-variant-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .class-lists-page .lst-segment {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .class-lists-page .lst-seg-btn {
        justify-content: center;
        padding: 10px 8px;
        font-size: 11px;
    }

    .class-lists-page .lst-class-chips {
        max-height: 160px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .class-lists-page .lst-preview-head {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
    }

    .class-lists-page .lst-preview-stage {
        height: min(56vh, 480px);
        min-height: 280px;
        padding: 14px;
    }

    /* Process notebook */
    .process-notebook-page .pnb-workspace {
        grid-template-columns: 1fr;
    }

    .process-notebook-page .pnb-studio {
        padding: 16px;
        border-radius: 18px;
    }

    .process-notebook-page .pnb-hero-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .process-notebook-page .pnb-intro-icon {
        width: 46px;
        height: 46px;
        font-size: 20px;
        border-radius: 14px;
    }

    .process-notebook-page .pnb-hero-copy h2 {
        font-size: 17px;
    }

    .process-notebook-page .pnb-status-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .process-notebook-page .pnb-status-main span {
        white-space: normal;
    }

    .process-notebook-page .pnb-step-card {
        padding: 14px 16px;
    }

    .process-notebook-page .pnb-filter-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .process-notebook-page .pnb-counter-grid {
        grid-template-columns: 1fr;
    }

    .process-notebook-page .pnb-photo-row {
        flex-direction: column;
        align-items: stretch;
    }

    .process-notebook-page .pnb-photo-actions {
        width: 100%;
    }

    .process-notebook-page .pnb-photo-actions .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    .process-notebook-page .pnb-section-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .process-notebook-page .pnb-preview-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 16px 12px;
        scrollbar-width: none;
    }

    .process-notebook-page .pnb-preview-pills::-webkit-scrollbar {
        display: none;
    }

    .process-notebook-page .pnb-preview-pill {
        flex: 0 0 auto;
    }

    .process-notebook-page .pnb-preview-mock {
        max-width: 100%;
    }

    .process-notebook-page .lst-preview-stage {
        height: min(52vh, 420px);
        min-height: 260px;
        padding: 14px;
    }
}

@media (max-width: 680px) {
    /* Report card table: tighter sticky columns + reliable horizontal scroll */
    [data-report-cards-page] .report-card-table th.is-student-last,
    [data-report-cards-page] .report-card-table td.is-student-last {
        min-width: 120px;
        width: 120px;
        padding-right: 10px;
    }

    [data-report-cards-page] .report-card-table th.is-student-first,
    [data-report-cards-page] .report-card-table td.is-student-first {
        right: 120px;
        min-width: 88px;
        width: 88px;
        padding-right: 10px;
    }

    [data-report-cards-page] .report-card-table th,
    [data-report-cards-page] .report-card-table td {
        padding: 8px 10px;
        font-size: 11px;
    }

    [data-report-cards-page] .report-score-field {
        min-width: 84px;
    }

    [data-report-cards-page] .report-score-field input,
    [data-report-cards-page] .report-score-field select {
        width: 84px;
        min-width: 84px;
        font-size: 11px;
        padding: 8px 6px;
    }

    [data-report-cards-page] .report-card-term-scroller {
        margin-inline: -2px;
        scroll-padding-inline: 12px;
    }

    [data-report-cards-page] .report-card-tabs-multi .stage-tabs button {
        min-width: 96px;
        min-height: 44px;
        padding: 8px 10px;
    }

    [data-report-cards-page] .report-card-tabs-multi .stage-tabs button span {
        font-size: 10px;
    }

    [data-class-grades-page] .grades-toolbar-actions {
        grid-template-columns: 1fr;
    }

    /* Attendance report — card layout on phone */
    [data-attendance-page] .att-report-table {
        border: 0;
        min-width: 0;
        width: 100%;
        overflow: visible;
    }

    [data-attendance-page] .att-report-table thead {
        display: none;
    }

    [data-attendance-page] .att-report-table tbody {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    [data-attendance-page] .att-report-table tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 12px;
        padding: 14px;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        background: linear-gradient(180deg, #fff, #f8fbff);
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    }

    [data-attendance-page] .att-report-table tbody tr.att-row-alt td {
        background: transparent !important;
    }

    [data-attendance-page] .att-report-table td {
        border: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
        font-size: 12px;
        text-align: right;
    }

    [data-attendance-page] .att-report-table td::before {
        content: attr(data-label);
        font-size: 10px;
        font-weight: 800;
        color: #64748b;
    }

    [data-attendance-page] .att-report-table td[data-label=""]::before {
        content: none;
    }

    [data-attendance-page] .att-report-table td.att-tbl-num {
        display: none;
    }

    [data-attendance-page] .att-report-table td.att-tbl-date {
        grid-column: 1 / -1;
        font-size: 14px;
        font-weight: 800;
        color: #0f172a;
        padding-bottom: 4px;
        border-bottom: 1px dashed #e2e8f0;
        margin-bottom: 2px;
    }

    [data-attendance-page] .att-report-table td.att-tbl-date::before {
        content: none;
    }

    [data-attendance-page] .att-report-table td:last-child {
        grid-column: 1 / -1;
        margin-top: 4px;
    }

    [data-attendance-page] .att-report-table .att-detail-btn {
        width: 100%;
        justify-content: center;
        min-height: 40px;
        font-size: 12px;
    }

    [data-attendance-page] .att-notice-status-tabs a {
        font-size: 10px;
        padding: 10px 6px;
    }

    [data-attendance-page] .objection-card {
        grid-template-columns: 1fr;
    }

    [data-attendance-page] .objection-review textarea {
        width: 100%;
        min-height: 88px;
    }

    .class-lists-page .lst-segment {
        grid-template-columns: 1fr;
    }

    .process-notebook-page .pnb-section-grid {
        grid-template-columns: 1fr;
    }

    .process-notebook-page .pnb-section-btn {
        min-height: 44px;
        font-size: 12px;
    }

    .au-quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 400px) {
    [data-report-cards-page] .report-card-table th.is-student-last,
    [data-report-cards-page] .report-card-table td.is-student-last {
        min-width: 108px;
        width: 108px;
    }

    [data-report-cards-page] .report-card-table th.is-student-first,
    [data-report-cards-page] .report-card-table td.is-student-first {
        right: 108px;
        min-width: 76px;
        width: 76px;
    }

    .class-lists-page .lst-pill span {
        font-size: 11px;
    }
}

/* ── Cultural Unit (واحد پرورشی) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout > .cu-dashboard,
    .settings-layout > .settings-page.hp-page,
    .settings-layout > .elections-page,
    .settings-layout > .sports-file-page,
    .settings-layout > .health-file-page,
    .settings-layout > .school-reps-page,
    .settings-layout > .class-seating-page,
    .settings-layout > .consent-forms-page,
    .settings-layout > .consent-editor-page,
    .settings-layout > .consent-show-page,
    [data-school-calendar-page] {
        min-width: 0;
    }

    /* Hub dashboard */
    .cu-dashboard .au-quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cu-dashboard .au-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cu-dashboard .au-lists-grid-top,
    .cu-dashboard .au-lists-grid-bottom {
        grid-template-columns: 1fr;
    }

    /* Honors — tab bar + action buttons */
    [data-hp-page] .hp-tabbar-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    [data-hp-page] .hp-tab-group {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 6px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    [data-hp-page] .hp-tab-group::-webkit-scrollbar {
        display: none;
    }

    [data-hp-page] .hp-tabbar .hp-tab {
        flex: 0 0 auto;
        min-height: 44px;
        white-space: nowrap;
    }

    [data-hp-page] .hp-tabbar .hp-tab span {
        display: inline;
    }

    [data-hp-page] .hp-action-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    [data-hp-page] .hp-action-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    [data-hp-page] .disc-filter-row,
    [data-hp-page] .disc-student-grid {
        grid-template-columns: 1fr;
    }

    [data-hp-page] .hp-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    [data-hp-page] .disc-hero {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 18px;
    }

    /* Elections */
    .elections-page .elec-list-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .elections-page .elec-toolbar {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .elections-page .elec-org-pick {
        width: 100%;
    }

    .elections-page .elec-org-pick select {
        width: 100%;
    }

    .elections-page .elec-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .elections-page .elec-event-grid {
        grid-template-columns: 1fr;
        padding: 0 14px 16px;
    }

    /* Sports & health — hero toolbars */
    .sports-file-page .sports-hero,
    .health-file-page .health-hero {
        padding: 14px 16px;
    }

    .health-file-page .health-hero-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .health-file-page .health-hero-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .health-file-page .health-hero-actions .secondary-btn,
    .health-file-page .health-hero-actions .primary-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
        font-size: 12px !important;
    }

    .sports-file-page .report-card-cascade,
    .sports-file-page .sports-cascade,
    .health-file-page .health-cascade {
        grid-template-columns: 1fr;
    }

    .sports-file-page .sports-hero-head {
        flex-direction: column;
        align-items: stretch;
    }

    .health-file-page .health-board-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .health-file-page .health-board-head .report-card-search {
        width: 100%;
        min-width: 0;
    }

    /* School reps */
    .school-reps-page .sreps-hero-head {
        flex-direction: column;
        align-items: stretch;
    }

    .school-reps-page .sreps-hero-orbit {
        display: none;
    }

    .school-reps-page .sreps-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .school-reps-page .sreps-tabs::-webkit-scrollbar {
        display: none;
    }

    .school-reps-page .sreps-tabs a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .school-reps-page .sreps-hero-actions {
        width: 100%;
    }

    .school-reps-page .sreps-hero-actions .sreps-sample-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .school-reps-page .section-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .school-reps-page .section-head .secondary-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .school-reps-page .sreps-assign-grid,
    .school-reps-page .sreps-role-grid {
        grid-template-columns: 1fr;
    }

    .school-reps-page .sreps-student-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Consent forms */
    .consent-forms-page .consent-summary-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .consent-forms-page .consent-list-toolbar,
    .consent-editor-page .consent-list-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .consent-forms-page .consent-list-toolbar-actions,
    .consent-editor-page .consent-list-toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .consent-forms-page .consent-list-toolbar-actions .consent-btn,
    .consent-editor-page .consent-list-toolbar-actions .consent-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .consent-forms-page .consent-org-pick,
    .consent-forms-page .consent-org-pick select {
        width: 100%;
    }

    .consent-forms-page .consent-card-grid {
        grid-template-columns: 1fr;
    }

    .consent-editor-page .consent-editor-layout {
        grid-template-columns: 1fr;
    }

    .consent-show-page .consent-show-hero .section-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .consent-show-page .consent-show-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .consent-show-page .consent-show-actions .consent-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .consent-show-page .consent-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        gap: 6px;
        padding-bottom: 4px;
    }

    .consent-show-page .consent-tabs::-webkit-scrollbar {
        display: none;
    }

    .consent-show-page .consent-tabs a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .consent-show-page .consent-stat-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    /* Elections — manage & tabs */
    .elections-page .elec-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    .elections-page .elec-tabs::-webkit-scrollbar {
        display: none;
    }

    .elections-page .elec-tabs a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .elections-page .elec-manage-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .elections-page .elec-manage-toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .elections-page .elec-manage-toolbar-actions .elec-btn,
    .elections-page .elec-manage-toolbar-actions .elec-back-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .elections-page .elec-event-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .elections-page .elec-event-actions .elec-action-btn {
        width: 100%;
        min-width: 0;
    }

    .elections-vote-page .elec-vote-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    /* Calendar */
    [data-school-calendar-page] .sc-filter-bar {
        grid-template-columns: 1fr;
    }

    [data-school-calendar-page] .sc-filter-bar.is-org-locked {
        grid-template-columns: 1fr;
    }

    [data-school-calendar-page] .sc-month-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    [data-school-calendar-page] .sc-month-tabs::-webkit-scrollbar {
        display: none;
    }

    [data-school-calendar-page] .sc-month-tab {
        flex: 0 0 auto;
        min-width: 52px;
    }

    /* Calendar import */
    .settings-layout > .settings-page .section-head .profile-side-pair {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .settings-layout > .settings-page .section-head .profile-side-pair .app-action-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .settings-layout > .settings-page .upload-row.compact-upload {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .settings-layout > .settings-page .upload-row.compact-upload .primary-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .settings-layout > .settings-page .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .settings-layout > .settings-page .form-actions .primary-btn,
    .settings-layout > .settings-page .form-actions .secondary-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }
}

@media (max-width: 680px) {
    .cu-dashboard .au-quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .cu-dashboard .au-quick-btn {
        min-height: 88px;
    }

    .cu-dashboard .au-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Honors */
    [data-hp-page] .hp-action-group {
        grid-template-columns: 1fr;
    }

    [data-hp-page] .hp-card-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    [data-hp-page] .disc-list-filters,
    [data-hp-page] .disc-rep-filter-bar {
        padding: 12px 16px;
    }

    /* Elections manage & vote */
    .elections-page .elec-cand-cards {
        grid-template-columns: 1fr;
    }

    .elections-page .elec-event-actions {
        grid-template-columns: 1fr 1fr;
    }

    .elections-page .elec-manage-toolbar-actions {
        grid-template-columns: 1fr;
    }

    .elections-vote-page .elec-vote-grid {
        grid-template-columns: 1fr;
    }

    .elections-vote-page .elec-vote-dock {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .elections-vote-page .elec-vote-dock .elec-btn {
        width: 100%;
        min-height: 48px;
        justify-content: center;
    }

    /* Health file */
    .health-file-page .health-hero-actions {
        grid-template-columns: 1fr;
    }

    .health-file-page .health-student-grid {
        grid-template-columns: 1fr;
    }

    .health-file-page .health-dossier-header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .health-file-page .health-dossier-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .health-file-page .health-dossier-footer .primary-btn,
    .health-file-page .health-dossier-footer .secondary-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    /* School reps */
    .school-reps-page .sreps-student-grid {
        grid-template-columns: 1fr;
    }

    .school-reps-page .sreps-students-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .school-reps-page .sreps-students-tools {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .school-reps-page .sreps-students-tools .report-card-search {
        flex: 1 1 100%;
        min-width: 0;
    }

    .school-reps-page .sreps-date-row {
        grid-template-columns: 1fr;
    }

    /* Consent */
    .consent-forms-page .consent-summary-row {
        grid-template-columns: 1fr;
    }

    .consent-show-page .consent-show-actions {
        grid-template-columns: 1fr;
    }

    .consent-show-page .consent-stat-row {
        grid-template-columns: 1fr;
    }

    .consent-show-page .consent-monitor-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .consent-show-page .consent-monitor-filters label {
        width: 100%;
    }

    .consent-forms-page .consent-list-toolbar-actions,
    .consent-editor-page .consent-list-toolbar-actions {
        grid-template-columns: 1fr;
    }

    .consent-show-page .table-wrap {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    /* Calendar — keep full month width and scroll horizontally on phones */
    [data-school-calendar-page] .sc-grid-scroll {
        overflow-x: auto !important;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        max-width: 100%;
    }

    [data-school-calendar-page] .sc-grid {
        min-width: 900px !important;
        width: max-content !important;
        max-width: none !important;
        table-layout: fixed;
    }

    [data-school-calendar-page] .sc-day,
    [data-school-calendar-page] .sc-week-label,
    [data-school-calendar-page] .sc-week-label span {
        min-width: 110px;
    }

    [data-school-calendar-page] .sc-note-card {
        grid-template-columns: 4px minmax(0, 1fr);
    }

    [data-school-calendar-page] .sc-note-actions {
        grid-column: 1 / -1;
        flex-direction: row;
        justify-content: flex-end;
    }

    [data-school-calendar-page] .sc-occasions-list {
        grid-template-columns: 1fr;
    }

    [data-school-calendar-page] .sc-color-options {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    [data-hp-page] .hp-tabbar .hp-tab {
        padding: 8px 10px;
        font-size: 11px;
    }

    [data-hp-page] .hp-tabbar .hp-tab span {
        font-size: 10px;
    }

    .cu-dashboard .au-quick-btn strong {
        font-size: 11px;
    }

    .elections-page .elec-event-actions {
        grid-template-columns: 1fr;
    }

    .cu-dashboard .au-hero-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

/* ── Online Learning (آموزش آنلاین) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout > .ol-dashboard,
    .settings-layout[data-oex-page],
    .settings-layout[data-oex-manage],
    .settings-layout[data-oex-report-card],
    .settings-layout[data-oex-report-cards-print],
    .settings-layout[data-ohw-page],
    .settings-layout[data-ocl-page],
    .settings-layout[data-ocl-manage],
    .settings-layout[data-oex-participants],
    .settings-layout[data-oex-report],
    .settings-layout[data-ohw-show],
    .settings-layout.messenger-admin-page {
        min-width: 0;
    }

    .settings-layout[data-oex-page] > .settings-page,
    .settings-layout[data-oex-manage] > .settings-page,
    .settings-layout[data-oex-report-card] > .settings-page,
    .settings-layout[data-oex-report-cards-print] > .settings-page,
    .settings-layout[data-ohw-page] > .settings-page,
    .settings-layout[data-ocl-page] > .settings-page,
    .settings-layout[data-ocl-manage] > .settings-page,
    .settings-layout[data-oex-participants] > .settings-page,
    .settings-layout[data-oex-report] > .settings-page,
    .settings-layout[data-ohw-show] > .settings-page,
    .settings-layout > .settings-page[data-oex-wizard],
    .settings-layout > .settings-page[data-ohw-create],
    .settings-layout > .settings-page[data-ocl-form],
    .settings-layout > .settings-page[data-ocl-schedule-form],
    .settings-layout.messenger-admin-page > .settings-page {
        min-width: 0;
    }

    /* Hub dashboard */
    .ol-dashboard .ol-hero {
        padding: 18px 16px;
    }

    .ol-dashboard .ol-hero h1 {
        font-size: 20px;
    }

    .ol-dashboard .au-quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ol-dashboard .au-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ol-dashboard .au-lists-grid {
        grid-template-columns: 1fr;
    }

    .ol-dashboard .ol-list-panel .section-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .ol-dashboard .ol-list-panel .section-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .ol-dashboard .ol-list-panel .section-head .secondary-btn {
        width: auto !important;
        flex: 0 0 auto !important;
        min-height: 36px;
        padding: 8px 14px;
        margin-top: 0 !important;
        justify-content: center;
    }

    .ol-dashboard .au-feed-row {
        grid-template-columns: auto 1fr;
    }

    .ol-dashboard .au-feed-row .status-pill {
        grid-column: 2;
        justify-self: start;
        margin-top: 2px;
    }

    /* Exams / homework / classes — keep add action on same row (left in RTL) */
    .oex-hero .section-head,
    .ohw-hero .section-head,
    .ol-dashboard .au-list-panel .section-head,
    .ol-dashboard .ol-list-panel .section-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .oex-hero .section-head > div:first-child,
    .ohw-hero .section-head > div:first-child,
    .ol-dashboard .au-list-panel .section-head > div:first-child,
    .ol-dashboard .ol-list-panel .section-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .oex-hero .section-head h2,
    .ohw-hero .section-head h2,
    .ol-dashboard .au-list-panel .section-head h2,
    .ol-dashboard .ol-list-panel .section-head h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
    }

    .oex-hero .section-head p,
    .ohw-hero .section-head p,
    .ol-dashboard .au-list-panel .section-head p,
    .ol-dashboard .ol-list-panel .section-head p {
        display: none;
    }

    .oex-hero .oex-create-btn,
    .ohw-hero .ohw-create-btn,
    .ol-dashboard .au-list-panel .section-head .secondary-btn,
    .ol-dashboard .ol-list-panel .section-head .secondary-btn {
        width: auto !important;
        flex: 0 0 auto !important;
        min-height: 40px;
        margin-top: 0 !important;
        justify-content: center;
    }

    .ohw-hero-actions {
        width: auto;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        gap: 6px;
        max-width: min(46vw, 168px);
    }

    .ohw-hero-actions .primary-btn,
    .ohw-hero-actions .secondary-btn {
        width: 100%;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 10.5px;
        justify-content: center;
        white-space: nowrap;
    }

    /* Exam wizard header — same row on tablet */
    [data-oex-wizard] .oex-composer-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    [data-oex-wizard] .oex-composer-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    [data-oex-wizard] .oex-composer-head h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 15px;
    }

    /* Exam edit wizard — tablet layout */
    .settings-layout:has(> .settings-page[data-oex-wizard]) {
        min-width: 0;
        overflow-x: clip;
    }

    [data-oex-wizard].oex-wizard-page {
        min-width: 0;
        overflow-x: clip;
        width: 100%;
    }

    [data-oex-wizard] .settings-card.oex-composer {
        min-width: 0;
    }

    [data-oex-wizard].oex-wizard-page,
    [data-oex-wizard].settings-page {
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    }

    /* Exam wizard — horizontal scroll menus + fluid step panel */
    [data-oex-wizard] .oex-composer {
        min-width: 0;
        max-width: 100%;
        overflow-x: clip;
    }

    [data-oex-wizard] .oex-context-bar {
        display: block;
        flex-wrap: nowrap;
        overflow: hidden;
        min-width: 0;
        max-width: 100%;
        margin: 0 0 12px;
        padding: 8px 10px;
    }

    [data-oex-wizard] .oex-context-scroll {
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding-bottom: 6px;
        scrollbar-width: thin;
    }

    [data-oex-wizard] .oex-context-link {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    [data-oex-wizard] .oex-steps {
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    [data-oex-wizard] .oex-step {
        flex: 0 0 auto !important;
        scroll-snap-align: start;
    }

    [data-oex-wizard] .oex-step-panel,
    [data-oex-wizard] .oex-step-panel.is-active {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: clip;
    }

    [data-oex-wizard] .oex-step-panel > *,
    [data-oex-wizard] .oex-step-panel.is-active > * {
        min-width: 0;
        max-width: 100%;
    }

    [data-oex-wizard] .oex-form {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }

    [data-oex-wizard] .oex-date-grid,
    [data-oex-wizard] .oex-cascade-2,
    [data-oex-wizard] .oex-cascade-3 {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-mode-picks,
    [data-oex-wizard] .oex-scope-picks,
    [data-oex-wizard] .oex-scope-3,
    [data-oex-wizard] .oex-source-3,
    [data-oex-wizard] .oex-sol-4 {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .disc-notify-toggle {
        width: 100%;
        min-width: 0;
    }

    [data-oex-wizard] .oex-wizard-foot {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        margin-top: 0;
        z-index: 40;
        grid-template-columns: 1fr 1fr;
    }

    /* Homework / class edit — composer header (tablet) */
    [data-ohw-create] .ohw-composer-head,
    [data-ocl-form] .ohw-composer-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    [data-ohw-create] .ohw-composer-head > div:first-child,
    [data-ocl-form] .ohw-composer-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    [data-ohw-create] .ohw-composer-head h2,
    [data-ocl-form] .ohw-composer-head h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 15px;
    }

    [data-ohw-create] .ohw-composer-head p,
    [data-ocl-form] .ohw-composer-head p {
        display: none;
    }

    [data-ohw-create] .ohw-back-btn,
    [data-ocl-form] .ohw-back-btn {
        flex: 0 0 auto;
        order: 2;
        width: auto !important;
        padding: 6px 8px;
    }

    [data-ohw-create] .ohw-back-copy,
    [data-ocl-form] .ohw-back-copy {
        display: none;
    }

    [data-ohw-create],
    [data-ocl-form] {
        min-width: 0;
    }

    [data-ohw-create] .ohw-date-grid,
    [data-ohw-create] .ohw-cascade-2,
    [data-ohw-create] .ohw-cascade-3,
    [data-ocl-form] .ohw-date-grid,
    [data-ocl-form] .ohw-cascade-2 {
        grid-template-columns: 1fr;
    }

    [data-ohw-create] .ohw-fab-submit,
    [data-ocl-form] .ohw-fab-submit {
        left: 12px;
        right: 12px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        width: auto;
        justify-content: center;
    }

    /* Exam / homework / class manage — 3-column action tiles */
    .oex-action-rail,
    [data-oex-manage] .oex-action-grid.oex-action-rail,
    [data-ocl-manage] .ocl-action-rail {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 8px;
        overflow: visible;
        padding-bottom: 0;
    }

    .oex-action-rail .oex-action-btn,
    [data-ocl-manage] .ocl-action-btn {
        min-width: 0;
        width: 100%;
        justify-items: center;
        text-align: center;
        padding: 12px 6px;
        gap: 6px;
        border-radius: 16px;
        box-shadow: 0 8px 20px rgba(15, 23, 42, .05);
    }

    .oex-action-rail .oex-action-btn > i,
    [data-ocl-manage] .ocl-action-btn > i {
        width: 36px;
        height: 36px;
        margin: 0 auto;
        font-size: 14px;
        border-radius: 12px;
    }

    .oex-action-rail .oex-action-btn span,
    [data-ocl-manage] .ocl-action-btn span {
        font-size: 10.5px;
        line-height: 1.35;
        font-weight: 800;
    }

    .oex-action-rail .oex-action-btn small,
    [data-ocl-manage] .ocl-action-btn small {
        display: none;
    }

    [data-oex-manage] .oex-manage-top {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
    }

    [data-oex-manage] .oex-manage-top .oex-back-btn {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
        min-height: 44px;
    }

    [data-oex-manage] .oex-manage-top .secondary-btn {
        flex: 0 0 auto;
        width: auto;
        min-height: 40px;
        margin-top: 0;
    }

    [data-oex-manage] .oex-stat-grid-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    [data-oex-manage] .oex-stat-card {
        padding: 12px;
        gap: 10px;
        border-radius: 16px;
    }

    [data-oex-manage] .oex-stat-card > i {
        width: 36px;
        height: 36px;
        font-size: 14px;
        border-radius: 12px;
        flex-shrink: 0;
    }

    [data-oex-manage] .oex-stat-card strong {
        font-size: 12.5px;
        line-height: 1.4;
    }

    [data-oex-manage] .oex-manage-ops .section-head p {
        display: none;
    }

    [data-ohw-show] .ohw-detail-top {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    [data-ohw-show] .ohw-detail-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    [data-ohw-show] .ohw-detail-actions .ohw-card-btn {
        width: 100%;
        min-width: 0;
        min-height: 42px;
        flex-direction: column;
        gap: 4px;
        padding: 8px 4px;
        font-size: 10.5px;
        border-radius: 14px;
    }

    [data-ohw-show] .ohw-detail-actions .ohw-card-btn i {
        font-size: 14px;
    }

    [data-ohw-show] .ohw-detail-actions .ohw-card-btn span {
        font-size: 10px;
        font-weight: 800;
    }

    /* Exam manage */
    .oex-manage-banner h2 {
        font-size: 20px;
    }

    .oex-manage-banner {
        padding: 18px 16px;
    }

    .oex-charts-row,
    .oex-report-charts {
        grid-template-columns: 1fr;
    }

    /* Exam / homework filters */
    .oex-filter-body {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .oex-filter-body .search-submit-btn,
    .oex-filter-body .filter-reset-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    /* Class schedule wizard */
    .ocl-sch-steps {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }
    .oex-report-sheet {
        padding: 16px 14px;
        gap: 16px;
    }

    .oex-report-table-wrap,
    .oex-combo-chart-wrap {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .oex-report-kpi {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    /* Homework detail */
    [data-ohw-show] .ohw-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
    }

    [data-ohw-show] .ohw-tabs::-webkit-scrollbar {
        display: none;
    }

    [data-ohw-show] .ohw-tabs a {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    [data-ohw-show] .ohw-detail-banner h2 {
        font-size: 18px;
    }

    .ocl-sch-steps::-webkit-scrollbar {
        display: none;
    }

    /* Classroom waiting / denied (standalone pages) */
    .ocl-wait {
        padding: 16px;
    }

    .ocl-wait-body {
        padding: 8px 18px 22px;
    }

    .ocl-denied {
        padding: 16px;
    }

    .unit-soon-card {
        padding: 40px 18px;
    }
}

@media (max-width: 680px) {
    .ol-dashboard .au-quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .ol-dashboard .au-quick-btn {
        min-height: 88px;
    }

    .ol-dashboard .au-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ol-dashboard .au-hero-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .ohw-hero-actions {
        max-width: min(52vw, 190px);
    }

    .ohw-hero-actions .primary-btn,
    .ohw-hero-actions .secondary-btn {
        font-size: 10px;
        padding: 6px 8px;
    }

    /* Exam wizard — full mobile layout */
    [data-oex-wizard] {
        min-width: 0;
        overflow-x: clip;
    }

    [data-oex-wizard] .oex-composer {
        gap: 12px;
        min-width: 0;
    }

    [data-oex-wizard] .oex-composer-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    [data-oex-wizard] .oex-composer-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    [data-oex-wizard] .oex-composer-head h2 {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    [data-oex-wizard] .oex-composer-head p {
        display: none;
    }

    [data-oex-wizard] .oex-back-btn {
        flex: 0 0 auto;
        order: 2;
        padding: 6px 8px;
    }

    [data-oex-wizard] .oex-back-copy {
        display: none;
    }

    [data-oex-wizard] .oex-back-icon {
        width: 36px;
        height: 36px;
        border-radius: 12px;
    }

    [data-oex-wizard] .oex-step-meta small {
        display: none;
    }

    [data-oex-wizard] .oex-step-meta strong {
        font-size: 11px;
    }

    [data-oex-wizard] .oex-form-block {
        padding: 12px;
    }

    [data-oex-wizard] .oex-scope-3,
    [data-oex-wizard] .oex-source-3,
    [data-oex-wizard] .oex-sol-4 {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-settings-access {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-neg-row {
        flex-direction: column;
        align-items: stretch;
    }

    [data-oex-wizard] .oex-neg-row .oex-neg-ratio {
        flex: 1 1 auto;
        width: 100%;
    }

    [data-oex-wizard] .oex-key-code-row {
        flex-direction: column;
        align-items: stretch;
    }

    [data-oex-wizard] .oex-key-apply {
        width: 100%;
    }

    [data-oex-wizard] .oex-builder-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    [data-oex-wizard] .oex-class-multi-head {
        flex-direction: column;
        align-items: stretch;
    }

    [data-oex-wizard] .oex-class-multi-actions {
        width: 100%;
    }

    [data-oex-wizard] .oex-class-tool {
        flex: 1;
        justify-content: center;
    }

    [data-oex-wizard] .oex-review-card dl > div {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .stylish-radios {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    [data-oex-wizard] .stylish-radios label {
        width: 100%;
        min-width: 0;
    }

    [data-oex-wizard] .oex-subjects-table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    [data-oex-wizard].oex-wizard-page,
    [data-oex-wizard].settings-page {
        padding-bottom: calc(160px + env(safe-area-inset-bottom, 0px));
    }

    [data-oex-wizard] .oex-wizard-foot {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        margin-top: 0;
        z-index: 40;
        grid-template-columns: 1fr 1fr;
    }

    [data-oex-wizard] .oex-foot-save {
        grid-column: 1 / -1;
        width: 100%;
        justify-self: stretch;
    }

    [data-oex-wizard] .oex-foot-save.is-next-slot {
        grid-column: 2;
        width: auto;
    }

    [data-oex-wizard] .oex-date-grid,
    [data-oex-wizard] .oex-cascade-2,
    [data-oex-wizard] .oex-cascade-3 {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-q-options {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-q-head {
        flex-wrap: wrap;
        gap: 8px;
    }

    [data-oex-wizard] .settings-card.oex-composer {
        padding: 12px;
        min-width: 0;
        max-width: 100%;
        overflow-x: clip;
        border-radius: 19px;
    }

    [data-oex-wizard] .oex-form,
    [data-oex-wizard] .oex-step-panel {
        min-width: 0;
    }

    [data-oex-wizard] .oex-mode-picks,
    [data-oex-wizard] .oex-scope-picks {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    [data-oex-wizard] .disc-notify-toggle {
        width: 100%;
        min-width: 0;
        padding: 12px;
        gap: 10px;
    }

    [data-oex-wizard] .disc-notify-copy {
        min-width: 0;
    }

    [data-oex-wizard] .disc-notify-copy strong {
        font-size: 12px;
        line-height: 1.35;
    }

    [data-oex-wizard] .disc-notify-copy small {
        font-size: 10px;
    }

    [data-oex-wizard] .identity-toggle > label {
        width: 100%;
    }

    [data-oex-wizard] .grading-scale-toggle {
        max-width: none;
    }

    [data-oex-wizard] .form-grid,
    [data-oex-wizard] .form-grid.compact {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .subject-default-grid,
    [data-oex-wizard] .subject-default-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    [data-oex-wizard] .subject-default-grid .secondary-btn,
    [data-oex-wizard] .subject-default-chips .secondary-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        justify-content: center;
        font-size: 11px;
        padding: 8px 10px;
    }

    [data-oex-wizard] .oex-review-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    [data-oex-wizard] .oex-review-card dl > div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    [data-oex-wizard] .oex-class-multi-list {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-class-multi {
        padding: 12px;
    }

    [data-oex-wizard] .oex-math-note {
        font-size: 11px;
        line-height: 1.5;
        margin: 0;
    }

    [data-oex-wizard] .oex-builder-toolbar .primary-btn {
        width: 100%;
        justify-content: center;
    }

    [data-oex-wizard] .oex-q-card {
        padding: 12px;
        min-width: 0;
    }

    [data-oex-wizard] .oex-opt-chip {
        grid-template-columns: 34px minmax(0, 1fr) auto;
        min-width: 0;
    }

    [data-oex-wizard] .oex-key-col {
        min-width: 150px;
    }

    [data-oex-wizard] .oex-subjects-table {
        min-width: 480px;
    }

    [data-oex-wizard] .oex-subject-single-card {
        padding: 12px;
    }

    [data-oex-wizard] .file-picker.compact-file {
        min-width: 0;
    }

    [data-oex-wizard] .oex-context-bar {
        display: block;
        border-radius: 14px;
        margin: 0 0 12px;
        padding: 8px 10px;
    }

    [data-oex-wizard] .oex-context-scroll {
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding-bottom: 6px;
    }

    [data-oex-wizard] .oex-context-lead {
        display: none;
    }

    [data-oex-wizard] .oex-context-link {
        flex: 0 0 auto;
        scroll-snap-align: start;
        min-height: 34px;
        padding: 0 10px;
        font-size: 10.5px;
        white-space: nowrap;
    }

    [data-oex-wizard] .oex-steps {
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        scrollbar-width: thin;
        max-width: 100%;
        min-width: 0;
        width: 100%;
        padding: 10px;
    }

    [data-oex-wizard] .oex-step {
        flex: 0 0 auto !important;
        min-width: 104px;
        max-width: none;
        scroll-snap-align: start;
    }

    [data-oex-wizard] .oex-step-panel.is-active {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: clip;
    }

    [data-oex-wizard] .oex-step-panel.is-active > * {
        min-width: 0;
        max-width: 100%;
    }

    [data-oex-wizard] .oex-wizard-foot {
        padding: 10px 12px;
        border-radius: 18px;
        gap: 8px;
        box-shadow: 0 12px 32px rgba(15, 23, 42, .12);
    }

    [data-oex-wizard] .oex-foot-prev,
    [data-oex-wizard] .oex-foot-next,
    [data-oex-wizard] .oex-foot-save {
        min-height: 44px;
        font-size: 12px;
        justify-content: center;
    }

    [data-oex-wizard] .rte-wrap,
    [data-ohw-create] .rte-wrap,
    [data-ocl-form] .rte-wrap {
        max-width: 100%;
        min-width: 0;
    }

    [data-oex-wizard] .rte-toolbar,
    [data-ohw-create] .rte-toolbar,
    [data-ocl-form] .rte-toolbar {
        gap: 4px;
        padding: 6px;
    }

    [data-oex-wizard] .rte-body,
    [data-ohw-create] .rte-body,
    [data-ocl-form] .rte-body {
        min-height: 160px;
        max-height: 280px;
        padding: 12px;
        font-size: 13px;
    }

    /* Homework create/edit */
    [data-ohw-create] {
        min-width: 0;
        overflow-x: clip;
    }

    [data-ohw-create] .ohw-composer {
        gap: 12px;
        min-width: 0;
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    [data-ohw-create] .settings-card {
        padding: 14px;
        border-radius: 19px;
    }

    [data-ohw-create] .ohw-form-block {
        padding: 12px;
        border-radius: 16px;
        min-width: 0;
    }

    [data-ohw-create] .ohw-date-grid,
    [data-ohw-create] .ohw-cascade-2,
    [data-ohw-create] .ohw-cascade-3 {
        grid-template-columns: 1fr;
    }

    [data-ohw-create] .disc-notify-toggle {
        width: 100%;
        min-width: 0;
    }

    [data-ohw-create] .ohw-mode-picks,
    [data-ohw-create] .stylish-radios {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    [data-ohw-create] .ohw-mode-picks label,
    [data-ohw-create] .stylish-radios label {
        width: 100%;
        min-width: 0;
    }

    [data-ohw-create] .ohw-class-multi-head {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    [data-ohw-create] .ohw-class-multi-actions {
        width: 100%;
    }

    [data-ohw-create] .ohw-class-tool {
        flex: 1;
        justify-content: center;
    }

    [data-ohw-create] .ohw-class-multi-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    [data-ohw-create] .ohw-fab-submit {
        left: 10px;
        right: 10px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        width: auto;
        justify-content: center;
        animation: none;
    }

    /* Class create/edit */
    [data-ocl-form] {
        min-width: 0;
        overflow-x: clip;
    }

    [data-ocl-form] .ohw-composer {
        gap: 12px;
        min-width: 0;
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }

    [data-ocl-form] .settings-card {
        padding: 14px;
        border-radius: 19px;
    }

    [data-ocl-form] .ohw-form-block {
        padding: 12px;
        border-radius: 16px;
        min-width: 0;
    }

    [data-ocl-form] .ohw-date-grid,
    [data-ocl-form] .ohw-cascade-2,
    [data-ocl-form] .ohw-cascade-3,
    [data-ocl-form] .ocl-date-row,
    [data-ocl-form] .ocl-title-slug-row {
        grid-template-columns: 1fr !important;
    }

    [data-ocl-form] .ocl-slug-row {
        flex-direction: column;
        align-items: stretch;
    }

    [data-ocl-form] .ocl-slug-prefix {
        max-width: none;
        border-right: 0;
        border-bottom: 1px solid #e2e8f0;
        border-radius: 12px 12px 0 0;
        font-size: 10px;
        word-break: break-all;
        white-space: normal;
    }

    [data-ocl-form] .ocl-slug-row input {
        border-radius: 0 0 12px 12px !important;
    }

    [data-ocl-form] .disc-notify-toggle {
        width: 100%;
        min-width: 0;
    }

    [data-ocl-form] .ocl-contact-host {
        max-height: min(420px, 55vh);
        padding: 10px;
    }

    [data-ocl-form] .ocl-contact-host .contact-bulk-row {
        flex-direction: column;
        align-items: stretch;
    }

    [data-ocl-form] .ocl-contact-host .contact-selected-count {
        margin-inline-start: 0;
        text-align: center;
    }

    [data-ocl-form] .ohw-fab-submit {
        left: 10px;
        right: 10px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        width: auto;
        justify-content: center;
        animation: none;
    }

    /* Class from schedule wizard */
    [data-ocl-schedule-form] {
        min-width: 0;
        overflow-x: clip;
    }

    [data-ocl-schedule-form] .ocl-sch-hero {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 14px;
    }

    [data-ocl-schedule-form] .ocl-sch-hero-side {
        justify-items: stretch;
    }

    [data-ocl-schedule-form] .ocl-sch-back {
        width: auto;
        justify-content: flex-start;
    }

    [data-ocl-schedule-form] .ocl-sch-back .ohw-back-copy {
        display: none;
    }

    [data-ocl-schedule-form] .ocl-sch-hero-art {
        display: none;
    }

    [data-ocl-schedule-form] .ocl-sch-filters,
    [data-ocl-schedule-form] .ocl-sch-tip-grid {
        grid-template-columns: 1fr;
    }

    .oex-wizard-foot {
        grid-template-columns: 1fr 1fr;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    }

    .oex-steps {
        display: flex;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 8px;
        max-width: 100%;
        min-width: 0;
    }

    .oex-step {
        flex: 0 0 auto !important;
        scroll-snap-align: start;
    }

    .oex-step-connector {
        display: none;
    }

    .oex-context-bar {
        display: block;
        overflow: hidden;
        min-width: 0;
        max-width: 100%;
    }

    .oex-context-scroll {
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 8px;
        max-width: 100%;
        min-width: 0;
        padding-bottom: 6px;
    }

    .oex-context-link {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
    }

    .oex-step-panel.is-active {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-x: clip;
    }

    .oex-step-panel.is-active > * {
        min-width: 0;
        max-width: 100%;
    }

    .oex-card-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .oex-card-btn.is-report-cta {
        min-width: 0;
        width: 100%;
        grid-column: 1 / -1;
    }

    .oex-manage-banner h2 {
        font-size: 18px;
    }

    .oex-meta-list {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .oex-report-kpi {
        grid-template-columns: 1fr;
    }

    .oex-report-title h1 {
        font-size: 20px;
    }

    .oex-answer-grid {
        justify-content: center;
        gap: 10px;
    }

    .oex-answer-col {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .oex-float-dock {
        left: 10px;
        right: 10px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        width: auto;
    }

    .oex-float-btn {
        min-height: 44px;
        justify-content: center;
    }

    .oex-participants-panel .advanced-search {
        grid-template-columns: 1fr;
    }

    .oex-participants-panel .section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .oex-filter-body {
        grid-template-columns: 1fr;
    }

    .ohw-class-multi-list {
        grid-template-columns: 1fr;
    }

    .ocl-sch-filters {
        grid-template-columns: 1fr;
    }

    .ocl-sch-week-chips {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ocl-wait h1 {
        font-size: 1.15rem;
    }

    .ocl-wait-brand {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .ol-dashboard .au-quick-btn strong {
        font-size: 11px;
    }

    .oex-card-actions {
        grid-template-columns: 1fr !important;
    }

    [data-ohw-show] .ohw-detail-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    [data-ohw-show] .ohw-detail-actions .ohw-card-btn span {
        display: inline;
    }

    .oex-action-rail .oex-action-btn span,
    [data-ocl-manage] .ocl-action-btn span {
        font-size: 10px;
    }

    .oex-take-topbar {
        padding: 10px 12px;
    }

    .oex-take-dock {
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom, 0px)) !important;
        width: auto;
    }

    [data-oex-wizard] .oex-wizard-foot {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-foot-prev,
    [data-oex-wizard] .oex-foot-next,
    [data-oex-wizard] .oex-foot-save {
        grid-column: 1;
        width: 100%;
        justify-self: stretch;
    }

    .ocl-sch-week-chips {
        grid-template-columns: 1fr;
    }

    .ohw-card-actions {
        grid-template-columns: 1fr !important;
    }

    [data-ohw-create] .ohw-class-multi-list {
        grid-template-columns: 1fr;
    }

    [data-oex-wizard] .oex-composer-head h2,
    [data-ohw-create] .ohw-composer-head h2,
    [data-ocl-form] .ohw-composer-head h2 {
        font-size: 13px;
    }

    [data-oex-wizard] .subject-default-grid .secondary-btn,
    [data-oex-wizard] .subject-default-chips .secondary-btn {
        flex: 1 1 100%;
    }
}

/* ── Communications (ارتباطات) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout[data-cm-hub],
    .settings-layout[data-cm-tickets],
    .settings-layout[data-cm-notifications],
    .settings-layout[data-cm-sms],
    .settings-layout[data-cm-bots],
    .settings-layout.messenger-admin-page,
    .settings-layout > .cm-dashboard,
    .settings-layout > .settings-page.cm-dashboard,
    .settings-layout > .settings-page.notification-page,
    .settings-layout > .settings-page.ticket-page {
        min-width: 0;
        overflow-x: clip;
    }

    /* Hub dashboard */
    .cm-dashboard .cm-hero,
    .cm-dashboard .au-hero {
        padding: 18px 16px;
    }

    .cm-dashboard .au-hero h1 {
        font-size: 20px;
    }

    .cm-dashboard .au-hero-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    /* Bots hero — pills in one horizontal row */
    .cm-bots-hero .au-hero-meta {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        width: 100%;
        max-width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .cm-bots-hero .au-hero-meta span,
    .cm-bots-hero .au-hero-meta .cm-bots-pill {
        flex: 0 0 auto !important;
        scroll-snap-align: start;
        white-space: nowrap;
    }

    .cm-dashboard .au-hero-art,
    .cm-sms-hero .au-hero-art,
    .cm-bots-hero .cm-bots-hero-art {
        display: none;
    }

    .cm-dashboard .au-quick-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cm-dashboard .au-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cm-dashboard .cm-lists-grid,
    .cm-dashboard .au-lists-grid {
        grid-template-columns: 1fr;
    }

    .cm-dashboard .cm-list-panel .section-head,
    .cm-dashboard .au-list-panel .section-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .cm-dashboard .cm-list-panel .section-head > div:first-child,
    .cm-dashboard .au-list-panel .section-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .cm-dashboard .cm-list-panel .section-head h2,
    .cm-dashboard .au-list-panel .section-head h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
    }

    .cm-dashboard .cm-list-panel .section-head p,
    .cm-dashboard .au-list-panel .section-head p {
        display: none;
    }

    .cm-dashboard .cm-list-panel .section-head .secondary-btn,
    .cm-dashboard .au-list-panel .section-head .secondary-btn {
        width: auto !important;
        flex: 0 0 auto !important;
        min-height: 36px;
        padding: 8px 14px;
        margin-top: 0 !important;
        justify-content: center;
    }

    .cm-dashboard .au-feed-row {
        grid-template-columns: auto minmax(0, 1fr);
        min-width: 0;
    }

    .cm-dashboard .au-feed-row.is-link > div {
        min-width: 0;
    }

    .cm-dashboard .au-feed-row .status-pill,
    .cm-dashboard .au-feed-row .cm-feed-unread {
        grid-column: 2;
        justify-self: start;
        margin-top: 2px;
    }

    .cm-dashboard .au-feed-row .au-feed-chevron {
        align-self: center;
    }

    .cm-dashboard .cm-feed-chat {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    /* Notifications */
    .notification-page {
        min-width: 0;
        overflow-x: clip;
    }

    .notification-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 6px;
        padding: 6px;
        grid-template-columns: unset;
    }

    .notification-tabs a {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
        min-height: 44px;
        padding: 10px 14px;
        font-size: 11px;
    }

    .notification-compose-grid {
        grid-template-columns: 1fr;
        padding: 14px;
    }

    .notification-compose-grid .wide,
    .notification-compose-grid fieldset {
        grid-column: auto;
    }

    .notification-audiences {
        grid-template-columns: 1fr !important;
    }

    .notification-person-filters {
        grid-template-columns: 1fr;
    }

    .notification-person-filters .wide {
        grid-column: auto;
    }

    .notification-person-list {
        grid-template-columns: 1fr !important;
    }

    .notification-full-view > header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .notification-compose > .section-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .notification-compose > .section-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Tickets */
    .settings-layout.ticket-detail-layout {
        grid-template-columns: 1fr;
    }

    .ticket-side-stack {
        min-width: 0;
    }

    .ticket-page {
        min-width: 0;
        overflow-x: clip;
    }

    .ticket-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 6px;
        padding: 6px;
        grid-template-columns: unset;
    }

    .ticket-tabs a {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
        min-height: 44px;
        padding: 10px 14px;
    }

    .ticket-manage-board header {
        flex-wrap: wrap;
        gap: 10px;
    }

    .ticket-toolbar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .ticket-toolbar > div {
        min-width: 0;
    }

    /* Messenger admin */
    .messenger-admin-page > .settings-page,
    .settings-layout.messenger-admin-page > .settings-page {
        min-width: 0;
    }

    .messenger-admin-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 6px;
        padding: 6px;
        position: relative;
        top: auto;
        grid-template-columns: unset;
    }

    .messenger-admin-tabs a {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
        min-height: 44px;
        padding: 10px 12px;
    }

    .messenger-admin-tabs a span {
        white-space: nowrap;
        font-size: 10px;
    }

    .messenger-admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-log-filters,
    .admin-event-filters {
        grid-template-columns: 1fr;
    }

    /* SMS / Bots */
    .cm-sms-page,
    .cm-bots-page {
        min-width: 0;
        overflow-x: clip;
    }

    .cm-sms-alert,
    .cm-bots-alert {
        flex-direction: column;
        align-items: stretch;
    }

    .cm-sms-alert .secondary-btn,
    .cm-bots-alert .secondary-btn {
        width: 100%;
        margin-right: 0;
        justify-content: center;
    }

    .cm-sms-compose-footer,
    .cm-bots-compose-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .cm-sms-compose-footer .primary-btn,
    .cm-bots-compose-footer .primary-btn {
        width: 100%;
        justify-content: center;
    }

    .cm-sms-table-wrap,
    .cm-bots-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cm-sms-section-head {
        flex-wrap: wrap;
        gap: 10px;
    }

    .cm-bots-compose-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .cm-bots-compose-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .cm-bots-selected-badge {
        flex: 0 0 auto;
    }
}

@media (max-width: 680px) {
    .cm-dashboard .au-quick-btn {
        min-height: 88px;
    }

    .cm-dashboard .au-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .cm-dashboard .stat-card {
        padding: 12px;
    }

    .cm-sms-audience-tabs {
        grid-template-columns: 1fr;
    }

    .cm-bots-platform-grid {
        grid-template-columns: 1fr;
    }

    .cm-bots-selection-mode {
        grid-template-columns: 1fr;
    }

    .cm-bots-compose-head {
        flex-wrap: wrap;
    }

    .ticket-side-cards {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .ticket-detail-head {
        flex-wrap: wrap;
    }

    .ticket-status-form {
        width: 100%;
    }

    .ticket-status-form select {
        flex: 1;
        min-width: 0;
    }

    .ticket-message {
        width: min(92%, 100%);
    }

    .messenger-admin-tabs a {
        padding: 8px 10px;
    }

    .notification-tabs a {
        font-size: 10.5px;
        padding: 8px 12px;
    }

    .notification-tabs,
    .ticket-tabs,
    .messenger-admin-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        grid-template-columns: unset !important;
    }
}

@media (max-width: 480px) {
    .ticket-side-cards {
        grid-template-columns: 1fr;
    }

    .messenger-admin-tabs a span {
        font-size: 9px;
    }

    .cm-dashboard .au-quick-btn strong {
        font-size: 11px;
    }
}

/* ── Accounting (حسابداری) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout:has(.settings-menu.acc-nav),
    .settings-layout:has(.settings-menu.lf-nav) {
        min-width: 0;
        overflow-x: clip;
    }

    .settings-layout:has(.settings-menu.acc-nav) > .settings-page,
    .settings-layout:has(.settings-menu.lf-nav) > .settings-page {
        min-width: 0;
        overflow-x: clip;
    }

    /* Hub / list panels — title + action on one row */
    .settings-layout:has(.acc-nav) .settings-page .section-head,
    .settings-layout:has(.acc-nav) .acc-part-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .settings-layout:has(.acc-nav) .settings-page .section-head > div:first-child,
    .settings-layout:has(.acc-nav) .acc-part-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .settings-layout:has(.acc-nav) .settings-page .section-head h2,
    .settings-layout:has(.acc-nav) .acc-part-head h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
    }

    .settings-layout:has(.acc-nav) .settings-page .section-head p,
    .settings-layout:has(.acc-nav) .acc-part-head p {
        display: none;
    }

    .settings-layout:has(.acc-nav) .settings-page .section-head .secondary-btn,
    .settings-layout:has(.acc-nav) .settings-page .section-head .primary-btn,
    .settings-layout:has(.acc-nav) .acc-part-head .secondary-btn,
    .settings-layout:has(.acc-nav) .acc-part-head .primary-btn {
        width: auto !important;
        flex: 0 0 auto !important;
        min-height: 36px;
        padding: 8px 14px;
        margin-top: 0 !important;
        justify-content: center;
    }

    /* Heroes */
    .acc-hero,
    .acc-page-hero,
    .acc-db-hero,
    .acc-student-hero,
    .acc-tu-hero,
    .acc-sf-hero,
    .acc-proj-create-hero,
    .acc-proj-show-hero,
    .ec-page .ec-hero {
        padding: 18px 16px;
    }

    .acc-hero h2,
    .acc-page-hero h2,
    .acc-db-hero h2,
    .acc-student-hero h2,
    .acc-tu-hero h2,
    .acc-sf-hero h2 {
        font-size: 20px;
    }

    .acc-hero-art,
    .acc-tu-hero-visual,
    .acc-sf-hero-orb,
    .acc-proj-create-hero-art {
        display: none;
    }

    .ec-hero-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .ec-hero-actions .primary-btn,
    .ec-hero-actions .secondary-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        justify-content: center;
    }

    /* KPI / stats */
    .acc-kpi-grid,
    .acc-hub-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .acc-db-stats,
    .acc-fe-stats,
    .acc-fe-stats.cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .acc-split {
        grid-template-columns: 1fr;
    }

    /* Scope tabs — horizontal scroll */
    .acc-db-scope {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .acc-db-scope-item {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }

    .acc-db-scope-item span {
        white-space: nowrap;
    }

    /* Filters */
    .acc-db-filter-row label {
        min-width: 0;
    }

    .acc-fe-filter-bar {
        flex-wrap: wrap;
        overflow-x: visible;
        align-items: stretch;
    }

    .acc-fe-filter-bar .acc-grow,
    .acc-fe-filter-search,
    .acc-fe-filter-field {
        flex: 1 1 100%;
        min-width: 0;
    }

    .acc-fe-filter-field.acc-fe-filter-date {
        flex: 1 1 calc(50% - 5px);
    }

    /* Table headers */
    .acc-fe-table-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
        padding: 14px 16px;
    }

    .acc-fe-table-head-text {
        flex: 1 1 auto;
        min-width: 0;
    }

    .acc-fe-table-head h3 {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .acc-fe-table-head p {
        display: none;
    }

    .acc-fe-table-head .secondary-btn,
    .acc-fe-table-head .primary-btn {
        flex: 0 0 auto;
        width: auto !important;
        min-height: 36px;
    }

    /* Tables */
    .acc-fe-table-scroll,
    .acc-fe-table-scroll-wide,
    .acc-db-list-wrap .responsive-table,
    .settings-layout:has(.acc-nav) .responsive-table,
    .acc-payroll-sen-wrap,
    .acc-pay-sheet-wrap,
    .acc-pay-import-preview-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .acc-fe-table {
        min-width: 720px;
    }

    .acc-table,
    .data-table.acc-table,
    .acc-sf-table {
        min-width: 560px;
    }

    /* Payroll */
    .acc-pay-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
    }

    .acc-pay-head-actions {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 8px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .acc-pay-chip {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .acc-pay-head-meta {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        padding-bottom: 2px;
        scrollbar-width: thin;
    }

    .acc-pay-head-meta span,
    .acc-pay-head-meta .dot {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .acc-pay-months-rail {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Sticky / floating bars above mobile nav */
    .acc-pc-float-save {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        padding: 12px 14px;
    }

    .acc-pay-base-fab {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    }

    .acc-bf-save-bar {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    }

    .acc-pay-adv-fab-bar {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    }

    .acc-payroll-page,
    .settings-layout.acc-pc-sheet-page .settings-page,
    .acc-fe-page,
    .acc-debtors-page,
    .acc-checks-page {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }

    /* Projects */
    .acc-proj-show-actions {
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .acc-proj-show-actions .primary-btn,
    .acc-proj-show-actions .secondary-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        justify-content: center;
    }

    .acc-proj-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .acc-proj-filter-bar label,
    .acc-proj-filter-bar .acc-grow {
        width: 100%;
        min-width: 0;
    }

    .acc-proj-filter-bar .primary-btn,
    .acc-proj-filter-bar .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    /* Audit */
    .acc-audit-filter-form {
        grid-template-columns: 1fr;
    }

    .acc-db-hero .acc-audit-stat {
        align-self: flex-start;
    }

    /* Bank / facilities */
    .acc-bf-cards-grid {
        grid-template-columns: 1fr;
    }

    .acc-bank-dl {
        grid-template-columns: 1fr;
    }

    /* Tuition */
    .acc-tu-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Dialogs */
    .settings-layout:has(.acc-nav) .modern-dialog .dialog-card,
    .acc-proj-scope-card {
        width: min(100%, calc(100vw - 24px));
        max-width: none;
    }

    .acc-pay-grid,
    .acc-pay-row-grid {
        grid-template-columns: 1fr;
    }

    .acc-pay-span-2 {
        grid-column: auto;
    }

    /* Learner finance */
    .lf-hub-hero {
        padding: 16px;
        overflow: hidden;
    }

    .lf-profile-row {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .lf-hub-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    .lf-hub-actions a {
        justify-content: center;
        min-height: 44px;
    }

    .lf-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Employment certificates */
    .ec-cards {
        grid-template-columns: 1fr;
    }

    .ec-filter {
        flex-direction: column;
        align-items: stretch;
    }

    .ec-filter .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    /* External self-pay guest page */
    body.epay-body .guest-shell.epay-shell {
        padding: 16px 12px 32px;
    }

    /* Petty cash sheet */
    .acc-pc-panel-head,
    .acc-pc-lines-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 16px 16px 0;
        gap: 10px;
    }

    .acc-pc-panel-head > div:first-child,
    .acc-pc-lines-toolbar > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .acc-pc-panel-head p,
    .acc-pc-lines-toolbar p {
        display: none;
    }

    .acc-pc-panel-head .acc-fe-btn,
    .acc-pc-lines-toolbar .acc-fe-btn {
        flex: 0 0 auto;
    }

    .acc-pc-table-scroll {
        margin: 0 12px 16px;
    }

    .acc-pc-meta-grid {
        grid-template-columns: 1fr;
    }

    .acc-exp-hero-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
}

@media (max-width: 680px) {
    .acc-kpi-grid {
        grid-template-columns: 1fr;
    }

    .acc-hub-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    .acc-hub-card {
        padding: 12px 10px;
        min-width: 0;
    }

    .acc-hub-card strong {
        font-size: 12px;
    }

    .acc-hub-card small {
        font-size: 10px;
        line-height: 1.5;
    }

    .acc-hub-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
        border-radius: 12px;
    }

    .acc-db-stats,
    .acc-fe-stats,
    .acc-fe-stats.cols-3,
    .acc-tu-summary {
        grid-template-columns: 1fr !important;
    }

    .acc-db-hero-side .primary-btn,
    .acc-db-hero-side .secondary-btn,
    .ec-hero-actions .primary-btn,
    .ec-hero-actions .secondary-btn,
    .acc-proj-show-actions .primary-btn,
    .acc-proj-show-actions .secondary-btn {
        flex: 1 1 calc(50% - 4px);
        width: auto;
    }

    .acc-fe-filter-field.acc-fe-filter-date {
        flex: 1 1 100%;
    }

    .acc-db-list-head {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px 16px;
    }

    .acc-db-list-head-pager {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .acc-db-list-head-pager .pagination {
        flex-wrap: nowrap;
        width: max-content;
        min-width: 100%;
    }

    .acc-pay-head-actions {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .acc-pay-head-actions .acc-pay-chip {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
    }

    .acc-pay-money-grid {
        grid-template-columns: 1fr;
    }

    .acc-pay-self-slips {
        grid-template-columns: 1fr 1fr;
    }

    .lf-kpis {
        grid-template-columns: 1fr;
    }

    .lf-hub-actions {
        grid-template-columns: 1fr;
    }

    .acc-form-actions {
        flex-direction: column;
    }

    .acc-form-actions .primary-btn,
    .acc-form-actions .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    .acc-clear-dialog .dialog-actions {
        flex-direction: column;
    }

    .acc-clear-dialog .dialog-actions .primary-btn,
    .acc-clear-dialog .dialog-actions .secondary-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .acc-pay-self-slips {
        grid-template-columns: 1fr;
    }

    .acc-pay-head-actions .acc-pay-chip {
        flex: 1 1 100%;
    }

    body.epay-body .epay-stats {
        grid-template-columns: 1fr;
    }
}

/* ── Admin Affairs (امور اداری) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout.aa-module-layout,
    .settings-layout.aa-module-layout > .settings-page {
        min-width: 0;
        overflow-x: clip;
    }

    .aa-module-layout .settings-page {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }

    /* Section headers — title + action on one row */
    .aa-module-layout .settings-page .section-head,
    .aa-module-layout .aa-section-head,
    .aa-module-layout .af-section-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .aa-module-layout .settings-page .section-head > div:first-child,
    .aa-module-layout .aa-section-head > div:first-child,
    .aa-module-layout .af-section-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .aa-module-layout .settings-page .section-head h2,
    .aa-module-layout .aa-section-head h3,
    .aa-module-layout .af-section-head h3 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
    }

    .aa-module-layout .settings-page .section-head p,
    .aa-module-layout .aa-section-head p,
    .aa-module-layout .af-section-head p {
        display: none;
    }

    .aa-module-layout .settings-page .section-head .secondary-btn,
    .aa-module-layout .settings-page .section-head .primary-btn,
    .aa-module-layout .settings-page .section-head .aa-btn,
    .aa-module-layout .aa-section-head .aa-btn,
    .aa-module-layout .af-section-head .aa-btn {
        width: auto !important;
        flex: 0 0 auto !important;
        min-height: 36px;
        padding: 8px 14px;
        margin-top: 0 !important;
        justify-content: center;
        white-space: nowrap;
    }

    /* Heroes */
    .aa-module-layout .aa-hero,
    .aa-module-layout .aa-page-hero,
    .aa-module-layout .aa-create-hero,
    .aa-module-layout .aa-detail-hero,
    .aa-module-layout .af-hero {
        padding: 18px 16px;
        min-width: 0;
    }

    .aa-module-layout .aa-hero h2,
    .aa-module-layout .aa-page-hero h2,
    .aa-module-layout .aa-create-hero h2 {
        font-size: 20px;
    }

    .aa-module-layout .aa-hero-art,
    .aa-module-layout .aa-create-hero-visual {
        display: none;
    }

    .aa-module-layout .aa-hero-text,
    .aa-module-layout .aa-page-hero-main,
    .aa-module-layout .aa-create-hero-copy {
        min-width: 0;
        width: 100%;
    }

    /* Hero / page actions — horizontal scroll chips */
    .aa-module-layout .aa-hero-actions,
    .aa-module-layout .aa-page-hero-actions,
    .aa-module-layout .aa-create-hero-btns,
    .aa-module-layout .corr-page-hero-actions {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        touch-action: pan-x;
        gap: 8px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .aa-module-layout .aa-hero-actions .primary-btn,
    .aa-module-layout .aa-hero-actions .secondary-btn,
    .aa-module-layout .aa-page-hero-actions .aa-btn,
    .aa-module-layout .aa-create-hero-btns .aa-btn,
    .aa-module-layout .corr-page-hero-actions .aa-btn {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        width: auto !important;
        min-width: max-content;
        white-space: nowrap;
        justify-content: center;
    }

    /* Hub + stats */
    .aa-module-layout .aa-hub-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        min-width: 0;
    }

    .aa-module-layout .aa-stats-strip,
    .aa-module-layout .stats-grid.aa-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .aa-module-layout .aa-stat-tile,
    .aa-module-layout .stat-card {
        min-width: 0;
    }

    /* Scope tabs — horizontal scroll rail */
    .aa-module-layout .aa-scope-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 10px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .aa-module-layout .aa-scope-tab {
        flex: 0 0 min(280px, 78vw);
        scroll-snap-align: start;
    }

    /* Filters */
    .aa-module-layout .aa-filter-form,
    .aa-module-layout .aa-corr-filters-row {
        min-width: 0;
    }

    .aa-module-layout .aa-corr-filter-panel {
        overflow: visible;
    }

    /* Tables */
    .aa-module-layout .corr-table-wrap,
    .aa-module-layout .responsive-table,
    .aa-module-layout .circ-assignee-table-wrap,
    .aa-module-layout .af-card-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .aa-module-layout .corr-table-wrap .data-table,
    .aa-module-layout .responsive-table table {
        min-width: 640px;
    }

    /* Request cards */
    .aa-module-layout .aa-request-card {
        min-width: 0;
    }

    .aa-module-layout .aa-request-meta {
        flex-wrap: wrap;
    }

    /* Detail / timeline */
    .aa-module-layout .aa-detail-grid {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .aa-module-layout .aa-detail-meta {
        flex-wrap: wrap;
    }

    .aa-module-layout .aa-review-actions {
        grid-template-columns: 1fr;
    }

    /* Sticky bars above mobile nav */
    .aa-module-layout .aa-submit-bar,
    .aa-module-layout .aa-form-footer,
    .aa-module-layout .circ-submit-bar,
    .aa-module-layout .corr-submit-bar {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        z-index: 20;
    }

    /* Files drive */
    .aa-module-layout.gd-page,
    .aa-module-layout .gd-page,
    .aa-module-layout .gd-shell,
    .aa-module-layout .gd-main {
        min-width: 0;
        overflow-x: clip;
    }

    .aa-module-layout .gd-toolbar-actions {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 8px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .aa-module-layout .gd-toolbar-actions .aa-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .aa-module-layout .gd-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Correspondence form */
    .aa-module-layout .corr-choice-grid,
    .aa-module-layout .corr-recipient-grid,
    .aa-module-layout .corr-meta-grid {
        grid-template-columns: 1fr;
    }

    .aa-module-layout .corr-limit-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Circulars */
    .aa-module-layout .circ-card-grid,
    .aa-module-layout .circ-form-grid {
        min-width: 0;
    }

    .aa-module-layout .circ-card {
        min-width: 0;
    }

    /* Files settings */
    .aa-module-layout .af-type-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .aa-module-layout .af-storage-drivers {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Correspondence settings tabs */
    .aa-module-layout .corr-settings-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 8px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .aa-module-layout .corr-settings-tab {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .aa-module-layout .aa-hub-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .aa-module-layout .aa-hub-card {
        padding: 12px;
    }

    .aa-module-layout .aa-hub-card strong {
        font-size: 12px;
    }

    .aa-module-layout .aa-hub-card small {
        font-size: 9.5px;
        line-height: 1.5;
    }

    .aa-module-layout .gd-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .aa-module-layout .corr-limit-stats {
        grid-template-columns: 1fr;
    }
}

/* ── Academic Settings (تنظیمات پایه) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout.academic-module-layout,
    .settings-layout.academic-module-layout > .settings-page {
        min-width: 0;
        overflow-x: clip;
    }

    .academic-module-layout .settings-page {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }

    /* Section headers — title + badge/button on one row */
    .academic-module-layout .settings-page .section-head {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 10px;
    }

    .academic-module-layout .settings-page .section-head > div:first-child {
        flex: 1 1 auto;
        min-width: 0;
    }

    .academic-module-layout .settings-page .section-head h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 14px;
    }

    .academic-module-layout .settings-page .section-head p {
        display: none;
    }

    .academic-module-layout .settings-page .section-head .secondary-btn,
    .academic-module-layout .settings-page .section-head .primary-btn,
    .academic-module-layout .settings-page .section-head .status-chip,
    .academic-module-layout .settings-page .section-head .count-badge,
    .academic-module-layout .settings-page .section-head .warning-icon {
        width: auto !important;
        flex: 0 0 auto !important;
        min-height: 36px;
        margin-top: 0 !important;
        white-space: nowrap;
    }

    .academic-module-layout .settings-page .section-head .warning-icon {
        min-height: 0;
        width: 40px !important;
        height: 40px;
    }

    /* Stage / org tabs — horizontal scroll rail */
    .academic-module-layout .stage-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        gap: 8px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
        grid-template-columns: unset !important;
    }

    .academic-module-layout .stage-tabs button,
    .academic-module-layout .stage-tabs a {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
    }

    /* Year rows */
    .academic-module-layout .year-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        min-width: 0;
    }

    .academic-module-layout .year-row > span:nth-child(2) {
        width: 100%;
    }

    .academic-module-layout .year-row .row-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
        overflow: visible;
    }

    .academic-module-layout .year-row .row-actions > form,
    .academic-module-layout .year-row .row-actions > .status-chip {
        width: 100%;
    }

    .academic-module-layout .year-row .row-actions .secondary-btn,
    .academic-module-layout .year-row .row-actions .danger-outline-btn {
        width: 100%;
        justify-content: center;
    }

    .academic-module-layout .year-edit-inline {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }

    .academic-module-layout .year-edit-inline input {
        width: 100%;
        min-width: 0;
        flex: none;
    }

    .academic-module-layout .year-edit-inline .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    /* Transfer form */
    .academic-module-layout .copy-years {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .academic-module-layout .transfer-direction {
        padding: 4px 0;
        justify-self: center;
        transform: none;
    }

    .academic-module-layout .transfer-direction .transfer-arrow-h {
        display: none;
    }

    .academic-module-layout .transfer-direction .transfer-arrow-v {
        display: block;
        font-size: 18px;
    }

    .academic-module-layout .form-grid.compact {
        grid-template-columns: 1fr;
    }

    .academic-module-layout .sticky-save .primary-btn {
        width: 100%;
        justify-content: center;
    }

    .academic-module-layout .copy-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    /* Organizations */
    .academic-module-layout .organization-list,
    .academic-module-layout .organization-manage-card {
        min-width: 0;
    }

    .academic-module-layout .organization-summary {
        flex-wrap: wrap;
        gap: 10px;
    }

    .academic-module-layout .organization-title {
        flex: 1 1 auto;
        min-width: 0;
    }

    .academic-module-layout .grade-list {
        min-width: 0;
    }

    .academic-module-layout .grade-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Subjects */
    .academic-module-layout .subject-default-grid {
        grid-template-columns: 1fr;
    }

    .academic-module-layout .subject-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .academic-module-layout .subject-custom-list {
        grid-template-columns: 1fr;
    }

    /* Classes */
    .academic-module-layout .class-grade-filter {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .academic-module-layout .class-grade-filter .search-submit-btn,
    .academic-module-layout .class-grade-filter .filter-reset-btn {
        width: 100%;
        justify-content: center;
    }

    .academic-module-layout .class-placement-grid {
        grid-template-columns: 1fr;
    }

    .academic-module-layout .class-card-view-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .academic-module-layout .class-assignment-actions {
        grid-template-columns: 1fr;
    }

    /* Timetable */
    .academic-module-layout .tt-org-print-actions,
    .academic-module-layout .tt-class-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .academic-module-layout .tt-class-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 8px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .academic-module-layout .tt-class-tabs button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .academic-module-layout .tt-print-actions {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 8px;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .academic-module-layout .tt-print-actions .tt-print-btn,
    .academic-module-layout .tt-org-print-actions .aa-btn,
    .academic-module-layout .tt-org-print-actions .tt-print-btn-org {
        flex: 0 0 auto;
        white-space: nowrap;
        width: auto !important;
    }

    .academic-module-layout .tt-theme-picks {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        width: 100%;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .academic-module-layout .tt-board-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        border-radius: 16px;
    }

    .academic-module-layout .tt-day-chips {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .academic-module-layout .tt-period-list {
        grid-template-columns: 1fr;
    }

    /* Grading */
    .academic-module-layout .grading-scale-toggle {
        max-width: none;
        width: 100%;
    }

    .academic-module-layout .grading-preset-chips {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 8px;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .academic-module-layout .grading-preset-chips .secondary-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .academic-module-layout .subject-input-row.grading-discipline-row {
        grid-template-columns: minmax(0, 1fr) 96px 40px;
    }

    /* Appearance */
    .academic-module-layout .appearance-org-list {
        grid-template-columns: 1fr;
    }

    .academic-module-layout .appearance-color-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .academic-module-layout .appearance-presets {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 8px;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .academic-module-layout .appearance-presets > em {
        flex: 0 0 auto;
    }

    .academic-module-layout .appearance-presets [data-org-palette] {
        flex: 0 0 auto;
    }

    /* Hub slides */
    .academic-module-layout .hs-page {
        min-width: 0;
        overflow-x: clip;
    }

    .academic-module-layout .hs-studio,
    .academic-module-layout .hs-form,
    .academic-module-layout .hs-gallery {
        min-width: 0;
        max-width: 100%;
    }

    .academic-module-layout .hs-hero {
        min-width: 0;
        max-width: 100%;
    }

    /* Sticky / floating bars above mobile nav */
    .academic-module-layout .sticky-save,
    .academic-module-layout .form-actions.sticky-save {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        z-index: 20;
        padding: 12px 0;
        background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .96) 24%);
    }

    .academic-module-layout .subject-save-all-form {
        left: 12px;
        right: 12px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        z-index: 25;
    }

    .academic-module-layout .tt-grade-fabs {
        left: 12px;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        z-index: 25;
    }

    .academic-module-layout .tt-grade-fab-panel {
        max-height: calc(100vh - 180px);
    }

    /* Tables / responsive scroll */
    .academic-module-layout .responsive-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    /* Dialogs inside academic settings */
    .academic-module-layout .modern-dialog .dialog-card {
        max-width: calc(100vw - 16px);
    }

    .academic-module-layout .teacher-assignment-dialog .dialog-body .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .academic-module-layout .copy-options {
        grid-template-columns: 1fr;
    }

    .academic-module-layout .tt-day-chips {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .academic-module-layout .appearance-color-grid {
        grid-template-columns: 1fr;
    }

    .academic-module-layout .class-card-view-actions {
        grid-template-columns: 1fr;
    }

    .academic-module-layout .subject-input-row.grading-discipline-row {
        grid-template-columns: 1fr auto;
    }

    .academic-module-layout .grading-discipline-row .grading-penalty-field {
        grid-column: 1 / -1;
    }
}

/* ── Reports (گزارشات) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout.rep-layout,
    .settings-layout.rep-layout > .settings-page.rep-page {
        min-width: 0;
        overflow-x: clip;
    }

    .rep-layout .rep-page {
        gap: 16px;
        padding: 2px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }

    .rep-layout .rep-filters-head {
        padding: 14px 16px;
    }

    .rep-layout .rep-filters-head small {
        display: none;
    }

    .rep-layout .rep-panel-card ul li {
        flex-wrap: wrap;
        gap: 6px;
    }

    .rep-layout .rep-panel-card ul li strong {
        margin-inline-start: auto;
    }

    .rep-layout [data-rep-results] {
        min-width: 0;
    }

    .rep-layout .rep-results-stack {
        gap: 16px;
        min-width: 0;
    }

    .rep-layout .pretty-select,
    .rep-layout .pretty-select-trigger {
        min-width: 0;
        max-width: 100%;
    }

    .rep-layout .rep-filter-form .pretty-select {
        width: 100%;
    }
}

/* ── System Settings (تنظیمات سامانه) — full mobile responsive ── */
@media (max-width: 900px) {
    .settings-layout.sys-settings-layout,
    .settings-layout.sys-settings-layout > .settings-page {
        min-width: 0;
        overflow-x: clip;
    }

    .sys-settings-layout .sys-settings-page {
        gap: 12px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }

    .sys-settings-layout .sys-block {
        min-width: 0;
        border-radius: 16px;
    }

    .sys-settings-layout .sys-form-section {
        padding: 14px 14px 14px 18px;
    }

    .sys-settings-layout .form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .sys-settings-layout .form-grid label.full,
    .sys-settings-layout .form-grid .full {
        grid-column: 1 / -1;
    }

    .sys-settings-layout .sys-org-dual-logos,
    .sys-settings-layout .sys-media-grid {
        gap: 12px;
    }

    .sys-settings-layout .sys-media-preview,
    .sys-settings-layout .sys-org-logo-card .sys-media-preview {
        max-width: 100%;
    }

    .sys-settings-layout .upload-row,
    .sys-settings-layout .upload-choice {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .sys-settings-layout .upload-row .file-btn,
    .sys-settings-layout .upload-row .primary-btn,
    .sys-settings-layout .upload-row .secondary-btn {
        width: 100%;
        justify-content: center;
    }

    .sys-settings-layout .sys-theme-preview {
        padding: 14px;
    }

    .sys-settings-layout .sys-maint-card {
        padding: 14px;
    }

    .sys-settings-layout .sys-maint-timer,
    .sys-settings-layout .sys-maint-datetime {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .sys-settings-layout .sys-maint-timer input,
    .sys-settings-layout .sys-maint-datetime input {
        width: 100%;
    }

    .sys-settings-layout .responsive-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        margin-inline: 0;
    }

    .sys-settings-layout .responsive-table table {
        min-width: 560px;
    }

    .sys-settings-layout .sys-audit-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    /* Modules page */
    .sys-settings-layout .sys-modules-note {
        margin-inline: 14px;
        padding: 12px 14px;
    }

    .sys-settings-layout .sys-mod-grid {
        gap: 10px;
        padding-inline: 14px;
    }

    .sys-settings-layout .sys-mod-card {
        padding: 12px 14px;
    }

    .sys-settings-layout .sys-modules-save-fab {
        left: 12px;
        right: auto;
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        z-index: 25;
    }

    /* Notifications */
    .sys-settings-layout.sys-notif-page .sys-block {
        padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    }

    .sys-settings-layout .sys-notif-role-tier-grid,
    .sys-settings-layout .sys-notif-events-grid {
        gap: 10px;
    }

    .sys-settings-layout .sys-notif-events-grid > * {
        min-width: 0;
    }

    .sys-settings-layout .sys-notif-channel-pills {
        flex-wrap: wrap;
        gap: 8px;
    }

    .sys-settings-layout .sys-notif-template-audiences {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 8px;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .sys-settings-layout .sys-notif-template-audiences button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .sys-settings-layout .sys-notif-template-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        gap: 6px;
        padding-bottom: 4px;
        scrollbar-width: thin;
    }

    .sys-settings-layout .sys-notif-template-tabs button {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    /* Bots */
    .sys-settings-layout .bots-settings-page.has-floating-save {
        padding-bottom: calc(88px + 78px + env(safe-area-inset-bottom, 0px));
    }

    .sys-settings-layout .bots-card-head {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding: 14px 16px;
    }

    .sys-settings-layout .bots-card-head p {
        display: none;
    }

    .sys-settings-layout .bots-card-head-main {
        flex: 1 1 auto;
        min-width: 0;
    }

    .sys-settings-layout .bots-card-head h3 {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sys-settings-layout .bots-card-body {
        padding: 14px 16px 16px;
    }

    .sys-settings-layout .bots-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sys-settings-layout .bots-users-grid {
        grid-template-columns: 1fr;
    }

    .sys-settings-layout .bots-users-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .sys-settings-layout .bots-users-search {
        width: 100%;
        min-width: 0;
    }

    .sys-settings-layout .bots-users-search input {
        width: 100%;
    }

    .sys-settings-layout .bots-test-result pre,
    .sys-settings-layout .bots-guide-content pre {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Sticky save bars above mobile bottom nav */
    .sys-settings-layout .sys-save-bar,
    .sys-settings-layout .form-actions.sticky-save,
    .sys-settings-layout .sticky-save {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        z-index: 20;
    }

    .sys-settings-layout .pretty-select,
    .sys-settings-layout .pretty-select-trigger {
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .sys-settings-layout .sys-theme-grid {
        grid-template-columns: 1fr;
    }

    .sys-settings-layout .bots-stats-grid {
        grid-template-columns: 1fr;
    }

    .sys-settings-layout .sys-notif-stat {
        min-width: 72px;
        padding: 10px 12px;
    }

    .sys-settings-layout .sys-mod-card {
        flex-wrap: wrap;
    }

    .sys-settings-layout .sys-mod-card .sys-mod-toggle {
        margin-inline-start: auto;
    }
}

/* ── Universal completion (all modules / layouts) ───────────────── */
@media (max-width: 900px) {
    .page-content,
    .settings-content,
    .hub-content,
    .msg-main,
    .ocr-main,
    .guest-shell {
        min-width: 0;
        max-width: 100%;
    }

    [class*="toolbar"],
    [class*="filters"],
    [class*="-toolbar"],
    [class*="-filters"] {
        flex-wrap: wrap;
        gap: 8px;
        max-width: 100%;
    }

    [class*="grid"]:not(.stats-grid):not(.mobile-nav):not(.hub-sc-grid):not(.sc-grid):not(.seat-desks):not(.seat-workspace-grid) {
        min-width: 0;
    }

    .panel,
    .settings-card,
    .quick-panel,
    .lf-card,
    .aa-card,
    .acc-card,
    .cm-card,
    .report-panel {
        max-width: 100%;
        min-width: 0;
    }
}

@media (max-width: 680px) {
    .list-page-size,
    .bulk-toolbar label,
    .filter-bar label {
        width: 100%;
    }

    .list-page-size select,
    .bulk-toolbar select,
    .filter-bar select,
    .filter-bar input {
        width: 100%;
        min-width: 0;
    }

    .user-filters-form,
    .advanced-search form,
    [class*="filter-form"] {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .pagination a,
    .pagination button,
    .pager a,
    .pager button {
        min-height: 40px;
        min-width: 40px;
    }

    .hub-sc-grid {
        min-width: 520px;
    }

    .hub-sc-scroll,
    .hub-calendar-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── Global list/table mobile safety (all modules) ── */
@media (max-width: 900px) {
    .responsive-table,
    .table-wrap,
    .table-scroll,
    .table-responsive,
    [data-table-scroll],
    .data-table-wrap,
    .users-table-panel .responsive-table,
    .acc-fe-table-scroll,
    .acc-fe-table-scroll-wide,
    .cm-bots-table-wrap,
    .cm-sms-table-wrap,
    .sports-table-wrap,
    .corr-table-wrap,
    .circ-assignee-table-wrap,
    .oex-subjects-table-wrap,
    .oex-participants-scroll,
    .acc-pc-table-scroll,
    .acc-pay-fund-table-wrap,
    .rep-table-panel .responsive-table {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        max-width: 100%;
    }

    .data-table,
    table.data-table {
        max-width: none !important;
        table-layout: auto !important;
    }

    .data-table:not([class*="print"]):not(.hub-sc-grid):not(.hub-tt-table):not(.lst-table):not(.dn-att-table):not(.dn-summon-table):not(.dn-info-table) {
        min-width: 640px;
    }

    .users-data-table {
        min-width: 760px !important;
    }

    .users-data-table.is-students {
        min-width: 980px !important;
    }

    .users-data-table.is-prereg {
        min-width: 1000px !important;
    }

    .data-table th,
    .data-table td {
        word-break: normal;
        overflow-wrap: normal;
    }

    .users-data-table .col-org,
    .users-data-table .col-status,
    .users-data-table .col-user .user-cell-text {
        overflow-wrap: anywhere;
        word-break: break-word;
        white-space: normal;
    }
}

/* Keep text fields ≥16px on phones so iOS/Android do not zoom+jump on focus.
   Loaded last among global CSS; !important beats most module overrides. */
@media (max-width: 980px), (hover: none) and (pointer: coarse) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
    select,
    textarea,
    [contenteditable="true"],
    .pretty-select-search,
    .msg-field input,
    .msg-field select,
    .msg-field textarea,
    .contact-search input {
        font-size: 16px !important;
    }
}
