/* ================================================================
   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; }

/* Language toggle pill — sits just before the profile link in the header */
.sl-lang {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 999px;
    background: var(--white); border: 1px solid var(--border);
    color: var(--text); font-size: 13px; font-weight: 600;
    text-decoration: none; transition: background .15s, color .15s, border-color .15s;
    line-height: 1;
}
.sl-lang:hover,
.sl-lang:focus { background: var(--green-dark); color: var(--white); border-color: var(--green-dark); text-decoration: none; }
.sl-lang svg { flex-shrink: 0; }
.sl-lang-label { white-space: nowrap; }
[dir="rtl"] .sl-lang { flex-direction: row-reverse; }
@media (max-width: 600px) {
    .sl-lang { padding: 6px 10px; }
    .sl-lang-label { display: none; } /* keep just the globe icon on small screens */
}

/* 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 — disabled site-wide on student-facing pages (per request) */
/* .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;
    }
    /* Auth-page form tables (registration #table8 and its nested address
       table) must wrap, not horizontal-scroll. Override the data-table
       min-width above so the form fits a 320px phone. */
    body.sl-auth-page .sl-content-body table#table8,
    body.sl-auth-page .sl-content-body table#table8 table,
    body.sl-auth-page .sl-content-card table#table8,
    body.sl-auth-page .sl-content-card table#table8 table {
        min-width: 0 !important;
    }
    /* Tables explicitly marked .m-table get the card layout from
       mishkah-tables.css on mobile — they must never inherit the 480px
       minimum or they'll horizontally overflow inside their wrapper. */
    .sl-content-body table.m-table,
    .sl-content-card table.m-table {
        min-width: 0 !important;
    }

    /* 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 input[type="file"],
    .sl-main input[type="url"],
    .sl-main input[type="date"],
    .sl-main input[type="datetime-local"],
    .sl-main input[type="time"],
    .sl-main select,
    .sl-main textarea {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Long words in legacy headers (university name, addresses, URLs) wrap
       instead of forcing horizontal scroll on phones. */
    .sl-content-body td,
    .sl-content-body p,
    .sl-content-body h1, .sl-content-body h2, .sl-content-body h3,
    .sl-content-body b, .sl-content-body strong, .sl-content-body span {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* prelibrarydetails.php — the legacy verticaltabs widget uses
       fixed-pixel widths (.verticalslider 750px, tabs 160px, contents 550px).
       Stack it on mobile. */
    .sl-content-body .verticalslider {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }
    .sl-content-body .verticalslider_tabs {
        float: none !important;
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        border-bottom: 1px solid var(--border);
    }
    .sl-content-body .verticalslider_tabs li {
        flex: 1 1 50%;
        min-width: 120px;
    }
    .sl-content-body .verticalslider_tabs a:link,
    .sl-content-body .verticalslider_tabs a:visited {
        width: auto !important;
        height: auto !important;
        padding: 10px 12px !important;
        border-right: none !important;
        border-top: 1px solid var(--border) !important;
        font-size: 12px !important;
        text-align: center;
    }
    .sl-content-body .verticalslider_contents {
        float: none !important;
        width: 100% !important;
        position: relative !important;
        display: block !important;
        clear: both;
    }
    .sl-content-body .verticalslider_contents li {
        width: 100% !important;
        position: relative !important;
        padding: 12px !important;
    }
    .sl-content-body .verticalslider .arrow { display: none !important; }

    /* Legacy upload / registration inner tables sometimes have width="75%"
       or "70%" plus size="30" inputs that overflow narrow phones. They
       inherit the 480px data-table min-width above — undo that for forms. */
    .sl-content-body form table,
    .sl-content-body form table table {
        width: 100% !important;
        min-width: 0 !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,
a.sl-login-reg-btn:hover {
    background: var(--green-dark) !important;
    color: white !important;
    text-decoration: none !important;
    /* lock geometry — defeats global A:hover that resets font-size to 9pt */
    font-size: 14px !important;
    font-weight: 600 !important;
    padding: 10px 28px !important;
    border: 1px solid var(--green-dark) !important;
    transform: 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; }

/* ── 21b. AUTH-ONLY PAGES (newreg.php / arabic/reg.php) ──────── */
/* Pages tagged with class="sl-auth-page" on <body> render like the
   login page: no header, no sidebar — just the logo and the form. */
body.sl-auth-page .sl-hdr,
body.sl-auth-page .sl-sidebar { display: none !important; }

body.sl-auth-page .sl-layout {
    display: block !important;
    min-height: 100vh;
    background: var(--bg);
}

body.sl-auth-page .sl-main {
    flex: none !important;
    max-width: 760px;
    margin: 0 auto !important;
    padding: 32px 16px 48px !important;
    background: transparent;
}

/* Hide the "Registration form" page-title banner the skin injects */
body.sl-auth-page .sl-content-card-head { display: none !important; }

/* Drop the logo at the top of the column */
body.sl-auth-page .sl-main::before {
    content: "";
    display: block;
    width: 180px;
    height: 60px;
    margin: 0 auto 24px;
    background: url('/m-images/logo_mishkah.png') no-repeat center center;
    background-size: contain;
}

/* Form content sits in a clean white card */
body.sl-auth-page .sl-content-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 28px 32px;
    box-shadow: 0 4px 14px rgba(0,0,0,.04);
    /* The base .sl-content-card uses overflow:hidden, which combined with
       the mobile rule that only flips overflow-x to auto, clips the form
       vertically. Auth pages have a single tall form — let it grow. */
    overflow: visible !important;
}
body.sl-auth-page .sl-content-body {
    padding: 0 !important;
    overflow: visible !important;
}

/* Legacy style.css forces td.title2 { height: 16pt }, which combined with
   display:block (from the mobile stacking rules) caps the form's wrapper
   TD at ~21px and visually clips everything below the section heading. */
body.sl-auth-page .sl-content-body td.title2,
body.sl-auth-page .sl-content-body td.title3,
body.sl-auth-page .sl-content-body td.body1,
body.sl-auth-page .sl-content-body td.bodyreg1 {
    height: auto !important;
    min-height: 0 !important;
}

/* Legacy markup uses <tr height="20"> on wrapper rows; with display:block
   from the mobile stacking rules, that attribute caps the row at 20px and
   visually clips the form (form lives in a child TD). Force auto height. */
body.sl-auth-page .sl-content-body tr[height],
body.sl-auth-page .sl-content-body td[height] {
    height: auto !important;
}

/* Kill the global green-light row-hover so form rows don't flash green */
body.sl-auth-page .sl-content-body table tbody tr:hover > td,
body.sl-auth-page .sl-content-body table#table4 tbody tr:hover > td {
    background: transparent !important;
}
/* preserve the gray "stripe" rows that the original markup uses */
body.sl-auth-page .sl-content-body table tr[bgcolor]:hover > td {
    background: inherit !important;
}

/* Hide the redundant top "Registration form" maintitel — page is already
   self-evident from logo + content. */
body.sl-auth-page .sl-content-body td.maintitel { display: none !important; }

/* Section labels (title2 = "1- First Step...", title3 = "Existing Student") */
body.sl-auth-page .sl-content-body td.title2 {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text) !important;
    background: transparent !important;
    border-left: none !important;
    padding: 22px 8px 8px !important;
    text-align: center !important;
}
body.sl-auth-page .sl-content-body td.title3 {
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--text-muted) !important;
    background: transparent !important;
    border-left: none !important;
    padding: 18px 8px 8px !important;
    border-bottom: 1px solid var(--border) !important;
}

/* Kill the legacy alternating gray stripes — modern forms don't use them */
body.sl-auth-page .sl-content-body tr[bgcolor],
body.sl-auth-page .sl-content-body td[bgcolor] {
    background: transparent !important;
}

/* Field row label / cell — uniform spacing */
body.sl-auth-page .sl-content-body td.body1,
body.sl-auth-page .sl-content-body td.bodyreg1 {
    padding: 10px 8px !important;
    font-size: 14px !important;
    color: var(--text) !important;
    line-height: 1.4 !important;
    vertical-align: middle !important;
    background: transparent !important;
    border: none !important;
}

/* Required asterisk (in its own narrow td with a red <font>) */
body.sl-auth-page .sl-content-body td.body1 font[color="red"],
body.sl-auth-page .sl-content-body td.bodyreg1 font[color="red"],
body.sl-auth-page .sl-content-body td > p > font[color="red"],
body.sl-auth-page .sl-content-body font[color="red"] {
    color: #dc2626 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
}

/* Inputs / selects / textareas — uniform width and styling */
body.sl-auth-page .sl-content-body input[type="text"],
body.sl-auth-page .sl-content-body input[type="password"],
body.sl-auth-page .sl-content-body input[type="email"],
body.sl-auth-page .sl-content-body input[type="number"],
body.sl-auth-page .sl-content-body input[type="tel"],
body.sl-auth-page .sl-content-body select,
body.sl-auth-page .sl-content-body textarea {
    width: 100% !important;
    max-width: 320px !important;
    padding: 9px 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-family: inherit !important;
    color: var(--text) !important;
    background: var(--white) !important;
    box-shadow: none !important;
    transition: border-color .15s, box-shadow .15s;
}
body.sl-auth-page .sl-content-body input[type="text"]:focus,
body.sl-auth-page .sl-content-body input[type="password"]:focus,
body.sl-auth-page .sl-content-body input[type="email"]:focus,
body.sl-auth-page .sl-content-body input[type="number"]:focus,
body.sl-auth-page .sl-content-body input[type="tel"]:focus,
body.sl-auth-page .sl-content-body select:focus,
body.sl-auth-page .sl-content-body textarea:focus {
    border-color: var(--green-mid) !important;
    box-shadow: 0 0 0 3px rgba(45,122,79,.12) !important;
    outline: none;
}
/* Birth date dropdowns are narrow */
body.sl-auth-page .sl-content-body select[name="bdmonth"],
body.sl-auth-page .sl-content-body select[name="bdday"],
body.sl-auth-page .sl-content-body select[name="bdyear"] {
    max-width: 110px !important;
    width: auto !important;
    margin-right: 6px;
}

/* ── AUTH-PAGE REGISTRATION FORM POLISH ───────────────────────────
   Tightens spacing, removes inherited row borders, drops the lone
   asterisk column in favor of an inline `* ` on the label, and gives
   the Birth Date controls real widths on desktop. */

/* 1. Remove the per-row border that `table#table4 tr` inherits — for
      auth forms this striplines every row and reads heavy. */
body.sl-auth-page .sl-content-body table#table4 tr,
body.sl-auth-page .sl-content-body table#table8 tr {
    border-bottom: none !important;
}

/* 2. Compact row padding (was ~65px tall rows). */
body.sl-auth-page .sl-content-body table#table8 td.body1,
body.sl-auth-page .sl-content-body table#table8 td.bodyreg1 {
    padding: 6px 8px !important;
}

/* 3. Hide the standalone first-column cell at every width — whether
      it holds a red `*` (required rows) OR just `&nbsp;` (optional
      rows like Hm. Phone, Street, Address Line2, Code Supervisor).
      Without this, optional rows shift everything right by ~200px
      and break label/input alignment with required rows. */
body.sl-auth-page .sl-content-body table#table8 tr > td[width="3%"]:not(.body1):not(.bodyreg1) {
    display: none !important;
}
/* 4. On rows that originally had that asterisk cell, prepend a small
      red `* ` to the label so the required marker is preserved. */
body.sl-auth-page .sl-content-body table#table8 tr:has(> td > p > font[color="red"]) > td.body1:nth-child(2)::before,
body.sl-auth-page .sl-content-body table#table8 tr:has(> td > p > font[color="red"]) > td.bodyreg1:nth-child(2)::before,
body.sl-auth-page .sl-content-body table#table8 tr:has(> td > font[color="red"]) > td.body1:nth-child(2)::before,
body.sl-auth-page .sl-content-body table#table8 tr:has(> td > font[color="red"]) > td.bodyreg1:nth-child(2)::before {
    content: '* ';
    color: #dc2626;
    font-weight: 700;
    margin-right: 4px;
}

/* 5. Desktop column alignment — fix label column width so every label
      sits on one line and every input shares the same left edge. */
@media (min-width: 601px) {
    body.sl-auth-page .sl-content-body table#table8 td[width="35%"] {
        width: 200px !important;
        min-width: 200px !important;
        white-space: nowrap;
    }
}

/* 6. "Important note" hint next to the email input — currently a green
      link in the same cell as the input; render as a small italic hint
      below the field instead of an inline link blob. */
body.sl-auth-page .sl-content-body td a[href*="open_email_comment_window"] {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px !important;
    color: var(--text-muted) !important;
    font-style: italic;
    text-decoration: none !important;
}
body.sl-auth-page .sl-content-body td a[href*="open_email_comment_window"]:hover {
    color: var(--green-dark) !important;
    text-decoration: underline !important;
}

/* 7. Hide the calendar trigger icon next to Birth Date — the small
      "Ca" link/image extends past the year box and breaks the row's
      visual alignment with the input columns above and below. */
body.sl-auth-page .sl-content-body a[id$="_ID_Link"] {
    display: none !important;
}

/* 8. Birth Date controls — Month/Day are <select>, Year is <input> from
      commonlib/calendarDateInput.js. The global `select { width:100% }`
      rule squishes them; reset to natural widths and give per-control
      minimums so they read clearly on desktop. */
@media (min-width: 601px) {
    body.sl-auth-page .sl-content-body select.calendarDateInput,
    body.sl-auth-page .sl-content-body input.calendarDateInput {
        width: auto !important;
        max-width: none !important;
        min-width: 0 !important;
        display: inline-block !important;
        margin-right: 6px;
    }
    body.sl-auth-page .sl-content-body select.calendarDateInput[name$="_Month"] {
        min-width: 130px !important;
    }
    body.sl-auth-page .sl-content-body select.calendarDateInput[id$="_Day_ID"] {
        min-width: 80px !important;
    }
    body.sl-auth-page .sl-content-body input.calendarDateInput[id$="_Year_ID"] {
        width: 80px !important;
        max-width: 80px !important;
    }
}

/* Radio buttons + their labels (Gender row) */
body.sl-auth-page .sl-content-body input[type="radio"] {
    margin: 0 6px 0 0;
    accent-color: var(--green-dark);
    vertical-align: middle;
}
body.sl-auth-page .sl-content-body input[type="checkbox"] {
    accent-color: var(--green-dark);
    width: 16px; height: 16px;
    vertical-align: middle;
}

/* The Address section parent row (originally green) */
body.sl-auth-page .sl-content-body td[bgcolor="#9EBA9B"],
body.sl-auth-page .sl-content-body td[bgcolor="#9eba9b"],
body.sl-auth-page .sl-content-body tr[bgcolor="#9EBA9B"] > td {
    background: transparent !important;
}

/* "Address" word centered above the address fields — make it a real section divider */
body.sl-auth-page .sl-content-body td.maintitle,
body.sl-auth-page .sl-content-body td b[align="center"],
body.sl-auth-page .sl-content-body td > b {
    font-weight: 700 !important;
}
/* The literal "Address" label that lives inside a td.body1 (centered, bold)  */
body.sl-auth-page .sl-content-body td.body1[align="center"] b,
body.sl-auth-page .sl-content-body td.bodyreg1[align="center"] b {
    display: inline-block;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--text-muted) !important;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: 14px 0 4px;
}

/* "Important note" link beside email — turn into subtle hint */
body.sl-auth-page .sl-content-body td.body1 a,
body.sl-auth-page .sl-content-body td.bodyreg1 a {
    color: var(--green-mid) !important;
    font-size: 12px !important;
    text-decoration: none !important;
}
body.sl-auth-page .sl-content-body td.body1 a:hover,
body.sl-auth-page .sl-content-body td.bodyreg1 a:hover {
    text-decoration: underline !important;
    color: var(--green-dark) !important;
}

/* Calendar trigger next to Birth Date */
body.sl-auth-page .sl-content-body a[href*="calendar"] {
    color: var(--green-dark) !important;
}

/* Continue / Reset buttons */
body.sl-auth-page .sl-content-body input[type="submit"],
body.sl-auth-page .sl-content-body input[type="button"] {
    padding: 9px 22px !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border: none !important;
    background: var(--green-dark) !important;
    color: var(--white) !important;
    cursor: pointer;
    transition: background .15s;
}
body.sl-auth-page .sl-content-body input[type="submit"]:hover,
body.sl-auth-page .sl-content-body input[type="button"]:hover {
    background: var(--green-mid) !important;
}
body.sl-auth-page .sl-content-body input[type="reset"] {
    padding: 9px 22px !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    background: var(--white) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    cursor: pointer;
}
body.sl-auth-page .sl-content-body input[type="reset"]:hover {
    background: var(--bg) !important;
    color: var(--text) !important;
}

/* Note / helper text */
body.sl-auth-page .sl-content-body .blackmed,
body.sl-auth-page .sl-content-body font[color="red"] { font-size: 12px; }

/* Responsive — tablet */
@media (max-width: 768px) {
    body.sl-auth-page .sl-main { padding: 24px 12px 40px !important; }
    body.sl-auth-page .sl-content-card { padding: 22px 18px 28px; border-radius: 10px; }
    body.sl-auth-page .sl-main::before { width: 160px; height: 54px; margin-bottom: 18px; }
    body.sl-auth-page .sl-content-body input[type="text"],
    body.sl-auth-page .sl-content-body input[type="password"],
    body.sl-auth-page .sl-content-body input[type="email"],
    body.sl-auth-page .sl-content-body input[type="number"],
    body.sl-auth-page .sl-content-body select,
    body.sl-auth-page .sl-content-body textarea { max-width: 100% !important; }
}

/* Responsive — mobile: stack label/input vertically per row */
@media (max-width: 600px) {
    body.sl-auth-page .sl-main { padding: 18px 10px 32px !important; }
    body.sl-auth-page .sl-content-card { padding: 16px 12px 20px; border-radius: 10px; }
    body.sl-auth-page .sl-main::before { width: 140px; height: 48px; margin-bottom: 14px; }

    /* Force every nested table inside the content card to be flexible */
    body.sl-auth-page .sl-content-body table {
        width: 100% !important;
        max-width: 100% !important;
    }
    body.sl-auth-page .sl-content-body img { max-width: 100%; height: auto; }

    /* Convert form rows to stacked blocks (any deep nesting) */
    body.sl-auth-page .sl-content-body table#table8 tr,
    body.sl-auth-page .sl-content-body table#table8 tr > td {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    body.sl-auth-page .sl-content-body table#table8 > tbody > tr {
        margin-bottom: 14px;
        padding-bottom: 10px;
        border-bottom: 1px solid var(--border);
    }
    body.sl-auth-page .sl-content-body table#table8 tr > td {
        padding: 4px 0 !important;
        text-align: left !important;
    }
    /* Hide the standalone asterisk cell — too sparse on mobile */
    body.sl-auth-page .sl-content-body table#table8 tr > td:has(> p > font[color="red"]:only-child),
    body.sl-auth-page .sl-content-body table#table8 tr > td:has(> font[color="red"]:only-child) {
        display: none !important;
    }
    /* Add red asterisk inline on label cell instead */
    body.sl-auth-page .sl-content-body table#table8 tr > td.body1:nth-child(2)::before,
    body.sl-auth-page .sl-content-body table#table8 tr > td.bodyreg1:nth-child(2)::before {
        content: '* ';
        color: #dc2626;
        font-weight: 700;
        margin-right: 2px;
    }
    /* Inputs go full width */
    body.sl-auth-page .sl-content-body input[type="text"],
    body.sl-auth-page .sl-content-body input[type="password"],
    body.sl-auth-page .sl-content-body input[type="email"],
    body.sl-auth-page .sl-content-body input[type="number"],
    body.sl-auth-page .sl-content-body input[type="tel"],
    body.sl-auth-page .sl-content-body select,
    body.sl-auth-page .sl-content-body textarea {
        max-width: 100% !important;
        width: 100% !important;
    }
    body.sl-auth-page .sl-content-body select[name="bdmonth"],
    body.sl-auth-page .sl-content-body select[name="bdday"],
    body.sl-auth-page .sl-content-body select[name="bdyear"] {
        width: 31% !important;
        max-width: 31% !important;
        display: inline-block !important;
        margin-right: 2%;
    }
}

/* Prevent horizontal overflow at any width */
html, body.sl-auth-page { overflow-x: hidden; max-width: 100vw; }
body.sl-auth-page * { min-width: 0; }
body.sl-auth-page .sl-content-body table { table-layout: auto; }

/* Final, browser-agnostic mobile fallback (uses width-vw fallback for
   devices where @media rules sometimes lag behind a slow viewport change) */
@media (max-width: 600px) {
    body.sl-auth-page,
    body.sl-auth-page .sl-layout,
    body.sl-auth-page .sl-main,
    body.sl-auth-page .sl-content-card,
    body.sl-auth-page #sl-content-body { max-width: 100vw !important; }

    /* Force ANY descendant table inside the auth card to be flexible */
    body.sl-auth-page .sl-content-body table,
    body.sl-auth-page .sl-content-body tbody,
    body.sl-auth-page .sl-content-body tr {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    body.sl-auth-page .sl-content-body td {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        text-align: left !important;
    }
    /* But keep gender/birth-date rows usable: re-flow inline */
    body.sl-auth-page .sl-content-body td > input[type="radio"] + * { display: inline; }

    /* Inputs always fill the column */
    body.sl-auth-page .sl-content-body input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
    body.sl-auth-page .sl-content-body select,
    body.sl-auth-page .sl-content-body textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ── 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; }


/* ================================================================
   STITCH REDESIGN (newreg.php) --- body.reg-redesign
   Mishkah Modern Learning design system applied to the
   registration form. Overrides .sl-auth-page chrome for this
   page only.
   ================================================================ */

body.reg-redesign {
    font-family: 'Atkinson Hyperlegible Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
    background: #f8f9ff;
    color: #0b1c30;
    /* Stitch tokens */
    --reg-primary:           #004428;
    --reg-primary-container: #165d3b;
    --reg-on-primary:        #ffffff;
    --reg-surface:           #f8f9ff;
    --reg-surface-card:      #ffffff;
    --reg-surface-tint:      #e5eeff;
    --reg-outline:           #707971;
    --reg-outline-variant:   #bfc9c0;
    --reg-on-surface:        #0b1c30;
    --reg-on-surface-variant:#404942;
    --reg-error:             #ba1a1a;
    --reg-radius-sm:         0.5rem;   /* 8px  --- inputs, buttons */
    --reg-radius-lg:         0.75rem;  /* 12px --- section cards */
    --reg-shadow-sm:         0 1px 2px 0 rgb(0 0 0 / 0.05);
    --reg-shadow-md:         0 4px 6px -1px rgb(0 0 0 / 0.10);
}

/* Strip the legacy auth-page card chrome --- sections are their own cards. */
body.reg-redesign .sl-content-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    overflow: visible !important;
}
body.reg-redesign .sl-content-body {
    background: transparent !important;
    overflow: visible !important;
    padding: 0 !important;
}
body.reg-redesign .sl-main {
    max-width: 960px !important;
    padding-top: 40px !important;
}
body.reg-redesign .sl-main::before {
    width: 200px;
    height: 64px;
    margin-bottom: 24px;
}

/* The Stitch design contains its own page header (h1 + subtitle), so the
   legacy "1- First Step..." td.title2 row and any inherited maintitel get
   hidden on this page. */
body.reg-redesign .sl-content-body td.title2,
body.reg-redesign .sl-content-body td.maintitel { display: none !important; }

/* Reset the legacy table chrome that wraps the new form. */
body.reg-redesign .sl-content-body table#table4,
body.reg-redesign .sl-content-body table#table4 > tbody,
body.reg-redesign .sl-content-body table#table4 > tbody > tr,
body.reg-redesign .sl-content-body table#table4 > tbody > tr > td {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-collapse: collapse !important;
}

/* ------ Page header ------------------------------------------------------------------------------------------------------------------------------------------ */

body.reg-redesign .reg-form-header {
    text-align: center;
    margin: 0 0 48px;
}
body.reg-redesign .reg-title {
    font-size: 32px;
    line-height: 40px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--reg-primary);
    margin: 0 0 4px;
}
body.reg-redesign .reg-subtitle {
    font-size: 16px;
    line-height: 24px;
    color: var(--reg-on-surface-variant);
    margin: 0;
}

/* ------ Form layout ------------------------------------------------------------------------------------------------------------------------------------------ */

body.reg-redesign form[name="frm_reg"] {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ------ Section card --------------------------------------------------------------------------------------------------------------------------------------- */

body.reg-redesign .reg-section {
    background: var(--reg-surface-card);
    border: 1px solid var(--reg-outline-variant);
    border-radius: var(--reg-radius-lg);
    padding: 24px;
    box-shadow: var(--reg-shadow-sm);
}
body.reg-redesign .reg-section-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 24px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--reg-outline-variant);
}
body.reg-redesign .reg-section-head h2 {
    font-size: 24px;
    line-height: 32px;
    font-weight: 600;
    color: var(--reg-on-surface);
    margin: 0;
}
body.reg-redesign .reg-section-head .material-symbols-outlined {
    color: var(--reg-primary);
    font-size: 24px;
    font-variation-settings: 'FILL' 1;
}

/* ------ Field grid --------------------------------------------------------------------------------------------------------------------------------------------- */

body.reg-redesign .reg-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}
body.reg-redesign .reg-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
body.reg-redesign .reg-field-wide { grid-column: 1 / -1; }

body.reg-redesign .reg-field label,
body.reg-redesign .reg-field > label {
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--reg-on-surface-variant);
    margin: 0;
    display: block;
}
body.reg-redesign .reg-req {
    color: var(--reg-error);
    margin-left: 2px;
}
body.reg-redesign .reg-opt {
    font-weight: 400;
    color: var(--reg-outline);
    margin-left: 4px;
}

/* ------ Inputs / selects --------------------------------------------------------------------------------------------------------------------------- */

body.reg-redesign .reg-field input,
body.reg-redesign .reg-field select {
    width: 100% !important;
    max-width: none !important;
    height: 44px !important;
    padding: 0 12px !important;
    border: 1px solid var(--reg-outline-variant) !important;
    border-radius: var(--reg-radius-sm) !important;
    background: var(--reg-surface-card) !important;
    font-family: inherit !important;
    font-size: 16px !important;
    color: var(--reg-on-surface) !important;
    outline: none !important;
    box-shadow: none !important;
    transition: border-color .15s, box-shadow .15s !important;
}
body.reg-redesign .reg-field input:focus,
body.reg-redesign .reg-field select:focus {
    border-color: var(--reg-primary) !important;
    box-shadow: 0 0 0 1px var(--reg-primary) !important;
}

/* Inline hint link (e.g., "Important note" beside email) */
body.reg-redesign .reg-hint {
    font-size: 12px;
    line-height: 16px;
    color: var(--reg-on-surface-variant) !important;
    text-decoration: none !important;
    font-style: italic;
    margin-top: 2px;
    align-self: flex-start;
}
body.reg-redesign .reg-hint:hover {
    color: var(--reg-primary) !important;
    text-decoration: underline !important;
}

/* ------ Radio group (Gender) --------------------------------------------------------------------------------------------------------------- */

body.reg-redesign .reg-radio-group {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 44px;
}
body.reg-redesign label.reg-radio {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 400;
    color: var(--reg-on-surface);
    cursor: pointer;
    margin: 0;
    letter-spacing: 0;
}
body.reg-redesign label.reg-radio input[type="radio"] {
    width: 16px !important;
    height: 16px !important;
    accent-color: var(--reg-primary);
    margin: 0;
}

/* ------ Birth date picker (DateInput JS injects a nested <table>) --- */

body.reg-redesign .reg-date table {
    width: auto !important;
    border-collapse: separate !important;
    border-spacing: 8px 0 !important;
    margin: 0 !important;
}
body.reg-redesign .reg-date td {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}
body.reg-redesign .reg-date select.calendarDateInput,
body.reg-redesign .reg-date input.calendarDateInput {
    height: 44px !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    padding: 0 12px !important;
    border: 1px solid var(--reg-outline-variant) !important;
    border-radius: var(--reg-radius-sm) !important;
    background: var(--reg-surface-card) !important;
    font-family: inherit !important;
    font-size: 16px !important;
    color: var(--reg-on-surface) !important;
    display: inline-block !important;
}
body.reg-redesign .reg-date select.calendarDateInput[name$="_Month"] { min-width: 140px !important; }
body.reg-redesign .reg-date select.calendarDateInput[id$="_Day_ID"]  { min-width: 80px  !important; }
body.reg-redesign .reg-date input.calendarDateInput[id$="_Year_ID"]  { width: 90px !important; }
/* hide the calendar trigger icon --- design omits it */
body.reg-redesign .reg-date a[id$="_ID_Link"] { display: none !important; }

/* ------ Captcha ------------------------------------------------------------------------------------------------------------------------------------------------------ */

body.reg-redesign .reg-captcha {
    display: flex;
    align-items: center;
    gap: 12px;
}
body.reg-redesign .reg-captcha img {
    height: 44px;
    border: 1px solid var(--reg-outline-variant);
    border-radius: var(--reg-radius-sm);
    background: var(--reg-surface-tint);
}
body.reg-redesign .reg-captcha input { flex: 1; }

/* ------ Action buttons --------------------------------------------------------------------------------------------------------------------------------- */

body.reg-redesign .reg-actions {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding-top: 8px;
}
body.reg-redesign .reg-btn {
    height: 44px !important;
    padding: 0 32px !important;
    border-radius: var(--reg-radius-sm) !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    cursor: pointer;
    border: none !important;
    background: transparent;
    transition: background .15s, box-shadow .15s, transform .1s !important;
    min-width: 140px;
}
body.reg-redesign .reg-btn-primary {
    background: var(--reg-primary) !important;
    color: var(--reg-on-primary) !important;
    box-shadow: var(--reg-shadow-md) !important;
}
body.reg-redesign .reg-btn-primary:hover {
    background: var(--reg-primary-container) !important;
}
body.reg-redesign .reg-btn-primary:active { transform: scale(0.98); }
body.reg-redesign .reg-btn-secondary {
    background: transparent !important;
    color: var(--reg-primary) !important;
    border: 1px solid var(--reg-primary) !important;
}
body.reg-redesign .reg-btn-secondary:hover {
    background: rgba(0, 68, 40, 0.05) !important;
}

/* ------ Responsive --------------------------------------------------------------------------------------------------------------------------------------------- */

@media (max-width: 768px) {
    body.reg-redesign .sl-main {
        padding-left: 16px !important;
        padding-right: 16px !important;
        padding-top: 24px !important;
    }
    body.reg-redesign .reg-form-header { margin-bottom: 32px; }
    body.reg-redesign .reg-title { font-size: 28px; line-height: 36px; }
    body.reg-redesign .reg-grid { grid-template-columns: 1fr; gap: 16px; }
    body.reg-redesign .reg-section { padding: 18px; }
    body.reg-redesign .reg-section-head { margin-bottom: 16px; }
    body.reg-redesign .reg-section-head h2 { font-size: 20px; line-height: 28px; }
    body.reg-redesign .reg-actions { flex-direction: column-reverse; gap: 12px; padding-top: 4px; }
    body.reg-redesign .reg-btn { width: 100%; }
    body.reg-redesign .reg-radio-group { gap: 16px; }
    body.reg-redesign .reg-date select.calendarDateInput[name$="_Month"] { min-width: 0 !important; flex: 1 1 0; }
    body.reg-redesign .reg-date select.calendarDateInput[id$="_Day_ID"]  { min-width: 0 !important; flex: 1 1 0; }
    body.reg-redesign .reg-date input.calendarDateInput[id$="_Year_ID"]  { width: 80px !important; flex: 0 0 80px; }
}


/* ------ Hide legacy chrome that the PHP shell injects above the form ------ */
/* td.maintitel renders "Registration form" banner; first <form> in td.title2
   is the Existing Student login injected by top_main_loginuser(). */
body.reg-redesign .sl-content-body table#table4 td.maintitel { display: none !important; }
body.reg-redesign .sl-content-body table#table4 td.title2 > form:not([name="frm_reg"]) { display: none !important; }
body.reg-redesign .sl-content-body table#table4 td.title3 { display: none !important; }


/* Labels inherit text-align:center from the legacy <td>; force left-align */
body.reg-redesign .reg-field,
body.reg-redesign .reg-field label,
body.reg-redesign .reg-field > label,
body.reg-redesign .reg-section,
body.reg-redesign .reg-section-head,
body.reg-redesign .reg-form-header { text-align: left !important; }
body.reg-redesign .reg-form-header { text-align: center !important; }
body.reg-redesign .reg-actions { text-align: center !important; }
