:root {
    --bg: #f3f6fb;
    --card: #ffffff;
    --ink: #10284f;
    --muted: #5c6b84;
    --line: #d5e0f0;
    --navy: #0c3d91;
    --yellow: #ffd000;
    --pink: #e21878;
    --teal: #00a99d;
    --green: #0c3d91;
    --green-dark: #082a66;
    --mint: #eef3fb;
    --gold: #ffd000;
    --danger: #c62828;
    --shadow: 0 16px 40px rgba(8, 42, 102, 0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.7), transparent 28%),
        var(--bg);
    color: var(--ink);
    font-family: "Almarai", "Segoe UI", Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

a { color: var(--green); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.site-head {
    background: #fff;
    color: var(--ink);
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 10px 30px rgba(8, 42, 102, 0.06);
}

.site-bar, .menu-row {
    width: min(1440px, calc(100% - 32px));
    margin: 0 auto;
}

.site-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 8px 0 6px;
}

.brand { display: flex; align-items: center; color: inherit; }
.logo { height: 112px; width: auto; display: block; background: #fff; }
.login-logo { height: 108px; margin: 0 auto 8px; }

.final-grades-table {
    width: 100%;
    border-collapse: collapse;
}
.final-grades-table th,
.final-grades-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e8eef8;
    text-align: center;
    font-weight: 700;
}
.final-grades-table th:first-child,
.final-grades-table td:first-child {
    text-align: right;
}
.final-grades-table th {
    color: var(--navy);
    background: #f5f8fd;
}
.final-entry-sheet .final-total,
.final-entry-sheet .final-avg {
    font-weight: 800;
    color: var(--navy);
    text-align: center;
    min-width: 72px;
}
.final-entry-sheet .final-input {
    width: 88px;
    text-align: center;
}

.dash-page { max-width: 1100px; }
.dash-status {
    display: grid;
    gap: 4px;
    margin: 4px 0 16px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid #dce6f4;
    background: #fff;
}
.dash-status strong {
    font-size: 18px;
    font-weight: 800;
    color: var(--navy);
}
.dash-status span {
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}
.dash-status.needs {
    border-color: #f0c2c2;
    background: linear-gradient(180deg, #fff8f8, #fff);
}
.dash-status.needs strong { color: var(--danger); }
.dash-status.clear {
    border-color: #bfe8d8;
    background: linear-gradient(180deg, #f3fbf7, #fff);
}
.dash-status.clear strong { color: #0c7a62; }
.dash-meters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.dash-meter {
    display: grid;
    gap: 4px;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #dce6f4;
}
.dash-meter b {
    font-size: 30px;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.1;
}
.dash-meter span {
    font-size: 13px;
    font-weight: 800;
    color: var(--ink);
}
.dash-meter.is-warn {
    border-color: #f0c2c2;
    background: #fff8f8;
}
.dash-meter.is-warn b { color: var(--danger); }
.dash-meter.is-mid {
    border-color: #f0df9a;
    background: #fffaf0;
}
.dash-meter.is-mid b { color: #9a6b00; }
.dash-meter.is-ok {
    border-color: #bfe8d8;
    background: #f5fbf8;
}
.dash-meter.is-ok b { color: #0c7a62; }
.dash-panels {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}
.dash-panel {
    background: #fff;
    border: 1px solid #dce6f4;
    border-radius: 18px;
    padding: 14px 14px 10px;
    min-height: 220px;
}
.dash-panel > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e8eef8;
}
.dash-panel > header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--navy);
}
.dash-panel > header span {
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef3fb;
    color: var(--navy);
    font-size: 13px;
    font-weight: 800;
}
.dash-empty,
.dash-more {
    margin: 8px 2px 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}
.dash-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 2px;
}
.dash-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 4px;
    border-bottom: 1px solid #f0f4fa;
}
.dash-list li:last-child { border-bottom: 0; }
.dash-list strong {
    display: block;
    font-size: 14px;
    font-weight: 800;
    color: var(--ink);
}
.dash-list small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}
.dash-list-side {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.dash-list-side em {
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
    color: var(--danger);
}
.dash-list-side a {
    font-size: 13px;
    font-weight: 800;
    color: var(--navy);
    text-decoration: none;
}
.dash-list-side a:hover { text-decoration: underline; }
.dash-pct {
    display: inline-flex;
    min-width: 48px;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 12px;
}
.dash-pct.low { background: #fdeceb; color: var(--danger); }
.dash-pct.mid { background: #fff6dd; color: #9a6b00; }
.dash-pct.ok { background: #e7f7f2; color: #0c7a62; }
@media (max-width: 1023px) {
    .dash-meters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-panels { grid-template-columns: 1fr; }
    .dash-page { max-width: none; }
}
@media (max-width: 767px) {
    .dash-meters { grid-template-columns: 1fr 1fr; }
    .dash-meter b { font-size: 24px; }
    .dash-status strong { font-size: 16px; }
}

.homework-board {
    display: grid;
    gap: 12px;
}
.homework-card {
    background: #fff;
    border: 1px solid #dce6f4;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 8px 20px rgba(12, 61, 145, 0.05);
}
.homework-card.is-overdue { border-color: #f0c2c2; background: #fff9f9; }
.homework-card-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.homework-subject {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 2px 10px;
    border-radius: 999px;
    background: #eaf1fb;
    color: var(--navy);
    font-size: 12px;
    font-weight: 800;
}
.homework-due {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
.homework-card.is-overdue .homework-due { color: var(--danger); }
.homework-card h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--ink);
}
.homework-card p {
    margin: 0 0 12px;
    color: var(--muted);
    font-weight: 600;
    line-height: 1.7;
    white-space: pre-wrap;
}
.homework-card footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px solid #eef3fb;
    padding-top: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.homework-reply {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eef3fb;
}
.homework-reply h4 {
    margin: 0;
    font-size: 15px;
}
.homework-answer {
    background: #f5f8fc;
    border: 1px solid #e4ebf6;
    border-radius: 12px;
    padding: 10px 12px;
    line-height: 1.7;
    font-weight: 700;
    color: var(--ink);
    white-space: pre-wrap;
}
.homework-reply textarea,
.homework-file-input {
    white-space: normal;
    overflow: auto;
    height: auto;
    text-overflow: clip;
}
.homework-reply textarea {
    min-height: 96px;
    padding: 10px 14px;
    line-height: 1.7;
}
.homework-attachment-media {
    display: block;
    max-width: min(100%, 420px);
    max-height: 240px;
    border-radius: 12px;
    background: #0c1b33;
}
.homework-status-done { color: #0c7a43; font-weight: 800; }
.homework-status-wait { color: var(--muted); font-weight: 700; }
.homework-replies { margin-top: 16px; }
.homework-replies .section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.homework-replies-table { table-layout: fixed; width: 100%; }
.homework-replies-table .col-name { width: 22%; }
.homework-replies-table td { vertical-align: top; }

/* —— Login page —— */
body:has(.login-page) {
    background: #f4f7fc;
    min-height: 100%;
}
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: 1fr auto;
    background:
        radial-gradient(circle at 10% 12%, rgba(12, 61, 145, 0.05), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
}
.login-shell {
    width: min(520px, calc(100% - 28px));
    margin: 0 auto;
    padding: clamp(24px, 4vw, 40px) 0 20px;
    display: grid;
}
.login-showcase {
    position: relative;
    display: grid;
    gap: 18px;
    padding: 28px 22px 24px;
    border-radius: 28px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e7eef8;
    box-shadow: 0 14px 34px rgba(12, 61, 145, 0.08);
    animation: login-rise .55s ease both;
}
.login-dots {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 50px;
    height: 50px;
    background-image: radial-gradient(#b7c7e0 1.5px, transparent 1.5px);
    background-size: 10px 10px;
    opacity: .5;
}
.login-wave-deco {
    position: absolute;
    right: -36px;
    top: 24%;
    width: 140px;
    height: 180px;
    border: 2px solid rgba(12, 61, 145, 0.07);
    border-radius: 60% 40% 55% 45%;
    transform: rotate(18deg);
    pointer-events: none;
}
.login-brand {
    position: relative;
    z-index: 2;
    text-align: center;
}
.login-brand img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    display: block;
    margin: 0 auto 12px;
    background: #fff;
}
.login-brand h1 {
    margin: 0;
    font-family: "El Messiri", "Almarai", sans-serif;
    font-size: clamp(24px, 5vw, 32px);
    font-weight: 700;
    color: #0c3d91;
    line-height: 1.3;
}
.login-brand-line {
    display: block;
    width: 56px;
    height: 2px;
    margin: 10px auto;
    background: #e21878;
    border-radius: 99px;
}
.login-brand p {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #6b7c95;
}
.login-welcome {
    position: relative;
    z-index: 2;
    text-align: center;
}
.login-welcome h2 {
    margin: 0 0 6px;
    font-family: "El Messiri", "Almarai", sans-serif;
    font-size: clamp(26px, 5vw, 34px);
    color: #0c3d91;
    font-weight: 700;
}
.login-spark {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 3px 10px;
    vertical-align: middle;
    background: #ffd000;
    clip-path: polygon(50% 0, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0 50%, 39% 35%);
}
.login-spark.alt { background: #00a99d; width: 6px; height: 6px; margin-bottom: 12px; }
.login-welcome p {
    margin: 0;
    color: #7a8aa3;
    font-weight: 700;
    font-size: 14px;
}
.login-card {
    position: relative;
    z-index: 2;
    width: 100%;
    display: grid;
    gap: 14px;
    margin-top: 4px;
    padding: 22px 18px 18px;
    border-radius: 20px;
    background: #f7f9fd;
    border: 1px solid #e2eaf5;
}
.login-card-head {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin-bottom: 2px;
}
.login-lock {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #eaf1fb;
    color: var(--navy);
}
.login-card-head h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: var(--ink);
}
.login-card-rule {
    width: 42px;
    height: 3px;
    border-radius: 99px;
    background: var(--navy);
}
.login-error {
    background: #fdeceb;
    color: var(--danger);
    border: 1px solid #f3c4c1;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 700;
    font-size: 14px;
    text-align: center;
}
.login-field {
    display: grid;
    gap: 6px;
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}
.login-input {
    position: relative;
    display: grid;
}
.login-input > svg {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    color: #8ea0bc;
    pointer-events: none;
    z-index: 1;
}
.login-input input {
    width: 100%;
    min-height: 48px;
    border: 1.5px solid #d5e0f0;
    border-radius: 14px;
    background: #fff;
    font-weight: 700;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-input input:hover { border-color: #aebfdb; }
.login-input input:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(12, 61, 145, 0.12);
}
.login-eye {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #8ea0bc;
    display: grid;
    place-items: center;
    padding: 0;
    z-index: 1;
}
.login-eye:hover { color: var(--navy); background: #eef3fb; }
.login-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
    font-weight: 700;
}
.login-remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--ink);
    cursor: pointer;
}
.login-remember input {
    width: 16px;
    height: 16px;
    accent-color: var(--navy);
}
.login-help {
    color: var(--muted);
    font-size: 12px;
}
.login-submit {
    min-height: 50px;
    border: 0;
    border-radius: 14px;
    background: var(--navy);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    transition: background .15s ease, transform .12s ease;
}
.login-submit:hover { background: #0a337a; }
.login-submit:active { transform: translateY(1px); }
.login-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    padding: 18px clamp(16px, 4vw, 40px);
    border-top: 1px solid #dde7f4;
    background: rgba(255, 255, 255, 0.9);
    direction: ltr;
}
.login-footer-values,
.login-footer-copy { direction: rtl; }
.login-footer-values {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 28px;
}
.login-footer-values > div {
    display: flex;
    align-items: center;
    gap: 10px;
}
.login-fico {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #eaf1fb;
    color: var(--navy);
    flex: 0 0 auto;
}
.login-footer-values strong {
    display: block;
    color: var(--navy);
    font-size: 13px;
}
.login-footer-values span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.login-footer-copy {
    text-align: right;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.login-footer-copy strong {
    display: block;
    color: var(--navy);
    font-size: 13px;
    margin-bottom: 2px;
}
@keyframes login-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .login-showcase { animation: none; }
}
@media (max-width: 767px) {
    .login-page { padding: 12px 12px 0; }
    .login-shell { gap: 14px; }
    .login-card { padding: 18px 16px; border-radius: 22px; }
    .login-brand-name { font-size: clamp(22px, 7vw, 28px); }
    .login-footer {
        justify-content: center;
        text-align: center;
        padding: 14px 12px 18px;
        gap: 12px;
    }
    .login-footer-values {
        justify-content: center;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }
    .login-footer-values > div {
        justify-content: flex-start;
        padding: 10px 12px;
        border-radius: 12px;
        background: #f5f8fd;
    }
    .login-footer-copy { text-align: center; width: 100%; }
}
@media (max-width: 1023px) and (orientation: landscape) {
    .login-page {
        padding: 10px 16px 0;
        justify-content: flex-start;
    }
    .login-shell { max-width: 720px; }
    .login-card { padding: 16px 18px; }
    .login-footer-values {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .login-footer-values > div {
        flex: 1 1 180px;
    }
}
.site-meta { display: flex; align-items: center; gap: 12px; }
.year-pill {
    background: var(--navy);
    color: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
}
.who-name { font-weight: 700; }
.logout {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px 14px;
    color: var(--navy);
}

.menu-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
}

.nav {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    padding: 0;
}
.report-page { width: min(980px, calc(100% - 32px)); }
.report-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}
.report-toolbar label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 260px;
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}
.report-toolbar select {
    min-height: 44px;
    min-width: 260px;
    border: 1.5px solid #d5e0f0;
    border-radius: 12px;
    padding: 8px 12px;
    background: #fff;
}

.cert-sheet {
    margin-top: 8px;
    background:
        linear-gradient(180deg, rgba(255, 208, 0, 0.08), transparent 120px),
        #fff;
    border: 1px solid #c9d6ea;
    border-radius: 22px;
    box-shadow: 0 22px 50px rgba(8, 42, 102, 0.1);
    padding: 18px;
}
.cert-frame {
    position: relative;
    border: 2px solid #0c3d91;
    border-radius: 16px;
    padding: 28px 28px 22px;
    background:
        radial-gradient(circle at top left, rgba(0, 169, 157, 0.06), transparent 28%),
        radial-gradient(circle at top right, rgba(226, 24, 120, 0.05), transparent 24%),
        #fff;
}
.cert-frame::before {
    content: "";
    position: absolute;
    inset: 8px;
    border: 1px solid #d7e2f3;
    border-radius: 12px;
    pointer-events: none;
}

.cert-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 22px;
    position: relative;
    text-align: center;
}
.cert-logo {
    width: 110px;
    height: auto;
    display: block;
    margin: 0 auto;
    background: #fff;
}
.cert-brand-text {
    text-align: center;
    width: 100%;
}
.cert-school-ar {
    margin: 0;
    font-family: "El Messiri", "Almarai", serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.2;
}
.cert-school-en {
    margin: 2px 0 10px;
    color: var(--muted);
    font-size: 14px;
    letter-spacing: 0.04em;
}
.cert-rule {
    height: 4px;
    width: min(360px, 70%);
    margin: 0 auto 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--navy) 0 55%, var(--yellow) 55% 72%, var(--pink) 72% 84%, var(--teal) 84%);
}
.cert-brand-text h1 {
    margin: 0;
    font-family: "El Messiri", "Almarai", serif;
    font-size: 34px;
    color: var(--ink);
}
.cert-year {
    margin: 4px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.cert-identity {
    display: grid;
    grid-template-columns: 1.6fr 0.7fr 1fr 0.7fr;
    gap: 10px;
    margin-bottom: 18px;
    position: relative;
}
.cert-identity > div {
    background: #f5f8fd;
    border: 1px solid #dce6f5;
    border-radius: 14px;
    padding: 12px 14px;
}
.cert-identity span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}
.cert-identity strong {
    display: block;
    font-size: 18px;
    color: var(--navy);
    font-family: "El Messiri", "Almarai", serif;
}

.cert-summary {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #0c3d91, #114ea8 55%, #0b6e8a);
    color: #fff;
    position: relative;
}
.cert-overall {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}
.cert-overall h2 {
    margin: 0;
    color: #fff;
    font-size: 18px;
}
.cert-grade-label {
    margin: 4px 0 0;
    color: #ffe58a;
    font-weight: 800;
}
.cert-ring {
    --pct: 0;
    width: 126px;
    height: 126px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(#ffd000 calc(var(--pct) * 1%), rgba(255, 255, 255, 0.18) 0);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.cert-ring-inner {
    width: 98px;
    height: 98px;
    border-radius: 50%;
    background: #0a347c;
    display: grid;
    place-content: center;
    text-align: center;
}
.cert-ring-inner b {
    font-family: "El Messiri", "Almarai", serif;
    font-size: 34px;
    line-height: 1;
}
.cert-ring-inner small { color: #ffe58a; font-weight: 800; }

.cert-meters { display: grid; gap: 12px; }
.cert-meter-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 14px;
}
.cert-meter-top b { color: #ffd000; }
.cert-bar {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    overflow: hidden;
}
.cert-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffd000, #ffe98a);
}

.cert-block { margin-bottom: 20px; position: relative; }
.cert-block h2 {
    margin: 0 0 10px;
    font-size: 22px;
    color: var(--navy);
    display: flex;
    align-items: center;
    gap: 10px;
}
.cert-block h2::before {
    content: "";
    width: 8px;
    height: 22px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--yellow), var(--teal));
}
.cert-table-wrap {
    border: 1px solid #d5e0f0;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
}
.cert-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.cert-table th,
.cert-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e7eef8;
    text-align: center;
    vertical-align: middle;
    font-size: 14px;
}
.cert-table thead th {
    background: var(--navy);
    color: #fff;
    font-weight: 800;
}
.cert-table tbody td.subject,
.cert-table tbody th,
.cert-table.compact tbody th {
    text-align: right;
    font-weight: 700;
    color: var(--ink);
    background: #f8fafc;
}
.cert-table tbody td.avg,
.cert-table tbody td.effort { font-weight: 800; color: var(--navy); }
.cert-table tbody tr.is-muted { color: var(--muted); }
.cert-table tfoot th,
.cert-table tfoot td {
    background: #eef3fb;
    color: var(--navy);
    border-bottom: 0;
    font-weight: 800;
    text-align: right;
}
.cert-table.compact th { width: 38%; }
.cert-note, .cert-empty {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
}
.cert-split {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 16px;
}
.thinking-board {
    border: 1px solid #d5e0f0;
    border-radius: 16px;
    background: linear-gradient(180deg, #fbfdff 0%, #fff 40%);
    overflow: hidden;
}
.thinking-board-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: #0c3d91;
    color: #fff;
}
.thinking-board-head span,
.thinking-board-head strong {
    color: #fff;
}
.thinking-board-head span {
    font-size: 13px;
    font-weight: 700;
    opacity: .95;
}
.thinking-board-head strong {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: .02em;
}
.thinking-list {
    list-style: none;
    margin: 0;
    padding: 8px;
    display: grid;
    gap: 6px;
}
.thinking-list li {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid #e7eef8;
    background: #fff;
}
.thinking-list li.is-scored {
    border-color: #cfe0f8;
    background: #f7faff;
}
.thinking-list li.is-empty {
    opacity: .78;
}
.thinking-no {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef3fb;
    color: var(--navy);
    font-size: 12px;
    font-weight: 800;
}
.thinking-list li.is-scored .thinking-no {
    background: #0c3d91;
    color: #fff;
}
.thinking-main {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.thinking-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.35;
    text-align: left;
    direction: ltr;
}
.thinking-meta {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    line-height: 1.3;
}
.thinking-score {
    min-width: 42px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    background: #eef3fb;
    color: var(--navy);
}
.thinking-list li.is-scored .thinking-score {
    background: #dcecff;
    color: #0c3d91;
}
.thinking-list li.is-empty .thinking-score {
    background: #f3f5f8;
    color: #8b97a8;
}
.thinking-legend {
    margin: 0;
    padding: 8px 14px 12px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}
.cert-notes {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}
.cert-notes li {
    display: grid;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid #e1e9f5;
    border-radius: 12px;
    background: #f9fbfe;
}
.cert-notes strong { color: var(--navy); }

.cert-signoff {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 28px;
    position: relative;
}
.cert-signoff > div {
    border: 1px dashed #c7d5ea;
    border-radius: 14px;
    padding: 14px 12px 18px;
    text-align: center;
    background: #fff;
}
.cert-signoff span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}
.cert-signoff strong {
    display: block;
    min-height: 28px;
    color: var(--navy);
    font-family: "El Messiri", "Almarai", serif;
}
.cert-signoff i {
    display: block;
    height: 1px;
    margin-top: 18px;
    background: #c7d5ea;
}
.cert-signoff .seal {
    border-style: solid;
    border-color: rgba(12, 61, 145, 0.35);
    background: linear-gradient(180deg, #fff, #f4f8ff);
}

@media (max-width: 900px) {
    .cert-summary,
    .cert-split,
    .cert-identity,
    .cert-signoff { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .cert-identity,
    .cert-summary,
    .cert-split,
    .cert-signoff { grid-template-columns: 1fr; }
    .cert-sheet { padding: 10px; }
    .cert-frame { padding: 18px 14px; }
}

@media print {
    .site-head, .mast, .main-nav, .context-bar, .crumb, .pills, .no-print { display: none !important; }
    body { background: white !important; }
    .wrap, .report-page { width: auto; margin: 0; }
    .cert-sheet {
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        background: #fff;
    }
    .cert-frame { border-width: 2px; }
    .cert-summary { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .cert-table thead th,
    .cert-bar i,
    .cert-ring,
    .thinking-board-head,
    .thinking-no,
    .thinking-score { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .thinking-list li { break-inside: avoid; }
}
.nav a {
    display: grid;
    justify-items: center;
    color: var(--navy);
    padding: 10px 14px 8px;
    border-bottom: 3px solid transparent;
    border-radius: 0;
}
.nav a b { font-size: 15px; font-weight: 700; line-height: 1.2; }
.nav a small { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; font-weight: 500; }
.nav a:hover, .nav a.active {
    background: transparent;
    color: var(--navy);
    border-bottom-color: var(--yellow);
}
.nav a.feature {
    background: var(--yellow);
    border-radius: 14px;
    border-bottom-color: transparent;
    margin: 8px 0;
    padding: 8px 16px;
}
.nav a.feature small { color: var(--navy); }
.nav a.active small, .nav a:hover small { color: var(--navy); }

.flash {
    margin: 16px auto 0;
    max-width: 1100px;
    background: var(--mint);
    color: var(--green-dark);
    border: 1px solid #cfe3d6;
    border-radius: 12px;
    padding: 12px 16px;
}

.wrap { width: min(1100px, calc(100% - 32px)); margin: 24px auto 40px; }
.wrap.wide { width: min(1440px, calc(100% - 24px)); }

.card, .panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.card { padding: 22px; }
.panel { padding: 18px; }

h1, h2, .brand strong, .login-brand-name {
    font-family: "El Messiri", "Tajawal", serif;
    font-weight: 700;
}
h1 { font-size: 36px; line-height: 1.3; margin: 0 0 8px; }
h2 { font-size: 24px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.lede { color: var(--muted); margin-top: 0; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 280px));
    gap: 16px;
    margin-top: 18px;
}

.class-card {
    display: block;
    padding: 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.class-card:hover { border-color: #b7d2c4; }
.class-card span { display: block; color: var(--muted); margin-top: 6px; }
.class-card strong { font-size: 20px; color: var(--ink); }

.dash {
    display: grid;
    grid-template-columns: 1.5fr 0.7fr;
    gap: 22px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 28px 28px 22px;
    position: relative;
    overflow: hidden;
}
.dash::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--navy) 0 64%, var(--yellow) 64% 80%, var(--pink) 80% 90%, var(--teal) 90%);
}
.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.stat {
    background: var(--mint);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 16px;
    min-width: 0;
}
.stat b { display: block; font-size: 28px; color: var(--navy); font-family: "El Messiri", "Tajawal", serif; }
.stat span { color: var(--muted); font-size: 13px; }
@media (max-width: 767px) {
    .stats { grid-template-columns: 1fr; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.pills a, .btn, .btn-ghost, .btn-danger {
    border-radius: 12px;
    padding: 10px 16px;
    min-height: 44px;
    border: 1px solid var(--line);
    background: #fff;
}
.pills a.active {
    background: var(--navy);
    color: white;
    border-color: var(--navy);
}
.btn {
    background: var(--yellow);
    color: var(--green-dark);
    border-color: var(--yellow);
    font-weight: 700;
}
.btn-ghost { background: transparent; }
.btn-save {
    background: var(--navy);
    color: #fff;
    border: 0;
    border-radius: 12px;
    min-height: 42px;
    padding: 0 18px;
    font-weight: 700;
}
.btn-save:hover { background: var(--green-dark); }
.roster td { vertical-align: middle; }
.roster .code-cell { font-weight: 800; color: var(--navy); width: 72px; }
.name-form { display: flex; align-items: center; gap: 8px; }
.name-form input[name="full_name"] {
    flex: 1;
    min-width: 180px;
    background: #f4f7fc;
    border: 1.5px solid #d5e0f0;
    border-radius: 12px;
}
.name-form input[name="full_name"]:focus { background: #fff; }
.status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 700;
    background: #e7eef8;
    color: var(--navy);
}
.status.on { background: #e7f7f2; color: #0c7a62; }
.status.off { background: #fdeceb; color: var(--danger); }
.btn-danger, .link-danger { color: var(--danger); background: transparent; border: 0; padding: 0; }

.form-row, .inline-form, .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}
label { display: grid; gap: 6px; font-size: 14px; }
input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
    background: #f7f9fd;
    border: 1.5px solid #d0dced;
    border-radius: 12px;
    padding: 10px 12px;
    min-height: 44px;
    min-width: 0;
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-input input,
.login-input input[type="text"],
.login-input input[type="password"],
.login-input input:not([type]) {
    padding: 10px 52px 10px 48px !important;
    background: #fff !important;
    border-radius: 14px;
    text-align: right;
}
textarea { width: 100%; max-width: 100%; min-height: 64px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #aebfdb; background: #fff; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--navy);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(12, 61, 145, 0.12);
}

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th { background: var(--navy); color: #fff; font-weight: 700; }

.sheet-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(100dvh - 330px);
    min-height: 280px;
    border: 1px solid #cfdced;
    border-radius: 18px;
    background: white;
    box-shadow: 0 10px 28px rgba(8, 42, 102, 0.05);
    max-width: 100%;
}
/* Fill the container on wide screens; keep a floor so dense gradebooks still scroll horizontally. */
.sheet { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 980px; max-width: none; }
table.sheet.final-entry-sheet { width: 100%; min-width: 100%; }
.sheet th, .sheet td {
    border-bottom: 1px solid #e3ebf6;
    border-left: 1px solid #e8eef7;
    padding: 8px 10px;
    background: white;
    vertical-align: middle;
}
.sheet th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, #1553b8, #0c3d91);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    min-width: 96px;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 0 rgba(8, 42, 102, 0.2);
}
.sheet thead th:first-child {
    border-start-start-radius: 14px;
}
.sheet thead th:last-child {
    border-start-end-radius: 14px;
}
.sheet th .scale, .sheet th .hw-date { color: rgba(255, 255, 255, 0.78); }
.sheet th .link-danger { color: var(--yellow); }
.sheet .student {
    position: sticky;
    right: 0;
    z-index: 3;
    min-width: 220px;
    max-width: 300px;
    background: #f0f4fb;
    text-align: right;
    font-weight: 400;
    font-size: 16px;
    color: var(--ink);
    box-shadow: -6px 0 12px rgba(8, 42, 102, 0.06);
    overflow-wrap: anywhere;
}
.sheet td.student { font-weight: 400; font-size: 16px; }
.sheet th.student {
    background: linear-gradient(180deg, #1553b8, #0c3d91);
    color: #fff;
    z-index: 4;
    font-weight: 700;
    border-start-start-radius: 14px;
}
.sheet tr:nth-child(even) td { background: #f8fafd; }
.sheet tr:nth-child(even) td.student { background: #e8eef8; }
.sheet tr:hover td { background: #f3f7ff; }
.sheet tr:hover td.student { background: #e4ecf9; }
.sheet tr:focus-within td { background: #fff8dc; }
.sheet tr:focus-within td.student { background: #fff1b8; }
.sheet td.calc,
.sheet tr:nth-child(even) td.calc,
.sheet tr:focus-within td.calc { background: #fff6cc; color: var(--navy); font-weight: 800; }
.sheet .code { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.hw-title { display: block; max-width: 140px; white-space: normal; line-height: 1.35; }
.hw-date, .scale { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.sheet select.mark,
.sheet input.mark,
.sheet select,
.sheet .mark-field {
    min-height: 40px;
    border: 1.5px solid #c7d5ea;
    border-radius: 11px;
    background: #fff;
    color: var(--navy);
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.sheet select.mark.num {
    width: 72px;
    text-align: center;
    padding: 4px 6px;
}
.sheet input.mark.num {
    width: 84px;
    text-align: center;
    padding: 4px 6px;
}
.sheet select.mark.level {
    width: 132px;
    min-width: 120px;
    text-align: right;
    padding: 6px 10px;
    font-size: 13px;
}
.sheet select.mark.role { width: 148px; }
.sheet select.mark:hover,
.sheet input.mark:hover,
.sheet .mark-field:hover { border-color: #8eabd8; }
.sheet select.mark:focus,
.sheet input.mark:focus,
.sheet .mark-field:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(12, 61, 145, 0.14);
    background: #fff;
}
.sheet .note-input {
    width: 150px;
    min-height: 40px;
    border: 1.5px solid #c7d5ea;
    border-radius: 11px;
    padding: 6px 10px;
    background: #fff;
    font-weight: 600;
}
.sheet .star-input {
    width: 78px;
    text-align: center;
    font-weight: 800;
}
.sheet textarea {
    width: 190px;
    min-height: 52px;
    border-radius: 11px;
    background: #fff;
}
.calc {
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--navy);
    font-weight: 800;
    min-width: 72px;
    background: #fff8dc;
}
.hint { font-size: 14px; color: var(--muted); }

.savebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}
#save-status.ok { color: var(--green); }
#save-status.bad { color: var(--danger); }

.stack { display: grid; gap: 12px; margin-top: 18px; }
.stack input:not([type="checkbox"]):not([type="radio"]) { width: 100%; }
.error {
    background: #fdeceb;
    color: var(--danger);
    border-radius: 10px;
    padding: 10px 12px;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    background: var(--mint);
    color: var(--green-dark);
    font-size: 13px;
}

.split { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.split > :only-child { grid-column: 1 / -1; min-width: 0; }
.kicker {
    margin: 0 0 6px;
    color: var(--green);
    font-weight: 700;
    letter-spacing: 0;
}
.grade-switch, .section-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.grade-switch a, .section-switch a {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 8px 18px;
    border-radius: 14px;
    background: white;
    border: 1px solid var(--line);
    color: var(--ink);
    font-weight: 700;
}
.grade-switch a.active, .section-switch a.active {
    background: var(--green-dark);
    color: #fff;
    border-color: var(--green-dark);
}
.class-switch { padding: 8px 0; }
.class-switch label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 700; }
.class-switch select { min-width: 220px; background: white; min-height: 42px; }
.class-card {
    position: relative;
    padding-top: 22px;
}
.class-card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 18px;
    left: 18px;
    height: 4px;
    border-radius: 0 0 8px 8px;
    background: linear-gradient(90deg, var(--pink), var(--teal), var(--yellow));
}
.empty-note { background: #fff8dc; }
.brand strong { font-size: 22px; color: #fff; }
.grade-block { margin-top: 22px; }
.sections-home { margin-top: 28px; }
.grade-block h2, .sections-home h3 {
    display: inline-block;
    background: var(--navy);
    color: white;
    border-radius: 14px;
    padding: 6px 16px;
}
.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 14px;
    margin-top: 12px;
}
.section-card {
    background: #fff;
    border: 1px solid #e0e8f4;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(8, 42, 102, 0.05);
    color: var(--ink);
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.section-card:hover {
    border-color: #b8cae6;
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(8, 42, 102, 0.08);
}
.section-card.current {
    border-color: var(--navy);
    box-shadow: 0 0 0 2px rgba(12, 61, 145, 0.18), 0 14px 28px rgba(8, 42, 102, 0.08);
}
.section-open {
    display: grid;
    gap: 6px;
    padding: 16px;
    color: inherit;
    min-height: 148px;
    align-content: start;
    background:
        linear-gradient(180deg, rgba(12, 61, 145, 0.06), transparent 70%),
        #fff;
}
.section-kicker {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
}
.section-code {
    font-size: 34px;
    line-height: 1;
    color: var(--navy);
    font-weight: 800;
}
.section-meta { color: var(--muted); font-size: 14px; font-weight: 700; }
.section-cta {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border-radius: 10px;
    background: #eef3fb;
    color: var(--navy);
    font-weight: 800;
    font-size: 13px;
}
.section-card.current .section-cta {
    background: var(--navy);
    color: #fff;
}
.section-card .section-head {
    background: var(--navy);
    color: white;
    font-size: 22px;
    padding: 14px 16px 10px;
}
@media (max-width: 1023px) {
    .site-bar, .menu-row, .dash, .split, .savebar { display: grid; grid-template-columns: 1fr; }
    .menu-row { align-items: stretch; }
    .who { margin-right: 0; }
    .sheet-scroll { max-height: none; }
    .split { grid-template-columns: 1fr; }
}
