:root {
    --vg-primary: #4f46e5;
    --vg-primary-600: #4338ca;
    --vg-primary-50: #eef2ff;
    --vg-ink: #0f172a;
    --vg-muted: #64748b;
    --vg-line: #e2e8f0;
    --vg-bg: #f5f7fb;
    --vg-surface: #ffffff;
    --vg-side: #0f172a;
    --vg-side-ink: #cbd5e1;
    --vg-ok: #059669;
    --vg-warn: #d97706;
    --vg-bad: #dc2626;
    --vg-radius: 14px;
    --vg-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --vg-safe: rgba(220, 38, 38, .35);
    --bs-primary: var(--vg-primary);
    --bs-primary-rgb: 79, 70, 229;
    --bs-body-font-family: 'Tajawal', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-color: var(--vg-ink);
    --bs-border-color: var(--vg-line);
}

body {
    background: var(--vg-bg);
    font-size: 15.5px;
}

/* ---------- الهيكل ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--vg-side);
    color: var(--vg-side-ink);
    display: flex;
    flex-direction: column;
    padding: 1.25rem .9rem;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
}

.brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: #fff;
    text-decoration: none;
    padding: 0 .5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    margin-bottom: 1rem;
}

.brand-mark {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    font-size: 1.2rem;
}

.brand-name { display: block; font-weight: 800; line-height: 1.2; }
.brand-sub { display: block; font-size: .78rem; color: #94a3b8; }

.side-group {
    font-size: .72rem;
    letter-spacing: .04em;
    color: #64748b;
    margin: 1rem .6rem .4rem;
}

.side-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    border-radius: 10px;
    color: var(--vg-side-ink);
    text-decoration: none;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.side-link i { font-size: 1.1rem; opacity: .85; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: var(--vg-primary); color: #fff; box-shadow: 0 6px 18px rgba(79, 70, 229, .35); }

.side-foot { margin-top: auto; font-size: .75rem; color: #64748b; padding: 0 .6rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1.75rem;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--vg-line);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-title { font-weight: 700; }
.content { padding: 1.75rem; max-width: 1400px; width: 100%; }

.btn-icon { border: 1px solid var(--vg-line); background: #fff; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; font-size: 1.25rem; }

.backdrop { display: none; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1030; }
    .content { padding: 1rem; }
    .topbar { padding: .75rem 1rem; }
}

/* ---------- مكونات ---------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-head h1 { font-size: 1.6rem; font-weight: 800; margin: 0; }
.page-head p { color: var(--vg-muted); margin: .35rem 0 0; max-width: 70ch; }

.card {
    border: 1px solid var(--vg-line);
    border-radius: var(--vg-radius);
    box-shadow: var(--vg-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--vg-line);
    font-weight: 700;
    padding: .9rem 1.15rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-header:first-child { border-radius: var(--vg-radius) var(--vg-radius) 0 0; }
.card-body { padding: 1.15rem; }

.section-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; margin: 0 0 .9rem; }
.section-title .num { width: 26px; height: 26px; border-radius: 50%; background: var(--vg-primary-50); color: var(--vg-primary); display: grid; place-items: center; font-size: .85rem; }

.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.form-control, .form-select { border-radius: 10px; padding: .55rem .8rem; border-color: #d5dce6; }
.form-control:focus, .form-select:focus { border-color: var(--vg-primary); box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15); }
.form-text { color: var(--vg-muted); }

.btn { border-radius: 10px; font-weight: 600; padding: .5rem 1rem; }
.btn-sm { padding: .3rem .7rem; border-radius: 8px; }
.btn-primary { --bs-btn-bg: var(--vg-primary); --bs-btn-border-color: var(--vg-primary); --bs-btn-hover-bg: var(--vg-primary-600); --bs-btn-hover-border-color: var(--vg-primary-600); --bs-btn-active-bg: var(--vg-primary-600); --bs-btn-disabled-bg: var(--vg-primary); --bs-btn-disabled-border-color: var(--vg-primary); }
.btn-outline-primary { --bs-btn-color: var(--vg-primary); --bs-btn-border-color: var(--vg-primary); --bs-btn-hover-bg: var(--vg-primary); --bs-btn-hover-border-color: var(--vg-primary); --bs-btn-active-bg: var(--vg-primary); }
.btn-soft { background: var(--vg-primary-50); color: var(--vg-primary); border: 0; }
.btn-soft:hover { background: #e0e7ff; color: var(--vg-primary-600); }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th { font-size: .8rem; color: var(--vg-muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; background: #f8fafc; }
.table td, .table th { padding: .7rem .8rem; }
.table-card { overflow: hidden; }

.badge { font-weight: 600; border-radius: 999px; padding: .38em .7em; }
.badge-soft-ok { background: #d1fae5; color: #065f46; }
.badge-soft-warn { background: #fef3c7; color: #92400e; }
.badge-soft-bad { background: #fee2e2; color: #991b1b; }
.badge-soft-muted { background: #f1f5f9; color: #475569; }
.badge-soft-primary { background: var(--vg-primary-50); color: var(--vg-primary); }

.empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--vg-muted);
}

.empty > i { font-size: 2.6rem; color: #c7d2fe; display: block; margin-bottom: .75rem; }

/* ---------- إحصاءات المعاينة ---------- */
.stat {
    background: #f8fafc;
    border: 1px solid var(--vg-line);
    border-radius: 12px;
    padding: .65rem .85rem;
    height: 100%;
}

.stat-label { font-size: .78rem; color: var(--vg-muted); }
.stat-value { font-weight: 800; font-size: 1.1rem; }
.stat-hero { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; border: 0; }
.stat-hero .stat-label { color: #e0e7ff; }

.shots { display: flex; gap: 3px; direction: ltr; }

.shot {
    flex-basis: 0;
    background: linear-gradient(180deg, #6366f1, #4f46e5);
    color: #fff;
    font-size: .72rem;
    text-align: center;
    padding: .3rem 0;
    border-radius: 6px;
    min-width: 1.25rem;
}

/* ---------- محدد المدة ---------- */
.duration-box { background: #f8fafc; border: 1px solid var(--vg-line); border-radius: 12px; padding: 1rem; }
.duration-value { font-size: 2rem; font-weight: 800; color: var(--vg-primary); line-height: 1; }
.chip { border: 1px solid var(--vg-line); background: #fff; border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; font-weight: 600; color: var(--vg-ink); }
.chip:hover, .chip.active { border-color: var(--vg-primary); color: var(--vg-primary); background: var(--vg-primary-50); }

/* ---------- بطاقات الوجهات في إنشاء الحلقة ---------- */
.dest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem; }

.dest-card {
    border: 1.5px solid var(--vg-line);
    border-radius: 12px;
    padding: .75rem;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

.dest-card.selected { border-color: var(--vg-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.dest-card .dest-top { display: flex; align-items: center; gap: .5rem; }
.dest-card .dest-name { font-weight: 700; flex: 1; }
.dest-card .dest-meta { font-size: .78rem; color: var(--vg-muted); margin: .35rem 0 .5rem; }
.dest-card .primary-pick { font-size: .8rem; }

/* ---------- المزودون ---------- */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }

.provider-card { display: flex; flex-direction: column; height: 100%; }
.provider-card .card-body { display: flex; flex-direction: column; gap: .6rem; }
.provider-logo {
    width: 44px; height: 44px; border-radius: 12px;
    display: grid; place-items: center;
    font-weight: 800; color: #fff; font-size: 1.05rem;
    flex-shrink: 0;
}
.provider-name { font-weight: 800; line-height: 1.2; }
.provider-vendor { font-size: .8rem; color: var(--vg-muted); }
.provider-models { font-size: .78rem; color: var(--vg-muted); direction: ltr; text-align: right; }
.provider-status { font-size: .85rem; display: flex; align-items: center; gap: .4rem; }
.provider-card .actions { margin-top: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }

.key-input { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; direction: ltr; text-align: left; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding-inline-start: 2rem; margin-bottom: .45rem; font-size: .9rem; }
.steps li::before { content: counter(s); position: absolute; inset-inline-start: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--vg-primary-50); color: var(--vg-primary); font-size: .75rem; font-weight: 700; display: grid; place-items: center; }

/* ---------- منطقة الأمان ---------- */
.frame { position: relative; background: #1e293b; border-radius: 10px; overflow: hidden; direction: ltr; }
.frame-v { width: 135px; height: 240px; }
.frame-h { width: 240px; height: 135px; }
.overlay-img { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .5; }
.inset { position: absolute; background: var(--vg-safe); }
.inset-top { top: 0; left: 0; right: 0; }
.inset-bottom { bottom: 0; left: 0; right: 0; }
.inset-left { top: 0; bottom: 0; left: 0; }
.inset-right { top: 0; bottom: 0; right: 0; }
.frame-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: #fff; font-size: .8rem; }
.provider-card[hidden] { display: none; }
.key-input::placeholder { font-family: var(--bs-body-font-family); direction: rtl; text-align: right; }
.stat-value { white-space: nowrap; }

/* ---------- صفحة الإنتاج ---------- */
.stepper { display: flex; list-style: none; margin: 0; padding: 0; gap: .25rem; overflow-x: auto; }
.step { flex: 1; min-width: 110px; position: relative; text-align: center; }
.step a { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-decoration: none; color: var(--vg-ink); padding: .25rem; }
.step:not(:last-child)::after { content: ""; position: absolute; top: 22px; inset-inline-start: calc(50% + 26px); inset-inline-end: calc(-50% + 26px); height: 2px; background: var(--vg-line); }
.step-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.15rem; background: #f1f5f9; color: #64748b; border: 2px solid var(--vg-line); z-index: 1; }
.step-name { font-weight: 700; font-size: .85rem; }
.step-status { font-size: .75rem; color: var(--vg-muted); }
.step-succeeded .step-icon { background: #d1fae5; color: #047857; border-color: #6ee7b7; }
.step-succeeded:not(:last-child)::after { background: #6ee7b7; }
.step-running .step-icon, .step-queued .step-icon { background: var(--vg-primary-50); color: var(--vg-primary); border-color: var(--vg-primary); }
.step-failed .step-icon { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.step-skipped .step-icon { background: #f8fafc; color: #94a3b8; border-style: dashed; }

.stage-card .card-header .bi { color: var(--vg-primary); }
.stage-num { width: 24px; height: 24px; border-radius: 50%; background: var(--vg-primary-50); color: var(--vg-primary); display: grid; place-items: center; font-size: .8rem; }
.stage-message { font-size: .9rem; min-height: 1.2em; }
.stage-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; align-items: center; margin-top: .9rem; padding-top: .9rem; border-top: 1px dashed var(--vg-line); }
.script-box { line-height: 1.9; font-size: 1rem; }
.settings-group { font-size: .9rem; font-weight: 700; margin: 1.1rem 0 .6rem; padding-top: .9rem; border-top: 1px solid var(--vg-line); display: flex; gap: .4rem; align-items: center; }

.shot-list { display: flex; flex-direction: column; gap: .75rem; }
.shot-item { border: 1px solid var(--vg-line); border-radius: 12px; padding: .75rem; background: #fcfdff; }
.shot-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.shot-head audio { height: 32px; max-width: 260px; }
.shot-no { width: 28px; height: 28px; border-radius: 8px; background: var(--vg-ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.renders, .outputs { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .6rem; }
.render video, .output video { border-radius: 10px; background: #000; display: block; }
.v-vert { width: 160px; aspect-ratio: 9 / 16; }
.v-wide { width: 300px; aspect-ratio: 16 / 9; }
.output { background: #f8fafc; border: 1px solid var(--vg-line); border-radius: 12px; padding: .6rem; }
.no-provider { border: 1.5px dashed #c7d2fe; background: var(--vg-primary-50); border-radius: 12px; padding: .8rem .9rem; }
[data-field][hidden], .no-provider[hidden], #voice-fields[hidden] { display: none !important; }

/* ---------- مصدر الصوت ---------- */
.audio-options { display: flex; flex-direction: column; gap: .5rem; }
.audio-option { display: flex; gap: .65rem; align-items: flex-start; border: 1.5px solid var(--vg-line); border-radius: 12px; padding: .6rem .7rem; cursor: pointer; background: #fff; transition: border-color .15s, background .15s; }
.audio-option input { margin-top: .35rem; accent-color: var(--vg-primary); }
.audio-option:has(input:checked) { border-color: var(--vg-primary); background: var(--vg-primary-50); }
.audio-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--vg-primary-50); color: var(--vg-primary); flex-shrink: 0; }
.custom-audio { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; padding: .55rem .7rem; border: 1px dashed #c7d2fe; border-radius: 10px; background: #f8faff; }
.custom-audio audio { height: 32px; max-width: 240px; }
[data-audio-panel][hidden] { display: none !important; }

/* ---------- معاينة الفيديو في قائمة الحلقات ---------- */
.list-preview-cell { width: 1%; }
.list-preview, .list-preview-empty { display: block; border-radius: 10px; background: #0f172a; }
.list-preview.lp-vert, .list-preview-empty.lp-vert { width: 96px; aspect-ratio: 9 / 16; }
.list-preview.lp-wide, .list-preview-empty.lp-wide { width: 170px; aspect-ratio: 16 / 9; }
.list-preview-empty { background: #f1f5f9; border: 1.5px dashed var(--vg-line); display: grid; place-items: center; color: #94a3b8; font-size: 1.4rem; text-decoration: none; }

/* ---------- الشعار ---------- */
.logo-box { width: 84px; height: 84px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; border: 1px solid var(--vg-line); overflow: hidden; font-size: 1.6rem; }
.logo-box img { max-width: 80%; max-height: 80%; object-fit: contain; }

/* ---------- الشخصيات ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.char-card { text-decoration: none; color: inherit; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.char-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 23, 42, .1); }
.char-cover { aspect-ratio: 1; background: #f1f5f9; display: grid; place-items: center; color: #c7d2fe; font-size: 3rem; }
.char-cover img { width: 100%; height: 100%; object-fit: cover; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.g-item { margin: 0; border: 1px solid var(--vg-line); border-radius: 12px; overflow: hidden; background: #fff; }
.g-item.is-ref { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, .25); }
.g-img { position: relative; aspect-ratio: 1; background: #f8fafc; }
.g-img img { width: 100%; height: 100%; object-fit: contain; }
.g-wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--vg-primary); }
.g-ref { position: absolute; top: 6px; inset-inline-start: 6px; background: #f59e0b; color: #fff; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; }
.g-item figcaption { padding: .5rem; }
.g-prompt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.cast-card { border: 1.5px solid var(--vg-line); border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; display: block; margin: 0; }
.cast-card:has(input:checked) { border-color: var(--vg-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.cast-card input { position: absolute; opacity: 0; }
.cast-card .char-cover { font-size: 2rem; }
.cast-card .cast-name { padding: .35rem .5rem; font-weight: 700; font-size: .85rem; display: flex; align-items: center; gap: .3rem; }
.cast-card .cast-name::before { content: "\F26A"; font-family: bootstrap-icons; color: #cbd5e1; }
.cast-card:has(input:checked) .cast-name::before { content: "\F26B"; color: var(--vg-primary); }

/* ---------- ملف الشخصية ---------- */
.bible-section + .bible-section { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--vg-line); }
.bible-head { font-weight: 800; margin-bottom: .8rem; display: flex; align-items: center; gap: .45rem; }
.bible-head .bi { color: var(--vg-primary); }
.bible-when { font-size: .72rem; font-weight: 600; color: var(--vg-muted); background: #f1f5f9; border-radius: 999px; padding: .15rem .55rem; margin-inline-start: auto; }
.char-avatar { width: 64px; height: 64px; border-radius: 16px; overflow: hidden; background: #f1f5f9; display: grid; place-items: center; color: #c7d2fe; font-size: 1.8rem; flex-shrink: 0; border: 1px solid var(--vg-line); }
.char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.suggest-box { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 2rem; }
.suggest-chip { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: start; }
.g-item.is-original { border-color: var(--vg-primary); box-shadow: 0 0 0 2px rgba(79, 70, 229, .25); }
.g-orig { position: absolute; bottom: 6px; inset-inline-start: 6px; background: var(--vg-primary); color: #fff; border-radius: 999px; padding: .1rem .5rem; font-size: .72rem; font-weight: 700; }
.voice-sample { background: #f8fafc; border: 1px solid var(--vg-line); border-radius: 12px; padding: .75rem; }
[data-voice-synth][hidden], [data-voice-any][hidden], [data-voice-hint][hidden] { display: none !important; }

/* ---------- الهدف والترابط ---------- */
.goal-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.goal-option { display: inline-flex; align-items: center; gap: .35rem; border: 1.5px solid var(--vg-line); border-radius: 999px; padding: .3rem .8rem; cursor: pointer; font-weight: 600; font-size: .85rem; background: #fff; }
.goal-option input { display: none; }
.goal-option:has(input:checked) { border-color: var(--vg-primary); background: var(--vg-primary-50); color: var(--vg-primary); }
.promo-box { background: #fffbeb; border: 1px dashed #fcd34d; border-radius: 12px; padding: .75rem; }
[data-promo][hidden], [data-continuity-notes][hidden] { display: none !important; }

/* ---------- قائمة الحلقات: فلتر ومعاينة منبثقة ---------- */
.list-filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding: .75rem 1rem; }
.filter-search { position: relative; flex: 1 1 220px; max-width: 340px; }
.filter-search .bi { position: absolute; inset-inline-start: .75rem; top: 50%; transform: translateY(-50%); color: var(--vg-muted); }
.filter-search input { padding-inline-start: 2.2rem; }
.list-preview-btn { position: relative; display: block; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: #0f172a; cursor: pointer; }
.list-preview-btn.lp-vert { width: 96px; aspect-ratio: 9 / 16; }
.list-preview-btn.lp-wide { width: 170px; aspect-ratio: 16 / 9; }
.list-preview-btn .list-preview { width: 100%; height: 100%; object-fit: cover; border-radius: 0; pointer-events: none; }
.lp-play { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 23, 42, .25); transition: background .15s; }
.lp-play .bi { width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .92); color: var(--vg-primary); display: grid; place-items: center; font-size: 1.5rem; padding-inline-start: 3px; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.list-preview-btn:hover .lp-play, .list-preview-btn:focus-visible .lp-play { background: rgba(79, 70, 229, .35); }
.player-modal { background: #0b1120; color: #fff; border: 0; overflow: hidden; }
.player-modal .modal-header { border-bottom: 1px solid rgba(255, 255, 255, .1); }
#player-frame { display: block; width: 100%; height: min(80vh, 760px); border: 0; background: #000; }
#episode-rows tr[hidden] { display: none; }

/* ---------- تعبئة بالذكاء الاصطناعي ---------- */
.ai-quick { background: linear-gradient(135deg, #eef2ff, #faf5ff); border: 1px solid #c7d2fe; }
.ai-quick .bi-stars { color: #7c3aed; }
.ai-inline { display: flex; gap: .5rem; align-items: center; border-radius: 12px; padding: .5rem .6rem; }
.ai-filled { animation: aiFill 2.5s ease; }
@keyframes aiFill { 0% { background: #ede9fe; box-shadow: 0 0 0 3px rgba(124, 58, 237, .25); } 100% { background: #fff; box-shadow: none; } }

/* ---------- صفحات الدخول ---------- */
.auth-body { min-height: 100vh; background: radial-gradient(circle at 20% 20%, #eef2ff, transparent 40%), radial-gradient(circle at 80% 80%, #faf5ff, transparent 40%), var(--vg-bg); }
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 3rem 16px; }
.auth-brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem; justify-content: center; }
.auth-brand .brand-mark { color: #fff; }
.auth-card { border-radius: 18px; }
.role-user [data-open-key] { display: none !important; }
.user-box { display: flex; align-items: center; gap: .6rem; padding: .7rem .6rem; border-top: 1px solid rgba(255, 255, 255, .08); margin-top: .75rem; color: #e2e8f0; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: #334155; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.user-box .btn-link { color: #94a3b8; }

/* ---------- المحفظة ---------- */
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.pkg-card { transition: transform .15s, box-shadow .15s; }
.pkg-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15, 23, 42, .1); }
.pkg-best { border-color: var(--vg-primary); box-shadow: 0 0 0 2px rgba(79, 70, 229, .2); }
.pkg-points { font-size: 1.8rem; font-weight: 800; color: var(--vg-primary); }
.pkg-points small { font-size: .9rem; color: var(--vg-muted); }

/* مسار اعتماد الشخصية */
.wizard-steps { list-style: none; padding: 0; margin: 0; counter-reset: wz; }
.wizard-steps li { position: relative; padding: 0 2.1rem .8rem 0; counter-increment: wz; font-size: .9rem; }
.wizard-steps li::before { content: counter(wz); position: absolute; right: 0; top: 0; width: 1.5rem; height: 1.5rem; border-radius: 50%;
    display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--bs-secondary-bg, #e9ecef); color: var(--bs-secondary-color, #6c757d); }
.wizard-steps li.wz-done::before { content: "✓"; background: #198754; color: #fff; }
.wizard-steps li.wz-current::before { background: var(--bs-primary, #0d6efd); color: #fff; }
.wizard-steps li.wz-todo { opacity: .6; }

/* لوحة الأدمن */
.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { padding: 16px; border-top: 4px solid var(--bs-border-color); }
.kpi-ok { border-top-color: #198754; } .kpi-warn { border-top-color: #f59e0b; } .kpi-bad { border-top-color: #dc3545; }
.kpi-label { font-size: .85rem; color: var(--bs-secondary-color); font-weight: 700; }
.kpi-value { font-size: 2rem; font-weight: 800; line-height: 1.2; margin: 4px 0; }
.kpi-sub { font-size: .8rem; }
.kpi-target { font-size: .75rem; color: var(--bs-secondary-color); margin-top: 6px; }

/* ---------- الاتجاه من اليسار لليمين (الإنجليزية) ---------- */
[dir=ltr] .provider-models { text-align: left; }
[dir=ltr] .key-input::placeholder { direction: ltr; text-align: left; }
[dir=ltr] .wizard-steps li { padding: 0 0 .8rem 2.1rem; }
[dir=ltr] .wizard-steps li::before { right: auto; left: 0; }
[dir=ltr] body { font-family: Inter, Tajawal, system-ui, sans-serif; }
@media (max-width: 991.98px) {
    [dir=ltr] .sidebar:not(.open) { transform: translateX(-100%); }
}

/* دليل الاستخدام داخل البوابة */
.guide-toc-sticky { position: sticky; top: 1rem; }
.guide-toc-list { padding-inline-start: 1.1rem; }
.guide-toc-list li { margin-bottom: .35rem; }
.guide-toc-list a { text-decoration: none; }
.guide-toc-list a.active { font-weight: 700; }
.guide-portal { line-height: 1.9; padding: 1.5rem 1.75rem; }
.guide-portal h2 { font-size: 1.15rem; font-weight: 700; margin-top: 2rem; padding-top: .5rem; scroll-margin-top: 1rem; }
.guide-portal h2:first-child { margin-top: 0; }
@media (max-width: 1199.98px) { .guide-toc-sticky { position: static; } }

/* ================= التنقل في البوابة (v2) ================= */
.sidebar { padding: 1rem .75rem .75rem; gap: .5rem; transition: width .2s ease, transform .2s ease; }
.side-top { display: flex; align-items: center; gap: .5rem; border-bottom: 1px solid rgba(255, 255, 255, .08); padding-bottom: .9rem; }
.side-top .brand { border: 0; margin: 0; padding: 0 .35rem; flex: 1; min-width: 0; }
.brand-text { min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-close { background: rgba(255, 255, 255, .08); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; }
.side-cta { display: flex; align-items: center; justify-content: center; gap: .5rem; border-radius: 10px; font-weight: 700; padding: .55rem .75rem; margin: .35rem 0 .15rem; }
/* القائمة تتمرر وحدها: الروابط لا تُقص على الشاشات القصيرة */
.side-nav { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin-inline: -.25rem; padding-inline: .25rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-radius: 3px; }
.side-group { margin: .9rem .6rem .3rem; font-weight: 700; text-transform: none; white-space: nowrap; }
.side-group:first-child { margin-top: .35rem; }
.side-link { position: relative; padding: .5rem .7rem; margin-bottom: 2px; white-space: nowrap; }
.side-link:focus-visible, .side-collapse:focus-visible, .side-close:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.side-label { overflow: hidden; text-overflow: ellipsis; }
.side-badge { margin-inline-start: auto; font-size: .72rem; font-weight: 700; background: rgba(255, 255, 255, .12); color: #fff; border-radius: 999px; padding: .1rem .5rem; }
.side-badge.low { background: #f59e0b; color: #111827; }
.side-collapse { align-items: center; gap: .6rem; background: transparent; border: 0; color: #94a3b8; padding: .5rem .7rem; border-radius: 10px; font-size: .85rem; border-top: 1px solid rgba(255, 255, 255, .08); border-radius: 0; margin-top: .25rem; }
.side-collapse:hover { color: #fff; }

/* شريط مطوي إلى أيقونات (سطح المكتب) */
@media (min-width: 992px) {
    .side-collapsed .sidebar { width: 76px; }
    .side-collapsed .sidebar .side-label, .side-collapsed .sidebar .brand-text, .side-collapsed .sidebar .side-badge { display: none; }
    .side-collapsed .sidebar .side-group { margin: .6rem .4rem; height: 1px; background: rgba(255, 255, 255, .08); }
    .side-collapsed .sidebar .side-link, .side-collapsed .sidebar .side-cta, .side-collapsed .sidebar .side-collapse { justify-content: center; padding-inline: 0; }
    .side-collapsed .sidebar .side-top .brand { justify-content: center; padding: 0; }
    .side-collapsed .sidebar .side-collapse i { transform: scaleX(-1); }
}

/* الشريط العلوي: مسار الصفحة + الرصيد + اللغة + قائمة الحساب */
.topbar { gap: .75rem; min-height: 60px; }
.crumbs { display: flex; align-items: center; gap: .45rem; min-width: 0; flex: 1; font-size: .92rem; }
.crumb-group { color: var(--vg-muted); white-space: nowrap; }
.crumb-sep { color: #cbd5e1; font-size: .7rem; }
.crumb-page { color: var(--vg-ink); font-weight: 700; text-decoration: none; white-space: nowrap; }
.crumb-page:hover { color: var(--vg-primary); }
.crumb-current { color: var(--vg-muted); min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; margin-inline-start: auto; }
.topbar-lang { border: 1px solid var(--vg-line); white-space: nowrap; }
.balance-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .7rem; border-radius: 999px; background: var(--vg-primary-50); color: var(--vg-primary); text-decoration: none; font-size: .88rem; white-space: nowrap; }
.balance-chip:hover { background: #e0e7ff; }
.balance-chip.low { background: #fef3c7; color: #92400e; }
.user-chip { display: flex; align-items: center; gap: .55rem; background: transparent; border: 1px solid transparent; border-radius: 12px; padding: .2rem .35rem; max-width: 220px; }
.user-chip:hover, .user-chip[aria-expanded=true] { background: #fff; border-color: var(--vg-line); }
.user-chip .user-avatar { width: 34px; height: 34px; flex: none; }
.user-chip-text { flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; font-size: .85rem; }
.user-chip-text .fw-bold { max-width: 130px; }
.dropdown-menu .dropdown-item i { width: 1.25rem; display: inline-block; opacity: .75; }
.dropdown-header { white-space: normal; }

/* الجوال: درج كامل الارتفاع مع خلفية، والصفحة خلفه لا تتمرر */
@media (max-width: 991.98px) {
    .sidebar { width: min(300px, 86vw); box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .sidebar:not(.open) { box-shadow: none; }
    body.drawer-open { overflow: hidden; }
    .backdrop.show { backdrop-filter: blur(2px); }
}
@media (max-width: 575.98px) {
    .topbar { gap: .5rem; }
    .topbar-lang { padding-inline: .5rem; }
    .topbar-lang i + * , .topbar-lang { font-size: .8rem; }
}
.user-chip .user-avatar { background: var(--vg-primary); color: #fff; font-size: .9rem; }
.side-top .brand-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .95rem; }

/* ---------- المحفظة ---------- */
.wallet-hero { position: relative; overflow: hidden; isolation: isolate; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.5rem;
    padding: 1.6rem 1.8rem; margin-bottom: 1rem; border-radius: 20px; color: #fff;
    background: linear-gradient(135deg, #4338ca, #6d28d9 60%, #9333ea); box-shadow: 0 18px 44px rgba(79, 70, 229, .28); }
.wallet-hero.low { background: linear-gradient(135deg, #b45309, #d97706 60%, #f59e0b); box-shadow: 0 18px 44px rgba(217, 119, 6, .28); }
.wallet-label { opacity: .85; font-weight: 600; }
.wallet-amount { font-size: 2.8rem; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.wallet-amount small { font-size: 1rem; font-weight: 500; opacity: .8; }
.wallet-warn { margin-top: .35rem; font-size: .9rem; background: rgba(0,0,0,.18); display: inline-block; padding: .2rem .6rem; border-radius: 8px; }
.wallet-stats { display: flex; gap: 2rem; }
.wallet-stat-num { font-size: 1.5rem; font-weight: 800; }
.wallet-stat-label { font-size: .82rem; opacity: .8; }
.wallet-orb { position: absolute; z-index: -1; width: 340px; height: 340px; border-radius: 50%; inset-inline-end: -90px; top: -150px;
    background: radial-gradient(circle, rgba(255,255,255,.35), transparent 65%); animation: mo-float-a 12s ease-in-out infinite alternate; }
.wallet-info { border-style: dashed; }
.mo-panel .pkg-card { animation: mo-rise .5s cubic-bezier(.22,1,.36,1) backwards; }
.mo-panel .pkg-card:nth-child(2) { animation-delay: .06s; } .mo-panel .pkg-card:nth-child(3) { animation-delay: .12s; }
.mo-panel .pkg-card:nth-child(4) { animation-delay: .18s; } .mo-panel .pkg-card:nth-child(n+5) { animation-delay: .24s; }
.mo-panel tbody tr { animation: mo-rise .4s cubic-bezier(.22,1,.36,1) backwards; }
@media (max-width: 575.98px) { .wallet-amount { font-size: 2.2rem; } .wallet-hero { padding: 1.25rem; } }

/* ---------- باقات الشحن: بطاقات أعرض ---------- */
.pkg-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.pkg-card { border-radius: 18px; }
.pkg-card .card-body { padding: 1.6rem 1.5rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.pkg-card .card-body > .btn { margin-top: auto !important; }
.pkg-points { font-size: 2.4rem; line-height: 1.15; }
.pkg-card .fs-5 { font-size: 1.15rem !important; white-space: nowrap; }
.pkg-card .small { text-wrap: balance; }
.pkg-card .btn-primary { padding: .65rem 1rem; border-radius: 12px; font-weight: 700; }
@media (max-width: 575.98px) { .pkg-grid { grid-template-columns: 1fr; } }

/* ---------- قائمة الحلقات: الفترة والترقيم ---------- */
.ep-period { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ep-period a.chip { text-decoration: none; }
.ep-custom { display: inline-flex; align-items: center; gap: .35rem; margin-inline-start: auto; }
.ep-custom input[type=date] { width: auto; min-width: 140px; }
.ep-filters a.chip { color: inherit; }
.table-card .card-footer { background: transparent; border-top: 1px solid var(--vg-line); padding: .75rem 1rem; }
.pagination .page-link { border-radius: 8px !important; margin-inline: 2px; min-width: 34px; text-align: center; }
@media (max-width: 767.98px) { .ep-custom { margin-inline-start: 0; width: 100%; } .ep-custom input[type=date] { flex: 1; min-width: 0; } }

/* ---------- إصلاح وتحسين صوت المستخدم ---------- */
.audio-fix { border: 1px dashed var(--vg-line); border-radius: 10px; padding: .4rem .7rem; background: #fafbff; }
.audio-fix > summary { cursor: pointer; list-style: none; }
.audio-fix > summary::-webkit-details-marker { display: none; }
.audio-fix[open] > summary { margin-bottom: .25rem; color: var(--vg-primary); }
.audio-fix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem .75rem; font-size: .88rem; }

/* ---------- شريط الانتظار ---------- */
.wait-banner { border: 1px solid #c7d2fe; background: linear-gradient(135deg, #eef2ff, #faf5ff); position: sticky; top: 72px; z-index: 5; }
.wait-pulse { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: #e0e7ff; color: var(--vg-primary); }
.wait-progress { height: 8px; background: #e0e7ff; }
.wait-progress .progress-bar { transition: width .6s cubic-bezier(.22,1,.36,1); }
.wait-later { color: #4338ca; }
.skeleton { background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 37%, #eef2f7 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (max-width: 767.98px) { .wait-banner { top: 64px; } }

/* ---------- اختيار مستخدم ---------- */
.user-pick-col { min-width: 340px; flex: 1 1 340px; max-width: 460px; }
.user-pick-display:disabled { background: var(--vg-bg); color: var(--vg-ink); opacity: 1; }
.user-pick.is-picked .user-pick-display:disabled { background: var(--vg-primary-50); font-weight: 600; }
.user-pick-list .list-group-item { border-radius: 10px !important; margin-bottom: 4px; border: 1px solid var(--vg-line); }
.user-pick-list .list-group-item:focus { box-shadow: 0 0 0 3px rgba(79, 70, 229, .2); z-index: 1; }
.user-pick-list .user-avatar { background: var(--vg-primary); color: #fff; width: 36px; height: 36px; }
