:root {
    --primary: #0f2027;
    --secondary: #203a43;
    --accent: #d4af37;
    --text-dark: #2b3336;
    --ok: #1d6b3d;
    --warn: #8a6d1d;
    --bad: #8a1f1f;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Tajawal', sans-serif; }

body.dash {
    background: #f4f1e8;
    color: var(--text-dark);
    min-height: 100vh;
}

.dash-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.side {
    background: linear-gradient(180deg, #0f2027, #203a43);
    color: #fff;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 800;
    margin-bottom: 28px;
}

.side-brand img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}

.side a.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d7dde0;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 12px;
    margin-bottom: 6px;
    transition: 0.25s;
}

.side a.nav:hover,
.side a.nav.active {
    background: rgba(212, 175, 55, 0.16);
    color: var(--accent);
}

.side .out {
    margin-top: 18px;
    color: #f3c1c1 !important;
}

.main { padding: 22px; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.topbar h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.who {
    background: #fff;
    border-radius: 14px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 20px rgba(15,32,39,0.06);
    font-weight: 700;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

.stat {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 10px 24px rgba(15,32,39,0.06);
}

.stat b {
    display: block;
    font-size: 1.7rem;
    color: var(--accent);
}

.panel {
    background: #fff;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 10px 24px rgba(15,32,39,0.06);
    margin-bottom: 18px;
}

.panel h2 {
    font-size: 1.15rem;
    margin-bottom: 14px;
    color: var(--primary);
}

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

th, td {
    text-align: right;
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
}

th { color: #667; font-weight: 700; }

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
    background: #eee;
}

.badge.ok { background: #e8f6ee; color: var(--ok); }
.badge.warn { background: #fff6dd; color: var(--warn); }
.badge.bad { background: #fdecec; color: var(--bad); }

.btn {
    border: 0;
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 700;
}

.btn.ok { background: #e8f6ee; color: var(--ok); }
.btn.bad { background: #fdecec; color: var(--bad); }
.btn.gold {
    background: var(--accent);
    color: var(--primary);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f0eee6;
}

.search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e4e0d4;
    border-radius: 12px;
    margin-bottom: 12px;
}

.note {
    background: #fff8e6;
    border: 1px solid #f0e0a8;
    color: #6d5720;
    padding: 14px;
    border-radius: 12px;
}

.menu-btn {
    display: none;
    border: 0;
    background: var(--primary);
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 10px;
}

.lock-card {
    max-width: 520px;
    margin: 12vh auto;
    background: #fff;
    padding: 28px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(15,32,39,0.1);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #0f2027, #203a43);
    padding: 24px;
}

.login-box {
    width: min(440px, 100%);
    background: #fff;
    border-radius: 22px;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.login-box img {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    display: block;
    margin: 0 auto 12px;
}

.login-box h1 {
    text-align: center;
    color: var(--primary);
    font-size: 1.3rem;
    margin-bottom: 18px;
}

.login-box label { font-weight: 700; display: block; margin: 10px 0 6px; }

.login-box input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8ea;
    border-radius: 12px;
}

.login-box button {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: var(--primary);
    font-weight: 800;
    cursor: pointer;
}

.hint-box {
    margin-top: 14px;
    background: #f7f4ea;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.9rem;
    color: #555;
}

.error { color: #8a1f1f; text-align: center; margin-top: 10px; min-height: 1.2em; }

@media (max-width: 980px) {
    .dash-shell { grid-template-columns: 1fr; }
    .side {
        position: fixed;
        right: -110%;
        top: 0;
        width: min(280px, 86vw);
        z-index: 20;
        transition: right 0.3s;
    }
    .side.open { right: 0; }
    .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .cards, .grid-2 { grid-template-columns: 1fr 1fr; }
}

.num-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 12px 0 18px;
}

.num-btn {
    height: 64px;
    border: 2px solid var(--accent);
    background: #fff;
    color: var(--primary);
    border-radius: 16px;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    transition: 0.25s;
}

.num-btn.used {
    background: #ececec;
    color: #999;
    border-color: #d7d7d7;
    text-decoration: line-through;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.num-btn:disabled:not(.used):not(.active) {
    opacity: 0.55;
    cursor: not-allowed;
}

.admin-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 0 8px;
}

.admin-form .full { grid-column: 1 / -1; }

.admin-form label {
    display: block;
    font-weight: 800;
    margin-bottom: 6px;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e4e0d4;
    border-radius: 12px;
}

.form-status {
    margin-right: 10px;
    font-weight: 700;
}

.admin-form textarea {
    min-height: 120px;
    resize: vertical;
}

.news-admin-item {
    display: grid;
    grid-template-columns: 160px 1fr auto;
    gap: 14px;
    align-items: start;
    padding: 14px 0;
    border-bottom: 1px solid #efe7c8;
}

.news-admin-item:last-child { border-bottom: 0; }

.news-admin-item h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
}

.news-admin-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.news-admin-thumbs img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
    background: #f4efe0;
}

.news-admin-thumbs span {
    color: #8a7d5a;
    font-size: 0.9rem;
}

@media (max-width: 800px) {
    .news-admin-item {
        grid-template-columns: 1fr;
    }
}

.detail-box {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid #e4e0d4;
    border-radius: 16px;
    background: #fbfaf6;
}
.detail-box h3 { margin: 0 0 12px; }

@media (max-width: 800px) {
    .admin-form { grid-template-columns: 1fr; }
}

.jury-box {
    margin-top: 16px;
    padding: 14px 16px;
    background: #fffdf6;
    border: 1px solid #efe7c8;
    border-radius: 16px;
}

.jury-box h2 {
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.grade-box label {
    display: block;
    font-weight: 800;
    margin: 10px 0 6px;
}

.grade-box select,
.grade-box textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e4e0d4;
    border-radius: 12px;
}

.file-warn {
    background: #fdecec;
    color: #8a1f1f;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-weight: 700;
}

.question-view {
    min-height: 140px;
    border: 1px dashed #e0d7b2;
    border-radius: 18px;
    padding: 22px;
    background: #fffdf6;
    font-size: 1.25rem;
    line-height: 1.9;
    text-align: center;
}

.live-card {
    border: 2px solid var(--accent);
    background: linear-gradient(180deg, #fffdf4, #fff);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 16px;
    animation: livePulse 1.6s ease-in-out infinite;
}

.exam-progress {
    margin: 8px 0 14px;
    color: #445;
    font-weight: 700;
}

.exam-result {
    border: 2px solid var(--accent);
    background: linear-gradient(180deg, #fffdf4, #fff);
    border-radius: 18px;
    padding: 16px 18px;
    margin-bottom: 16px;
}

.exam-result h2 {
    margin: 0 0 8px;
}

.exam-result .score {
    font-size: 2rem;
    font-weight: 800;
    color: #1d6b3d;
}

.exam-result .q-scores {
    margin-top: 10px;
    color: #445;
}

@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.25); }
    50% { box-shadow: 0 0 0 8px rgba(212, 175, 55, 0.08); }
}

.eval-form {
    background: #fff;
    border: 1px solid #d7c9a3;
    border-radius: 18px;
    padding: 18px 16px 22px;
    overflow: auto;
}

.eval-form-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 12px;
    text-align: center;
}

.eval-form-head img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #d4af37;
}

.eval-form-head h2 {
    margin: 0;
    font-size: clamp(1.05rem, 2.4vw, 1.45rem);
    color: #0f2027;
    line-height: 1.7;
}

.eval-meta {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 16px;
    font-size: 0.98rem;
}

.eval-meta th,
.eval-meta td {
    border: 1px solid #8aa7b8;
    padding: 8px 10px;
}

.eval-meta th {
    width: 160px;
    background: #cfe8f6;
    font-weight: 800;
}

.eval-meta td { background: #fff; }

.eval-hint {
    color: #5b6568;
    font-size: 0.88rem;
    margin: 0 0 12px;
    line-height: 1.8;
}

.eval-sheet {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    text-align: center;
    font-size: 0.92rem;
}

.eval-sheet th,
.eval-sheet td {
    border: 1px solid #6f8b9a;
    padding: 6px 4px;
}

.eval-sheet thead .top {
    background: #f4c9a0;
    font-weight: 800;
}

.eval-sheet thead .sub {
    background: #cfe8f6;
    font-weight: 700;
}

.eval-sheet .q-label {
    background: #f4c9a0;
    font-weight: 800;
    width: 88px;
}

.eval-sheet tbody tr:nth-child(2) .q-label,
.eval-sheet tbody tr:nth-child(2) td:not(.deduct):not(.span-score) {
    background: #d7eef8;
}

.eval-sheet .deduct {
    background: #bfe6bf;
    font-weight: 800;
    min-width: 72px;
}

.eval-sheet .span-score {
    background: #eaf4fb;
    vertical-align: middle;
}

.eval-sheet input[type="number"] {
    width: 64px;
    max-width: 100%;
    padding: 6px 4px;
    border: 1px solid #c5d0d4;
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    font-family: inherit;
}

.eval-sheet .total-row th,
.eval-sheet .total-row td {
    background: #9fd39f;
    font-weight: 800;
    font-size: 1.05rem;
    padding: 12px 8px;
}

.eval-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    justify-content: center;
    margin: 12px 0 4px;
    font-weight: 700;
    color: #203a43;
}

.eval-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.eval-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e4e0d4;
    border-radius: 12px;
    font-family: inherit;
}

@media print {
    .dash-shell .side,
    .topbar,
    .file-warn,
    .eval-actions,
    #nums,
    #status-line,
    #jury-box { display: none !important; }
    .dash-shell { display: block; }
    .eval-form { border: 0; }
}

@media (max-width: 640px) {
    .num-grid { grid-template-columns: repeat(5, 1fr); gap: 8px; }
    .num-btn { height: 52px; font-size: 1.15rem; }
    .question-view { font-size: 1.08rem; padding: 16px; }
}

body.qbank-page {
    background:
        radial-gradient(900px 420px at 100% -8%, rgba(212, 175, 55, 0.22), transparent 55%),
        radial-gradient(700px 380px at 0% 100%, rgba(32, 58, 67, 0.08), transparent 50%),
        #f3efe3;
}

.qbank {
    position: relative;
    background: linear-gradient(180deg, #fffef9 0%, #fff 72%);
    border: 1px solid rgba(212, 175, 55, 0.32);
    border-radius: 28px;
    padding: 28px 24px 30px;
    box-shadow: 0 22px 50px rgba(15, 32, 39, 0.08);
    overflow: hidden;
}

.qbank::before {
    content: "";
    position: absolute;
    inset: 11px;
    z-index: 0;
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 20px;
    pointer-events: none;
}

.qbank > * {
    position: relative;
    z-index: 1;
}

.qbank-head {
    text-align: center;
    margin-bottom: 8px;
}

.qbank-mark {
    display: inline-flex;
    width: 54px;
    height: 54px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #0f2027;
    color: var(--accent);
    font-size: 1.25rem;
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.16);
    margin-bottom: 10px;
}

.qbank-head h2 {
    font-size: 1.55rem;
    margin: 0 0 10px;
    color: var(--primary);
}

.qbank-meter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #5b6568;
    font-weight: 800;
}

.qbank-meter b { color: var(--accent); font-size: 1.2rem; }

.qbank-bar {
    flex-basis: 100%;
    width: min(260px, 70%);
    height: 7px;
    margin: 4px auto 0;
    background: #efe6c8;
    border-radius: 99px;
    overflow: hidden;
}

.qbank-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #b8901f, #e6c65a);
    border-radius: 99px;
}

.qbank .num-grid {
    margin: 22px 0 20px;
    gap: 14px;
}

.qbank .num-btn {
    position: relative;
    height: 74px;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff, #faf4e4);
    box-shadow: 0 10px 18px rgba(15, 32, 39, 0.06), inset 0 1px 0 #fff;
}

.qbank .num-btn span { position: relative; z-index: 1; }

.qbank .num-btn:not(:disabled):hover {
    transform: translateY(-3px);
    background: linear-gradient(180deg, #fffdf6, #f6e7b4);
    box-shadow: 0 14px 26px rgba(212, 175, 55, 0.22);
}

.qbank .num-btn.active {
    background: linear-gradient(180deg, #e2c35a, #c49b28);
    color: #0f2027;
    border-color: #f4dd8a;
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.22), 0 14px 28px rgba(196, 155, 40, 0.35);
}

.qbank .num-btn.used {
    background: #f2efe6;
    color: #9a9588;
    border-color: #ddd6c4;
    text-decoration: none;
}

.qbank .num-btn.used i {
    position: absolute;
    top: 8px;
    left: 10px;
    font-size: 0.7rem;
    color: #1d6b3d;
}

.qbank .question-view {
    position: relative;
    min-height: 210px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 22px;
    padding: 34px 28px;
    background:
        radial-gradient(circle at 12% 18%, rgba(212, 175, 55, 0.1), transparent 32%),
        linear-gradient(180deg, #fffdf7, #fff8e8);
    box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.28);
    font-family: 'Amiri', 'Tajawal', serif;
    font-size: 1.55rem;
    line-height: 2.05;
}

.qbank-qnum {
    display: inline-block;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    background: #0f2027;
    color: var(--accent);
    padding: 5px 14px;
    border-radius: 999px;
    margin-bottom: 14px;
}

.qbank .question-view p { margin: 0; max-width: 46rem; }

.qbank-empty {
    font-family: 'Tajawal', sans-serif;
    color: #7a7466;
    font-size: 1.05rem;
    font-weight: 700;
}

.qbank-empty i {
    display: block;
    font-size: 1.8rem;
    color: var(--accent);
    margin-bottom: 10px;
}

.qbank-empty .fa-circle-check { color: var(--ok); }

.qbank-status {
    margin-top: 12px;
    text-align: center;
    color: var(--bad);
    font-weight: 700;
}

@media (max-width: 640px) {
    .qbank { padding: 20px 14px 22px; border-radius: 22px; }
    .qbank .num-btn { height: 56px; border-radius: 14px; }
    .qbank .question-view { min-height: 160px; font-size: 1.2rem; padding: 22px 14px; }
}
