/* ================================================================
   Mishkah University — Student Library UI
   Based on dashboard_preview.html design
   Applied via CSS override + JS DOM injection to legacy PHP pages
   ================================================================ */

/* ── 0. HIDE OLD HEADER / FOOTER elements immediately ─────────── */
/* Top login bar */
table[bgcolor="#999999"],
table[BGCOLOR="#999999"] { display: none !important; }

/* Logo + nav table wrapper — only hide when new shell is active */
body.sl-injected > div[align="center"],
body.sl-injected > center { display: none !important; }

/* Old outer layout table — we keep it but hide the table chrome */
table#table1 { border: none !important; background: transparent !important; }

/* Old footer */
td[bgcolor="#676767"],
td[BGCOLOR="#676767"],
body > table[dir="rtl"][align="center"],
body > table[align="center"]:not(#table1) { display: none !important; }

/* ── 1. RESET ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ── 2. DESIGN TOKENS (from dashboard_preview.html) ──────────── */
:root {
    --green-dark:   #1a5c37;
    --green-mid:    #2d7a4f;
    --green-light:  #e8f5ee;
    --bg:           #f3f4f6;
    --white:        #ffffff;
    --border:       #e5e7eb;
    --text:         #1f2937;
    --text-muted:   #6b7280;
    --radius:       10px;
    --sidebar-w:    220px;
    --header-h:     60px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* ── 3. INJECTED HEADER (.sl-hdr) ────────────────────────────── */
.sl-hdr {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 100;
}

.sl-hdr-left { display: flex; align-items: center; gap: 14px; }

.sl-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.sl-logo-img {
    height: 40px; width: auto; max-width: 140px;
    object-fit: contain; flex-shrink: 0;
}
.sl-logo-icon {
    width: 36px; height: 36px;
    background: var(--green-dark);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 800; font-size: 14px;
    flex-shrink: 0;
}
.sl-logo-text strong { display: block; font-size: 15px; color: var(--green-dark); }
.sl-logo-text span { font-size: 10px; color: var(--text-muted); letter-spacing: .5px; text-transform: uppercase; }

.sl-hdr-right { display: flex; align-items: center; gap: 12px; }

/* profile link in header */
.sl-user {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; color: var(--text);
    text-decoration: none; border-radius: 6px;
    padding: 4px 8px; transition: background .15s;
}
.sl-user:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.sl-user span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--green-dark); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
}

.sl-signoff {
    padding: 7px 16px; border-radius: 6px;
    background: var(--white); border: 1px solid var(--border);
    color: var(--text); font-size: 13px; cursor: pointer;
    text-decoration: none; transition: background .15s;
}
.sl-signoff:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* Hamburger */
.sl-hamburger {
    display: none; background: none; border: none; cursor: pointer;
    padding: 6px; flex-direction: column; gap: 5px;
    border-radius: 6px; transition: background .15s;
    min-width: 44px; min-height: 44px;
    align-items: center; justify-content: center;
}
.sl-hamburger:hover { background: var(--bg); }
.sl-hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

/* ── 4. LAYOUT WRAPPER (.sl-layout) ──────────────────────────── */
.sl-layout {
    display: flex;
    min-height: calc(100vh - var(--header-h));
}

/* ── 5. SIDEBAR (.sl-sidebar) ────────────────────────────────── */
.sl-sidebar {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    flex-shrink: 0;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}

/* Nav items */
.sl-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s;
    min-height: 44px;
    cursor: pointer;
}
.sl-nav-item:hover { background: var(--green-light); color: var(--green-dark); text-decoration: none; }
.sl-nav-item.active {
    background: var(--green-light);
    color: var(--green-dark);
    border-left-color: var(--green-dark);
    font-weight: 600;
}
.sl-nav-item svg { flex-shrink: 0; }

.sl-nav-badge {
    margin-left: auto;
    background: var(--green-dark); color: white;
    font-size: 11px; font-weight: 700;
    padding: 1px 7px; border-radius: 99px;
    min-width: 20px; text-align: center;
}

/* Service sub-items and section label */
.sl-nav-group-label {
    padding: 14px 20px 4px;
    font-size: 10px; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .7px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}
.sl-nav-sub {
    padding-left: 36px;
    font-size: 13px;
    min-height: 38px;
}
.sl-nav-sub svg { opacity: .75; }

/* ── 6. MAIN CONTENT (.sl-main) ──────────────────────────────── */
.sl-main {
    flex: 1;
    padding: 24px;
    min-width: 0;
    background: var(--bg);
}

/* ── 7. WELCOME BANNER (Islamic geometric pattern) ───────────── */
.sl-banner {
    background:
        radial-gradient(ellipse at top right, rgba(255,255,255,.08), transparent 50%),
        linear-gradient(135deg, #0f3d24 0%, var(--green-dark) 55%, var(--green-mid) 100%);
    border-radius: var(--radius);
    padding: 28px 32px;
    color: white;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(26,92,55,.18);
}
.sl-banner-text { position: relative; z-index: 2; max-width: 60%; }
.sl-banner h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.sl-banner p  { font-size: 13px; opacity: .85; margin: 0; }
.sl-banner-pattern {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}
[dir="rtl"] .sl-banner-pattern { transform: scaleX(-1); }

/* ── 8. QUICK ACTION CARDS ───────────────────────────────────── */
.sl-cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.sl-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow .15s, transform .15s;
    cursor: pointer;
    display: block;
}
.sl-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,.08); transform: translateY(-2px); text-decoration: none; color: var(--text); }
.sl-card-icon {
    width: 52px; height: 52px;
    border: 2px solid var(--green-dark);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
    color: var(--green-dark);
}
/* Colorful Gemini-style card icon — SVG already has internal colors,
   we just give it a tinted background tile per card */
.sl-card-icon-color {
    width: 64px; height: 64px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px;
    background: #f9fafb;
    transition: transform .15s;
}
.sl-card-icon-color svg { display: block; }
.sl-card-courses .sl-card-icon-color { background: #fef3c7; }
.sl-card-payment .sl-card-icon-color { background: #dbeafe; }
.sl-card-library .sl-card-icon-color { background: #e0f2fe; }
.sl-card-exams   .sl-card-icon-color { background: #fee2e2; }
.sl-card:hover .sl-card-icon-color { transform: scale(1.05); }
.sl-card-label { font-size: 13px; font-weight: 600; }

/* ── 9. BOTTOM GRID (notifications + live) ───────────────────── */
.sl-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    margin-bottom: 24px;
}
.sl-section-box {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.sl-section-head {
    padding: 14px 20px;
    font-size: 15px; font-weight: 600;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.sl-section-head a { font-size: 12px; color: var(--green-dark); text-decoration: none; font-weight: 400; }
.sl-section-head a:hover { text-decoration: underline; }

.sl-ntf-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 20px; border-bottom: 1px solid var(--border);
    font-size: 13px; gap: 16px;
}
.sl-ntf-row:last-child { border-bottom: none; }
.sl-ntf-date { color: var(--text-muted); white-space: nowrap; font-size: 12px; }
.sl-ntf-empty { padding: 32px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Live box */
.sl-live-box {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.sl-live-head { padding: 14px 20px; font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--border); }
.sl-live-body { padding: 20px; }
.sl-live-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: #ef4444; color: white; font-size: 11px; font-weight: 700;
    padding: 3px 9px; border-radius: 99px; margin-bottom: 12px;
    text-transform: uppercase; letter-spacing: .5px;
}
.sl-live-badge::before {
    content: ''; width: 6px; height: 6px;
    background: white; border-radius: 50%;
    animation: sl-pulse 1.2s infinite;
}
@keyframes sl-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.sl-live-join {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--green-dark); color: white !important;
    padding: 10px 20px; border-radius: 7px;
    text-decoration: none !important; font-size: 14px; font-weight: 600;
    margin-bottom: 14px; transition: background .15s;
}
.sl-live-join:hover,
.sl-live-join:visited,
.sl-live-join:active { background: var(--green-mid); color: white !important; text-decoration: none !important; }
.sl-live-desc { font-size: 12px; color: var(--text-muted); text-align: center; line-height: 1.5; }

/* ── 10. CONTENT CARD (wraps page content) ───────────────────── */
.sl-content-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.sl-content-card-head {
    padding: 16px 24px 14px;
    font-size: 17px; font-weight: 700;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.sl-content-card-head::before {
    content: '';
    display: inline-block; width: 3px; height: 20px;
    background: var(--green-dark); border-radius: 2px;
}
.sl-content-body { padding: 0; }

/* ── 11. PAGE CONTENT — style the old PHP table output ───────── */

/* Override old table backgrounds */
table { background: transparent !important; }
table#table1 { background: transparent !important; border: none !important; }

/* The main content table inside our new card */
.sl-content-body table#table4 {
    width: 100% !important;
    border-collapse: collapse !important;
    background: var(--white) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

/* Rows */
.sl-content-body table#table4 tr {
    border-bottom: 1px solid var(--border) !important;
}
.sl-content-body table#table4 tr:last-child {
    border-bottom: none !important;
}

/* Cells */
.sl-content-body table#table4 td {
    font-size: 13.5px !important;
    color: var(--text) !important;
    padding: 12px 20px !important;
    vertical-align: middle !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
    border: none !important;
    background: transparent !important;
    line-height: 1.55 !important;
}

/* OLD CSS CLASSES — modernized */
td.maintitel, .maintitel {
    font-size: 17px !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    padding: 16px 24px 14px !important;
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
}
td.maintitel::before, .maintitel::before {
    content: '';
    display: inline-block; width: 3px; height: 20px;
    background: var(--green-dark); border-radius: 2px; flex-shrink: 0;
}

td.title1, .title1 {
    font-size: 14px !important; font-weight: 600 !important;
    color: var(--text) !important;
    background: var(--green-light) !important;
    padding: 10px 20px !important;
    border-left: 3px solid var(--green-dark) !important;
}
td.title2, .title2 {
    font-size: 13px !important; font-weight: 500 !important;
    color: var(--text-muted) !important;
    padding: 8px 20px !important;
    background: transparent !important;
}
td.title3, .title3 {
    font-size: 14px !important; font-weight: 600 !important;
    color: var(--green-dark) !important;
    background: #f0faf4 !important;
    padding: 10px 20px !important;
}
td.body1, .body1 {
    font-size: 13.5px !important; color: var(--text) !important;
    line-height: 1.65 !important; padding: 10px 20px !important;
    background: transparent !important;
}

/* Alternating rows */
tr[bgcolor="#e9e9e9"] > td,
tr[bgcolor="#E9E9E9"] > td,
tr[BGCOLOR="#e9e9e9"] > td,
tr[BGCOLOR="#E9E9E9"] > td { background-color: #fafafa !important; }

/* Row hover */
.sl-content-body table#table4 tbody tr:hover > td { background: var(--green-light) !important; }

/* Table headers */
td.table_header, th.table_header {
    background: var(--green-dark) !important;
    color: white !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: .5px !important;
    padding: 12px 20px !important;
    text-align: left !important;
    border: none !important;
}

/* ── 12. FORMS & INPUTS ──────────────────────────────────────── */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="zip"],
input[type="number"],
input[type="search"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
    font-size: 14px !important;
    color: var(--text) !important;
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    border-radius: 7px !important;
    padding: 9px 12px !important;
    transition: border-color .15s, box-shadow .15s !important;
    outline: none !important;
    min-height: 40px !important;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus {
    border-color: var(--green-dark) !important;
    box-shadow: 0 0 0 3px rgba(26,92,55,.12) !important;
}

textarea {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
    font-size: 14px !important; color: var(--text) !important;
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    border-radius: 7px !important;
    padding: 9px 12px !important; resize: vertical !important;
    outline: none !important; min-height: 80px !important;
    transition: border-color .15s, box-shadow .15s !important;
}
textarea:focus {
    border-color: var(--green-dark) !important;
    box-shadow: 0 0 0 3px rgba(26,92,55,.12) !important;
}

select {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
    font-size: 14px !important; color: var(--text) !important;
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    border-radius: 7px !important;
    padding: 8px 12px !important; min-height: 40px !important;
    outline: none !important; cursor: pointer !important;
    transition: border-color .15s !important;
}
select:focus { border-color: var(--green-dark) !important; }

input[type="radio"],
input[type="checkbox"] {
    accent-color: var(--green-dark) !important;
    width: 15px !important; height: 15px !important;
    cursor: pointer !important; margin-right: 4px !important;
    vertical-align: middle !important;
}

/* ── 13. BUTTONS ─────────────────────────────────────────────── */

input[type="submit"],
input[type="button"],
.sl-btn {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
    font-size: 14px !important; font-weight: 600 !important;
    color: white !important;
    background: var(--green-dark) !important;
    border: none !important; border-radius: 7px !important;
    padding: 10px 24px !important; cursor: pointer !important;
    transition: background .15s, transform .15s !important;
    min-height: 40px !important;
    box-shadow: 0 2px 4px rgba(26,92,55,.25) !important;
    touch-action: manipulation !important;
}
input[type="submit"]:hover,
input[type="button"]:hover,
.sl-btn:hover {
    background: var(--green-mid) !important;
    transform: translateY(-1px) !important;
    text-decoration: none !important;
    color: white !important;
}
input[type="submit"]:active,
input[type="button"]:active { transform: translateY(0) !important; }

input[type="reset"] {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
    font-size: 14px !important; font-weight: 500 !important;
    color: var(--text) !important;
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    border-radius: 7px !important;
    padding: 9px 20px !important; cursor: pointer !important;
    transition: background .15s !important;
    min-height: 40px !important;
}
input[type="reset"]:hover { background: var(--bg) !important; }

/* ── 14. LINKS inside content ────────────────────────────────── */
.sl-main a { color: var(--green-dark); }
.sl-main a:hover { color: var(--green-mid); }

/* "Register now" link — only button-style when NOT inside a table cell (i.e. standalone action) */
/* Override for a.news inside td.title3 / td.body1 = subject name/syllabus link, NOT action button */
.sl-content-body td.title3 a.news,
.sl-content-body td.body1 a.news {
    background: transparent !important;
    color: var(--green-dark) !important;
    padding: 2px 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    min-height: unset !important;
    margin: 0 !important;
    display: block !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    text-transform: none !important;
}
.sl-content-body td.title3 a.news:hover {
    background: transparent !important;
    color: var(--green-mid) !important;
    text-decoration: underline !important;
    transform: none !important;
}
.sl-content-body td.body1 a.news {
    font-size: 13px !important;
    font-weight: 500 !important;
}

/* "Register now" link — old page sets color:white, make it a styled button */
.sl-content-body a.news {
    display: inline-block !important;
    background: var(--green-dark) !important;
    color: white !important;
    padding: 10px 28px !important;
    border-radius: 7px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: background .15s !important;
    margin: 8px 0 !important;
}
.sl-content-body a.news:hover { background: var(--green-mid) !important; }

/* ── 15. RTL (Arabic pages) ──────────────────────────────────── */
[dir="rtl"] .sl-hdr { flex-direction: row-reverse; }
[dir="rtl"] .sl-hdr-left { flex-direction: row-reverse; }
[dir="rtl"] .sl-hdr-right { flex-direction: row-reverse; }

[dir="rtl"] .sl-sidebar {
    border-right: none;
    border-left: 1px solid var(--border);
}

[dir="rtl"] .sl-nav-item {
    flex-direction: row-reverse;
    border-left: none;
    border-right: 3px solid transparent;
    text-align: right;
}
[dir="rtl"] .sl-nav-item:hover,
[dir="rtl"] .sl-nav-item.active {
    border-right-color: var(--green-dark);
    border-left-color: transparent;
}
[dir="rtl"] .sl-nav-badge { margin-left: 0; margin-right: auto; }
[dir="rtl"] .sl-nav-sub { padding-left: 20px; padding-right: 36px; }
[dir="rtl"] .sl-user { flex-direction: row-reverse; }

[dir="rtl"] td.title1, [dir="rtl"] .title1 {
    border-left: none !important;
    border-right: 3px solid var(--green-dark) !important;
}
[dir="rtl"] td.maintitel, [dir="rtl"] .maintitel { text-align: right !important; }
[dir="rtl"] .sl-content-card-head { flex-direction: row-reverse; }

[dir="rtl"] input[type="text"],
[dir="rtl"] input[type="password"],
[dir="rtl"] input[type="email"],
[dir="rtl"] textarea,
[dir="rtl"] select {
    direction: rtl !important;
    text-align: right !important;
}

[dir="rtl"] .sl-bottom-grid { direction: rtl; }
[dir="rtl"] .sl-cards-grid  { direction: rtl; }

/* ── 16. RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 1100px) {
    .sl-cards-grid   { grid-template-columns: repeat(2, 1fr); }
    .sl-bottom-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* Sidebar becomes off-canvas */
    .sl-sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-h);
        height: calc(100vh - var(--header-h));
        z-index: 200;
        transition: left .25s;
        box-shadow: 4px 0 20px rgba(0,0,0,.1);
    }
    .sl-sidebar.open { left: 0; }
    [dir="rtl"] .sl-sidebar { left: auto; right: -100%; }
    [dir="rtl"] .sl-sidebar.open { right: 0; left: auto; box-shadow: -4px 0 20px rgba(0,0,0,.1); }

    .sl-hamburger { display: flex; }

    .sl-main { padding: 16px; }
    .sl-banner { padding: 20px; }
    .sl-banner h1 { font-size: 18px; }

    .sl-user span { display: none; }
    .sl-bottom-grid { grid-template-columns: 1fr; }

    /* ── Legacy content responsive guard ─────────────────────
       The legacy PHP pages use fixed-pixel `width="..."` attributes
       on tables and large inline `<font size>` tags. On phones these
       overflow horizontally and break the layout. Below we
       neutralize those without rewriting every legacy page. */

    /* Legacy tables: allow them to keep readable column widths and
       let the wrapping card scroll horizontally instead of crushing
       cell text into one-letter-per-line columns. The earlier
       `width:100% !important; overflow-wrap:anywhere` combo caused
       narrow cart-style tables to break every word at every char. */
    .sl-main table,
    .sl-content-card table {
        max-width: 100%;
        table-layout: auto !important;
    }
    .sl-main td,
    .sl-content-card td,
    .sl-main th,
    .sl-content-card th {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    /* Multi-column legacy tables: horizontal scroll inside the card.
       The main content table (#table4) is the page wrapper and
       should still fill width — it's exempt from the min-width. */
    .sl-content-card { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    .sl-content-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sl-content-body table#table4 { width: 100% !important; min-width: 0 !important; }
    /* Inner data tables (cart rows, schedule rows, results rows etc.)
       keep a sensible minimum so columns don't collapse to characters. */
    .sl-content-body table#table4 table,
    .sl-content-card table table {
        min-width: 480px;
    }

    /* Images, iframes, video never bigger than their container */
    .sl-main img,
    .sl-main iframe,
    .sl-main video,
    .sl-content-card img,
    .sl-content-card iframe,
    .sl-content-card video {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Cap the giant <font size="N"> tags inherited from 1990s markup */
    .sl-main font[size],
    .sl-content-card font[size] {
        font-size: 14px !important;
    }
    .sl-main font[size="4"],
    .sl-main font[size="5"],
    .sl-main font[size="6"],
    .sl-content-card font[size="4"],
    .sl-content-card font[size="5"],
    .sl-content-card font[size="6"] {
        font-size: 16px !important;
    }

    /* Tighten cell padding so two-column tables fit */
    .sl-content-body table#table4 td {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
    td.maintitel, .maintitel { padding: 14px 16px 12px !important; font-size: 16px !important; }
    td.title1, .title1 { padding: 8px 12px !important; font-size: 13px !important; }
    td.title2, .title2,
    td.title3, .title3,
    td.body1,  .body1  { padding: 8px 12px !important; font-size: 13px !important; }

    /* Forms and inputs: full width on mobile */
    .sl-main input[type="text"],
    .sl-main input[type="email"],
    .sl-main input[type="password"],
    .sl-main input[type="number"],
    .sl-main input[type="tel"],
    .sl-main input[type="search"],
    .sl-main select,
    .sl-main textarea {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Body cannot scroll horizontally */
    html, body { overflow-x: hidden !important; max-width: 100vw; }
}

@media (max-width: 480px) {
    .sl-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .sl-card { padding: 16px 10px; }
    .sl-card-icon-color { width: 52px; height: 52px; }
    .sl-card-icon-color svg { width: 36px; height: 36px; }
    .sl-banner-text { max-width: 100%; }

    /* Even tighter cell padding on small phones */
    .sl-main { padding: 10px; }
    .sl-content-body table#table4 td { padding: 8px 10px !important; font-size: 12.5px !important; }

    /* Hide secondary chrome on tiny screens */
    .sl-banner { padding: 16px; }
    .sl-banner h1 { font-size: 16px; }
    .sl-banner p  { font-size: 12px; }

    /* Stack any 2-column legacy table cells when really tight */
    .sl-content-card table.sl-stack-mobile tr,
    .sl-content-card table.sl-stack-mobile tbody {
        display: block; width: 100%;
    }
    .sl-content-card table.sl-stack-mobile td {
        display: block; width: 100% !important;
    }
}

/* ── 17. LOADING REVEAL ──────────────────────────────────────── */
body.sl-loading { visibility: hidden; }
body.sl-ready   { visibility: visible; transition: opacity .15s; }

/* ── 18. SKIP LINK (accessibility) ──────────────────────────── */
.sl-skip {
    position: absolute; left: -999px; top: 6px; z-index: 9999;
    background: var(--green-dark); color: white;
    padding: 8px 16px; border-radius: 6px; font-weight: 600;
    text-decoration: none; transition: left .1s;
    font-size: 13px;
}
.sl-skip:focus { left: 6px; }

/* ── 19. FOCUS VISIBLE ───────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--green-dark) !important;
    outline-offset: 2px !important;
}

/* ── 20. UPLOAD ZONE ─────────────────────────────────────────── */
.sl-drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    margin: 20px;
    background: var(--bg);
}
.sl-drop-zone:hover,
.sl-drop-zone.over {
    border-color: var(--green-dark);
    background: var(--green-light);
}
.sl-drop-zone-icon { font-size: 40px; color: var(--text-muted); margin-bottom: 12px; }
.sl-drop-zone-text { font-size: 14px; color: var(--text-muted); margin-bottom: 6px; }
.sl-drop-zone-text strong { color: var(--green-dark); }
.sl-drop-zone-hint { font-size: 12px; color: #9ca3af; }

/* Overflow protection */
body { overflow-x: hidden; }

/* ── 21. LOGIN PAGE ──────────────────────────────────────────── */
#sl-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px 16px;
}
.sl-login-wrap {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.sl-login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
}
.sl-login-logo-img { height: 52px; width: auto; max-width: 180px; object-fit: contain; }
.sl-login-logo-fallback { display: flex; align-items: center; gap: 10px; }
.sl-login-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    width: 100%;
    box-shadow: 0 2px 16px rgba(0,0,0,.07);
    margin-bottom: 16px;
}
.sl-login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
    text-align: center;
}
.sl-login-card table { width: 100% !important; border: none !important; background: transparent !important; }
.sl-login-card td {
    background: transparent !important;
    border: none !important;
    padding: 6px 0 !important;
    color: var(--text) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif !important;
    font-size: 14px !important;
}
.sl-login-card td.maintitel,
.sl-login-card .maintitel,
.sl-login-card td.title3 { display: none !important; }
.sl-login-card img[src*="registernewuser"],
.sl-login-card img[src*="register"] { display: none !important; }
.sl-login-card input[type="text"],
.sl-login-card input[type="password"] { width: 100% !important; }
.sl-login-card input[type="submit"] { width: 100% !important; margin-top: 8px !important; }
/* hide captcha rows — empty in local dev, contain only a broken img in prod */
.sl-login-card td.body1:empty { display: none !important; padding: 0 !important; }
.sl-login-card img[src*="Captcha"],
.sl-login-card img[src*="captcha"],
.sl-login-card img[src*="security"] { max-width: 100% !important; border-radius: 6px; }
.sl-login-reg-btn {
    display: inline-block;
    border: 1px solid var(--green-dark);
    color: var(--green-dark) !important;
    padding: 10px 28px;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    transition: background .15s, color .15s;
    margin-bottom: 12px;
}
.sl-login-reg-btn:hover { background: var(--green-dark) !important; color: white !important; text-decoration: none !important; }
.sl-login-help { font-size: 12px; color: var(--text-muted); text-align: center; margin: 0; }
.sl-login-help a { color: var(--green-dark); text-decoration: none; }
.sl-login-help a:hover { text-decoration: underline; }

/* ── 22. EMPTY STATE ─────────────────────────────────────────── */
.sl-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: var(--text-muted);
}
.sl-empty-state svg { margin-bottom: 16px; opacity: .35; }
.sl-empty-state h3 { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.sl-empty-state p  { font-size: 14px; max-width: 320px; line-height: 1.6; margin: 0; }

/* ── 23. PROGRAMDETAILS KEY-VALUE GRID ───────────────────────── */
.sl-detail-grid {
    padding: 20px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0;
}
.sl-detail-row {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}
.sl-detail-row:nth-child(odd) { background: var(--bg); }
.sl-detail-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}
.sl-detail-value {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
}
.sl-detail-value a { color: var(--green-dark); text-decoration: none; }
.sl-detail-value a:hover { text-decoration: underline; }
[dir="rtl"] .sl-detail-row { border-right: none; border-left: 1px solid var(--border); }

/* ── 24. PRELIBRARY / LIBRARY SUBJECT ROWS ───────────────────── */
/* Subject names in td.title3 — left-align, remove button-like centering */
.sl-content-body td.title3 { text-align: left !important; }
[dir="rtl"] .sl-content-body td.title3 { text-align: right !important; }
.sl-content-body td.title3 a {
    display: block !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--green-dark) !important;
    text-decoration: none !important;
    padding: 2px 0 !important;
}
.sl-content-body td.title3 a:hover { text-decoration: underline !important; color: var(--green-mid) !important; }
/* Instructor/syllabus rows below subject name */
.sl-content-body td.body1 a {
    color: var(--green-dark) !important;
    text-decoration: none !important;
}
.sl-content-body td.body1 a:hover { text-decoration: underline !important; }
