:root {
    --ycb-primary: #2E3192;
    --ycb-primary-hover: #25287A;
    --ycb-primary-active: #1F2268;
    --ycb-primary-light: #E8E9F4;
    --ycb-bg: #FFFFFF;
    --ycb-surface: #F7F8FC;
    --ycb-border: #E2E5F0;
    --ycb-text: #1A1C2E;
    --ycb-text-secondary: #5B6078;
    --ycb-text-muted: #8B90A5;
    --ycb-success: #1F7A4D;
    --ycb-warning: #B7791F;
    --ycb-error: #B42318;
    --ycb-info: #1D4ED8;
    --ycb-radius: 6px;
    --ycb-font: "IBM Plex Sans Arabic", "Tajawal", "Segoe UI", Tahoma, sans-serif;
}

html, body {
    direction: rtl;
    text-align: right;
    font-family: var(--ycb-font);
    background: #fff;
    color: var(--ycb-text);
    margin: 0;
}

.text-secondary { color: var(--ycb-text-secondary) !important; }
.text-muted { color: var(--ycb-text-muted) !important; }
.page-title { color: var(--ycb-text); letter-spacing: 0; }
.page-header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-breadcrumbs {
    padding: .35rem 0 0 !important;
    min-height: 0 !important;
}
.page-breadcrumbs .mud-breadcrumb-item,
.page-breadcrumbs .mud-breadcrumb-separator {
    font-size: .8rem;
    color: var(--ycb-text-secondary);
}

.bank-logo { display: block; object-fit: contain; }
.bank-logo-on-dark {
    /* Official blue logo → light mark on primary app bar */
    filter: brightness(0) invert(1);
}

.shell-appbar {
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.shell-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

.shell-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.shell-brand-title {
    font-weight: 600;
    font-size: .95rem;
    color: #fff;
    white-space: nowrap;
}

.shell-brand-sub {
    font-size: .72rem;
    color: rgba(255,255,255,.78);
    white-space: nowrap;
}

.shell-drawer {
    border-inline-start: 1px solid var(--ycb-border);
    background: #fff !important;
}

.shell-main {
    background: #fff;
    min-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
}

.mud-layout,
.mud-main-content {
    background: #fff !important;
}

.shell-content {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.mud-nav-link.active {
    background: var(--ycb-primary-light) !important;
    color: var(--ycb-primary) !important;
    border-inline-start: 3px solid var(--ycb-primary);
    font-weight: 600;
}

.kpi-card {
    border-color: var(--ycb-border) !important;
    background: #fff;
    height: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.kpi-card:hover {
    border-color: #C8CDDF !important;
    box-shadow: 0 2px 8px rgba(46,49,146,.08);
}

.kpi-label {
    color: var(--ycb-text-secondary);
    font-weight: 500;
}

.kpi-value {
    color: var(--ycb-primary);
    font-weight: 700;
}

.status-badge {
    font-weight: 500;
}

.empty-state {
    background: #fff;
    border-color: var(--ycb-border) !important;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        linear-gradient(180deg, rgba(46,49,146,.06) 0%, rgba(247,248,252,1) 42%, #fff 100%);
}

.auth-card {
    width: min(420px, 100%);
    border: 1px solid var(--ycb-border);
    background: #fff;
}

.auth-footer {
    color: var(--ycb-text-muted);
    font-size: .75rem;
    text-align: center;
}

.panel-card {
    background: #fff;
    border: 1px solid var(--ycb-border);
    border-radius: var(--ycb-radius);
}

.journey-track {
    display: flex;
    align-items: center;
    gap: .35rem;
    overflow-x: auto;
    padding-bottom: .25rem;
}

.journey-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    min-width: 88px;
    text-align: center;
    color: var(--ycb-text-muted);
}

.journey-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 1px solid var(--ycb-border);
    background: #fff;
}

.journey-step.is-done .journey-dot {
    background: var(--ycb-primary-light);
    color: var(--ycb-primary);
    border-color: #C5C8E8;
}

.journey-step.is-current .journey-dot {
    background: var(--ycb-primary);
    color: #fff;
    border-color: var(--ycb-primary);
}

.journey-step.is-current {
    color: var(--ycb-primary);
    font-weight: 600;
}

.journey-line {
    flex: 1;
    min-width: 18px;
    height: 2px;
    background: var(--ycb-border);
    margin-bottom: 1.4rem;
}

.journey-line.is-done {
    background: var(--ycb-primary);
}

.table-toolbar {
    background: #fff;
    border: 1px solid var(--ycb-border);
    border-radius: var(--ycb-radius);
    padding: 1rem;
}

/* أزرار البحث/المسح بمحاذاة حقول Margin.Dense */
.table-toolbar .toolbar-action-btn {
    height: 40px;
    min-height: 40px;
    margin: 0;
}

.workflow-stage-group {
    overflow: hidden;
}

.workflow-stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--ycb-border);
    background: var(--ycb-surface, #F7F8FC);
}

.workflow-rules-table {
    background: transparent;
}

.nav-group-title {
    padding: .75rem 1rem .25rem;
    color: var(--ycb-text-muted);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}

#blazor-error-ui {
    /* لا نعرض شريط الخطأ الأحمر — الرسالة تظهر كـ toast وتستمر الواجهة */
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

#blazor-error-ui .reload { color: #fff; margin-inline-start: .75rem; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; inset-inline-end: .75rem; top: .5rem; }

.blazor-error-boundary {
    /* ErrorBoundary يعيد المحتوى عبر Recover — لا نعرض صندوق خطأ أحمر */
    background: transparent;
    padding: 0;
    color: inherit;
}

.blazor-error-boundary::after {
    content: none;
}

.shell-user {
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-inline-start: .5rem;
    color: #fff;
    max-width: 220px;
}

.shell-profile-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: .35rem;
    margin-inline-start: .5rem;
    color: #fff;
}

.shell-profile-icon-btn {
    color: #fff !important;
}

.shell-user-clickable {
    cursor: pointer;
    border-radius: 8px;
    padding: .15rem .35rem;
    transition: background .15s ease;
    max-width: 180px;
}

.shell-user-clickable:hover {
    background: rgba(255, 255, 255, .12);
}

.shell-user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.shell-user-name {
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shell-user-role {
    font-size: .7rem;
    opacity: .85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shell-profile-popover {
    z-index: 2000;
}

.shell-profile-card {
    min-width: 280px;
    max-width: 320px;
    padding: 1rem 1.1rem .9rem;
    background: #fff;
    color: var(--ycb-text-primary, #1A1C2E);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(26, 28, 46, .16);
}

.shell-profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.shell-profile-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.shell-profile-label {
    color: var(--ycb-text-muted, #8B90A5);
    font-size: .78rem;
    flex-shrink: 0;
}

.shell-profile-value {
    font-size: .85rem;
    font-weight: 500;
    text-align: start;
    word-break: break-word;
}

.shell-logout-btn {
    border-color: rgba(255,255,255,.45) !important;
    color: #fff !important;
    white-space: nowrap;
}

.shell-logout-btn:hover {
    background: rgba(255,255,255,.12) !important;
    border-color: #fff !important;
}

.screen-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: calc(100vh - 64px - 3rem);
    box-sizing: border-box;
}

.screen-page.screen-page--results {
    justify-content: flex-start;
    padding-top: 1.5rem;
    min-height: 0;
}

.screen-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(560px, 100%);
}

.screen-brand {
    margin: 0 0 1.75rem;
    font-family: "IBM Plex Sans Arabic", "Tajawal", sans-serif;
    font-size: clamp(1.75rem, 3.5vw, 2.35rem);
    font-weight: 700;
    color: var(--ycb-primary, #2E3192);
    letter-spacing: 0.01em;
    text-align: center;
    line-height: 1.3;
}

.screen-search {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.screen-name-row {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: .35rem;
    width: 100%;
}

.screen-name-field {
    grid-column: 2;
    min-width: 0;
}

.screen-extra-toggle {
    grid-column: 3;
    justify-self: center;
}

.screen-search-btn {
    min-width: 180px;
}

.screen-advanced {
    width: 100%;
}

.screen-results {
    width: min(900px, 100%);
    margin-top: 2rem;
}

.screen-hit-fields {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.75rem;
}

.screen-hit-field {
    display: block;
    line-height: 1.65;
}

.screen-hit-label {
    display: inline;
    font-weight: 700;
    color: var(--ycb-primary, #2E3192);
    margin-inline-end: 0.4rem;
}

.screen-hit-label::after {
    content: ":";
}

.screen-hit-value {
    color: var(--ycb-text, #1A1C2E);
}

.screen-banned-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: var(--ycb-error);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.9rem 1rem;
    text-align: center;
    animation: screen-banned-fade 0.55s ease-in-out 2;
}

@keyframes screen-banned-fade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.18; }
}

@media (prefers-reduced-motion: reduce) {
    .screen-banned-banner { animation: none; }
}

.shell-content:has(.screen-page) {
    max-width: none;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: calc(100vh - 64px - 3rem);
}

.overview-tab {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.overview-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .75rem;
}

.overview-kpi {
    background: #fff;
    border: 1px solid var(--ycb-border);
    border-radius: var(--ycb-radius);
    padding: 1rem 1.1rem;
    min-width: 0;
}

.overview-kpi-label {
    font-size: .72rem;
    color: var(--ycb-text-muted);
    margin-bottom: .35rem;
}

.overview-kpi-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ycb-text);
    line-height: 1.35;
    word-break: break-word;
}

.overview-kpi-unit {
    font-size: .82rem;
    font-weight: 500;
    color: var(--ycb-text-secondary);
    margin-inline-start: .25rem;
}

.overview-kpi-sub {
    display: block;
    margin-top: .2rem;
    font-size: .75rem;
    font-weight: 400;
    color: var(--ycb-text-muted);
}

.overview-section {
    background: #fff;
    border: 1px solid var(--ycb-border);
    border-radius: var(--ycb-radius);
    overflow: hidden;
}

.overview-section-head {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .8rem 1rem;
    background: var(--ycb-surface);
    border-bottom: 1px solid var(--ycb-border);
    color: var(--ycb-primary);
    font-size: .92rem;
    font-weight: 600;
}

.overview-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    background: var(--ycb-border);
}

.overview-field {
    padding: .9rem 1rem;
    min-width: 0;
    background: #fff;
}

.overview-field.is-wide {
    grid-column: 1 / -1;
}

.overview-field-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--ycb-text);
    margin-bottom: .3rem;
}

.overview-field-value {
    font-size: .9rem;
    font-weight: 500;
    color: var(--ycb-text);
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
}

.overview-field-value.is-empty {
    color: var(--ycb-text-muted);
    font-weight: 400;
}

.overview-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

@media (min-width: 1200px) {
    .overview-fields {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 960px) {
    .shell-brand-sub { display: none; }

    .overview-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .overview-fields {
        grid-template-columns: 1fr;
    }
}

.manifest-editor {
    direction: ltr;
    text-align: left;
    height: 28rem;
    background: var(--ycb-surface);
    border: 1px solid var(--ycb-border);
    border-radius: var(--ycb-radius);
    overflow: hidden;
}

.manifest-editor .monaco-editor,
.manifest-monaco,
.manifest-editor > div {
    height: 100%;
    min-height: 28rem;
}

.scoring-slider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .35rem;
}

.scoring-slider-label {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .6rem;
    align-items: baseline;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.scoring-feature-name {
    direction: ltr;
    unicode-bidi: isolate;
    color: var(--ycb-text-muted);
    font-size: .75rem;
}

.scoring-slider-track {
    direction: rtl;
    flex: 0 0 7.5rem;
    width: 7.5rem;
}

.scoring-slider-track .mud-slider {
    margin: 0;
    padding-block: 0;
    height: 1.35rem;
}

.scoring-weights-toggle {
    display: flex;
    align-items: center;
    gap: .15rem;
    margin: .35rem 0;
}
