/* ── Google Font ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Reset & Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Inter', Arial, sans-serif;
    background: #f5f0fa;
    color: #1e293b;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Page wrapper ────────────────────────────────────────────────────────────── */
.page { max-width: 1380px; margin: 0 auto; padding: 0 0 40px; }

/* ── Top bar ─────────────────────────────────────────────────────────────────── */
.topbar {
    background: linear-gradient(135deg, #3d1266 0%, #57208c 60%, #7b2ca8 100%);
    color: #fff;
    padding: 0 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    box-shadow: 0 4px 20px rgba(37,99,235,.35);
}
.topbar h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -.3px;
    margin: 0;
}
.topbar p { margin: 2px 0 0; opacity: .75; font-size: .82rem; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.top-actions span { font-size: .82rem; opacity: .85; }
.school-badge {
    background: rgba(255,255,255,.2);
    border-radius: 20px;
    padding: 3px 12px;
    font-size: .75rem;
    font-weight: 700;
    margin-left: 10px;
    vertical-align: middle;
    letter-spacing: .3px;
}


/* ── Site Header ────────────────────────────────────────────────────────────── */
.site-header {
    background: #fff;
    padding: 10px 32px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #ede0f8;
}
.site-header-inner {
    max-width: 1380px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    padding: 8px 0;
}
.site-logo {
    display: flex;
    justify-content: center;
    align-items: center;
}
.site-logo img {
    height: 100px !important;
    width: 100px !important;
    max-height: 100px !important;
    max-width: 100px !important;
    object-fit: contain;
    display: block;
}
.site-user {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.user-school {
    background: #f7effe;
    border: 1px solid #ddb6f0;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: .78rem;
    font-weight: 600;
    color: #57208c;
    white-space: nowrap;
}
.user-name {
    font-size: .82rem;
    color: #57208c;
    font-weight: 600;
    white-space: nowrap;
}
/* ── Nav bar (inside header) ─────────────────────────────────────────────────── */
.nav-bar { display: none; } /* legacy — replaced by site-nav */
.site-nav {
    display: flex;
    gap: 4px;
    padding: 4px 20px 0;
    flex-wrap: wrap;
    justify-content: center;
}
.site-nav a {
    color: #57208c;
    text-decoration: none;
    padding: 8px 20px;
    font-size: .85rem;
    font-weight: 600;
    border-radius: 0;
    display: inline-block;
    transition: all .15s;
    border-bottom: 3px solid transparent;
    letter-spacing: .2px;
}
.site-nav a:hover { color: #57208c; border-bottom-color: #ddb6f0; }
.site-nav a.nav-active { color: #57208c; border-bottom-color: #57208c; font-weight: 700; }

/* ── Main content area ───────────────────────────────────────────────────────── */
.main-content { padding: 24px 28px; }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 22px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    margin-bottom: 20px;
    border: 1px solid #e8edf5;
}
.card h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.login-card { max-width: 460px; margin: 60px auto; }

/* ── Stats ───────────────────────────────────────────────────────────────────── */
.stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.stat {
    background: #fff;
    border-radius: 14px;
    padding: 18px 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,.055);
    border: 1px solid #e8edf5;
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #7b36b8, #8b5cf6);
}
.stat h3 { font-size: 2rem; font-weight: 800; color: #57208c; line-height: 1; margin-bottom: 4px; }
.stat p { font-size: .75rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .5px; margin: 0; }

/* ── Grade tabs — BIG and prominent ─────────────────────────────────────────── */
.grade-tabs-wrap {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: #fff;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid #e8edf5;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    align-items: center;
}
.grade-tabs-label {
    font-size: .72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-right: 4px;
}
.grade-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: #f8faff;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    color: #475569;
    transition: all .18s;
    letter-spacing: -.2px;
    min-width: 90px;
    text-align: center;
}
.grade-tab:hover { border-color: #ce93e8; background: #f7effe; color: #57208c; }
.grade-tab.active {
    border-color: #57208c;
    background: linear-gradient(135deg, #57208c, #7b2ca8);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37,99,235,.35);
}

/* ── Subject items ───────────────────────────────────────────────────────────── */
.subject-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    background: #f8faff;
    border: 2px solid #e8edf5;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.subject-item:hover { border-color: #ce93e8; background: #f7effe; }
.subject-item.active {
    background: linear-gradient(135deg, #57208c, #7b2ca8);
    border-color: #57208c;
    color: #fff;
}
.subject-item.active .tenure-badge { opacity: .85; }
.subject-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(37,99,235,.12);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
}
.subject-item.active .subject-icon { background: rgba(255,255,255,.2); }
.subject-name { font-size: .9rem; font-weight: 600; }

/* ── Topic rows ──────────────────────────────────────────────────────────────── */
.topic-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    background: #f8faff;
    border: 2px solid #e8edf5;
    cursor: pointer;
    transition: all .15s;
}
.topic-row:hover { border-color: #ce93e8; background: #f7effe; }
.topic-row.active-topic {
    background: linear-gradient(135deg, #57208c, #7b2ca8);
    border-color: #57208c;
    color: #fff;
}
.topic-num {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(37,99,235,.12);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .75rem; color: #57208c; flex-shrink: 0;
}
.topic-row.active-topic .topic-num { background: rgba(255,255,255,.25); color: #fff; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #57208c, #7b2ca8);
    color: #fff;
    text-decoration: none;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: .88rem;
    font-weight: 600;
    font-family: inherit;
    transition: opacity .15s, transform .1s;
    letter-spacing: .1px;
}
.btn:hover { opacity: .9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.danger { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.btn.secondary { background: linear-gradient(135deg, #475569, #334155); }
.btn.success { background: linear-gradient(135deg, #16a34a, #15803d); }
.btn.small { padding: 6px 12px; font-size: .78rem; border-radius: 8px; }

/* ── Delete button ───────────────────────────────────────────────────────────── */
.del-btn {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    padding: 5px 11px;
    border-radius: 8px;
    font-size: .75rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all .15s;
    white-space: nowrap;
}
.del-btn:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
label {
    display: block;
    font-weight: 600;
    font-size: .82rem;
    margin-bottom: 5px;
    color: #374151;
}
input, select, textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: .9rem;
    font-family: inherit;
    color: #1e293b;
    background: #f9fafb;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #7b36b8;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
    background: #fff;
}

/* ── Grid layouts ────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ── Table ───────────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
    background: #f7effe;
    padding: 10px 12px;
    border-bottom: 2px solid #d4a4e8;
    text-align: left;
    vertical-align: middle;
    font-size: .77rem;
    font-weight: 700;
    color: #57208c;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: .84rem;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8faff; }
.table td.thumb-cell { padding: 6px 8px !important; width: 68px !important; max-width: 68px !important; overflow: hidden !important; }
.table td.thumb-cell * { max-width: 52px !important; max-height: 52px !important; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.approved  { background: #dcfce7; color: #166534; }
.pending   { background: #fef3c7; color: #92400e; }
.rejected  { background: #fee2e2; color: #991b1b; }

/* ── Alerts ──────────────────────────────────────────────────────────────────── */
.alert {
    padding: 13px 18px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: .88rem;
    font-weight: 500;
    border-left: 4px solid;
}
.alert.success { background: #f0fdf4; color: #166534; border-color: #22c55e; }
.alert.error   { background: #fef2f2; color: #991b1b; border-color: #ef4444; }

/* ── Sidebar layout (teacher/student) ───────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
.sidebar .subject-link {
    display: block;
    padding: 12px 15px;
    border-radius: 12px;
    text-decoration: none;
    color: #1e293b;
    margin-bottom: 8px;
    background: #f8faff;
    border: 2px solid #e8edf5;
    font-weight: 500;
    font-size: .88rem;
    transition: all .15s;
}
.sidebar .subject-link:hover { border-color: #ce93e8; background: #f7effe; }
.sidebar .subject-link.active {
    background: linear-gradient(135deg, #57208c, #7b2ca8);
    border-color: #57208c;
    color: #fff;
}

/* ── Misc ────────────────────────────────────────────────────────────────────── */
.muted { color: #64748b; font-size: .85rem; }
.empty {
    padding: 24px;
    background: #f8fafc;
    border: 1.5px dashed #cbd5e1;
    border-radius: 12px;
    color: #94a3b8;
    text-align: center;
    font-size: .85rem;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.notice-box {
    background: #fffbeb;
    border: 1.5px solid #fbbf24;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: .85rem;
    color: #92400e;
}

/* ── Thumbnails ──────────────────────────────────────────────────────────────── */
.thumb-wrap {
    position: relative;
    width: 52px !important; height: 52px !important;
    min-width: 52px !important; max-width: 52px !important;
    min-height: 52px !important; max-height: 52px !important;
    border-radius: 8px; overflow: hidden !important;
    background: #f1f5f9;
    display: block !important;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}
.thumb-img, .thumb-wrap img { width: 52px !important; height: 52px !important; max-width: 52px !important; max-height: 52px !important; object-fit: cover !important; display: block !important; border-radius: 6px; }
.thumb-video { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.thumb-link { display: block; width: 100%; height: 100%; position: relative; }
.thumb-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.5);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    gap: 4px; font-size: .65rem; font-weight: 700;
    opacity: 0; transition: opacity .18s;
    border-radius: 8px; cursor: pointer;
}
.thumb-wrap:hover .thumb-overlay { opacity: 1; }
.thumb-wrap:hover .thumb-img { transform: scale(1.07); }
.thumb-icon { font-size: 1rem; }
.thumb-doc { background: #f7effe; border: 1.5px solid #ddb6f0; }
.thumb-doc .thumb-link { display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; }
.thumb-doc-icon { font-size: 1.3rem; line-height: 1; }
.thumb-doc-label { font-size: .52rem; font-weight: 700; color: #57208c; margin-top: 2px; text-transform: uppercase; }
.no-file { color: #94a3b8; font-size: .78rem; }

/* ── Tenure badges ───────────────────────────────────────────────────────────── */
.tenure-badge {
    display: inline-block; padding: 2px 9px; border-radius: 10px;
    font-size: .68rem; font-weight: 700; letter-spacing: .3px;
}
.tenure-active   { background: #dcfce7; color: #166534; }
.tenure-expired  { background: #fee2e2; color: #991b1b; }
.tenure-upcoming { background: #fef3c7; color: #92400e; }
.tenure-none     { background: #f1f5f9; color: #64748b; }
.tenure-dates    { font-size: .72rem; color: #94a3b8; margin-top: 3px; }

/* ── School cards (superadmin) ───────────────────────────────────────────────── */
.school-card {
    background: #fff;
    border-radius: 14px;
    padding: 16px 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,.055);
    border: 1.5px solid #e8edf5;
    border-left: 4px solid #7b36b8;
    margin-bottom: 10px;
    transition: box-shadow .15s;
}
.school-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.1); }
.school-card.inactive { border-left-color: #cbd5e1; opacity: .7; }

/* ── Responsive (desktop/tablet only — mobile handled in header.php inline styles) ── */
@media (max-width: 980px) {
    .layout, .grid-2 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(3, 1fr); }
    .main-content { padding: 16px; }
    .grade-tab { font-size: .88rem; padding: 8px 16px; min-width: 70px; }
}
@media (max-width: 560px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── 3-column layout ── */
.col3-layout {
    display: grid;
    grid-template-columns: 210px 230px 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 1080px) {
    .col3-layout { grid-template-columns: 200px 1fr; }
    .col3-layout > *:nth-child(3) { grid-column: 1 / -1; }
}

/* ── Topic tabs ── */
.topic-tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px; }
.topic-tab { padding:6px 15px; border-radius:20px; border:2px solid #e2e8f0; background:#f8faff; color:#475569; font-size:.8rem; font-weight:600; text-decoration:none; transition:all .15s; white-space:nowrap; }
.topic-tab:hover { border-color:#ce93e8; background:#f7effe; color:#57208c; }
.topic-tab.active { border-color:#57208c; background:linear-gradient(135deg,#57208c,#7b2ca8); color:#fff; }

/* ── Table horizontal scroll wrapper ── */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; border-radius:12px; }


/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE TABLE FIX — all data tables become card-style on mobile
   ══════════════════════════════════════════════════════════════════════════════ */

/* Wrap all table containers */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }

@media (max-width: 768px) {

    /* ── Any div with overflow-x:auto containing a table ── */
    div[style*="overflow-x"] { max-width: 100%; box-sizing: border-box; }

    /* ── General table: hide header, stack rows as cards ── */
    .table {
        display: block !important;
        width: 100% !important;
    }
    .table thead { display: none !important; }
    .table tbody { display: block !important; width: 100% !important; }
    .table tr {
        display: block !important;
        margin-bottom: 12px !important;
        border: 1.5px solid #ede0f8 !important;
        border-radius: 10px !important;
        padding: 10px 12px !important;
        background: #fff !important;
        box-shadow: 0 1px 4px rgba(87,32,140,.07) !important;
    }
    .table td {
        display: block !important;
        padding: 4px 0 !important;
        border: none !important;
        font-size: .83rem !important;
        word-break: break-word !important;
        white-space: normal !important;
    }
    /* Label each cell using data-label attribute */
    .table td[data-label]:before {
        content: attr(data-label) ": ";
        font-weight: 700;
        font-size: .72rem;
        color: #94a3b8;
        text-transform: uppercase;
        display: inline;
    }
    /* Thumb cell stays compact */
    .table td.thumb-cell {
        display: inline-block !important;
        width: 60px !important;
        vertical-align: top !important;
        padding-right: 8px !important;
    }

    /* ── Matrix table: keep scrollable, don't stack ── */
    .matrix-table {
        display: table !important;
        font-size: .7rem !important;
        min-width: 500px;
    }
    .matrix-table thead { display: table-header-group !important; }
    .matrix-table tbody { display: table-row-group !important; }
    .matrix-table tr { display: table-row !important; border-radius: 0 !important; box-shadow: none !important; padding: 0 !important; }
    .matrix-table td, .matrix-table th { display: table-cell !important; padding: 4px 6px !important; white-space: nowrap !important; }

    /* ── Stats table (if any): keep normal ── */
    .stats-table { display: table !important; }

    /* ── Card layout fix: prevent overflow ── */
    .card { overflow: hidden !important; word-wrap: break-word !important; }
    .card * { max-width: 100% !important; box-sizing: border-box !important; }
    /* Exception: don't constrain images/SVGs wrongly */
    .card img { max-width: 100% !important; height: auto !important; }
    .card svg { max-width: none !important; }

    /* ── Content inside cards ── */
    h2, h3 { word-break: break-word !important; }
    code { word-break: break-all !important; }

    /* ── Prevent any element from exceeding viewport ── */
    * { max-width: 100vw; }
    img, video, iframe, embed, object { max-width: 100% !important; height: auto; }

    /* ── Form elements full width ── */
    input[type=text], input[type=password], input[type=email],
    input[type=tel], input[type=date], input[type=number],
    input[type=search], select, textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* ── Buttons in rows wrap ── */
    .actions { flex-wrap: wrap !important; gap: 6px !important; }

    /* ── Grade/topic heading in content pages ── */
    .grade-heading, .subject-heading, .topic-heading {
        word-break: break-word !important;
        white-space: normal !important;
    }

    /* ── Expand/collapse topic blocks ── */
    [id^="grade"], [id^="s"], [id^="t"], [id^="mgmt"], [id^="tTopic"], [id^="stCat"] {
        overflow: hidden !important;
    }

    /* ── Feed post ── */
    .feed-post { margin-left: 0 !important; margin-right: 0 !important; }
    .feed-caption { word-break: break-word !important; }
    .feed-comment-item { word-break: break-word !important; }

    /* ── Badge/pill overflow ── */
    .badge, .st, .cat-pill {
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 120px !important;
        display: inline-block !important;
        vertical-align: middle !important;
    }
}


/* ══════════════════════════════════════════════════════════════
   CRITICAL MOBILE FIX — force all content inside cards to stay
   within screen width. Applied with maximum specificity.
   ══════════════════════════════════════════════════════════════ */
@media screen and (max-width: 768px) {

    /* Nuclear overflow fix */
    html { overflow-x: hidden !important; }
    body { overflow-x: hidden !important; width: 100% !important; }
    .page { overflow-x: hidden !important; width: 100% !important; max-width: 100vw !important; }
    .main-content { overflow-x: hidden !important; }
    .card { overflow: hidden !important; }

    /* All table containers become scrollable */
    .card div[style*="overflow-x"] {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-width: 100% !important;
    }

    /* Shrink table font and cell padding aggressively */
    .card .table { font-size: .72rem !important; }
    .card .table th { padding: 5px 5px !important; font-size: .68rem !important; white-space: nowrap !important; }
    .card .table td { padding: 5px 5px !important; white-space: normal !important; word-break: break-word !important; }

    /* Specific column hiding on very small tables */
    .card .table .hide-mobile { display: none !important; }

    /* Content card rows are already full width */
    .content-card-row { width: 100% !important; box-sizing: border-box !important; overflow: hidden !important; }

    /* Fix any inline-style overflow containers */
    [style*="overflow-x:auto"] {
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Prevent text overflow */
    .card * {
        max-width: 100% !important;
        word-break: break-word !important;
    }
    /* Exceptions - don't break SVG/button/badge layout */
    .card svg,
    .card button,
    .card .badge,
    .card .btn { max-width: none !important; word-break: normal !important; }

    /* Fix long school names / usernames */
    .card strong, .card td, .card span {
        overflow-wrap: break-word !important;
    }

    /* Grade headings */
    .grade-heading, .subject-heading, .topic-heading {
        word-break: break-word !important;
        white-space: normal !important;
        font-size: .88rem !important;
    }
}


/* ── Fix all hardcoded 2-col grids on mobile ─────────────────────────────── */
@media (max-width: 768px) {
    /* Target any grid with fixed column widths */
    .resp-2col-grid,
    .sa-dashboard-grid,
    .col3-layout,
    .layout,
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr !important;
    }

    /* Sidebar menus stack above content */
    .resp-2col-grid > *:first-child,
    .sa-dashboard-grid > *:first-child {
        width: 100% !important;
    }

    /* School cards fully visible */
    .school-card {
        overflow: hidden !important;
        word-break: break-word !important;
    }
    .school-card * {
        max-width: 100% !important;
        box-sizing: border-box !important;
        word-break: break-word !important;
    }

    /* Action buttons in school cards wrap */
    .school-card .actions,
    .school-card div[style*="display:flex"] {
        flex-wrap: wrap !important;
    }

    /* Prevent button text overflow */
    .btn, button {
        white-space: normal !important;
        word-break: break-word !important;
    }

    /* Stats: always 2 columns */
    .stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
