/* ISNAD Academy — الأساس: الخط، ألوان إسناد، المكوّنات المشتركة */
@font-face { font-family: 'Expo Arabic'; src: url(/assets/fonts/ExpoArabic-Book.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Expo Arabic'; src: url(/assets/fonts/ExpoArabic-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Expo Arabic'; src: url(/assets/fonts/ExpoArabic-Semibold.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Expo Arabic'; src: url(/assets/fonts/ExpoArabic-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --navy: #08182F; --navy-2: #0E2343; --navy-3: #16305A; --bronze: #C57340; --bronze-2: #D9874F; --bronze-soft: #F6E7DC;
  --sky: #DAE5FE; --ivory: #FBF5EF;
  --bg: #F5F0E9; --card: #FFFFFF; --ink: #0B1B33; --muted: #5E6A7D; --faint: #8E97A6; --line: #E6DDD1; --line-2: #F0EAE2;
  --ok: #1C8A5A; --ok-soft: #E3F4EC; --warn: #A86A12; --warn-soft: #FBF0DC; --bad: #C23A33; --bad-soft: #FBE6E4;
  --radius: 14px; --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(8, 24, 47, .05), 0 6px 22px rgba(8, 24, 47, .07);
  --shadow-lg: 0 12px 48px rgba(8, 24, 47, .18);
  --font: 'Expo Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }
.num, input[type=tel], .ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* العلامة: لوكو إسناد | Academy — الفاصل أبيض */
.brand { display: inline-flex; align-items: center; text-decoration: none; direction: ltr; line-height: 0; }
.brand img { height: 42px; width: auto; display: block; }
@media (max-width: 640px) { .brand img { height: 36px; } }

/* الأزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--bronze); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, transform .08s, box-shadow .15s; }
.btn:hover { background: var(--bronze-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.navy { background: var(--navy); }
.btn.navy:hover { background: var(--navy-3); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--line-2); }
.btn.soft { background: var(--bronze-soft); color: #8E4A20; }
.btn.soft:hover { background: #F0D9C8; }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #a92f29; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.lg { min-height: 52px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; transition: background .15s; }
.icon-btn:hover { background: rgba(8, 24, 47, .07); }

/* الحقول */
.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field > span, .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.input, .field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; font-size: 15px; }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--bronze); box-shadow: 0 0 0 3px rgba(197, 115, 64, .16); }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr 1fr; } .grid3 > :first-child { grid-column: 1 / -1; } }

/* اختيار مقسّم */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--line-2); border-radius: 12px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(8, 24, 47, .12); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; cursor: pointer; }
.chip.on { border-color: var(--bronze); background: var(--bronze-soft); color: #8E4A20; font-weight: 500; }

/* مفتاح تشغيل */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-2); cursor: pointer; }
.switch:first-of-type { border-top: 0; }
.switch .t { font-weight: 500; }
.switch .d { font-size: 13px; color: var(--muted); }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: #D5CCC0; position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: inset-inline-start .2s; }
.switch input:checked { background: var(--bronze); }
.switch input:checked::after { inset-inline-start: 21px; }

/* البطاقات والشارات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.live { background: #FDE8E7; color: #C23A33; }
.badge.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
.badge.bronze { background: var(--bronze-soft); color: #8E4A20; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: #fff; font-weight: 600; font-size: 14px; flex: none; }
.avatar.b { background: var(--bronze); }

/* الإشعارات المنبثقة */
.toasts { position: fixed; inset-inline: 0; bottom: 24px; display: grid; justify-items: center; gap: 8px; z-index: 1000; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #1B2638; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; max-width: 520px; animation: toastIn .22s ease-out; }
.toast .act { background: transparent; border: 0; color: #F2B48C; font-weight: 600; cursor: pointer; padding: 4px 6px; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* نافذة / ورقة سفلية */
.sheet-bg { position: fixed; inset: 0; background: rgba(5, 14, 28, .45); z-index: 900; display: grid; place-items: center; padding: 16px; animation: fade .18s; }
.sheet { background: var(--card); color: var(--ink); border-radius: 22px; width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: var(--shadow-lg); animation: up .22s ease-out; }
.sheet header { position: sticky; top: 0; background: var(--card); display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line-2); z-index: 1; }
.sheet header h3 { margin: 0; font-size: 18px; font-weight: 600; }
.sheet .body { padding: 18px 20px; }
.sheet footer { position: sticky; bottom: 0; background: var(--card); display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-2); }
@media (max-width: 640px) {
  .sheet-bg { place-items: end stretch; padding: 0; }
  .sheet { width: 100%; border-radius: 22px 22px 0 0; max-height: 94dvh; }
  .sheet footer .btn { flex: 1; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }

/* قائمة منبثقة */
.menu { position: fixed; z-index: 950; min-width: 220px; max-width: calc(100vw - 16px); background: #fff; color: var(--ink); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; border: 1px solid var(--line-2); animation: fade .12s; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 12px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: start; text-decoration: none; font-size: 14px; color: inherit; }
.menu button:hover, .menu a:hover { background: var(--line-2); }
.menu .ico.end { margin-inline-start: auto; color: var(--bronze); }
.menu .sep { height: 1px; background: var(--line-2); margin: 6px 4px; }
.menu .danger { color: var(--bad); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { width: 44px; height: 44px; margin: 0 auto 12px; color: var(--faint); stroke-width: 1.4; }
.spinner { width: 22px; height: 22px; border: 2.5px solid rgba(197, 115, 64, .25); border-top-color: var(--bronze); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, var(--line-2), #f7f2ec, var(--line-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; }
@keyframes sk { to { background-position: -200% 0; } }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: inherit; cursor: pointer; font-size: 13px; }
.lang-btn .ico { width: 16px; height: 16px; }
