/* StratEngine — واجهة المرحلة الأولى */

:root {
    --primary: #16385d;        /* أزرق داكن */
    --primary-hover: #0f2a47;
    --bg: #ffffff;             /* أبيض */
    --card-bg: #f5f7fa;        /* رمادي فاتح للكروت */
    --border: #dfe4ea;
    --text: #1f2937;
    --text-muted: #6b7280;     /* رمادي متوسط */
    --green: #2f9e5f;          /* حالات مكتملة */
    --green-bg: #e8f5ee;
    --orange: #d97417;         /* تنبيهات */
    --orange-bg: #fdf1e3;
    --red: #c0392b;
    --red-bg: #fdecea;
    --blue-bg: #e9f0f8;
    --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; width: 100%; }

/* الشريط العلوي */
.topbar {
    background: var(--primary);
    color: #fff;
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 32px;
    height: 64px;
}
.brand {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.3px;
}
.brand span { color: #9db8d6; }
.topnav { display: flex; gap: 20px; flex: 1; }
.topnav a {
    color: #d5e0ec;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
}
.topnav a:hover { color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 14px; margin-inline-start: auto; }
.user-name { font-size: 14px; font-weight: 600; color: #d5e0ec; }

.main { flex: 1; padding: 40px 24px 64px; }

.footer {
    border-top: 1px solid var(--border);
    padding: 18px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* العناوين */
.page-head { margin-bottom: 28px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; }
.page-head h1 { font-size: 26px; font-weight: 700; color: var(--primary); }
.page-sub { color: var(--text-muted); font-size: 15px; margin-top: 4px; }

/* الأزرار */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border-radius: var(--radius);
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #268350; }
.btn-outline {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.5);
}
.btn-outline:hover { background: rgba(255,255,255,0.1); }
.btn-light {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn-light:hover { border-color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn[disabled], .btn.btn-disabled {
    background: #c7ced6;
    color: #fff;
    cursor: not-allowed;
}
.btn-block { display: block; width: 100%; }

/* الكروت */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 24px;
}
.card h2 {
    font-size: 19px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 18px;
}
.card-white { background: #fff; }

/* النماذج */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.field label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
}
.field .hint { font-weight: 400; color: var(--text-muted); font-size: 13px; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    background: #fff;
    color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
}
.field textarea { resize: vertical; min-height: 96px; }
.required::after { content: " *"; color: var(--red); }

.form-actions { margin-top: 24px; display: flex; gap: 12px; }

/* التنبيهات */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 15px;
}
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-warning { background: var(--orange-bg); color: var(--orange); }

/* الشارات */
.badge {
    display: inline-block;
    padding: 3px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}
.badge-gray { background: #eceff3; color: var(--text-muted); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue { background: var(--blue-bg); color: var(--primary); }

/* الجداول */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.table th, .table td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}
.table th {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
}
.table tr:last-child td { border-bottom: none; }
.table a { color: var(--primary); font-weight: 700; text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* شبكة المشاريع */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.project-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.project-card:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(22,56,93,0.08); }
.project-card h3 { font-size: 17px; font-weight: 700; color: var(--primary); }
.project-card .meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }

/* صفحة تسجيل الدخول */
.auth-wrap { max-width: 480px; margin: 40px auto 0; }
.auth-wrap .brand-big {
    display: block;
    text-align: center;
    font-size: 30px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
    text-decoration: none;
}
.auth-wrap .brand-big span { color: #7d99b8; }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 15px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-muted); }
.auth-switch a { color: var(--primary); font-weight: 700; text-decoration: none; }

/* تفاصيل المشروع */
.detail-list { display: grid; gap: 14px; }
.detail-item { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
.detail-item .label { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
.detail-item .value { font-size: 15px; white-space: pre-wrap; }
.detail-item .value.empty { color: var(--text-muted); font-style: italic; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.section-head h2 { font-size: 19px; font-weight: 700; color: var(--primary); }

.checklist { list-style: none; display: grid; gap: 8px; margin-top: 12px; }
.checklist li { font-size: 14px; font-weight: 600; }
.checklist li.done { color: var(--green); }
.checklist li.missing { color: var(--orange); }
.checklist li::before { content: "✔ "; }
.checklist li.missing::before { content: "✖ "; }

.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state p { margin-bottom: 18px; font-size: 16px; }

.note { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.inline-form { display: inline; }
.link-danger { color: var(--red); background: none; border: none; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.link-danger:hover { text-decoration: underline; }

/* ═══════ المرحلة الثانية: التشخيص التفاعلي ═══════ */

/* رأس الجولة والعداد */
.round-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.round-part { font-size: 14px; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; }
.round-head h1 { font-size: 24px; font-weight: 800; color: var(--primary); }
.timer-box { text-align: center; }
.timer {
    font-size: 40px;
    font-weight: 800;
    color: var(--primary);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 22px;
    min-width: 140px;
    direction: ltr;
}
.timer-danger { color: var(--red); border-color: var(--red); }
.timer-paused { color: var(--orange); border-color: var(--orange); }

/* بطاقة السؤال */
.question-card { border-inline-start: 4px solid var(--primary); }
.q-label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.q-text { font-size: 19px; font-weight: 700; color: var(--primary); margin: 4px 0 10px; }
.q-explanation { font-size: 15px; color: var(--text); }
.q-meta { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* بطاقات Post-it */
.postits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-top: 20px;
}
.postit {
    border-radius: 4px;
    padding: 14px;
    min-height: 150px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    position: relative;
    transform: rotate(-0.4deg);
}
.postit:nth-child(even) { transform: rotate(0.5deg); }
.postit::before {
    content: "";
    position: absolute;
    top: -8px;
    right: 50%;
    transform: translateX(50%) rotate(1deg);
    width: 68px;
    height: 16px;
    background: rgba(255,255,255,0.55);
    border: 1px solid rgba(0,0,0,0.05);
}
.postit-no { font-size: 12px; font-weight: 700; color: rgba(0,0,0,0.45); margin-bottom: 6px; }
.postit textarea {
    flex: 1;
    background: transparent;
    border: none;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    line-height: 1.6;
    min-height: 100px;
}
.postit textarea:focus { outline: none; }
.postit-text { flex: 1; font-size: 15px; font-weight: 600; color: #333; white-space: pre-wrap; }
.postit-author { font-size: 12px; font-weight: 700; color: rgba(0,0,0,0.45); margin-top: 10px; text-align: left; }
.postit-static { min-height: 120px; }

/* ألوان المنهجية */
.postit-yellow { background: #FDF3B4; }
.postit-green  { background: #D9F2D0; }
.postit-orange { background: #FFDFB8; }
.postit-blue   { background: #D2E5F7; }
.postit-pink   { background: #FADCE9; }
.postit-purple { background: #E6DAF5; }

.color-preview {
    padding: 10px 14px;
    border-radius: 4px;
    font-weight: 700;
    text-align: center;
    color: #333;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* شريط مسار الجولات */
.rounds-strip-label { font-size: 14px; font-weight: 700; color: var(--text-muted); margin: 14px 0 8px; }
.rounds-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.round-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
}
.round-chip-no {
    width: 22px; height: 22px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #eceff3;
    font-size: 12px;
}
.round-chip-active { border-color: var(--orange); color: var(--orange); background: var(--orange-bg); }
.round-chip-active .round-chip-no { background: var(--orange); color: #fff; }
.round-chip-done { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.round-chip-done .round-chip-no { background: var(--green); color: #fff; }

.board-part-title { font-size: 21px; font-weight: 800; color: var(--primary); margin: 30px 0 16px; }

/* رابط دخول المشارك */
.join-link {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    font-size: 12px;
    color: var(--text-muted);
    vertical-align: middle;
}
.btn-copy { padding: 3px 10px; font-size: 12px; }

/* ═══════════ المرحلة الثالثة: التحليل المباشر ═══════════ */
.badge-purple { background: #efe7fa; color: #6b3fa0; }

.analysis-intro { font-size: 15px; color: var(--text); margin-bottom: 18px; line-height: 1.9; }

/* لوحة اختيار الألوان */
.color-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cp-chip {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: var(--radius);
    border: 1px solid var(--border); background: #fff;
    font-family: inherit; cursor: pointer; text-align: right;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.cp-chip:hover:not(:disabled) { border-color: var(--primary); }
.cp-chip.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.cp-chip.is-approved { background: var(--green-bg); }
.cp-chip.is-locked { opacity: 0.55; cursor: not-allowed; }
.cp-swatch { width: 34px; height: 34px; border-radius: 6px; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.cp-info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cp-title { font-weight: 700; font-size: 14px; color: var(--primary); }
.cp-meta { font-size: 12px; color: var(--text-muted); }

/* مساحة العمل */
.ana-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.ana-section-title { font-size: 20px; font-weight: 800; color: var(--primary); margin-bottom: 8px; }
.ana-color-name { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.ana-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── واجهة السوليتير: الرزمة في الأعلى وأكوام المجموعات في الأسفل ── */
.sol-deck-row { display: flex; align-items: stretch; gap: 20px; margin: 14px 0 6px; flex-wrap: wrap; }
.sol-deck {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 10px; border: 2px dashed transparent; border-radius: var(--radius);
}
.sol-deck.drop-hover { border-color: var(--primary); background: var(--blue-bg); }
.sol-deck-stack {
    position: relative; width: 120px; height: 120px; border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.18),
                4px 4px 0 -1px rgba(255,255,255,0.85), 4px 4px 4px rgba(0,0,0,0.14),
                8px 8px 0 -2px rgba(255,255,255,0.85), 8px 8px 6px rgba(0,0,0,0.10);
    display: flex; align-items: center; justify-content: center;
}
.sol-deck-count { font-size: 40px; font-weight: 800; color: rgba(0,0,0,0.55); }
.sol-deck-label { font-size: 13px; font-weight: 700; color: var(--text-muted); }

.sol-top-wrap { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 10px; }
.sol-top-card {
    border-radius: 6px; padding: 18px 20px; min-height: 96px; max-width: 560px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.20); cursor: grab;
    display: flex; align-items: center;
}
.sol-top-card:active { cursor: grabbing; }
.sol-top-card.is-dragging { opacity: 0.4; }
.sol-top-text { font-size: 17px; font-weight: 700; color: #333; white-space: pre-wrap; line-height: 1.8; }
.sol-top-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sol-hint-note { font-size: 13px; color: var(--text-muted); }
.sol-guide { margin: 4px 0 0; }

.sol-review-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    background: var(--green-bg); border: 1px solid var(--green);
    border-radius: var(--radius); padding: 14px 18px; margin: 14px 0 6px;
    font-size: 14px; line-height: 1.8;
}
.sol-done-banner { border-width: 2px; box-shadow: 0 0 0 3px rgba(46,160,67,0.12); }
.print-scope { color: var(--text-muted); font-weight: 600; }

.sol-piles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; margin-top: 18px; align-items: start; }
.sol-pile {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 12px 10px 14px; border: 2px solid transparent; border-radius: var(--radius);
    background: var(--card-bg);
}
.sol-pile.drop-hover { border-color: var(--primary); background: var(--blue-bg); }
.sol-pile.is-hint { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,166,0,0.25); }
.sol-pile.is-hint::after { content: '💡'; position: absolute; top: -12px; inset-inline-start: -6px; font-size: 20px; }
.sol-pile.is-open { border-color: var(--primary); }
.sol-pile-actions { position: absolute; top: 6px; inset-inline-end: 6px; display: flex; gap: 4px; z-index: 2; }

.sol-pile-stack {
    position: relative; width: 100%; max-width: 170px; min-height: 110px; border-radius: 6px;
    padding: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.16);
    transition: transform 0.12s;
}
.sol-pile-stack.has-cards {
    box-shadow: 0 2px 4px rgba(0,0,0,0.16),
                3px 3px 0 -1px rgba(255,255,255,0.9), 3px 3px 4px rgba(0,0,0,0.12),
                6px 6px 0 -2px rgba(255,255,255,0.9), 6px 6px 5px rgba(0,0,0,0.09);
}
.sol-pile-stack:hover { transform: translateY(-3px); }
.sol-pile-stack.is-empty { background: #fff !important; border: 2px dashed var(--border); box-shadow: none; }
.sol-pile-peek {
    font-size: 12.5px; font-weight: 600; color: #333; line-height: 1.6;
    max-height: 86px; overflow: hidden; white-space: pre-wrap;
}
.sol-pile-empty { font-size: 12px; color: var(--text-muted); }
.sol-pile-count { font-size: 15px; font-weight: 800; color: var(--primary); }
.sol-pile-title { font-size: 13px; padding: 6px 10px; }

.sol-new-pile {
    justify-content: center; min-height: 170px; cursor: pointer;
    border: 2px dashed var(--border); background: #fff;
}
.sol-new-pile:hover, .sol-new-pile.drop-hover { border-color: var(--primary); background: var(--blue-bg); }
.sol-new-plus { font-size: 34px; font-weight: 800; color: var(--text-muted); }
.sol-new-label { font-size: 13px; font-weight: 700; color: var(--text-muted); }

.sol-open {
    margin-top: 18px; border: 1px solid var(--primary); border-radius: var(--radius);
    background: var(--card-bg); padding: 14px;
}
.sol-open-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sol-open-head .sol-close { margin-inline-start: auto; }
.sol-open-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; max-height: 340px; overflow-y: auto; padding: 2px; }
.sol-todeck { flex-shrink: 0; }

.ana-kw { font-size: 12px; font-weight: 700; color: var(--text-muted); background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.ana-mini {
    border: 1px solid var(--border); background: #fff; border-radius: 6px;
    width: 26px; height: 26px; font-size: 13px; cursor: pointer; color: var(--text-muted); padding: 0;
}
.ana-mini:hover { border-color: var(--primary); color: var(--primary); }
.ana-del:hover { border-color: var(--red); color: var(--red); }
.ana-merge { padding: 4px 6px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-family: inherit; max-width: 130px; }

.ana-title-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 15px; font-weight: 700; color: var(--primary); background: #fff; }
.ana-title-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.ana-title-static { font-size: 15px; font-weight: 700; color: var(--primary); padding: 4px 0; }

.ana-card {
    display: flex; align-items: flex-start; gap: 8px;
    border-radius: 4px; padding: 10px 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.10); cursor: grab;
}
.ana-card.is-dragging { opacity: 0.4; }
.ana-pick { margin-top: 4px; cursor: pointer; }
.ana-card-body { flex: 1; }
.ana-card-text { font-size: 14px; font-weight: 600; color: #333; white-space: pre-wrap; }
.ana-empty-drop { text-align: center; color: var(--text-muted); font-size: 13px; padding: 14px; border: 1px dashed var(--border); border-radius: 8px; }

/* ═══════════ التحليل الموضوعي (تحليل الأولويات) ═══════════ */
.t-warn { color: var(--orange); font-weight: 700; }
.t-h2 { font-size: 19px; font-weight: 800; color: var(--primary); margin: 26px 0 10px; }
.t-results { margin-top: 20px; }
.t-deck-stack { background: linear-gradient(135deg, #fdf3c7 0%, #d8ecd9 35%, #f8d9dd 70%, #e6dcf5 100%); }
.t-pile-stack .sol-pile-peek { border-radius: 4px; padding: 8px; }

/* جدول الانشغالات المهيمنة */
.thematic-themes .col-theme-label {
    width: 130px; background: var(--card-bg); color: var(--primary);
    font-weight: 800; text-align: center;
}

/* مصفوفة الألوان × الموضوعات */
.t-matrix-wrap { overflow-x: auto; }
.thematic-matrix { min-width: 520px; }
.thematic-matrix .col-theme-head { background: var(--card-bg); color: var(--primary); text-align: center; font-size: 13px; white-space: nowrap; }
.thematic-matrix .col-color-label { font-size: 13px; font-weight: 700; white-space: nowrap; }
.thematic-matrix .col-count { font-size: 15px; }
.thematic-matrix .mx-total th, .thematic-matrix .mx-total td { background: var(--card-bg); font-weight: 800; }
.mx-swatch {
    display: inline-block; width: 14px; height: 14px; border-radius: 3px;
    margin-inline-end: 6px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}

/* شريط التوزيع اللوني — يُعرض أمام المستشار عند تحليل بنية كل موضوع */
.struct-strip {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px 12px; margin: 10px 0; display: flex; flex-direction: column; gap: 8px;
}
.struct-colors { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.struct-cell {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    min-width: 46px; padding: 6px 8px; border-radius: 8px; background: var(--card-bg);
}
.struct-cell.is-zero { opacity: 0.4; }
.struct-swatch {
    display: block; width: 22px; height: 16px; border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
}
.struct-swatch.sm { display: inline-block; width: 13px; height: 11px; vertical-align: -1px; margin-inline-end: 2px; }
.struct-num { font-size: 16px; font-weight: 800; color: var(--primary); line-height: 1; }
.struct-lbl { font-size: 10px; color: var(--text-muted); font-weight: 700; }
.struct-total { background: var(--blue-bg); margin-inline-start: 6px; }
.struct-aggs { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text); }
.struct-agg { white-space: nowrap; }

/* كتلة تحليل بنية الموضوع */
.thematic-struct-block {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; margin-bottom: 16px; background: var(--card-bg);
}
.struct-theme-title { font-size: 16px; font-weight: 800; color: var(--primary); margin-bottom: 10px; }
.struct-field { margin: 8px 0; }
.struct-label { font-size: 13px; font-weight: 800; color: var(--text-muted); margin-bottom: 4px; }
.struct-text { font-size: 14px; line-height: 1.9; color: var(--text); }
.struct-input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: 14px; line-height: 1.8; color: var(--text); background: #fff; resize: vertical;
}
.struct-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.struct-rank { font-size: 14px; font-weight: 700; color: var(--primary); margin: 8px 0; }

/* على كومة الموضوع نفسها: شريط مصغّر */
.sol-pile .struct-strip { padding: 6px 8px; gap: 5px; width: 100%; }
.sol-pile .struct-cell { min-width: 30px; padding: 3px 4px; }
.sol-pile .struct-swatch { width: 16px; height: 11px; }
.sol-pile .struct-num { font-size: 12px; }
.sol-pile .struct-lbl { display: none; }
.sol-pile .struct-aggs { display: none; }

/* جدول النتيجة والطباعة */
.result-table { width: 100%; border-collapse: collapse; margin-bottom: 26px; border: 1px solid var(--border); }
.result-table th, .result-table td { border: 1px solid var(--border); padding: 10px 14px; text-align: right; vertical-align: top; }
.result-title { font-size: 17px; font-weight: 800; color: #333; text-align: center; }
.result-table thead tr:nth-child(2) th { background: var(--card-bg); font-weight: 700; color: var(--primary); }
.col-count { width: 90px; text-align: center; font-weight: 800; font-size: 18px; color: var(--primary); }
.col-phrase { font-weight: 700; font-size: 15px; }
.result-empty { text-align: center; color: var(--text-muted); font-weight: 400; }
.result-cards { margin-top: 8px; font-weight: 400; }
.result-cards summary { cursor: pointer; font-size: 12px; color: var(--text-muted); }
.result-cards ul { margin: 8px 14px 0; font-size: 13px; color: var(--text); }

.print-toolbar { padding: 16px 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.print-sheet { padding-bottom: 60px; }
.print-head { margin-bottom: 24px; }
.print-head h1 { font-size: 24px; font-weight: 800; color: var(--primary); }
.print-h2 { font-size: 19px; font-weight: 800; color: var(--primary); margin: 26px 0 8px; }
.print-lead { font-size: 14px; line-height: 1.9; color: var(--text); margin-bottom: 12px; }
.print-lead-strong { font-size: 16px; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
/* فاصل صفحة عند الطباعة (يُتجاهل على الشاشة، ويظهر كفاصل خفيف في المعاينة) */
.print-break { border-top: 1px dashed var(--border); margin-top: 28px; padding-top: 20px; }

@media print {
    .no-print { display: none !important; }
    body { font-size: 13px; }
    .print-sheet { max-width: 100%; }
    .result-table { page-break-inside: avoid; }
    .thematic-struct-block { page-break-inside: avoid; background: #fff; }
    .struct-strip { page-break-inside: avoid; }
    .t-matrix-wrap { overflow: visible; }
    /* كل قسم رئيسي يبدأ في صفحة جديدة عند الطباعة، والفاصل المرئي يُلغى */
    .print-break { page-break-before: always; border-top: 0; margin-top: 0; padding-top: 0; }
}

/* ═══════════ التحليل الثالث: توازن نقاط القوة ونقاط الضعف ═══════════ */
.bal-steps-card { padding: 16px; }
.bal-steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.bal-step .cp-swatch { display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: rgba(0,0,0,0.55); }
.bal-swatch-review { background: var(--blue-bg); color: var(--primary) !important; }
.bal-step-badge { margin-inline-start: auto; font-size: 13px; font-weight: 800; color: var(--text-muted); }
.bal-step-badge.ok { color: var(--green); }
.bal-armed {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px;
    background: var(--blue-bg); border: 1px solid var(--primary); border-radius: var(--radius);
    padding: 8px 12px; margin: 10px 0;
}

/* شاشة التوازن تحتاج عرضاً أكبر من الحاوية العادية (قائمة + مصفوفة جنباً إلى جنب) */
.main:has(#balance-app) { max-width: 1440px; }

/* قائمة العبارات (يميناً) + المصفوفة (يساراً) */
.bal-layout { display: flex; gap: 18px; align-items: flex-start; margin-top: 14px; }
.bal-list {
    flex: 0 0 340px; max-height: 680px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.bal-list.drop-hover { outline: 2px dashed var(--primary); outline-offset: -2px; background: var(--blue-bg); }
.bal-list table { width: 100%; border-collapse: collapse; }
.bal-list th, .bal-list td { padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: right; vertical-align: middle; }
.bal-list th { position: sticky; top: 0; z-index: 1; background: var(--card-bg); color: var(--primary); font-weight: 800; }
.bal-list tr.is-placed td { background: #fafbfc; }
.bal-list tr.is-placed .bal-phrase { color: var(--text-muted); }
.bal-list tr.is-armed td { background: var(--blue-bg); }
.bal-list-drop { text-align: center; font-size: 12px; color: var(--text-muted); padding: 10px; }
.bal-phrase { cursor: pointer; font-weight: 600; line-height: 1.7; }
.bal-phrase:hover { color: var(--primary); text-decoration: underline; }
.bal-num { text-align: center !important; font-weight: 800; color: var(--primary); }
.bal-pos { white-space: nowrap; text-align: center !important; font-size: 12px; font-weight: 700; direction: ltr; }

.bal-chip {
    display: inline-block; padding: 2px 7px; margin: 1px; border-radius: 5px;
    font-size: 12px; font-weight: 800; color: #333; line-height: 1.5; direction: ltr;
    box-shadow: 0 1px 3px rgba(0,0,0,0.22); cursor: pointer; user-select: none; white-space: nowrap;
}
.bal-chip[draggable="true"] { cursor: grab; }
.bal-chip.is-dragging { opacity: 0.35; }
.bal-chip.is-placed { opacity: 0.55; }
tr.is-armed .bal-chip { box-shadow: 0 0 0 2px var(--primary); }

.bal-matrix-wrap { flex: 1; min-width: 0; }
/* direction: ltr حتى يبدأ التمرير (على الشاشات الضيقة) من الصفر يساراً */
.bal-matrix-scroll { overflow-x: auto; padding-bottom: 4px; direction: ltr; }
.bal-matrix {
    direction: ltr; display: grid; min-width: 560px;
    grid-template-columns: 30px 26px repeat(11, minmax(40px, 1fr)) 30px;
    grid-template-rows: 30px repeat(11, minmax(44px, auto)) 24px 30px;
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff;
}
.bm-band { display: flex; align-items: center; justify-content: center; text-align: center; direction: rtl; font-size: 12px; font-weight: 800; color: #fff; padding: 2px; }
.bm-top-low, .bm-right-low { background: #8a94a6; }
.bm-top-high, .bm-right-high { background: var(--primary); }
.bm-bottom { background: var(--card-bg); color: var(--primary); }
.bm-right span { writing-mode: vertical-rl; }
.bm-side { display: flex; align-items: center; justify-content: center; background: var(--card-bg); color: var(--primary); font-size: 12px; font-weight: 800; direction: rtl; }
.bm-side span { writing-mode: vertical-rl; transform: rotate(180deg); }
.bm-num { display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: var(--text-muted); }
.bm-cell {
    display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 1px; padding: 3px;
    border-right: 1px solid rgba(0,0,0,0.07); border-bottom: 1px solid rgba(0,0,0,0.07);
}
.bm-cell.drop-hover { box-shadow: inset 0 0 0 2px var(--primary); background: var(--blue-bg) !important; }
.bm-cell.bm-vsplit { border-right: 3px solid var(--primary); }
.bm-cell.bm-hsplit { border-bottom: 3px solid var(--primary); }

/* الأرباع الأربعة */
/* أربعة ألوان متباينة في الصبغة والدرجة: أخضر، أزرق، رملي دافئ، رمادي محايد */
.q-goals { background: #bfe6c8; }
.q-projects { background: #bcd6f8; }
.q-rec_continuous { background: #f6dfae; }
.q-rec_oneoff { background: #dcdee4; }
/* حدّ داكن للرموز حتى تبقى واضحة فوق أي خلفية (رمز أخضر فوق ربع أخضر مثلاً) */
.bm-cell .bal-chip, .bpm-cell .bpm-code { border: 1px solid rgba(0,0,0,0.38); box-shadow: 0 1px 2px rgba(0,0,0,0.25); }
.bal-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 10px; font-size: 13px; }
.bal-legend-item { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.bal-legend-sw { width: 18px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.15); }
.bal-legend-note { color: var(--text-muted); font-size: 12px; }

/* بطاقة المعلومات عند المرور/النقر */
.bal-pop {
    position: absolute; z-index: 1000; width: 290px; direction: rtl; text-align: right;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 10px 28px rgba(15,23,42,0.18); padding: 10px 12px; font-size: 13px;
}
.bal-pop.is-pinned { border-color: var(--primary); }
.bal-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.bal-pop-freq { font-size: 12px; font-weight: 800; color: var(--text-muted); }
.bal-pop-phrase { font-weight: 700; line-height: 1.7; color: var(--text); }
.bal-pop-pos { margin-top: 6px; font-size: 12px; color: var(--primary); }
.bal-pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* نافذة العبارة وبطاقاتها المصدر */
.bal-modal { position: fixed; inset: 0; z-index: 1100; background: rgba(15,23,42,0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.bal-modal-box { background: #fff; width: 100%; max-width: 640px; max-height: 85vh; overflow-y: auto; border-radius: 12px; padding: 18px 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.bal-modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 16px; line-height: 1.7; }
.bal-modal-head strong { flex: 1; color: var(--primary); }
.bal-modal-meta { font-size: 13px; line-height: 1.9; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.bal-modal-sub { font-size: 13px; font-weight: 800; color: var(--text-muted); margin-bottom: 8px; }
.bal-cards { list-style: none; display: grid; gap: 8px; padding: 0; margin: 0; }
.bal-cards li { padding: 10px 12px; border-radius: 4px; font-size: 14px; font-weight: 600; color: #333; box-shadow: 0 1px 4px rgba(0,0,0,0.10); white-space: pre-wrap; }

/* المراجعة والجداول */
.bal-h3 { font-size: 16px; font-weight: 800; color: var(--primary); margin: 16px 0 6px; }
.bal-zone { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; }
.bal-empty { padding: 6px 0 12px; }
.bal-result thead th { background: var(--card-bg); color: var(--primary); font-weight: 800; }
.bal-result .col-code, .bal-key .col-code { width: 80px; text-align: center; font-weight: 800; direction: ltr; }
.bal-result .col-small { width: 82px; text-align: center; font-weight: 800; }
.bal-result .col-color { width: 110px; white-space: nowrap; }

/* مربع الأهمية والأثر للطباعة */
.bal-print-matrix-wrap { overflow-x: auto; }
.bal-print-matrix { direction: ltr; width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 11px; }
.bal-print-matrix td, .bal-print-matrix th { border: 1px solid #c9ced8; padding: 3px; text-align: center; vertical-align: middle; }
.bal-print-matrix .bpm-corner { border: 0; background: transparent; }
.bpm-col-band { width: 30px; }
.bpm-col-num { width: 26px; }
.bpm-top, .bpm-bottom { font-size: 12px; font-weight: 800; direction: rtl; padding: 6px; }
.bpm-top-low, .bpm-right-low { background: #8a94a6; color: #fff; }
.bpm-top-high, .bpm-right-high { background: var(--primary); color: #fff; }
.bpm-bottom, .bpm-side { background: var(--card-bg); color: var(--primary); }
.bpm-side, .bpm-right { font-size: 11px; font-weight: 800; direction: rtl; }
.bpm-side span, .bpm-right span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.bpm-num { font-weight: 800; color: var(--text-muted); background: #fff; }
.bpm-cell { height: 40px; }
.bpm-cell.bm-vsplit { border-right: 3px solid var(--primary); }
.bpm-cell.bm-hsplit { border-bottom: 3px solid var(--primary); }
.bpm-code { display: inline-block; margin: 1px; padding: 1px 5px; border-radius: 4px; font-weight: 800; font-size: 11px; color: #333; direction: ltr; white-space: nowrap; }

@media (max-width: 1000px) {
    .bal-layout { flex-direction: column; }
    .bal-list { flex-basis: auto; width: 100%; max-height: 380px; }
}

/* ═══════════ التحليل الرابع: تحليل المحيط ═══════════ */
.main:has(#env-app) { max-width: 1440px; }
.env-step-num { display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: var(--primary); background: var(--blue-bg); }

/* الفئات الثلاث: ألوان متباينة (برتقالي / أزرق / رمادي) */
.z-1 { background: #f5b98e; }
.z-2 { background: #bcd6f8; }
.z-3 { background: #dcdee4; }

/* رموز الإكراهات (R) والفرص (OPP) */
.env-risk { background: #f4b6b0; }
.env-opp { background: #a9dfbf; }
.env-code {
    display: inline-block; padding: 1px 6px; margin-inline-end: 6px; border-radius: 4px;
    font-size: 11px; font-weight: 800; color: #333; direction: ltr; border: 1px solid rgba(0,0,0,0.25); white-space: nowrap;
}
.env-chip { min-width: 30px; text-align: center; }

/* الجداول */
.env-table td, .env-table th { vertical-align: top; }
.env-col-title { width: 190px; font-weight: 700; }
.env-key-table .env-col-title { width: 170px; }
.col-num { width: 44px; text-align: center; font-weight: 800; color: var(--primary); }
.env-themes { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.env-table tr.is-on td { background: #f2f8f3; }
.env-actions-col { width: 100px; white-space: nowrap; text-align: center; }
.env-col-key { width: 170px; font-size: 13px; color: var(--text-muted); }
.env-col-group { width: 190px; }
.env-list-text { font-weight: 600; line-height: 1.6; }
.env-list-key { font-size: 12px; color: var(--text-muted); }

/* إدخال العناصر */
.env-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.env-chip-el {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
    background: var(--blue-bg); color: var(--primary); font-size: 13px; font-weight: 700; cursor: pointer;
}
.env-x {
    border: 0; background: transparent; color: var(--text-muted); font-size: 15px; line-height: 1;
    cursor: pointer; padding: 0 2px;
}
.env-x:hover { color: var(--red); }
.env-add {
    flex: 1; min-width: 180px; padding: 6px 10px; border: 1px dashed var(--border); border-radius: 8px;
    font-family: inherit; font-size: 13px; background: #fff;
}
.env-add:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-style: solid; }
.env-add-wide { width: 100%; margin-top: 10px; }
.env-add-item { width: 100%; resize: vertical; margin-top: 6px; }
.env-inline { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 14px; font-weight: 700; }
.env-items { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.env-items li { display: flex; align-items: flex-start; gap: 4px; font-size: 13px; line-height: 1.7; }
.env-item-text { flex: 1; cursor: pointer; }
.env-item-text:hover { color: var(--primary); text-decoration: underline; }
.env-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.env-pane { min-width: 0; }

/* المرحلة 6: التبويب */
.env-tabs { display: flex; gap: 8px; margin: 16px 0 10px; flex-wrap: wrap; }
.env-tab {
    padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); background: #fff;
    font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; color: var(--text);
}
.env-tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.env-groups-bar { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 8px; }
.env-groups-title { font-size: 13px; font-weight: 800; color: var(--text-muted); margin-bottom: 8px; }
.env-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.env-group-card {
    display: flex; align-items: center; gap: 6px; padding: 6px 8px; min-width: 200px;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
}
.env-group-card.drop-hover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--blue-bg); }
.env-group-new { justify-content: center; min-width: 150px; border-style: dashed; color: var(--text-muted); font-weight: 700; cursor: pointer; }
.env-group-select { width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 12px; background: #fff; }
.env-group-title { font-size: 15px; font-weight: 800; color: var(--primary); margin: 12px 0 6px; }
.env-ungrouped { color: var(--text-muted); }
.env-cat-title { font-size: 17px; font-weight: 800; color: var(--primary); margin: 18px 0 6px; }
.env-print-list { margin: 0; padding-inline-start: 16px; font-size: 12.5px; line-height: 1.7; }
.env-print-list li { margin-bottom: 2px; }

@media (max-width: 1000px) {
    .env-two { grid-template-columns: 1fr; }
}
@media print {
    .z-1, .z-2, .z-3, .env-code, .env-risk, .env-opp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .env-key-table td { font-size: 12px; }
}

@media print {
    .bal-print-matrix, .bal-print-matrix *, .bpm-code, .result-title, .bal-legend-sw {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .bal-print-matrix { font-size: 10px; }

    /* قاعدة عامة لكل صفحات الطباعة: الجدول لا يبدأ في منتصف الصفحة إلا إذا اكتمل فيها؛
       وإلا ينتقل كاملاً (مع عنوانه) إلى صفحة جديدة. */
    .print-keep, .result-table, .bal-print-matrix, .print-color-block, .thematic-struct-block {
        break-inside: avoid; page-break-inside: avoid;
    }
    .print-h2, .bal-h3, .print-lead, .print-lead-strong, .bal-zone, .struct-theme-title {
        break-after: avoid; page-break-after: avoid;
    }
    .result-table tr { break-inside: avoid; page-break-inside: avoid; }
    .result-table thead { display: table-header-group; }
}

/* ═══════════ ضبط الطباعة: لا صفحة بيضاء تحت عنوان، ولا رقم موضوع تحت كلمته ═══════════ */
.col-theme-label { white-space: nowrap; }

/* صفحة A4 بهوامش ثابتة حتى يطابق القياس في print.js الصفحة المطبوعة */
@page { size: A4; margin: 14mm; }

/* القياس قبل الطباعة: محاكاة عرض الصفحة المطبوعة وحجم خطها */
html.print-measure .print-sheet { width: 182mm !important; max-width: 182mm !important; }
html.print-measure body { font-size: 13px; }
html.print-measure .no-print { display: none !important; }

@media print {
    /* العناوين تلتصق دائماً بما بعدها */
    .env-cat-title, .env-group-title, .struct-label { break-after: avoid; page-break-after: avoid; }
    /* كتلة أطول من صفحة: تبدأ تحت عنوانها مباشرة وتنقسم بين الصفحات (الصف لا ينقسم والرأس يتكرر) */
    .print-split, .print-split .result-table, .print-split .bal-print-matrix {
        break-inside: auto; page-break-inside: auto;
    }
}
/* ═══════════ كراس تحليل الاحتياجات التدريبية ═══════════ */
.main:has(#needs-app) { max-width: 1500px; }
.nd-head { padding: 14px 16px; }
.nd-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.nd-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.nd-plan { font-size: 13px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.nd-plan input { width: 78px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; text-align: center; direction: ltr; }

.nd-layout { display: flex; gap: 16px; align-items: flex-start; margin-top: 16px; }
.nd-sources-wrap { flex: 0 0 360px; position: sticky; top: 12px; }
.nd-tabs { margin: 0 0 8px; }
.nd-tabs .env-tab { padding: 6px 12px; font-size: 13px; }
.nd-hide { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; cursor: pointer; }
.nd-sources { max-height: calc(100vh - 150px); overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.nd-bucket { position: sticky; top: 0; z-index: 1; background: var(--card-bg); padding: 6px 10px; font-size: 12px; font-weight: 800; color: var(--primary); border-bottom: 1px solid var(--border); }
.nd-src { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: grab; font-size: 13px; line-height: 1.6; }
.nd-src:hover { background: #f7f9fc; }
.nd-src.is-done { background: #f6faf7; }
.nd-src.is-done .nd-src-text { color: var(--text-muted); }
.nd-src.is-excluded .nd-src-text { text-decoration: line-through; }
.nd-src.is-armed { background: var(--blue-bg); box-shadow: inset 3px 0 0 var(--primary); }
.nd-src.is-dragging { opacity: 0.4; }
.nd-src-text { flex: 1; font-weight: 600; }
.nd-src-text small { color: var(--text-muted); font-weight: 400; }
.nd-src-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.nd-tag { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.nd-tag.t-training { background: #d9ecff; color: #1d4f91; }
.nd-tag.t-rec { background: #efe7fa; color: #6b3fa0; }
.nd-tag.t-ex { background: #eceef2; color: #666; }

.nd-board { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.nd-col { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.nd-col-training { border-top: 4px solid #3b82c4; }
.nd-col-rec { border-top: 4px solid #8a5cc2; }
.nd-col-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.nd-col-title { font-size: 17px; font-weight: 800; color: var(--primary); }
.nd-col-hint { font-size: 12px; color: var(--text-muted); }
.nd-zone { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 10px; }
.nd-zone.drop-hover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--blue-bg); }
.nd-zone-title { font-size: 14px; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.nd-zone-title span { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.nd-zone-title small { float: left; font-size: 11px; color: var(--text-muted); }
.nd-drop {
    border: 2px dashed var(--border); border-radius: 8px; padding: 10px; text-align: center;
    font-size: 12px; font-weight: 700; color: var(--text-muted); background: #fff; cursor: pointer;
}
.nd-drop.drop-hover { border-color: var(--primary); background: var(--blue-bg); color: var(--primary); }
.nd-manual { border: 0; background: none; color: var(--primary); font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: underline; }

.nd-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.nd-card.drop-hover { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,160,67,0.18); }
.nd-card.is-suggest { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,166,0,0.22); }
.nd-card.is-suggest::before { content: '💡 مشابه — أفلت هنا للربط بدل إنشاء بند مكرر'; display: block; font-size: 11px; font-weight: 700; color: #a86b00; margin-bottom: 4px; }
.nd-card.is-dragging { opacity: 0.4; }
.nd-card.is-blank { border-style: dashed; border-color: var(--orange); }
.nd-text { min-height: 24px; font-size: 14px; font-weight: 700; line-height: 1.8; color: var(--text); padding: 2px 4px; border-radius: 4px; outline: none; cursor: text; }
.nd-text:hover { background: #fafbfd; }
.nd-text:focus { background: #fff; box-shadow: 0 0 0 2px var(--primary); }
.nd-text:empty::before { content: attr(data-ph); color: var(--text-muted); font-weight: 400; }
.nd-orig { font-size: 11px; color: #a86b00; margin-top: 2px; }
.nd-similar { font-size: 12px; color: #a86b00; font-weight: 700; }
.nd-similar:not(:empty) { margin-top: 4px; padding: 4px 6px; background: #fff7e6; border-radius: 6px; }
.nd-codes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.nd-link { display: inline-flex; align-items: center; gap: 2px; cursor: help; }
.nd-unlink { border: 0; background: transparent; font-size: 13px; line-height: 1; color: rgba(0,0,0,0.5); cursor: pointer; padding: 0 1px; }
.nd-unlink:hover { color: var(--red); }
.nd-card-foot { display: flex; align-items: center; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.nd-card-foot .env-group-select { width: auto; flex: 1; min-width: 130px; }
.nd-flip { width: auto; padding: 0 6px; font-size: 11px; font-weight: 700; }
.nd-groups { background: #fafbfd; border: 1px dashed var(--border); border-radius: 8px; padding: 8px; margin-bottom: 10px; }
.nd-group-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }

@media (max-width: 1200px) {
    .nd-layout { flex-direction: column; }
    .nd-sources-wrap { position: static; flex-basis: auto; width: 100%; }
    .nd-sources { max-height: 360px; }
}
@media (max-width: 800px) { .nd-board { grid-template-columns: 1fr; } }

/* الورقتان المطبوعتان: شكل مستند لا جدول */
.needs-sheet { max-width: 820px; }
.needs-doc-head { text-align: center; margin-bottom: 22px; }
.needs-doc-title { font-size: 22px; font-weight: 800; color: #111; margin-bottom: 6px; }
.needs-doc-period { font-size: 18px; font-weight: 800; color: #111; }
.needs-doc-project { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.needs-sec { font-size: 17px; font-weight: 800; color: var(--primary); margin: 20px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--border); }
.needs-sec span { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.needs-group { font-size: 15px; font-weight: 800; color: #111; margin: 14px 0 6px; }
.needs-group.is-bullet::before { content: '•'; margin-inline-end: 8px; }
.needs-items { margin: 0 0 6px; padding-inline-start: 26px; font-size: 14px; line-height: 2; color: #111; }
.needs-block { margin-bottom: 6px; }
.btn.is-current { border-color: var(--primary); color: var(--primary); }
@media print {
    .needs-sec, .needs-group { break-after: avoid; page-break-after: avoid; }
    .needs-items li { break-inside: avoid; }
}
/* ── الكراس: تمييز الأهداف والمشاريع بلونين، ومنطقة إفلات بارزة في أعلى كل قسم ── */
.nd-zone { padding: 10px; }
.nd-zone-goal { background: #fff6e0; border: 2px solid #efc56a; }
.nd-zone-project { background: #e4f5ee; border: 2px solid #6cc19b; }
.nd-zone-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nd-zone-title small { float: none; margin-inline-start: auto; font-weight: 700; }
.nd-nature-pill { display: inline-block; padding: 2px 12px; border-radius: 999px; font-size: 14px; font-weight: 800; color: #fff; }
.nd-zone-goal .nd-nature-pill { background: #c98a12; }
.nd-zone-project .nd-nature-pill { background: #23885d; }

.nd-drop {
    display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
    min-height: 64px; margin-bottom: 10px; padding: 12px; border-radius: 10px;
    border: 3px dashed; background: rgba(255,255,255,0.75); font-size: 14px; font-weight: 800;
    transition: background 0.12s, transform 0.12s;
}
.nd-zone-goal .nd-drop { border-color: #e0a536; color: #9a6608; }
.nd-zone-project .nd-drop { border-color: #3ea578; color: #1b6b48; }
.nd-drop-icon { font-size: 26px; line-height: 1; }
.nd-drop:hover { background: #fff; }
.nd-drop.drop-hover { transform: scale(1.02); background: #fff; box-shadow: 0 0 0 4px rgba(26,58,92,0.15); }
.nd-zone-goal .nd-drop.drop-hover { border-style: solid; background: #ffeec2; }
.nd-zone-project .nd-drop.drop-hover { border-style: solid; background: #c9efdc; }
.nd-manual { font-size: 12px; }

/* قائمة بنود كل قسم بارتفاع ثابت وتمرير داخلي: القسمان ظاهران معاً دائماً */
.nd-zone-list { max-height: 42vh; overflow-y: auto; padding: 2px; }
.nd-zone-empty { text-align: center; font-size: 12px; color: var(--text-muted); padding: 8px; }
.nd-zone-goal .nd-card { border-inline-start: 5px solid #e0a536; }
.nd-zone-project .nd-card { border-inline-start: 5px solid #3ea578; }
/* القسمان (أهداف + مشاريع) ومنطقتا إفلاتهما يتّسعان في شاشة واحدة: كل قائمة نصف المساحة المتبقية */
.nd-zone-list { max-height: max(180px, calc((100vh - 340px) / 2)); }
.nd-board { position: sticky; top: 8px; }
/* الطباعة: لا هامش سفلي ولا مسافة بعد آخر عنصر، حتى لا تُدفع إلى صفحة أخيرة فارغة */
@media print {
    .print-sheet { padding-bottom: 0 !important; margin-bottom: 0 !important; }
    html, body { height: auto !important; min-height: 0 !important; }
    .print-sheet > :last-child, .print-page:last-child, .print-page:last-child > :last-child,
    .needs-doc > :last-child, .needs-doc > :last-child .needs-items { margin-bottom: 0 !important; padding-bottom: 0 !important; }
}
/* ═══════════ كراس التحليل الكامل ═══════════ */
.bk-sheet { max-width: 900px; }
.bk-section { border-top: 2px dashed var(--border); margin-top: 34px; padding-top: 26px; }

/* الغلاف */
.bk-cover {
    min-height: 920px; display: flex; flex-direction: column; justify-content: space-between;
    border: 3px solid var(--primary); border-radius: 6px; padding: 40px 44px; margin-top: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #f3f6fa 100%);
}
.bk-cover-top { font-size: 16px; font-weight: 800; color: var(--primary); letter-spacing: 1px; direction: ltr; text-align: left; }
.bk-cover-main { text-align: center; }
.bk-cover-kicker { display: inline-block; font-size: 22px; font-weight: 800; color: #fff; background: var(--primary); padding: 6px 26px; border-radius: 999px; margin-bottom: 26px; }
.bk-cover-title { font-size: 36px; font-weight: 800; color: #111; line-height: 1.5; margin-bottom: 14px; }
.bk-cover-sub { font-size: 17px; font-weight: 600; color: var(--text-muted); }
.bk-cover-meta { width: 100%; border-collapse: collapse; font-size: 14px; }
.bk-cover-meta th, .bk-cover-meta td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: right; }
.bk-cover-meta th { width: 130px; color: var(--primary); font-weight: 800; }

/* الفهرس */
.bk-toc-title { font-size: 26px; font-weight: 800; color: var(--primary); margin-bottom: 18px; }
.bk-toc-list { list-style: none; padding: 0; margin: 0 0 22px; }
.bk-toc-list li { display: flex; align-items: center; gap: 14px; padding: 12px 6px; border-bottom: 1px dotted #b8c0cc; font-size: 16px; }
.bk-toc-list li.is-missing { color: var(--text-muted); }
.bk-toc-no { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.bk-toc-list li.is-missing .bk-toc-no { background: #c5ccd6; }
.bk-toc-name { flex: 1; font-weight: 700; }
.bk-toc-state { font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.bk-toc-state.is-done { background: var(--green-bg); color: #1b6b48; }
.bk-toc-state.is-draft { background: #fff1d6; color: #9a6608; }
.bk-toc-state.is-none { background: #eceef2; color: #6b7280; }
.bk-toc-note { font-size: 13px; color: var(--text-muted); }

/* شريط عنوان القسم (مثل النموذج الورقي) */
.bk-banner {
    display: flex; align-items: center; gap: 14px; margin: 0 0 18px;
    background: #e9edf2; border: 1.5px solid #4b5563; box-shadow: 3px 3px 0 #4b5563;
    padding: 12px 18px; border-radius: 2px;
}
.bk-banner-no { font-size: 22px; font-weight: 800; color: var(--primary); white-space: nowrap; }
.bk-banner-no::after { content: ':'; }
.bk-banner-title { flex: 1; font-size: 20px; font-weight: 800; color: #111; }
.bk-banner-draft { font-size: 12px; font-weight: 800; color: #9a6608; background: #fff1d6; padding: 2px 10px; border-radius: 999px; }

/* تقديم المشروع والتشخيص */
.bk-facts th { width: 150px; background: var(--card-bg); color: var(--primary); font-weight: 800; }
.bk-facts td { line-height: 1.9; }
.bk-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 14px; }
.bk-stats div { border: 1px solid var(--border); border-radius: 8px; padding: 10px; text-align: center; background: #fafbfd; }
.bk-stats b { display: block; font-size: 24px; font-weight: 800; color: var(--primary); }
.bk-stats b.bk-date { font-size: 14px; direction: ltr; }
.bk-stats span { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.bk-rounds td { vertical-align: top; }
.bk-question { font-size: 13px; color: var(--text-muted); margin-top: 2px; line-height: 1.7; }

@media print {
    .booklet .print-sheet { padding-top: 0; }
    .bk-cover { min-height: 262mm; margin-top: 0; break-after: page; page-break-after: always; }
    .bk-section { break-before: page; page-break-before: always; border-top: 0; margin-top: 0; padding-top: 0; }
    .bk-banner { break-after: avoid; page-break-after: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .bk-cover, .bk-toc-no, .bk-toc-state, .bk-stats div, .bk-cover-kicker { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    /* داخل الكراس: أول جزء من كل تحليل يأتي تحت شريط عنوانه، لا في صفحة جديدة */
    .bk-section > .print-page:first-of-type { break-before: auto; page-break-before: auto; }
    /* كل ورقة من ورقتي الكراس الاحتياجي في صفحة مستقلة */
    .bk-section.needs-doc { break-before: page; }
}
/* أوراق الكراس الاحتياجي: العنوان والأقسام تلتصق بأول البنود، والقوائم تنقسم بين الصفحات بنداً بنداً */
@media print {
    .needs-doc-head, .bk-banner, .needs-sec, .needs-group { break-after: avoid; page-break-after: avoid; }
    .needs-block, .needs-items { break-inside: auto; page-break-inside: auto; }
    .needs-items li { break-inside: avoid; page-break-inside: avoid; }
    .needs-items { orphans: 3; widows: 2; }
}
/* ═══════════ التحليل الخامس: التحليل الإداري (5M) ═══════════ */
.main:has(#mgmt-app) { max-width: 1440px; }
.mg-lead { font-size: 16px; font-weight: 700; color: var(--primary); background: var(--card-bg); border-inline-start: 4px solid var(--primary); padding: 10px 14px; border-radius: 6px; margin: 10px 0 16px; line-height: 1.9; }
.mg-intro-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.mg-intro-grid > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: #fff; }
.mg-intro-grid h4 { font-size: 15px; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.mg-intro-grid p { font-size: 13.5px; line-height: 1.9; }
.mg-domain-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.mg-dcard { border: 1px solid var(--border); border-top: 5px solid var(--mg); border-radius: var(--radius); padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.mg-dcard-head { font-size: 16px; font-weight: 800; color: var(--mg); display: flex; align-items: center; gap: 8px; }
.mg-dcard-head span { width: 26px; height: 26px; border-radius: 50%; background: var(--mg); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.mg-dcard-head small { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.mg-dcard-q { font-size: 13.5px; font-weight: 700; line-height: 1.8; }
.mg-dcard-s { font-size: 12.5px; color: var(--text-muted); line-height: 1.8; flex: 1; }
.mg-start, .mg-next { display: flex; justify-content: flex-start; margin-top: 18px; }

/* التوزيع */
.mg-search { display: flex; gap: 8px; align-items: center; margin: 12px 0 6px; flex-wrap: wrap; }
.mg-search input { flex: 1; min-width: 220px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; }
.mg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: #fafbfd; }
.mg-list-flat { max-height: none; }
.mg-card { border-radius: 4px; padding: 8px 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.12); font-size: 13px; line-height: 1.7; }
.mg-card[draggable="true"] { cursor: grab; }
.mg-card.is-dragging { opacity: 0.4; }
.mg-card-text { font-weight: 600; color: #333; white-space: pre-wrap; }
.mg-card-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; font-size: 11px; color: rgba(0,0,0,0.5); flex-wrap: wrap; }
.mg-card-meta select { font-family: inherit; font-size: 11px; padding: 2px 4px; border: 1px solid rgba(0,0,0,0.2); border-radius: 4px; background: rgba(255,255,255,0.8); }

.mg-piles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.mg-pile { position: relative; border: 2px solid var(--border); border-top: 6px solid var(--mg); border-radius: var(--radius); background: #fff; padding: 10px; display: flex; flex-direction: column; gap: 4px; min-height: 190px; transition: box-shadow .12s, transform .12s; }
.mg-pile.drop-hover { border-color: var(--mg); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mg) 25%, transparent); transform: scale(1.02); }
.mg-pile.is-hint { box-shadow: 0 0 0 3px rgba(255,166,0,0.35); }
.mg-pile.is-hint::after { content: '💡'; position: absolute; top: -12px; inset-inline-start: -6px; font-size: 20px; }
.mg-pile.is-open { border-color: var(--mg); }
.mg-pile-head { display: flex; align-items: center; gap: 6px; }
.mg-pile-no { width: 24px; height: 24px; border-radius: 50%; background: var(--mg); color: #fff; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.mg-pile-name { flex: 1; font-size: 15px; font-weight: 800; color: var(--mg); }
.mg-info { border: 1px solid var(--border); background: #fff; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; color: var(--mg); font-weight: 800; }
.mg-pile-alias { font-size: 11px; color: var(--text-muted); font-weight: 700; }
.mg-pile-count { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.mg-pile-count small { font-size: 12px; color: var(--text-muted); }
.mg-pile-def { font-size: 11.5px; color: var(--text-muted); line-height: 1.7; flex: 1; }
.mg-open-panel { border-color: var(--mg); }
@media (max-width: 1100px) { .mg-piles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .mg-piles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* الدليل الجانبي (لا يحجب الصفحة: بلا خلفية معتمة) */
.mg-guide { position: fixed; top: 70px; left: 12px; bottom: 12px; width: 380px; max-width: calc(100vw - 24px); z-index: 900; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 34px rgba(15,23,42,0.22); display: flex; flex-direction: column; }
.mg-guide-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--primary); }
.mg-guide-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); }
.mg-guide-tabs button { font-family: inherit; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.mg-guide-tabs button.is-active { background: var(--mg, var(--primary)); border-color: var(--mg, var(--primary)); color: #fff; }
.mg-guide-body { overflow-y: auto; padding: 10px 14px; font-size: 13px; line-height: 1.9; }
.mg-guide-body h4 { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.mg-guide-body h5 { font-size: 13px; font-weight: 800; color: var(--primary); margin: 10px 0 2px; }
.mg-guide-body ul { padding-inline-start: 18px; }
.mg-g-q { font-weight: 800; }
.mg-kw { display: flex; flex-wrap: wrap; gap: 4px; }
.mg-kw span { background: var(--card-bg); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.mg-cmp li { margin-bottom: 4px; }

/* النتائج والرسوم (مشتركة بين الشاشة والتقرير) */
.mg-dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-inline-end: 7px; vertical-align: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mg-col-domain { width: 190px; text-align: right; font-weight: 800; }
.mg-col-domain small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; }
.mg-domains-table td { line-height: 1.8; }
.mg-def { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.mg-dist-table .col-small, .mg-marks td { text-align: center; }
.mg-round-note { font-size: 11.5px; }
.mg-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 14px; }
.mg-summary div { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fafbfd; display: flex; flex-direction: column; gap: 2px; }
.mg-summary span { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.mg-summary b { font-size: 17px; color: var(--primary); }
.mg-summary em { font-style: normal; font-size: 12px; color: var(--text-muted); }
.mg-charts { display: grid; grid-template-columns: 260px 1fr; gap: 22px; align-items: center; }
.mg-donut { margin: 0; text-align: center; }
.mg-donut svg { width: 200px; height: 200px; }
.mg-donut svg circle { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mg-donut-num { font-family: Cairo, sans-serif; font-size: 7px; font-weight: 800; fill: #1f3b5b; }
.mg-donut-lbl { font-family: Cairo, sans-serif; font-size: 3.2px; fill: #6b7280; }
.mg-donut figcaption { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin-top: 8px; font-size: 12px; }
.mg-donut figcaption i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mg-bars { display: flex; flex-direction: column; gap: 10px; }
.mg-bar-row { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.mg-bar-track { height: 22px; background: #eef1f5; border-radius: 6px; overflow: hidden; }
.mg-bar { display: block; height: 100%; border-radius: 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mg-bar-num { font-weight: 800; color: var(--primary); text-align: center; }
.mg-marks th { background: var(--card-bg); color: var(--primary); font-weight: 800; text-align: center; }
.mg-sign { display: inline-block; direction: ltr; background: var(--primary); color: #fff; border-radius: 6px; padding: 0 6px; margin-inline-start: 4px; font-size: 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.mg-mark-n { font-size: 12px; color: var(--text-muted); }
.mg-marks-note { font-size: 13px; }
.mg-equal { font-weight: 700; }
.mx-total-col { background: var(--card-bg); font-weight: 800; }
@media (max-width: 760px) { .mg-charts { grid-template-columns: 1fr; } .mg-summary { grid-template-columns: 1fr; } }

/* تحليل كل مجال */
.mg-domain-block { border-top: 5px solid var(--mg); }
.mg-domain-block .struct-theme-title { color: var(--mg); }
.mg-head-meta { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-inline-start: 8px; }
.mg-prompts, .mg-cards-ref { margin: 8px 0; font-size: 13px; }
.mg-prompts summary, .mg-cards-ref summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.mg-prompts ul { padding-inline-start: 20px; margin-top: 4px; line-height: 1.9; color: var(--text-muted); }
.mg-warn { font-size: 12.5px; font-weight: 700; color: #a8530b; }
.mg-warn:not(:empty) { margin-top: 4px; padding: 5px 8px; background: #fff3e0; border-radius: 6px; }
.mg-saved { font-size: 11px; color: var(--green); min-height: 14px; }
.mg-free { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fff; }
.mg-checks { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 4px; font-size: 14px; }
.mg-checks li.ok { color: #1b6b48; } .mg-checks li.no { color: #a8530b; font-weight: 700; }

@media print {
    .mg-guide { display: none !important; }
    .mg-charts { grid-template-columns: 230px 1fr; }
    .mg-domain-block { border-top-width: 5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    /* جدول الألوان يتّسع لعرض A4 مهما كان عدد الأعمدة (إصلاح قصّ الأعمدة في التحليل الموضوعي) */
    .thematic-matrix { min-width: 0 !important; width: 100%; table-layout: fixed; }
    .thematic-matrix .col-theme-head { white-space: normal; font-size: 11px; padding: 6px 3px; }
    .thematic-matrix .col-color-label { white-space: normal; width: 125px; font-size: 11.5px; }
    .thematic-matrix td { padding: 6px 3px; }
}.bk-toc-no.is-text { flex-basis: auto; width: auto; padding: 0 12px; border-radius: 999px; font-size: 13px; }

/* التحليل السادس (8F): ثماني أكوام بدل خمس */
.mg-piles.mg-piles-n8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .mg-piles.mg-piles-n8 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .mg-piles.mg-piles-n8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ═══════════ المرحلة الثالثة: التشخيص وصناعة السيناريوهات الاستراتيجية ═══════════ */
.scn-zone { position: relative; border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 14px 12px; margin: 14px 0; background: #fff; }
.scn-zone > .scn-tag { position: absolute; top: -10px; inset-inline-start: 12px; }
.scn-tag { display: inline-block; font-size: 11px; font-weight: 800; padding: 1px 10px; border-radius: 999px; background: #6b7280; color: #fff; margin-inline-end: 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.scn-zone-ref { background: #f6f7f9; border-style: dashed; }
.scn-zone-ref > .scn-tag { background: #6b7280; }
.scn-zone-data { background: #f3f8fd; border-color: #c7dcf1; }
.scn-zone-data > .scn-tag { background: #2f6fb5; }
.scn-zone-own { background: #fff; border-color: #bfe3cf; }
.scn-zone-own > .scn-tag { background: #2e9e6b; }
.scn-zone h5, .scn-study h5 { font-size: 13px; font-weight: 800; color: var(--primary); margin: 10px 0 4px; }
.scn-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.scn-link { font-size: 12px; font-weight: 600; margin-inline-start: 8px; }
.scn-rank .scn-tie-row td, .scn-rank .scn-tie-row th { background: #fff8e6; }
.scn-minus { background: #b8434f; }
.scn-tie-msg { color: #9a6608; }
.scn-advice { background: #fff8e6; color: #7a5307; }
.scn-themes { padding-inline-start: 22px; margin: 4px 0; }
.scn-radio { display: flex; gap: 18px; flex-wrap: wrap; margin: 8px 0; font-weight: 700; }
.scn-rhythm td, .scn-rhythm th { font-size: 13px; }
.scn-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 10px 0 18px; }
.scn-cards.scn-cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.scn-card { border: 1px solid var(--border); border-top: 5px solid var(--primary); border-radius: var(--radius); padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.scn-card.is-rec { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,158,107,0.18); }
.scn-card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scn-code { font-size: 18px; font-weight: 800; color: var(--primary); }
.scn-type { font-size: 12px; font-weight: 700; color: var(--text-muted); direction: rtl; }
.scn-card-sig { font-weight: 700; font-size: 14px; }
.scn-ref-mini, .scn-ref { background: #f6f7f9; border: 1px dashed #c5ccd6; border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.8; flex: 1; }
.scn-ref-title { font-size: 16px; font-weight: 800; color: var(--primary); }
.scn-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.scn-tabs button { font-family: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.scn-tabs button.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.scn-compare-wrap { overflow-x: auto; }
.scn-compare th { font-size: 13px; vertical-align: top; }
.scn-compare td { vertical-align: top; min-width: 170px; font-size: 13px; }
.scn-compare textarea.struct-input { min-height: 70px; font-size: 13px; }
.scn-choose { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
.scn-opt { display: block; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer; background: #fff; }
.scn-opt:has(input:checked) { border-color: var(--green); background: var(--green-bg); }
.scn-history { margin-top: 16px; font-size: 13px; }
.scn-lib-search { padding: 8px; border-bottom: 1px solid var(--border); }
.scn-lib-search input { width: 100%; }
.scn-lib-list { list-style: none; padding: 0 !important; margin: 0 0 8px; }
.scn-lib-list li { padding: 6px 4px; border-bottom: 1px dotted var(--border); }
.scn-lib-list li.is-cand { background: #eef7f1; }
.scn-study { border-top: 5px solid var(--primary); }
.scn-changed .btn { margin-inline-start: 8px; }
@media (max-width: 1100px) { .scn-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .scn-cards, .scn-cards.scn-cards-3, .scn-two { grid-template-columns: 1fr; } }
@media print { .scn-compare td { min-width: 0; } .scn-zone, .scn-ref { break-inside: avoid; } }

/* مراحل المشروع (صفحة المشروع) */
.phases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.phase { border: 1px solid var(--border); border-top: 5px solid var(--primary); border-radius: var(--radius); padding: 12px 14px; background: #fff; }
.phase.is-locked { border-top-color: #c5ccd6; background: #f8f9fb; }
.phase-head { font-size: 15px; font-weight: 800; color: var(--primary); display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.phase-no { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; flex: 0 0 26px; }
.phase-list { padding-inline-start: 20px; margin: 4px 0 8px; font-size: 13.5px; line-height: 2; }
@media (max-width: 900px) { .phases { grid-template-columns: 1fr; } }

/* كراس التحليل الشامل: عناوين المراحل والملاحق الاختيارية */
.bk-phase { font-size: 13px; font-weight: 800; color: #fff; background: var(--primary); display: inline-block; padding: 4px 14px; border-radius: 999px; margin-bottom: 10px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bk-toc-list li.bk-toc-phase { display: block; border-bottom: 0; padding: 16px 6px 4px; font-size: 14px; font-weight: 800; color: var(--primary); }
.bk-toc-state.is-off { background: #f1f3f6; color: #8a93a3; }
.bk-options { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; font-weight: 700; }

/* المرحلة الثالثة: إيقاع العمل وحجم الاستثمار والسياسات الأربع */
.scn-picks { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 10px; }
.scn-pick { border: 2px solid var(--border); border-radius: 10px; padding: 8px 16px; font-weight: 800; cursor: pointer; background: #fff; }
.scn-pick.is-on { border-color: var(--primary); background: #eef3fa; color: var(--primary); }
.scn-match { background: #fff8e6; border: 1px solid #f0d9a4; border-radius: 8px; padding: 8px 12px; margin: 6px 0 10px; }
.scn-policies { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.scn-policy { border: 1px solid var(--border); border-top: 5px solid #c5ccd6; border-radius: var(--radius); padding: 12px; background: #fff; display: flex; flex-direction: column; gap: 6px; opacity: .82; }
.scn-policy.is-on { border-color: var(--primary); border-top-color: var(--primary); opacity: 1; box-shadow: 0 0 0 3px rgba(47,111,181,0.18); }
.scn-policy.is-confirmed { border-color: var(--green); border-top-color: var(--green); box-shadow: 0 0 0 3px rgba(46,158,107,0.2); }
.scn-policy-head { display: flex; justify-content: space-between; align-items: center; }
.scn-policy-name { font-size: 16px; font-weight: 800; color: var(--primary); }
.scn-policy-axes { display: flex; gap: 6px; flex-wrap: wrap; }
.scn-policy-axes span { font-size: 12px; font-weight: 800; background: #eef1f5; border-radius: 999px; padding: 2px 10px; }
.scn-policy-pri { padding-inline-start: 18px; margin: 0; font-size: 12.5px; }
.scn-policy-flag { font-weight: 800; color: var(--green); }
.scn-pol-mini { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.scn-pending { color: #9a6608; font-style: italic; }
.scn-draft { font-size: 12px; margin-top: 4px; }
.scn-row-chosen th, .scn-row-chosen td { background: var(--green-bg); }
.scn-summary th { width: 190px; }
@media (max-width: 1100px) { .scn-policies { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .scn-policies { grid-template-columns: 1fr; } }

/* توضيح خيارات الإيقاع والاستثمار */
.scn-picks { align-items: stretch; }
.scn-pick-card { flex: 1 1 200px; display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; }
.scn-pick-card ul { margin: 0; padding-inline-start: 18px; line-height: 1.8; }
.scn-pick-title { font-size: 15px; font-weight: 800; }
.scn-pick-when { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.scn-pick-effect { margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--border); font-weight: 800; color: var(--primary); }

/* معايير الاختيار القابلة للتحديد */
.scn-howto { background: #eef3fa; border: 1px solid #c7dcf1; border-radius: 8px; padding: 8px 12px; margin: 8px 0 12px; font-size: 13px; line-height: 1.9; }
.scn-crit { list-style: none; padding: 0; margin: 0; }
.scn-crit label { display: flex; gap: 6px; align-items: center; cursor: pointer; padding: 2px 0; }
.scn-pick-count { font-size: 12px; font-weight: 800; color: var(--text-muted); }
.scn-pick-count.is-ok { color: var(--green); }

/* رمز نوع التوليفة (M+ × F−) يُعرض من اليسار لليمين دون انقلاب الإشارات */
.scn-type { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* جدول السيناريو: المرجع الثابت بجانب نسخة المشروع القابلة للتحرير */
.scn-sections { table-layout: fixed; }
.scn-sections th, .scn-sections td { vertical-align: top; }
.scn-sec-col { width: 150px; font-size: 13px; }
.scn-sec-mark { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; margin-inline-end: 4px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.scn-ref-cell { background: #f6f7f9; font-size: 13px; line-height: 1.9; }
.scn-ref-cell ul { margin: 0; padding-inline-start: 18px; }
.scn-sections textarea.struct-input { min-height: 90px; font-size: 13px; }
.scn-tag-own { background: #2e9e6b; }
.scn-edited { display: block; margin-top: 4px; font-size: 11px; font-weight: 800; color: #1b6b48; background: var(--green-bg); border-radius: 999px; padding: 1px 8px; width: fit-content; }
.scn-edited[hidden] { display: none; }
.scn-reset { margin-top: 4px; }
.scn-sec ul { margin: 0; padding-inline-start: 18px; }
@media (max-width: 760px) { .scn-sec-col { width: 90px; } }

/* نص السيناريو المنسّق (فقرات وبنود متداخلة) */
.scn-ref-cell p, .scn-rich p { margin: 0 0 6px; }
.scn-ref-cell ul ul, .scn-rich ul ul { margin-top: 2px; }
.scn-fmt-hint { font-size: 12px; }
@media print { .scn-rich p { margin: 0 0 4px; } .scn-rich ul { margin: 0 0 4px; padding-inline-start: 18px; } }

/* نسخة المشروع بنفس إطار النص المرجعي: نفس الخط والتباعد، دون شريط تمرير داخلي */
.scn-sections td { padding: 10px 12px; }
.scn-sections textarea.struct-input { min-height: 0; overflow: hidden; resize: vertical; font-size: 13px; line-height: 1.9; padding: 8px 10px; }

/* خيارات الطباعة بعد اعتماد التوجه */
.scn-print-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; background: #fff; }
.scn-print-opt { display: flex; gap: 6px; align-items: center; font-weight: 700; font-size: 13px; margin: 4px 0; cursor: pointer; }
.scn-print-opt.is-off { color: var(--text-muted); cursor: default; }
.scn-print-box .btn { margin-top: 8px; }

/* زر تسجيل الخروج داخل نموذج POST */
.logout-form { display: inline; margin: 0; }
