:root {
  --primary: #24276C;
  --gold: #D8A43F;
  --gold-soft: #F2C37F;
  --primary-soft: #E8E9F5;
  --ink: #171A33;
  --muted: #5A5E73;
  --line: #E3E4EC;
  --line-strong: #D3D5E2;
  --bg: #F4F4F8;
  --card: #FFFFFF;
  --warn-bg: #FBEBD0;
  --warn-ink: #6E4700;
  --dot: #D8A43F;
  --danger: #A12A1C;
  --radius: 16px;
  font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* هيكل تطبيق الطلبة */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.screen { flex: 1; display: flex; flex-direction: column; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.content { padding: 18px 16px 24px; display: flex; flex-direction: column; gap: 16px; }

.hero { background: var(--primary); border-bottom: 4px solid var(--gold); color: #fff; padding: calc(22px + env(safe-area-inset-top)) 20px 22px; border-radius: 0 0 24px 24px; display: flex; flex-direction: column; gap: 16px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-id { display: flex; align-items: center; gap: 12px; }
.logo { width: 44px; height: 44px; border-radius: 50%; background: #fff; padding: 1px; display: grid; place-items: center; flex: none; overflow: hidden; }
.logo img { width: 100%; height: 100%; object-fit: cover; }
.hero small { font-size: 13px; opacity: .88; display: block; }
.hero strong { font-size: 18px; font-weight: 700; display: block; }
.icon-btn { position: relative; width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.14); border: 0; color: #fff; display: grid; place-items: center; flex: none; }
.icon-btn .badge { position: absolute; top: 9px; left: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid var(--primary); }
.hero-chip { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); border-radius: 12px; padding: 10px 14px; font-size: 13px; }

.topbar { background: var(--card); padding: calc(18px + env(safe-area-inset-top)) 20px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.ghost-btn { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card); color: var(--primary); font-size: 13px; font-weight: 600; }
.square-btn { width: 44px; height: 44px; border-radius: 12px; background: var(--bg); border: 0; display: grid; place-items: center; flex: none; color: var(--ink); }

.pinned { display: flex; flex-direction: column; gap: 8px; background: var(--card); border: 1.5px solid var(--gold-soft); border-radius: 18px; padding: 16px; }
.pinned .title { font-size: 16px; font-weight: 700; line-height: 1.5; }
.pinned .excerpt { font-size: 13px; color: var(--muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; display: inline-block; }
.tag-warn { background: var(--warn-bg); color: var(--warn-ink); }
.meta { font-size: 12px; color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; }
.section-title h2 { margin: 0; font-size: 16px; }
.group-label { font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 4px 0; margin: 0; }

.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; align-items: flex-start; }
.item.unread { border-color: #CBD5DC; }
.item.read { background: #F9FAFB; }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-title { font-size: 14px; font-weight: 600; line-height: 1.5; }
.item.unread .item-title { font-weight: 700; }
.mini-tag { align-self: flex-start; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--dot); }

.cat-uni { background: #E8E9F5; color: #24276C; }
.cat-college { background: #E2F1EA; color: #1E5B3E; }
.cat-exams { background: #E3EEF7; color: #1D4F7A; }
.cat-events { background: #F3E7F0; color: #6B2B5C; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px; line-height: 1.8; }

/* تفاصيل الإعلان */
.detail { background: var(--card); min-height: 100%; flex: 1; }
.detail-head { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.detail-head span { font-size: 16px; font-weight: 700; }
.detail-body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.detail-body h1 { margin: 0; font-size: 22px; line-height: 1.5; }
.author { display: flex; align-items: center; gap: 12px; }
.author .avatar { border-radius: 50%; width: 40px; height: 40px; }
.prose { font-size: 15px; line-height: 1.9; color: #2A3540; white-space: pre-line; overflow-wrap: anywhere; }
.box { background: var(--bg); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.attach { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.file-ico { flex: none; width: 40px; height: 40px; border-radius: 10px; background: #FBE4E1; color: #8E2A1E; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.actions { display: flex; gap: 10px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--card); position: sticky; bottom: 0; }

.btn { min-height: 48px; border-radius: 14px; border: 0; background: var(--primary); color: #fff; font-size: 15px; font-weight: 600; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn-light { background: var(--card); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-block { width: 100%; }
.btn-danger { background: var(--card); color: var(--danger); border: 1px solid #E8C6C1; }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 600; font-size: 14px; padding: 8px 0; min-height: 44px; }

/* الإعدادات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 44px; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .txt { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.toggle-row strong { font-size: 15px; font-weight: 600; }
.toggle-row small { font-size: 12px; color: var(--muted); line-height: 1.5; }
.sw { appearance: none; -webkit-appearance: none; flex: none; width: 48px; height: 28px; border-radius: 999px; background: #C3CBD2; position: relative; margin: 0; transition: background .15s; cursor: pointer; }
.sw::after { content: ""; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: right .15s; }
.sw:checked { background: var(--primary); }
.sw:checked::after { right: 23px; }
.note { font-size: 12px; color: var(--muted); line-height: 1.7; padding: 0 4px; margin: 0; }
.status { display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-size: 14px; }

/* النماذج */
.auth { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: calc(32px + env(safe-area-inset-top)) 24px 32px; gap: 22px; max-width: 440px; width: 100%; margin: 0 auto; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.auth-brand .logo { width: 96px; height: 96px; box-shadow: 0 2px 12px rgba(36,39,108,.18); }
.auth-brand h1 { margin: 0; font-size: 22px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 14px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { min-height: 48px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 14px; background: var(--card); font-size: 15px; width: 100%; }
.field textarea { min-height: 140px; resize: vertical; line-height: 1.7; }
.field input[dir="ltr"] { text-align: left; }
.field .hint { font-size: 12px; color: var(--muted); }
.error { background: #FBE4E1; color: #7E2316; border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.6; }
.ok { background: #E2F1EA; color: #1E5B3E; border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.6; }
.center-row { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }

.demo-bar { background: #FFF6E6; color: var(--warn-ink); font-size: 12px; text-align: center; padding: 6px 12px; border-bottom: 1px solid var(--gold-soft); }

/* شريط التنقل */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; max-width: 560px; margin: 0 auto; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 5; }
.tab { min-width: 72px; min-height: 48px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; font-weight: 500; position: relative; }
.tab[aria-current="page"] { color: var(--primary); font-weight: 700; }
.tab .count { position: absolute; top: -2px; left: 14px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--dot); color: #171A33; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.loading { flex: 1; display: grid; place-items: center; color: var(--muted); font-size: 14px; padding: 60px 0; }
.toast { position: fixed; bottom: calc(90px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: 90vw; }

/* لوحة النشر */
.admin { min-height: 100vh; display: flex; flex-direction: column; }
.admin-head { background: var(--primary); border-bottom: 3px solid var(--gold); color: #fff; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 18px; }
.admin-head small { opacity: .85; }
.admin-head .ghost-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.admin-tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
.admin-tab { border: 0; background: none; padding: 14px 16px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.admin-tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.admin-main { padding: 24px; max-width: 980px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.panel h2 { margin: 0; font-size: 17px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } .admin-main { padding: 16px; } }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
.dept-list { display: flex; flex-wrap: wrap; gap: 6px; }
.dept-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; font-weight: 600; }
.dept-pill button { border: 0; background: none; color: var(--primary); width: 24px; height: 24px; border-radius: 50%; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 160px; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px; }
.inline-form .btn { min-height: 44px; }
.preview-phone { border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: var(--bg); }

/* الدراسات العليا */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 860px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid-3 { grid-template-columns: 1fr; } }
.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #ECEDF3; color: var(--muted); white-space: nowrap; }
.st-ok { background: #E2F1EA; color: #1E5B3E; }
.st-warn { background: var(--warn-bg); color: var(--warn-ink); }
.st-bad { background: #FBE4E1; color: #7E2316; }
.st-info { background: var(--primary-soft); color: var(--primary); }
.st-done { background: #EDE3F7; color: #4F2A7A; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--bg); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.tile-n { font-size: 26px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
table.sheet td, table.sheet th { vertical-align: middle; }
input.mark { width: 84px; min-height: 40px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 8px; text-align: center; font-variant-numeric: tabular-nums; background: var(--card); }
input.mark:disabled { background: var(--bg); color: var(--muted); }
.field select, .field input { font-variant-numeric: tabular-nums; }
td select { min-height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 2px 8px; background: var(--card); }

/* كشف الدرجات */
.transcript { max-width: 820px; margin: 0 auto 32px; background: #fff; color: #111; padding: 32px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 16px; }
.tr-head { display: flex; align-items: center; gap: 16px; border-bottom: 3px solid var(--gold); padding-bottom: 12px; }
.tr-head img { width: 76px; height: 76px; }
.tr-head h1 { margin: 4px 0 0; font-size: 20px; color: var(--primary); }
.tr-uni { font-size: 17px; font-weight: 700; color: var(--primary); }
.transcript table { width: 100%; border-collapse: collapse; }
.transcript th, .transcript td { border: 1px solid #C9CBD8; padding: 6px 8px; text-align: right; }
.transcript thead th, .tr-info th { background: #EEEFF6; font-weight: 600; color: #222; font-size: 12px; }
.tr-term h2 { font-size: 14px; margin: 0 0 6px; color: var(--primary); }
.transcript tfoot td { background: #FAFAFC; font-size: 12px; }
.tr-sum { font-size: 14px; }
.tr-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11px; color: #555; border-top: 1px solid #DDD; padding-top: 8px; }
.tr-sign { display: flex; justify-content: space-between; padding: 24px 40px 8px; font-weight: 600; }
@media print {
  .no-print, .tabbar, .demo-bar, .toast { display: none !important; }
  body, .app, .admin { background: #fff !important; }
  .transcript { border: 0; padding: 0; margin: 0; max-width: none; }
  .screen { padding-bottom: 0 !important; }
  @page { size: A4; margin: 14mm; }
}

/* اختيار نوع المستخدم في شاشة الدخول */
.roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
.role-opt { min-height: 50px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 8px; font-size: 14px; font-weight: 600; }
.role-opt[aria-checked="true"] { background: var(--primary); color: #fff; }
.portal { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; color: var(--primary); }
.portal span { flex: 1; display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.portal small { color: var(--muted); font-size: 12px; }
.portal > svg:last-child { transform: scaleX(-1); color: var(--muted); }
.portal:hover { border-color: var(--primary); }

/* ملفي */
.hero-photo { width: 100%; height: 100%; object-fit: cover; border-radius: 14px; }
.icon-btn:has(.hero-photo) { padding: 0; overflow: hidden; }
.me-head { padding: 16px; display: flex; gap: 16px; align-items: center; }
.me-photo { position: relative; flex: none; width: 88px; height: 88px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; cursor: pointer; border: 3px solid var(--gold-soft); }
.me-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.me-photo-edit { position: absolute; bottom: -2px; left: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; border: 2px solid var(--card); }
.me-photo:focus-within, input.sr:focus-visible + * { outline: 3px solid var(--gold); }
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.kv { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
@media (max-width: 380px) { .kv { grid-template-columns: 1fr; } }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.kv dd[dir="ltr"] { text-align: right; }
.doc-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-row .file-ico { background: var(--primary-soft); color: var(--primary); }
.upload-btn { min-height: 40px; font-size: 13px; padding: 0 12px; flex: none; cursor: pointer; }
input.sr:focus-visible + .upload-btn, .upload-btn:focus-within { outline: 3px solid var(--gold); }
h3.sub { margin: 4px 0 0; font-size: 14px; color: var(--primary); border-top: 1px solid var(--line); padding-top: 12px; }

.me-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; overflow: hidden; flex: none; border: 2px solid var(--gold-soft); }
.me-btn img { width: 100%; height: 100%; object-fit: cover; }

.tiles-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
@media (max-width: 900px) { .tiles-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
@media (max-width: 520px) { .tiles-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-4 { grid-template-columns: 1fr !important; } }

.opts { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.opts legend { font-size: 13px; font-weight: 600; padding: 0 6px; }

.credit { text-align: center; font-size: 12px; font-weight: 600; color: var(--primary); opacity: .75; margin: 8px 0 4px; }

.install-card { background: #FFF6E3; border: 1px solid #F0D9A4; border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.6; }
.install-card strong { color: var(--primary); font-size: 15px; }
.card .install-card { border: 0; border-radius: 0; background: transparent; }
