/* ================================================================
   نظام متابعة درجات الطلبة — جامعة القادسية
   لوحة التصميم: أخضر جامعي عميق + ذهبي أكاديمي، على خلفية رملية هادئة
   ================================================================ */

:root {
    --font-official: "Simplified Arabic", "Traditional Arabic", "Dubai",
                     Tahoma, "Segoe UI", "Times New Roman", serif;
    /* الهوية */
    --brand-900: #0b3b22;
    --brand-800: #10492a;
    --brand-700: #14532d;
    --brand-600: #1a6b3a;
    --brand-500: #22874b;
    --brand-050: #eaf3ed;

    --gold-600: #a97c1e;
    --gold-500: #c9a227;
    --gold-400: #e3c05a;
    --gold-050: #fdf7e6;

    /* المحايدات */
    --ink: #16202a;
    --ink-soft: #3d4b59;
    --muted: #6b7a89;
    --line: #dde4ea;
    --line-soft: #eef2f6;
    --panel: #ffffff;
    --bg: #f2f5f4;

    /* الحالات */
    --ok: #12693c;      --ok-bg: #dff3e5;
    --warn: #8a5b06;    --warn-bg: #fdf0d2;
    --bad: #9b1c1c;     --bad-bg: #fde5e5;
    --info: #1e4e79;    --info-bg: #e3eefa;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(16,32,42,.06), 0 1px 3px rgba(16,32,42,.04);
    --shadow-md: 0 4px 12px rgba(16,32,42,.08), 0 2px 4px rgba(16,32,42,.04);
    --shadow-lg: 0 18px 48px rgba(11,59,34,.22);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: "Segoe UI", "Noto Naskh Arabic", "Dubai", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.6;
}

h1 { font-size: 1.4rem; margin: 0 0 .25rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 2rem 0 .8rem; color: var(--ink-soft); font-weight: 700; }

a { color: var(--brand-600); }

/* ================= التخطيط ================= */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 248px;
    background: linear-gradient(170deg, var(--brand-800) 0%, var(--brand-900) 100%);
    color: #e8f1ea;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
}
.sidebar::after {
    content: "";
    position: absolute; inset-block: 0; inset-inline-start: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--gold-400), transparent 60%);
}

.brand {
    padding: 1.4rem 1.25rem 1.2rem;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand img {
    width: 72px; height: 72px; object-fit: contain;
    background: #fff; border-radius: 50%; padding: 5px;
    box-shadow: 0 4px 14px rgba(0,0,0,.28);
}
.brand-title { font-size: 1rem; font-weight: 700; margin-top: .6rem; }
.brand-sub { font-size: .75rem; opacity: .72; margin-top: .15rem; line-height: 1.5; }

.nav-group { padding: 1rem .75rem; display: flex; flex-direction: column; gap: .2rem; }
.nav-label {
    font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
    opacity: .5; padding: .5rem .65rem .3rem;
}

.sidebar a {
    color: #dfeae2;
    text-decoration: none;
    padding: .6rem .75rem;
    font-size: .93rem;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; gap: .65rem;
    transition: background .15s ease, color .15s ease;
}
.sidebar a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.sidebar a:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar a.active {
    background: rgba(255,255,255,.15);
    color: #fff; font-weight: 600;
    box-shadow: inset 3px 0 0 var(--gold-400);
}
.sidebar a.active svg { opacity: 1; color: var(--gold-400); }

.sidebar-foot {
    margin-top: auto; padding: 1rem 1.25rem;
    font-size: .7rem; opacity: .5; border-top: 1px solid rgba(255,255,255,.08);
}

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    padding: .7rem 1.75rem;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--shadow-sm);
}
.who { display: flex; align-items: center; gap: .7rem; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(140deg, var(--brand-500), var(--brand-700));
    color: #fff; display: grid; place-items: center;
    font-weight: 700; font-size: .95rem;
}
.who-name { font-weight: 600; line-height: 1.25; }
.role { color: var(--muted); font-size: .78rem; }

.content { padding: 1.75rem; flex: 1; max-width: 1500px; width: 100%; }

.page-head { margin-bottom: 1.4rem; }
.page-head .sub { color: var(--muted); font-size: .88rem; }

/* ================= الأزرار ================= */
.btn-primary {
    background: linear-gradient(140deg, var(--brand-600), var(--brand-800));
    color: #fff; border: 0;
    padding: .6rem 1.5rem; border-radius: var(--radius-sm); cursor: pointer;
    font-size: .93rem; font-family: inherit; font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: transform .12s ease, box-shadow .15s ease, filter .15s ease;
    display: inline-flex; align-items: center; gap: .5rem;
}
.btn-primary svg { width: 17px; height: 17px; }
.btn-primary:hover { filter: brightness(1.1); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-plain {
    background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft);
    padding: .4rem 1rem; border-radius: var(--radius-sm); cursor: pointer;
    font-family: inherit; font-size: .88rem;
    transition: background .15s ease, border-color .15s ease;
}
.btn-plain:hover { background: var(--line-soft); border-color: #c9d3dc; }

.btn-link {
    color: var(--brand-600); text-decoration: none; font-size: .85rem; font-weight: 600;
    padding: .25rem .6rem; border-radius: 6px;
    transition: background .15s ease;
    display: inline-flex; align-items: center; gap: .3rem;
}
.btn-link:hover { background: var(--brand-050); }
.btn-link + .btn-link { margin-inline-start: .25rem; }

/* ================= البطاقات الإحصائية ================= */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 1rem;
    transition: transform .15s ease, box-shadow .15s ease;
    position: relative; overflow: hidden;
}
.card::before {
    content: ""; position: absolute; inset-block: 0; inset-inline-start: 0;
    width: 4px; background: var(--brand-500);
}
.card.gold::before { background: var(--gold-500); }
.card.ok::before { background: var(--ok); }
.card.bad::before { background: var(--bad); }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-icon {
    width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--brand-050); color: var(--brand-700);
}
.card.gold .card-icon { background: var(--gold-050); color: var(--gold-600); }
.card.ok .card-icon { background: var(--ok-bg); color: var(--ok); }
.card.bad .card-icon { background: var(--bad-bg); color: var(--bad); }
.card-icon svg { width: 21px; height: 21px; }

.card-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.card-label { color: var(--muted); font-size: .82rem; margin-top: .1rem; }

/* ================= الجداول ================= */
.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
    padding: .85rem 1.15rem; border-bottom: 1px solid var(--line);
    font-weight: 700; font-size: .95rem;
    display: flex; justify-content: space-between; align-items: center;
}

.grid { width: 100%; border-collapse: collapse; background: var(--panel); }
.grid th, .grid td { padding: .6rem .75rem; text-align: center; border-bottom: 1px solid var(--line-soft); }
.grid thead th {
    background: var(--brand-050); color: var(--brand-800);
    font-weight: 700; font-size: .8rem; letter-spacing: .01em;
    border-bottom: 2px solid #cfe0d5; white-space: nowrap;
}
.grid tbody tr { transition: background .12s ease; }
.grid tbody tr:hover { background: #f7faf8; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid td.name { text-align: right; font-weight: 500; }
.grid td.num, .grid td.words { font-variant-numeric: tabular-nums; }
.grid td.words { color: var(--muted); font-size: .8rem; }
.grid .strong { font-weight: 700; }
.grid .big { font-size: 1.05rem; color: var(--brand-700); }
.grid tfoot td { background: var(--brand-050); border-top: 2px solid #cfe0d5; font-weight: 600; }
.grid tr.carried { background: var(--gold-050); }
.grid tr.carried:hover { background: #fbf3dc; }

.rank {
    display: inline-grid; place-items: center;
    width: 24px; height: 24px; border-radius: 50%;
    background: var(--line-soft); color: var(--ink-soft);
    font-size: .78rem; font-weight: 700;
}
.rank.top { background: var(--gold-050); color: var(--gold-600); }

.entry input {
    width: 64px; padding: .3rem; text-align: center; font-family: inherit;
    border: 1px solid var(--line); border-radius: 6px; font-size: .92rem;
    transition: border-color .15s ease, box-shadow .15s ease;
    font-variant-numeric: tabular-nums;
}
.entry input:hover { border-color: #b9c6d2; }
.entry input:focus {
    outline: 0; border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(34,135,75,.15);
}
.entry input:disabled { background: var(--line-soft); color: var(--muted); }

.tag {
    background: var(--gold-400); color: #4a3608; font-size: .65rem; font-weight: 700;
    padding: .1rem .45rem; border-radius: 4px; margin-inline-start: .4rem;
    vertical-align: middle;
}

.badge {
    padding: .2rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
    white-space: nowrap; display: inline-block;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--line-soft); color: var(--muted); }
.badge.info { background: var(--info-bg); color: var(--info); }

.hash { font-family: ui-monospace, "Cascadia Mono", monospace; font-size: .72rem; color: var(--muted); }

/* ================= عناصر متفرقة ================= */
.student-head {
    background: linear-gradient(120deg, var(--brand-800), var(--brand-600));
    color: #eaf3ed; border-radius: var(--radius);
    padding: 1rem 1.35rem; display: flex; gap: 2.5rem; flex-wrap: wrap;
    margin-bottom: 1.1rem; box-shadow: var(--shadow-md);
}
.student-head .lbl { opacity: .7; font-size: .78rem; display: block; }
.student-head strong { font-size: 1.05rem; }

.lbl { color: var(--muted); font-size: .82rem; }

.tabs { display: flex; gap: .45rem; margin-bottom: .9rem; }
.tab {
    background: var(--panel); border: 1px solid var(--line); padding: .45rem 1.2rem;
    border-radius: 999px; cursor: pointer; font-family: inherit; font-size: .88rem;
    transition: all .15s ease; color: var(--ink-soft);
}
.tab:hover { border-color: var(--brand-500); color: var(--brand-700); }
.tab.active {
    background: var(--brand-700); color: #fff; border-color: var(--brand-700);
    box-shadow: var(--shadow-sm);
}

.note {
    color: var(--muted); font-size: .84rem; margin-top: .9rem;
    display: flex; align-items: center; gap: .45rem;
}
/* حماية عامة: أي أيقونة SVG بلا حجم صريح تأخذ حجماً افتراضياً معقولاً
   بدل أن تتمدد لملء الحاوية. */
svg { width: 1em; height: 1em; }
.note svg { width: 16px; height: 16px; flex-shrink: 0; }
.integrity svg { width: 20px; height: 20px; flex-shrink: 0; }
.card-icon svg { width: 21px; height: 21px; }
.sidebar a svg { width: 18px; height: 18px; }
.search svg { width: 18px; height: 18px; }
.btn-primary svg { width: 17px; height: 17px; }
.empty { color: var(--muted); padding: 3rem; text-align: center; }

.integrity {
    padding: .85rem 1.15rem; border-radius: var(--radius); margin-bottom: 1.1rem;
    display: flex; gap: .6rem; align-items: center; box-shadow: var(--shadow-sm);
}
.integrity.ok { background: var(--ok-bg); color: var(--ok); }
.integrity.bad { background: var(--bad-bg); color: var(--bad); }
.integrity svg { width: 20px; height: 20px; flex-shrink: 0; }

.alert {
    background: var(--bad-bg); color: var(--bad); padding: .65rem .9rem;
    border-radius: var(--radius-sm); font-size: .87rem;
    border-inline-start: 3px solid var(--bad);
}

/* ================= شاشة الدخول ================= */
.login-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(1100px 620px at 12% -8%, rgba(34,135,75,.30), transparent 62%),
        radial-gradient(880px 520px at 102% 108%, rgba(201,162,39,.22), transparent 60%),
        linear-gradient(155deg, #0d3f26, #071d12);
}

.login-shell {
    display: grid; grid-template-columns: 1.05fr .95fr;
    width: min(940px, 96vw); min-height: 540px;
    background: var(--panel); border-radius: 22px; overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* --- لوحة الهوية (على اليمين في الاتجاه العربي) --- */
.login-brand {
    position: relative;
    padding: 1.6rem;
    display: flex; flex-direction: column; justify-content: space-between; align-items: center;
    color: #eef5f0; text-align: center;
    background:
        radial-gradient(520px 360px at 80% 15%, rgba(34,135,75,.55), transparent 65%),
        linear-gradient(160deg, var(--brand-700), var(--brand-900));
}
.login-brand::after {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(340px 240px at 20% 90%, rgba(201,162,39,.20), transparent 70%);
    pointer-events: none;
}

.brand-core { position: relative; z-index: 1; }
.brand-core img {
    width: 108px; height: 108px; object-fit: contain;
    background: rgba(255,255,255,.94); border-radius: 50%; padding: 9px;
    box-shadow: 0 10px 30px rgba(0,0,0,.32);
}
.brand-core h2 {
    margin: 1.1rem 0 .5rem; font-size: 1.75rem; font-weight: 800;
    line-height: 1.35; letter-spacing: -.01em; color: #fff;
}
.brand-core p { margin: 0; font-size: .87rem; opacity: .82; line-height: 1.75; }

.chip {
    position: relative; z-index: 1;
    background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.16);
    padding: .35rem .95rem; border-radius: 999px; font-size: .74rem;
    backdrop-filter: blur(6px); white-space: nowrap;
}
.chip .dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: #4ade80; margin-inline-end: .3rem;
    box-shadow: 0 0 0 3px rgba(74,222,128,.22);
}

/* --- نموذج الدخول --- */
.login-form {
    padding: 2.6rem 2.4rem;
    display: flex; flex-direction: column; gap: .85rem; justify-content: center;
}
.login-form h1 { margin: 0; font-size: 1.75rem; font-weight: 800; }
.login-form .sub { margin: 0 0 .9rem; color: var(--muted); font-size: .88rem; }
.login-form label {
    display: flex; flex-direction: column; gap: .35rem;
    font-size: .85rem; color: var(--ink-soft); font-weight: 600;
}
.login-form input {
    padding: .68rem .85rem; border: 1px solid var(--line); border-radius: 10px;
    font-family: inherit; font-size: .95rem; background: #fbfcfd;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.login-form input:hover { border-color: #c3cfda; }
.login-form input:focus {
    outline: 0; background: #fff; border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(34,135,75,.15);
}

.btn-block { justify-content: center; width: 100%; padding: .78rem; border-radius: 10px; margin-top: .5rem; }

.login-foot {
    border-top: 1px solid var(--line-soft); margin-top: .9rem; padding-top: .8rem;
    font-size: .76rem; color: var(--muted);
    display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap;
}
.pill {
    background: var(--line-soft); color: var(--ink-soft);
    padding: .15rem .55rem; border-radius: 999px; font-size: .72rem;
}


@media screen and (max-width: 780px) {
    .login-shell { grid-template-columns: 1fr; min-height: 0; }
    .login-brand { padding: 1.6rem 1.2rem; }
    .login-form { padding: 1.8rem 1.4rem; }
    .brand-core img { width: 78px; height: 78px; }
    .brand-core h2 { font-size: 1.3rem; }
    .chip-top, .chip-bottom { display: none; }
}

/* ================= شريط الأدوات والبحث ================= */
.toolbar {
    display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
    margin-bottom: 1.1rem;
}
.search {
    position: relative; display: flex; align-items: center; flex: 1; min-width: 260px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
    padding: 0 1rem; box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(34,135,75,.14); }
.search svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search input {
    flex: 1; border: 0; outline: 0; background: transparent;
    padding: .65rem .7rem; font-family: inherit; font-size: .93rem;
}
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
    border: 0; background: var(--line-soft); color: var(--muted);
    width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
    font-size: 1rem; line-height: 1; display: grid; place-items: center;
}
.search-clear:hover { background: #e2e8ee; color: var(--ink); }

.filters { display: flex; gap: .4rem; }
.chip-btn {
    background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft);
    padding: .45rem 1rem; border-radius: 999px; cursor: pointer;
    font-family: inherit; font-size: .85rem; transition: all .15s ease;
}
.chip-btn:hover { border-color: var(--brand-500); color: var(--brand-700); }
.chip-btn.active {
    background: var(--brand-700); color: #fff; border-color: var(--brand-700);
    box-shadow: var(--shadow-sm);
}

/* ================= علامة نسخة العرض ================= */

/* ================= البطاقة ================= */
.card-actions { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 1rem; }
.card-actions h1 { margin: 0; }

.card-sheet {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.75rem; box-shadow: var(--shadow-sm);
    max-width: 100%; overflow-x: hidden;
}
.card-header { text-align: center; line-height: 1.65; font-size: .88rem; margin-bottom: 1.2rem; }
.card-header img { width: 74px; height: 74px; object-fit: contain; margin-bottom: .4rem; }
.card-title {
    font-weight: 700; font-size: 1.05rem; margin-top: .45rem;
    padding-top: .45rem; border-top: 2px solid var(--gold-500);
    display: inline-block; padding-inline: 2rem;
}
.card-name { font-weight: 700; margin-top: .35rem; font-size: 1rem; }

.sheet-grid { display: block; }
.stage-wrap { margin-bottom: .5rem; }
.stage-head {
    background: linear-gradient(120deg, var(--brand-700), var(--brand-500));
    color: #fff; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: .45rem .9rem; font-weight: 700; font-size: .88rem;
    display: flex; justify-content: space-between; align-items: center;
}
.stage-avg { font-weight: 400; font-size: .84rem; }
.stage-avg strong { font-weight: 700; }
.stage-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-top: .7rem; }

.card-block { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem; }
.block-head { font-size: .8rem; margin-bottom: .4rem; font-weight: 700; color: var(--brand-800); }
.card-table { width: 100%; border-collapse: collapse; font-size: .78rem; table-layout: fixed; }
.card-table col.c-name { width: 32%; }
.card-table col.c-units { width: 10%; }
.card-table col.c-fig { width: 12%; }
.card-table col.c-words { width: 17%; }
.card-table td, .card-table th { overflow-wrap: anywhere; word-break: break-word; }
.card-table th, .card-table td { border: 1px solid #b9c6d2; padding: .22rem .4rem; text-align: center; }
.card-table thead th { background: var(--brand-050); font-weight: 700; }
.card-table td.name { text-align: right; }
.card-table td.words { color: #55606b; font-size: .74rem; }
.card-table tr.carried { background: var(--gold-050); }

.block-foot {
    display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: .5rem;
    font-size: .8rem; background: var(--line-soft); padding: .35rem .6rem; border-radius: 6px;
}
.signatures {
    display: flex; justify-content: space-between; margin-top: .9rem;
    font-size: .74rem; color: #55606b; gap: .5rem;
}

.final-box {
    border: 2px solid var(--gold-500); border-radius: var(--radius);
    padding: 1.1rem; text-align: center; margin: 1.5rem 0;
    background: linear-gradient(160deg, var(--gold-050), #fff);
}
.final-label { color: var(--gold-600); font-size: .88rem; font-weight: 700; }
.final-value {
    font-size: 2.3rem; font-weight: 700; color: var(--brand-800);
    line-height: 1.15; font-variant-numeric: tabular-nums;
}
.final-grade { font-weight: 700; color: var(--brand-600); }
.final-note { color: var(--muted); font-size: .74rem; margin-top: .45rem; }

.bio-table { width: 100%; border-collapse: collapse; font-size: .83rem; margin-bottom: 1.2rem; }
.bio-table th, .bio-table td { border: 1px solid #b9c6d2; padding: .32rem .55rem; text-align: right; }
.bio-table th { background: var(--brand-050); width: 18%; font-weight: 700; color: var(--brand-800); }

.side-tables { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.side-title {
    font-weight: 700; font-size: .84rem; margin-bottom: .35rem; color: var(--brand-800);
    border-inline-start: 3px solid var(--gold-500); padding-inline-start: .5rem;
}

.notes-box { margin-top: 1.2rem; }
.notes-box p {
    border: 1px solid #b9c6d2; border-radius: 6px; padding: .7rem; min-height: 3.2rem;
    font-size: .83rem; margin: 0; line-height: 1.85;
}

.page-break { height: 0; }

/* ================= الطباعة ================= */
@page { size: A4 portrait; margin: 8mm; }

@media print {
    body { background: #fff; font-size: 7pt; line-height: 1.2; }
    .shell { display: block; }
    .content { padding: 0; max-width: none; }
    .card-sheet { border: 0; padding: 0; box-shadow: none; }

    /* الوجه الأول كله في ورقة عمودية واحدة:
       المراحل الأربع فوق بعضها، وفصلا كل مرحلة جنباً إلى جنب. */
    .sheet-grid { display: block; }
    .stage-wrap { margin: 0 0 .8mm; break-inside: avoid; }
    .stage-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5mm; margin-top: .8mm; }
    .card-block { padding: 1mm; margin: 0; border-radius: 2px; break-inside: avoid; }

    .card-header { margin-bottom: .8mm; font-size: 6.4pt; line-height: 1.15; }
    .card-header img { width: 26px; height: 26px; margin-bottom: .3mm; }
    .card-title { font-size: 8.5pt; margin-top: .6mm; padding-top: .6mm; padding-inline: 7mm; }
    .card-name { font-size: 8pt; margin-top: .5mm; }

    .stage-head { padding: .8mm 1.5mm; font-size: 7pt; border-radius: 2px; }
    .stage-avg { font-size: 6.8pt; }
    .block-head { font-size: 6pt; margin-bottom: .5mm; }
    .card-table { font-size: 5.7pt; }
    .card-table th, .card-table td { padding: .1mm .5mm; }
    .card-table td.words { font-size: 5.2pt; }
    .block-foot { font-size: 5.4pt; gap: 1.5mm; padding: .2mm .8mm; margin-top: .4mm; }
    .signatures { font-size: 4.8pt; margin-top: .5mm; }

    .final-box { padding: 1mm; margin: .6mm 0 0; break-inside: avoid; }
    .final-value { font-size: 12pt; line-height: 1.05; }
    .final-label, .final-grade { font-size: 7pt; }
    .final-note { font-size: 5.6pt; margin-top: .5mm; }

    /* الوجه الثاني في ورقة مستقلة */
    .page-break { break-before: page; }
    .bio-table { font-size: 7pt; margin-bottom: 3mm; }
    .bio-table th, .bio-table td { padding: 1mm 1.5mm; }
    .side-tables {
        display: flex;
        flex-direction: column;
        gap: 8mm;
    }
    .side-tables .panel {
        border: 1px solid var(--line);
        break-inside: avoid;
        box-shadow: none;
    }
    .side-tables .panel-head {
        background: #eef3f0 !important;
        color: var(--brand-800) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        font-weight: bold;
        border-bottom: 1px solid var(--line);
        padding: 6px 12px;
    }
    .grid th, .grid td {
        padding: 6px 10px !important;
        font-size: 8.5pt;
    }
    .notes-box p { font-size: 7pt; min-height: 14mm; }

    .stage-head, .card-table thead th, .bio-table th, .final-box, .tag {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .stage-head { background: var(--brand-700) !important; color: #fff !important; }
    .card-table thead th, .bio-table th { background: #eef3f0 !important; }
}

/* ================= الشاشات الصغيرة ================= */
@media screen and (max-width: 1100px) {
    .stage-cols { grid-template-columns: 1fr; }
    .side-tables { grid-template-columns: 1fr; }
}
@media screen and (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; }
    .nav-group { flex-direction: row; overflow-x: auto; }
    .nav-label, .sidebar-foot, .brand-sub { display: none; }
    .content { padding: 1rem; }
}

/* ================= النماذج ================= */
.form-panel { padding-bottom: 1.25rem; }
.form-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: .9rem 1.1rem; padding: 1.1rem 1.25rem;
}
.form-grid label {
    display: flex; flex-direction: column; gap: .3rem;
    font-size: .84rem; color: var(--ink-soft); font-weight: 600;
}
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select {
    padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font-family: inherit; font-size: .93rem; background: #fbfcfd; color: var(--ink);
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.form-grid input:hover, .form-grid select:hover { border-color: #c3cfda; }
.form-grid input:focus, .form-grid select:focus {
    outline: 0; background: #fff; border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(34,135,75,.15);
}
.req { color: var(--bad); }

.form-actions {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: 1rem 1.25rem 0; border-top: 1px solid var(--line-soft); margin-top: .4rem;
}
.form-actions .spacer { flex: 1; }
.btn-plain.danger { color: var(--bad); border-color: #f0c9c9; }
.btn-plain.danger:hover { background: var(--bad-bg); }
.btn-danger {
    background: var(--bad); color: #fff; border: 0;
    padding: .45rem 1.1rem; border-radius: var(--radius-sm); cursor: pointer;
    font-family: inherit; font-size: .88rem; font-weight: 600;
}
.btn-danger:hover { filter: brightness(1.1); }
.danger-text { color: var(--bad); font-size: .84rem; }

.toolbar .btn-primary { text-decoration: none; }

/* ---------- تبويبات الفصول ---------- */
.tabs-wrap { flex-wrap: wrap; }
.tabs-wrap .tab {
    display: flex; flex-direction: column; align-items: center; gap: .1rem;
    padding: .4rem 1rem; line-height: 1.3;
}
.tab-stage { font-size: .72rem; opacity: .75; }
.tab-sem { font-weight: 600; font-size: .88rem; }

/* ---------- حالة الاتصال بالخادم ---------- */
#components-reconnect-modal {
    display: none; position: fixed; inset-block-start: 0; inset-inline: 0;
    z-index: 1000; padding: .8rem 1.2rem; text-align: center;
    font-size: .9rem; font-weight: 600;
    background: var(--warn-bg); color: var(--warn);
    border-bottom: 2px solid #e0a92a;
}
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: block; }
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    background: var(--bad-bg); color: var(--bad); border-bottom-color: #d06a6a;
}
#components-reconnect-modal .show-only,
#components-reconnect-modal .failed-only,
#components-reconnect-modal .rejected-only { display: none; }
#components-reconnect-modal.components-reconnect-show .show-only,
#components-reconnect-modal.components-reconnect-failed .failed-only,
#components-reconnect-modal.components-reconnect-rejected .rejected-only { display: inline; }

/* ---------- رسائل الحفظ ---------- */
.flash {
    display: flex; align-items: center; gap: .5rem;
    padding: .7rem 1.1rem; border-radius: var(--radius); margin-bottom: 1rem;
    font-weight: 600; box-shadow: var(--shadow-sm);
}
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash svg { width: 18px; height: 18px; }

.form-actions.no-border { border-top: 0; padding: 1rem 0 0; }
.foot-note { font-weight: 400; font-size: .84rem; color: var(--ink-soft); }
.stage-summary { margin-top: 1.25rem; }

/* التبويبات صارت روابط */
a.tab { text-decoration: none; }

.search-go {
    border: 0; background: var(--brand-700); color: #fff;
    padding: .38rem 1rem; border-radius: 999px; cursor: pointer;
    font-family: inherit; font-size: .82rem; font-weight: 600; margin-inline-start: .4rem;
}
.search-go:hover { filter: brightness(1.12); }
a.search-clear { text-decoration: none; margin-inline-start: .35rem; }
a.chip-btn { text-decoration: none; display: inline-block; }

.hint { font-weight: 400; color: var(--muted); font-size: .78rem; }

/* ================= النسخة الإنكليزية من البطاقة ================= */
.lang-switch { display: flex; gap: .35rem; }

.card-en { direction: ltr; text-align: left; }
.card-en .card-table td.name,
.card-en .bio-table th,
.card-en .bio-table td { text-align: left; }
.card-en .card-header { text-align: center; }
.card-en .side-title { border-inline-start: 3px solid var(--gold-500); }
.card-en .card-table td.words { font-size: .74em; }

@media print {
    .card-en .card-table td.words { font-size: 4.9pt; }
}
.flash.gold { background: var(--gold-050); color: var(--gold-600); }
.flash.gold svg { color: var(--gold-600); }

/* ================= وثيقة التخرج ================= */
.doc-sheet {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 2rem 2.2rem; box-shadow: var(--shadow-sm);
    max-width: 100%; overflow-x: hidden; font-size: .88rem; line-height: 1.75;
}
.doc-en { direction: ltr; text-align: left; }

.doc-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: start; padding-inline: 2mm; }
.doc-head-side { font-size: .82rem; line-height: 1.7; }
.doc-head-side .bold { font-weight: 700; }
.doc-refs { text-align: end; }
.doc-logo img { width: 66px; height: 82px; object-fit: contain; }
/* صندوق الصورة في طرف الترويسة: يمين النسخة الإنكليزية ويسار العربية،
   لأن عمود العدد/التاريخ يقع في جهة نهاية السطر في كلتا اللغتين. */
.photo-box {
    width: 92px; height: 110px; border: 1px solid #9aa6b1; border-radius: 3px;
    margin-inline-start: auto; margin-top: .5rem;
    display: grid; place-items: center; font-size: .68rem; color: var(--muted);
}

.doc-to { text-align: center; font-weight: 700; margin-top: .8rem; }
.doc-title {
    text-align: center; font-weight: 700; font-size: 1.15rem; margin: .3rem 0 1rem;
    text-decoration: underline; text-underline-offset: 5px;
}
.doc-body { text-align: justify; margin: 0 0 1.1rem; line-height: 2.1; }

.doc-year { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .8rem; margin-bottom: .8rem; }
.doc-block { border: 1px solid #7b8894; }
.doc-block-head {
    background: var(--brand-050); border-bottom: 1px solid #7b8894;
    padding: .3rem .5rem; font-weight: 700; font-size: .78rem; text-align: center;
}
.doc-table { width: 100%; border-collapse: collapse; font-size: .78rem; table-layout: fixed; }
.doc-table th, .doc-table td { border: 1px solid #7b8894; padding: .18rem .4rem; text-align: center; }
.doc-table th { background: #f2f6f4; font-weight: 700; font-size: .74rem; }
.doc-table td.name { text-align: start; overflow-wrap: anywhere; }
.doc-table td.words { font-size: .74rem; }
.doc-table tfoot td { background: #f7f9f8; font-weight: 600; }
.doc-table col.d-name { width: 48%; }
.doc-table col.d-units { width: 12%; }
.doc-table col.d-fig { width: 13%; }
.doc-table col.d-words { width: 27%; }

.doc-note-line { font-size: .8rem; margin: .3rem 0 .8rem; }

.doc-remarks { margin-top: 1rem; font-size: .82rem; }
.remarks-title { font-weight: 700; margin-bottom: .3rem; }
.doc-remarks ol { margin: 0; padding-inline-start: 1.4rem; line-height: 1.9; }

.doc-signs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
    margin-top: 2rem; text-align: center; font-size: .82rem;
}
.doc-signs.two { grid-template-columns: repeat(2, 1fr); margin-top: 1.6rem; padding-inline: 12%; }
.sig-name { display: block; font-weight: 700; }
.sig-role { display: block; color: var(--ink-soft); margin-top: .15rem; }

@media print {
    .doc-sheet {
        border: 0; padding: 0; box-shadow: none;
        font-size: 7.4pt; line-height: 1.3;
    }
    .doc-head-side { font-size: 6.8pt; line-height: 1.3; }
    .doc-logo img { width: 40px; height: 50px; }
    .photo-box { width: 56px; height: 66px; font-size: 5pt; margin-top: 1mm; }
    .doc-to { margin-top: .5mm; font-size: 7.6pt; }
    .doc-title { font-size: 9.5pt; margin: .4mm 0 1.2mm; }
    .doc-body { line-height: 1.5; margin-bottom: 1.2mm; font-size: 7.2pt; }
    .doc-year { gap: 1.4mm; margin-bottom: 1.1mm; break-inside: avoid; }
    .doc-block-head { font-size: 6.2pt; padding: .3mm .6mm; }
    .doc-table { font-size: 5.9pt; }
    .doc-table th { font-size: 5.8pt; }
    .doc-table th, .doc-table td { padding: .1mm .4mm; }
    .doc-table td.words { font-size: 5.6pt; }
    .doc-note-line { font-size: 6.4pt; margin: .5mm 0 1mm; }
    .doc-remarks { font-size: 6.2pt; margin-top: 1.2mm; break-inside: avoid; }
    .doc-remarks ol { line-height: 1.5; padding-inline-start: 4mm; }
    .remarks-title { margin-bottom: .5mm; }
    .doc-signs { margin-top: 15mm; font-size: 6.6pt; break-inside: avoid; }
    .doc-signs.two { margin-top: 12mm; }
    .doc-block-head, .doc-table th, .doc-table tfoot td {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
}

/* ================= تأييد التخرج ================= */
.conf-sheet {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 2rem 2.2rem; box-shadow: var(--shadow-sm);
    max-width: 100%; overflow-x: hidden;
    /* الشاشة تعرض ما ستُخرجه الطابعة: الخط الرسمي نفسه وحجمه وتباعده،
       فلا يُفاجأ الموظف بورقة تختلف عمّا رآه. */
    font-family: var(--font-official);
    font-size: 1.12rem; line-height: 1.95;
    display: flex; flex-direction: column; min-height: 60vh;
}
.conf-title { font-size: 1.5rem; }
.conf-signs { font-size: 1.02rem; }
.conf-notes { font-size: .84rem; }
/* التواقيع والملاحظات تُدفع إلى أسفل الورقة */
.conf-signs { margin-top: auto; }

.conf-head { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: start; }
.conf-logo img { width: 72px; height: 72px; object-fit: contain; }
.conf-head-mid { text-align: center; font-weight: 700; line-height: 1.7; }
.conf-refs {
    display: flex; justify-content: space-between; font-weight: 400;
    font-size: .82rem; margin-top: .6rem; color: var(--ink-soft);
}

.conf-title {
    text-align: center; font-weight: 700; font-size: 1.1rem; margin: 1rem 0 1.2rem;
    text-decoration: underline; text-underline-offset: 5px;
}

/* الصورة في العمود الأخير: يسار الصفحة في الاتجاه العربي */
.conf-body { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 1.4rem; align-items: start; }
.conf-photo { text-align: center; }
.conf-photo .photo-box { width: 120px; height: 140px; margin: 0 auto; }
.conf-national { margin-top: .7rem; }
.lbl-sm { font-size: .68rem; color: var(--muted); line-height: 1.4; }
.value-box {
    border: 1px solid #9aa6b1; border-radius: 3px; padding: .2rem;
    font-size: .8rem; margin-top: .25rem; min-height: 1.6rem;
}

.conf-intro { font-weight: 700; margin-bottom: .5rem; }
.conf-mid { margin: .5rem 0; font-weight: 600; }
.fld { margin-bottom: .3rem; }
.fld .k { color: var(--ink-soft); }
.fld .v { font-weight: 600; }
.fld .v.strong { font-weight: 700; }
.fld-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .2rem 1.5rem; }
.fld-grid .wide { grid-column: 1 / -1; }

.conf-signs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
    padding-top: 2.5rem; text-align: center; font-size: .84rem;
}

.conf-notes { margin-top: 2rem; font-size: .78rem; color: var(--ink-soft); }
.conf-notes ul { margin: .2rem 0 0; padding-inline-start: 1.2rem; line-height: 1.8; }

.flash.warn { background: var(--warn-bg); color: var(--warn); }

@media print {
    /* ضبط تأييد التخرج ليكون ورقة A4 واحدة بالضبط */
    .conf-sheet {
        border: 0; padding: 0; box-shadow: none;
        /* خط رسمي أكبر وتباعد أوسع: النموذج المعتمد يُقرأ من مسافة،
           والورقة الواحدة تتسع له بعد توزيع الفراغ على السطور. */
        font-family: var(--font-official);
        font-size: 11pt; line-height: 1.75;
        height: 270mm; min-height: 0; max-height: 270mm; overflow: hidden;
        page-break-after: avoid; break-after: avoid;
        page-break-inside: avoid; break-inside: avoid;
    }
    .conf-refs { font-size: 11pt; line-height: 2; }
    .conf-to { font-size: 11.5pt; }
    .conf-intro { font-size: 11.5pt; }
    .conf-mid { margin: 3mm 0; font-size: 11.5pt; }
    .fld-grid { gap: 1mm 1rem; }
    .conf-fields .fld { font-size: 11.5pt; }
    .conf-logo img { width: 58px; height: 58px; }
    .conf-title { font-size: 14pt; margin: 4mm 0 5mm; }
    .conf-photo .photo-box { width: 100px; height: 118px; }
    .conf-signs { padding-top: 5mm; font-size: 10.5pt; break-inside: avoid; }
    .conf-notes { margin-top: 3mm; font-size: 8pt; line-height: 1.6; break-inside: avoid; }
    .conf-logo img, .value-box { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ================= شاشة المالك ================= */
.sidebar a.nav-danger { color: #ffc9c9; }
.sidebar a.nav-danger:hover { background: rgba(255,90,90,.16); color: #fff; }
.sidebar a.nav-danger.active { box-shadow: inset 3px 0 0 #ef5350; }

.danger-panel { border-color: #f0c9c9; margin-bottom: 1.25rem; }
.danger-panel .panel-head { background: var(--bad-bg); color: var(--bad); border-bottom-color: #f0c9c9; }
.danger-panel.hard { border-color: var(--bad); border-width: 2px; }

.reset-body { padding: 1.1rem 1.25rem; }
.reset-body p { margin: 0 0 .8rem; font-size: .9rem; }
.reset-body .danger-text { display: flex; align-items: center; gap: .4rem; font-weight: 600; }
.reset-body form { display: flex; align-items: flex-end; gap: .8rem; flex-wrap: wrap; }

.confirm-label {
    display: block; font-size: .84rem; color: var(--ink-soft); font-weight: 600;
}
.confirm-label input { display: block; margin-top: .35rem; }
.reset-body form {
    display: flex; align-items: flex-end; gap: .8rem; flex-wrap: wrap;
}
.confirm-label code {
    background: var(--line-soft); padding: .05rem .35rem; border-radius: 4px;
    font-family: inherit; color: var(--bad);
}
.confirm-label input {
    padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font-family: inherit; font-size: .93rem; min-width: 220px;
}
.confirm-label input:focus {
    outline: 0; border-color: var(--bad); box-shadow: 0 0 0 3px rgba(155,28,28,.14);
}

/* ---- شاشة المنهج والوحدات ---- */
.grid.entry input.w-full { width: 100%; min-width: 0; }
.grid.entry tr.new-row { background: var(--line-soft); }
.grid.entry tr.new-row input::placeholder { color: var(--ink-soft); opacity: .6; }

/* ---- إدارة المستخدمين ---- */
.user-form {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .9rem; align-items: end;
}
.user-form label {
    display: block; font-size: .84rem; color: var(--ink-soft); font-weight: 600; min-width: 0;
}
.user-form input, .user-form select {
    display: block; width: 100%; margin-top: .35rem;
    padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px;
    font-family: inherit; font-size: .93rem; background: #fff;
}
.user-form input:focus, .user-form select:focus {
    outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(20,83,45,.12);
}
.user-form button { align-self: end; }
.inline-form { display: inline; }
.row-actions { white-space: nowrap; }
.btn-link.danger { color: var(--bad); }

/* ---- شريط تقدّم التنقل ---- */
.nav-progress {
    position: fixed; inset-block-start: 0; inset-inline-start: 0;
    height: 3px; width: 0; z-index: 9999;
    background: linear-gradient(90deg, var(--gold, #b8860b), var(--brand, #14532d));
    opacity: 0; transition: width .25s ease, opacity .2s ease;
}
.nav-progress.on { width: 92%; opacity: 1; transition: width 2.4s cubic-bezier(.1,.8,.2,1), opacity .1s; }

/* انتقال هادئ للمحتوى عند التصفح المحسَّن */
@media screen and (prefers-reduced-motion: no-preference) {
    .content { animation: page-in .18s ease-out; }
}
/* تلاشٍ فقط بلا إزاحة — كي لا يتحرك زر تحت إصبع المستخدم أثناء الضغط. */
@keyframes page-in { from { opacity: .45; } to { opacity: 1; } }

/* استجابة فورية للمس والضغط */
a, button, .tab, .chip-btn { touch-action: manipulation; }
.tab, .btn-link, .chip-btn { transition: background-color .12s ease, color .12s ease, border-color .12s ease; }

@media print {
    .nav-progress, .sidebar, .topbar, .no-print, .card-actions {
        display: none !important;
    }
}

.sidebar-foot .ver { margin-top: .35rem; opacity: .65; font-size: .72rem; letter-spacing: .02em; }

/* ---- حضور المستخدمين ---- */
.dot-live {
    display: inline-block; width: .55rem; height: .55rem; border-radius: 50%;
    background: #16a34a; margin-inline-end: .4rem; vertical-align: middle;
    box-shadow: 0 0 0 3px rgba(22,163,74,.18);
}
@media screen and (prefers-reduced-motion: no-preference) {
    .dot-live { animation: live-pulse 2s ease-in-out infinite; }
}
@keyframes live-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
    50%      { box-shadow: 0 0 0 6px rgba(22,163,74,.06); }
}

/* ---- الحقول التفاعلية القابلة للتعديل قبل الطباعة ---- */
.editable-input {
    border: none;
    border-bottom: 1px dashed #ccc;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    padding: 1px 0;
    margin: 0;
    outline: none;
    transition: border-bottom-color 0.15s, background-color 0.15s;
}
.editable-input:focus {
    border-bottom: 1px solid var(--brand);
    background-color: rgba(0,0,0,0.02);
}
textarea.editable-input {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    resize: none;
}
@media print {
    .editable-input {
        border-bottom: none !important;
        background-color: transparent !important;
        outline: none !important;
        padding: 0 !important;
    }
    .no-print-textarea::placeholder {
        color: transparent !important;
        opacity: 0 !important;
    }
}


/* Auth and Registration Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f4f6f9;
    direction: rtl;
    text-align: right;
}
.auth-card {
    background: #ffffff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}
.auth-logo {
    text-align: center;
    margin-bottom: 20px;
}
.auth-title {
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
    color: #333;
}
.auth-subtitle {
    text-align: center;
    margin-bottom: 20px;
    color: #666;
    font-size: 0.9rem;
}


/* ================= العلامة المائية وظهر الوثيقة ================= */
.doc-sheet, .conf-sheet { position: relative; }

.doc-watermark {
    position: absolute; inset: 0; z-index: 0;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.doc-watermark img {
    width: 82%; max-width: 17cm; height: auto;
    /* صورة مُعدّة للعلامة المائية: خلفيتها شفافة ولونها موحّد،
       فتظهر خطوط الشعار وحدها خلف النص بلا مربع أبيض يغطّيه. */
    opacity: .16;
}
/* كل محتوى الوثيقة والتأييد فوق العلامة المائية */
.doc-sheet > *:not(.doc-watermark),
.conf-sheet > *:not(.doc-watermark) { position: relative; z-index: 1; }

.doc-back { margin-top: 1.5rem; }
.doc-back-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 1rem; flex-wrap: wrap;
    border-bottom: 2px solid var(--brand); padding-bottom: .5rem; margin-bottom: .9rem;
}
.doc-back-title { font-weight: 700; color: var(--brand); font-size: 1.02rem; }
.doc-back-name { font-size: .84rem; color: var(--ink-soft); }
.doc-back-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: .9rem; }
.doc-back-grid .doc-block { break-inside: avoid; }
.doc-table td.none { text-align: center; color: var(--ink-soft); }
.doc-notes-box {
    border: 1px solid var(--line); border-radius: 4px;
    min-height: 4.2cm; padding: .5rem;
}
.doc-signs.back-signs { margin-top: 1.2rem; }

@media print {
    /* الظهر ورقة مستقلة تماماً — تُطبع على الوجه الثاني. */
    .doc-back { break-before: page; page-break-before: always; margin-top: 0; }

    /* كل وجه ورقة مستقلة، فالتوسيط المطلق داخل الوجه = توسيط في الورقة.
       (position: fixed تُربك التقسيم إلى صفحات فتنزل العلامة إلى الأسفل.) */
    .doc-sheet { min-height: 268mm; }
    .doc-watermark { position: absolute; inset: 0; }
    /* التأييد ورقة واحدة بارتفاع ثابت، فتتوسّط العلامة فيه تلقائياً.
       شعار الكلية أعرض من شعار الجامعة، فيُضبط عرضه ليغطي الورقة بلا خروج. */
    .conf-sheet .doc-watermark img { width: 15.5cm; opacity: .14; }
    .doc-watermark img {
        width: 16.5cm; max-width: none; opacity: .16;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .doc-back-title { font-size: 10pt; }
    .doc-back-name { font-size: 7.6pt; }
    .doc-back-grid { gap: 3mm; }
    .doc-notes-box { min-height: 3.4cm; }
}

/* مجموعة بلا خريجين — تبقى ظاهرة لتُثبت أن الدراسة فُحصت ولم تُهمَل */
.panel.muted-panel { opacity: .72; }
.panel.muted-panel .panel-head { background: var(--line-soft); color: var(--ink-soft); }

/* ================= استمارة السيرة الدراسية (خ-5) ================= */
.hist-sheet {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.6rem 1.8rem; box-shadow: var(--shadow-sm);
    font-family: var(--font-official);
    font-size: .95rem; line-height: 1.8; max-width: 100%;
}
.hist-guide { font-size: .78rem; color: var(--ink-soft); }
.hist-code { font-weight: 700; margin-bottom: .6rem; }
.hist-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 1.5rem; flex-wrap: nowrap;
}
.hist-head > div { flex: 0 0 auto; }
.hist-head.second { margin-bottom: .7rem; }
/* العنوان لا يُضغط ولا تتراكب حروفه مهما ضاق السطر. */
.hist-title {
    font-weight: 700; font-size: 1.15rem;
    /* خط سفلي مرسوم كحدّ لا كـ text-decoration: بعض الخطوط العربية على ويندوز
       تُخرج حروفاً متراكبة مع التسطير، وهذا لا يقع مع الحدّ. */
    border-bottom: 1.5px solid currentColor; padding-bottom: 1px;
    white-space: nowrap; flex: 0 0 auto; margin-inline: auto;
    letter-spacing: 0;
}

/* خانة تُملأ بخط اليد إن تُركت فارغة. */
.hist-sheet .fill {
    display: inline-block; min-width: 5.5rem; max-width: 12rem;
    border-bottom: 1px dotted var(--ink-soft);
}
.hist-sheet .fill.wide { min-width: 9rem; max-width: 16rem; }
.hist-sheet .fill:not(:empty) { border-bottom: 0; font-weight: 600; }

.hist-table { width: 100%; border-collapse: collapse; margin-bottom: .7rem; }
.hist-table td, .hist-table th {
    border: 1px solid #7b8894; padding: .3rem .5rem; vertical-align: middle;
}
.hist-table th { background: #eef3f1; font-weight: 700; text-align: center; }
.hist-table .lbl { background: #f5f8f7; font-weight: 700; width: 22%; }
.hist-table .band { background: #e6efe9; font-weight: 700; text-align: center; }
.hist-table.rows td { height: 1.9rem; text-align: center; }
.hist-table.rows td.num { width: 5%; }
.hist-table .c-year { width: 14%; }
.hist-table .c-class { width: 10%; }
.hist-table .c-status { width: 22%; }
.hist-table .c-limit { width: 13%; }
.hist-table .c-notes { width: 18%; }
.hist-table .c-orders { width: 18%; }
.hist-table.legend .lbl { width: 26%; }

.hist-signs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem;
    text-align: center; margin-top: 1.6rem;
}
.hist-signs .sig-role { display: block; font-weight: 700; }
.hist-signs .sig-name { display: block; margin-top: 1.6rem; }
.hist-signs .sig-date { display: block; color: var(--ink-soft); margin-top: .5rem; }

@media print {
    .hist-sheet {
        border: 0; padding: 0; box-shadow: none;
        font-size: 10.5pt; line-height: 1.7;
    }
    .hist-guide { font-size: 8pt; }
    .hist-title { font-size: 13pt; }
    .hist-table.rows td { height: 7mm; }
    .hist-table td, .hist-table th { padding: .8mm 1.5mm; }
    .hist-table th, .hist-table .lbl, .hist-table .band {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .hist-signs { margin-top: 10mm; font-size: 10pt; }
    .hist-signs .sig-name { margin-top: 12mm; }
}

.sidebar-foot .ver .stamp {
    display: inline-block; margin-inline-start: .35rem;
    font-family: ui-monospace, monospace; opacity: .8; letter-spacing: .02em;
}

