/* بوابة منزال: the shared frame (sidebar, menu, page header) for the portal's own pages and
   for projects that use it. Menzal brand: burgundy #640211 and gold #B07A04 on black. */
:root {
  --brand: #640211;
  --brand-ink: #ffffff;
  --brand-text: #640211;
  --brand-soft: #f5e6e8;
  --gold: #b07a04;
  --gold-text: #7f5700;
  --gold-soft: #fbf1da;
  --side-bg: #000000;
  --side-text: #f3ece6;
  --side-muted: #a89c93;
  --side-hover: #1a1412;
  --side-active: #2a0a10;
  --bg: #f8f4ef;
  --surface: #ffffff;
  --surface-2: #f2ebe3;
  --text: #1d1512;
  --muted: #6d6059;
  --border: #e7dcd1;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(60, 20, 10, .06);
  --sidebar-w: 236px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #8a1a2b; --brand-text: #f09aa7; --brand-soft: #3a1a1f;
    --gold: #d6a23a; --gold-text: #e6b75a; --gold-soft: #2e2413;
    --side-hover: #171211; --side-active: #2e1015;
    --bg: #121010; --surface: #1c1817; --surface-2: #26201e; --text: #efe7e1; --muted: #a99d95; --border: #3a302d;
    --danger: #f07167; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #8a1a2b; --brand-text: #f09aa7; --brand-soft: #3a1a1f;
  --gold: #d6a23a; --gold-text: #e6b75a; --gold-soft: #2e2413;
  --side-hover: #171211; --side-active: #2e1015;
  --bg: #121010; --surface: #1c1817; --surface-2: #26201e; --text: #efe7e1; --muted: #a99d95; --border: #3a302d;
  --danger: #f07167; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif; line-height: 1.6; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }

/* ---------- frame ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex: none; display: flex; flex-direction: column; background: var(--side-bg); color: var(--side-text); border-inline-end: 3px solid var(--gold); z-index: 20; }
.sidebar-brand { padding: 8px 12px 14px; border-bottom: 1px solid #2a2220; text-align: center; }
.brand-logo { display: block; width: 100%; height: auto; margin: -6px auto -10px; }
.sidebar-product { color: var(--gold); font-weight: 700; font-size: .92rem; letter-spacing: .02em; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 15; }
.scrim[hidden] { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobilebar { display: none; }
.content { padding: 22px 24px 48px; max-width: 1100px; width: 100%; }
.view-head { margin-bottom: 16px; }
.view-head h1 { margin: 0; font-size: 1.55rem; font-weight: 800; line-height: 1.3; }
.view-sub { margin: 2px 0 0; color: var(--muted); font-size: .94rem; }

/* ---------- menu (filled by menu.js) ---------- */
.nav { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; overflow-y: auto; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--side-text); text-decoration: none; font-weight: 500; border-inline-start: 3px solid transparent; }
.nav-link svg { width: 21px; height: 21px; flex: none; color: var(--side-muted); }
.nav-link:hover { background: var(--side-hover); }
.nav-link[aria-current="page"] { background: var(--side-active); border-inline-start-color: var(--gold); font-weight: 700; }
.nav-link[aria-current="page"] svg { color: var(--gold); }
.nav-link:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.nav-count, .nav-alert { margin-inline-start: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; font-size: .78rem; font-weight: 700; text-align: center; }
.nav-count { background: #2a2220; color: var(--side-muted); }
.nav-count:empty { display: none; }
.nav-alert { background: var(--gold); color: #000; }
.nav-alert[hidden] { display: none; }
.nav-project, .nav-sub { display: flex; flex-direction: column; gap: 4px; }
.nav-project + .nav-project { margin-top: 6px; border-top: 1px solid #2a2220; padding-top: 6px; }
.nav-project-title, .nav-sub-title { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; border-radius: 8px; }
.nav-project-title::-webkit-details-marker, .nav-sub-title::-webkit-details-marker { display: none; }
.nav-project-title { padding: 10px 12px; font-weight: 800; color: var(--side-text); font-size: .98rem; }
.nav-sub-title { padding: 6px 12px; font-size: .78rem; font-weight: 700; color: var(--side-muted); }
.nav-project-title::after, .nav-sub-title::after { content: "▾"; margin-inline-start: auto; font-size: .8rem; transition: transform .15s; }
.nav-project:not([open]) > .nav-project-title::after, .nav-sub:not([open]) > .nav-sub-title::after { transform: rotate(90deg); }
.nav-project-title:hover, .nav-sub-title:hover { background: var(--side-hover); }
.nav-project-title:focus-visible, .nav-sub-title:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.nav-sub { padding-inline-start: 6px; }

/* ---------- «الإجراءات المطلوبة» ---------- */
.roles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { font: inherit; font-size: .88rem; font-weight: 700; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 4px 14px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.role-list { display: grid; gap: 14px; }
.role-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px 18px; min-width: 0; box-shadow: var(--shadow); }
.role-card[open] { padding-bottom: 16px; }
.role-head { display: flex; align-items: center; gap: 10px; padding: 12px 0; cursor: pointer; list-style: none; }
.role-head::-webkit-details-marker { display: none; }
.role-head::before { content: "▾"; color: var(--muted); transition: transform .15s; }
.role-card:not([open]) > .role-head::before { transform: rotate(90deg); }
.role-head h2 { margin: 0; font-size: 1.15rem; color: var(--brand-text); }
.role-head:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; border-radius: 8px; }
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tasks a { display: grid; grid-template-columns: 9rem 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; }
.tasks a:hover { background: var(--brand-soft); border-color: var(--brand-text); }
.tasks a:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.task-project { font-size: .8rem; font-weight: 700; color: var(--muted); }
.task-text { font-weight: 700; min-width: 0; }
.task-done .task-text { color: var(--muted); font-weight: 500; }
.note { font-size: .78rem; font-weight: 700; color: var(--gold-text); background: var(--gold-soft); border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.role-head .note { margin-inline-start: auto; }
.task-done .note { color: var(--muted); background: var(--bg); }
.source-state { margin: 0 0 14px; font-size: .88rem; color: var(--muted); }
.source-state .bad { color: var(--danger); }
.empty { margin: 0; padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 12px; }

@media (max-width: 900px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; height: 100%; transform: translateX(100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 24px rgba(0, 0, 0, .4); }
  .mobilebar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 4px 12px; background: var(--side-bg); color: var(--side-text); border-bottom: 3px solid var(--gold); }
  .menu-btn { width: 42px; height: 42px; display: grid; place-items: center; background: none; border: 1px solid #3a302d; border-radius: 10px; color: var(--side-text); cursor: pointer; flex: none; }
  .menu-btn svg { width: 22px; height: 22px; }
  .menu-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  .mobilebar-logo { height: 52px; width: auto; margin: -2px -10px; }
  .mobilebar-title { font-weight: 700; margin-inline-start: auto; color: var(--gold); }
  .content { padding: 16px 16px 40px; }
}
@media (max-width: 560px) {
  .tasks a { grid-template-columns: 1fr auto; }
  .task-project { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .nav-project-title::after, .nav-sub-title::after, .role-head::before { transition: none; }
}
