/* System-wide width guardrails.
 * Pages and tables fit the available viewport width without horizontal scroll.
 */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.app-shell,
.app-content,
.page,
.public-shell,
.public-main,
.public-main > .container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.app-content > *,
.page > *,
.public-main > *,
.form-grid,
.toolbar,
.data-table-toolbar {
    max-width: 100%;
    min-width: 0;
}

.table-card,
.desktop-table,
.table-wrap,
.table-responsive {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Keep the desktop navigation background running for the full document height.
 * app.css fixes the sidebar to 100vh, which makes it visually stop when a page
 * is taller than one viewport. On desktop the sidebar should stretch with the
 * app shell instead. Mobile/off-canvas behavior is left untouched.
 */
@media (min-width: 1025px) {
    .app-shell {
        align-items: stretch;
    }

    .app-shell > .sidebar {
        position: relative !important;
        top: auto !important;
        height: auto !important;
        min-height: 100vh;
        align-self: stretch;
        overflow-y: visible;
    }
}

/* app.css historically forced table wrappers to scroll and tables to a
 * 720/760px minimum width. Override that globally so tables stay at 100%.
 */
.desktop-table,
.table-wrap,
.table-responsive,
.table-card .table-responsive {
    overflow-x: visible !important;
}

.data-table,
.desktop-table > table,
.table-wrap > table,
.table-responsive > table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: auto;
}

.data-table th,
.data-table td,
.desktop-table > table th,
.desktop-table > table td,
.table-wrap > table th,
.table-wrap > table td,
.table-responsive > table th,
.table-responsive > table td {
    min-width: 0 !important;
    max-width: none;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: normal;
}

.table-actions,
.icon-actions,
.data-table-actions {
    flex-wrap: wrap;
    max-width: 100%;
}

.data-table th > *,
.data-table td > *,
.desktop-table > table th > *,
.desktop-table > table td > *,
.table-wrap > table th > *,
.table-wrap > table td > *,
.table-responsive > table th > *,
.table-responsive > table td > * {
    max-width: 100%;
}

/* Teacher Workload: keep the summary extremely compact. */
.twl-page {
    gap: .65rem !important;
}

.twl-page .twl-teacher-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .2rem .9rem;
    padding: .38rem .65rem;
    min-height: 0;
}

.twl-page .twl-teacher-card .twl-section-heading,
.twl-page .twl-teacher-card > p {
    display: none !important;
}

.twl-page .twl-teacher-facts {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .18rem 1rem;
    margin: 0;
}

.twl-page .twl-teacher-facts > div {
    display: inline-flex;
    align-items: baseline;
    gap: .28rem;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

/* Nisab is already summarized directly below, so do not repeat the target. */
.twl-page .twl-teacher-facts > div:nth-child(4) {
    display: none;
}

.twl-page .twl-teacher-facts dt {
    margin: 0;
    color: var(--muted, #64748b);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.twl-page .twl-teacher-facts dd {
    margin: 0;
    font-size: .8rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

/* Teacher Workload Nisab summary: one compact row, always selected/target. */
.twl-page .twl-status-grid {
    gap: .5rem;
}

.twl-page .twl-status-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .55rem;
    min-height: 0;
    padding: .4rem .62rem;
}

.twl-page .twl-status-card-header {
    flex: 0 0 auto;
    justify-content: flex-start;
}

.twl-page .twl-status-card h2 {
    font-size: .78rem;
    line-height: 1.15;
}

.twl-page .twl-status-badge,
.twl-page .twl-status-card p,
.twl-page .twl-status-card small {
    display: none !important;
}

.twl-page .twl-status-hours {
    gap: .2rem;
    margin: 0;
    white-space: nowrap;
}

.twl-page .twl-status-hours::before {
    content: "Nisab:";
    font-size: .72rem;
    font-weight: 800;
}

.twl-page .twl-status-hours strong {
    font-size: .95rem;
    line-height: 1;
}

.twl-page .twl-status-hours span {
    font-size: .72rem;
}

/* Available-module add action is intentionally icon-only. */
.twl-page .twl-available-table td:last-child .button.button-primary.button-small {
    display: inline-grid;
    place-items: center;
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    gap: 0;
    font-size: 0;
    line-height: 0;
}

.twl-page .twl-available-table td:last-child .button.button-primary.button-small svg {
    width: 16px;
    height: 16px;
}

/* Module code appears below the module name as a compact label. */
.twl-module-code-label {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 30px;
    margin-top: .28rem;
    padding: .3rem .6rem;
    border: 1px solid rgba(127, 127, 127, .28);
    border-radius: 999px;
    background: rgba(127, 127, 127, .08);
    color: inherit;
    font-size: .82rem;
    line-height: 1.2;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
}

.twl-page .data-table th small {
    font-size: .7rem;
    font-weight: 700;
    color: var(--muted, #64748b);
}

@media (max-width: 680px) {
    .twl-page .twl-teacher-card {
        align-items: flex-start;
    }

    .twl-page .twl-teacher-facts {
        flex-basis: 100%;
        gap: .25rem .7rem;
    }

    .twl-page .twl-status-card {
        padding: .45rem .55rem;
    }
}
