/* أنماط البوابة الجديدة — بألوان وخطوط الصفحة الرئيسية نفسها */
:root {
  --navy-950: #0b1f3d; --navy-900: #0e2a52; --blue-700: #1a4f8f; --blue-500: #2f6fb8; --gold: #d9a94e;
  --paper: #f4f8fc; --ink: #0c1a2b; --muted: #5b6b80; --line: #dfe7f1;
  --ok: #20A67A; --err: #C74B3E; --warn: #E5A93D; --exit: #00A2E8;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Tajawal', 'Cairo', sans-serif; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: .92rem; }

/* أزرار */
.btn { font: inherit; font-weight: 700; border: 1px solid var(--line); background: #fff; color: var(--navy-900); border-radius: 999px; padding: 8px 18px; cursor: pointer; transition: .15s; }
.btn { width: auto; height: auto; margin: 0; display: inline-flex; align-items: center; justify-content: center; box-shadow: none; white-space: nowrap; }
.btn:hover { border-color: var(--blue-500); background: #fff; color: var(--navy-900); box-shadow: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn.primary:hover { background: var(--navy-900); color: #fff; }
.btn.exit:hover { background: #0090cf; color: #fff; }
.btn.ghost:hover { background: rgba(127,177,224,.15); }
.tn-user .btn.ghost:hover { color: #fff; }
.btn.ghost { background: transparent; }
.btn.exit { background: var(--exit); border-color: var(--exit); color: #fff; }
.btn.danger { color: var(--err); border-color: #f0c9c4; }
.btn.sm { padding: 5px 12px; font-size: .85rem; }
.btn.block { width: 100%; display: flex; }
.btn:disabled { opacity: .6; cursor: wait; }

/* الدخول */
.login-page { min-height: 100vh; display: flex; flex-direction: column; background:
  radial-gradient(1200px 500px at 15% -10%, rgba(127,177,224,.25), transparent 60%),
  linear-gradient(160deg, var(--navy-950) 0%, var(--navy-900) 45%, var(--blue-700) 100%); }
.login-shell { flex: 1; display: grid; grid-template-columns: 1fr minmax(320px, 420px); gap: 40px; align-items: center; max-width: 1050px; width: 100%; margin: 0 auto; padding: 40px 20px; }
.login-brand { color: #fff; }
.login-brand img { max-width: 260px; background: #fff; border-radius: 16px; padding: 10px 16px; }
.login-brand h1 { font-family: 'Cairo', sans-serif; font-weight: 900; font-size: clamp(2rem, 4vw, 3rem); margin: 22px 0 8px; }
.login-brand p { color: rgba(255,255,255,.78); font-size: 1.05rem; line-height: 1.9; }
.login-card { background: #fff; border-radius: 22px; padding: 30px 28px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.45); border-bottom: 6px solid var(--gold); }
.login-card h2 { font-family: 'Cairo', sans-serif; color: var(--navy-900); margin: 0 0 16px; }
.login-card label, .modal-card label { display: block; font-weight: 700; color: var(--navy-900); margin: 12px 0 6px; font-size: .95rem; }
.login-card input, .modal-card input:not([type=checkbox]):not([type=radio]):not([type=file]), .modal-card select, .modal-card textarea, .panel-head input, .panel-head select {
  width: 100%; font: inherit; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdff; }
.pw-wrap { display: flex; gap: 8px; }
.pw-toggle { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 0 12px; cursor: pointer; }
.login-card .btn.primary { margin-top: 20px; padding: 11px; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .82rem; margin: 12px 0 0; text-align: center; }
.portal-foot { text-align: center; color: rgba(255,255,255,.7); padding: 14px; direction: ltr; font-size: .85rem; }

.alert { border-radius: 12px; padding: 10px 14px; margin: 8px 0; font-size: .93rem; line-height: 1.8; }
.alert.error { background: #fdecea; color: #8a2a20; border: 1px solid #f5c2bb; }
.alert.info { background: #eaf3fc; color: var(--navy-900); border: 1px solid #c8dcf2; }
.alert.warn { background: #fff4dc; color: #6b4a07; border: 1px solid #f1d48f; }

/* الشريط العلوي */
.topnav { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 10px 6vw; background: var(--navy-950); color: #fff; border-bottom: 3px solid var(--gold); }
.tn-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: 'Cairo', sans-serif; font-weight: 800; }
.tn-brand img { width: 38px; height: 38px; object-fit: contain; }
.tn-links { display: flex; gap: 4px; flex-wrap: wrap; }
.tn-links a { color: rgba(255,255,255,.82); text-decoration: none; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .92rem; }
.tn-links a:hover, .tn-links a.on { background: rgba(255,255,255,.12); color: #fff; }
.tn-user { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.tn-user .who { display: flex; flex-direction: column; font-weight: 700; font-size: .92rem; line-height: 1.3; text-align: left; }
.tn-user .who small { color: var(--gold); font-weight: 500; }
.tn-user .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); }

.banner { display: flex; align-items: center; gap: 12px; justify-content: center; flex-wrap: wrap; background: #fff4dc; color: #6b4a07; padding: 10px 6vw; border-bottom: 1px solid #f1d48f; }

/* الصفحة الرئيسية */
.hero .subtitle.sm { font-size: .9rem; margin: 0; }
.topic-tools { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; }
.topic-tools input { max-width: 520px; font: inherit; padding: 12px 18px; border-radius: 999px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.95); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: inherit; font-size: .85rem; border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.chip.on, .chip:hover { background: var(--gold); border-color: var(--gold); color: var(--navy-950); }
a.meta-pill { text-decoration: none; display: flex; flex-direction: column; justify-content: center; position: relative; font-weight: 700; color: #fff; }
a.meta-pill p { margin: 4px 0 0; font-weight: 500; font-size: .82rem; opacity: .92; }
.pill-tag { position: absolute; top: 6px; left: 8px; font-size: .68rem; background: rgba(0,0,0,.18); border-radius: 999px; padding: 1px 8px; font-weight: 500; }
.meta-pill.BTN.DD { background: #3FA9D8; }
.empty-note { color: rgba(255,255,255,.8); }

/* النوافذ */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(11,31,61,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 20px; padding: 24px 26px; width: min(460px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 30px 70px -20px rgba(0,0,0,.5); border-top: 5px solid var(--gold); }
.modal-card.wide { width: min(760px, 100%); }
.modal-card h3 { font-family: 'Cairo', sans-serif; color: var(--navy-900); margin: 0 0 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-card .check, .modal-card .radio { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; }
.modal-card fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 14px 0 6px; padding: 6px 14px 8px; }
.modal-card legend { font-weight: 700; color: var(--navy-900); padding: 0 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.progress { position: relative; height: 22px; background: var(--paper); border-radius: 999px; overflow: hidden; margin-top: 8px; border: 1px solid var(--line); }
.progress div { height: 100%; width: 0; background: var(--ok); transition: width .2s; }
.progress span { position: absolute; inset: 0; text-align: center; font-size: .8rem; line-height: 22px; }
.tmp-pass { font-family: monospace; font-size: 1.5rem; text-align: center; background: var(--paper); border-radius: 12px; padding: 12px; letter-spacing: 2px; user-select: all; }

/* الإدارة */
.mwrap { max-width: 1280px; margin: 0 auto; padding: 24px 4vw 60px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { font: inherit; font-weight: 700; border: 1px solid var(--line); background: #fff; border-radius: 12px 12px 0 0; padding: 10px 18px; cursor: pointer; color: var(--muted); }
.tab.on { background: var(--blue-700); color: #fff; border-color: var(--blue-700); }
.panel { background: #fff; border-radius: 18px; padding: 18px; border: 1px solid var(--line); box-shadow: 0 18px 40px -24px rgba(11,31,61,.3); }
.panel-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head input[type=search] { flex: 1; min-width: 200px; }
.panel-head .muted { flex: 1; margin: 0; }
.filters select, .filters input { width: auto; }
.inline { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--navy-900); }
.tw { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 760px; }
table.grid th { background: #eef4fc; color: var(--navy-900); text-align: right; padding: 9px 10px; font-weight: 700; position: sticky; top: 0; }
table.grid td { border-top: 1px solid var(--line); padding: 8px 10px; vertical-align: top; }
table.grid tr.off td { opacity: .55; }
table.grid.small { font-size: .85rem; }
td.acts { white-space: nowrap; }
.sess-sum { display: flex; flex-wrap: wrap; gap: 8px 18px; background: var(--paper); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; font-size: .92rem; }
.badge { border-radius: 999px; padding: 2px 8px; font-size: .8rem; background: #eef4fc; color: var(--navy-900); white-space: nowrap; }
.badge.ok { background: #e3f5ee; color: #0f6b4c; }
.badge.warn { background: #fff4dc; color: #6b4a07; border-radius: 999px; padding: 2px 8px; font-size: .8rem; }
tr.ev-login_fail td, tr.ev-locked td { background: #fdf3f2; }
.note-cell { max-width: 360px; font-size: .82rem; color: #3a4a5f; word-break: break-word; }
tr.ev-denied td { background: #fdf3f2; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; color: var(--muted); }

#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy-900); color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); max-width: 360px; }
.toast.err { background: var(--err); }

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; gap: 20px; }
  .login-brand { text-align: center; }
  .login-brand img { max-width: 200px; }
  .tn-user { margin-inline-start: 0; width: 100%; justify-content: space-between; }
  .row2, .row3 { grid-template-columns: 1fr; }
}

.build-tag { margin: 0 0 8px; font-size: .78rem; color: var(--muted); text-align: left; }

a.meta-pill.locked { filter: grayscale(.85); opacity: .62; cursor: not-allowed; }
a.meta-pill.locked:hover { opacity: .8; }
