/* هوية منزال الموحّدة لكل صفحات البوابة ومشاريعها، مأخوذة من موقع منزال
   (menzal-accounting): الكحلي #001F3F مع الذهبي #B8860B على خلفية كريمية، وخط Almarai.
   تُحمَّل بعد ملف كل صفحة فتغلب ألوانها، وكل صفحة تبقى تعمل بدونها. */
:root {
  --brand: #001f3f;
  --brand-ink: #ffffff;
  --brand-text: #001f3f;
  --brand-soft: #e9eef4;
  --gold: #b8860b;
  --gold-text: #8a6408;
  --gold-soft: #f8f0dc;
  --side-bg: #ffffff;
  --side-text: #12222f;
  --side-muted: #6a7681;
  --side-hover: #f7f5ed;
  --side-active: #e9eef4;
  --side-line: #e4e2da;
  --bg: #fffdf5;
  --surface: #ffffff;
  --surface-2: #f7f5ed;
  --text: #12222f;
  --muted: #6a7681;
  --border: #e4e2da;
  --grid-line: #ece9df;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(0, 31, 63, .05), 0 6px 20px rgba(0, 31, 63, .05);
  --plan-day-bg: #d9e3ee;
  --plan-day-fg: #001f3f;
  --plan-day-edge: #1d4f80;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #1d4f80; --brand-text: #a9c9ea; --brand-soft: #16283b;
    --gold: #d6a23a; --gold-text: #e6b75a; --gold-soft: #2e2413;
    --side-bg: #0f1b27; --side-text: #e6edf3; --side-muted: #93a1ad; --side-hover: #162636; --side-active: #1a2e44; --side-line: #223446;
    --bg: #0b141d; --surface: #111e2a; --surface-2: #182837; --text: #e6edf3; --muted: #93a1ad; --border: #26384a; --grid-line: #1f3041;
    --danger: #f07167; --shadow: none;
    --plan-day-bg: #1d3a57; --plan-day-fg: #dbe9f7; --plan-day-edge: #6aa2d6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #1d4f80; --brand-text: #a9c9ea; --brand-soft: #16283b;
  --gold: #d6a23a; --gold-text: #e6b75a; --gold-soft: #2e2413;
  --side-bg: #0f1b27; --side-text: #e6edf3; --side-muted: #93a1ad; --side-hover: #162636; --side-active: #1a2e44; --side-line: #223446;
  --bg: #0b141d; --surface: #111e2a; --surface-2: #182837; --text: #e6edf3; --muted: #93a1ad; --border: #26384a; --grid-line: #1f3041;
  --danger: #f07167; --shadow: none;
  --plan-day-bg: #1d3a57; --plan-day-fg: #dbe9f7; --plan-day-edge: #6aa2d6;
  color-scheme: dark;
}

body { font-family: "Almarai", "IBM Plex Sans Arabic", Tahoma, sans-serif; -webkit-font-smoothing: antialiased; }
input, select, textarea, button { font-family: inherit; }

/* شريط الهوية أعلى الصفحة: كحلي ثم ذهبي */
body::before { content: ""; position: fixed; top: 0; inset-inline: 0; height: 4px; z-index: 30; pointer-events: none;
  background: linear-gradient(to right, var(--brand) 0 60%, var(--gold) 60% 100%); }

/* ---------- القائمة الجانبية ---------- */
.sidebar { background: var(--side-bg); color: var(--side-text); border-inline-end: 1px solid var(--side-line); }
.sidebar-brand { padding: 22px 16px 14px; border-bottom: 1px solid var(--side-line); }
.brand-logo { width: 112px; height: auto; margin: 0 auto 8px; }
.sidebar-product { color: var(--gold-text); font-size: .86rem; }
.nav-link { color: var(--side-text); }
.nav-link svg { color: var(--side-muted); }
.nav-link[aria-current="page"] { background: var(--side-active); color: var(--brand-text); border-inline-start-color: var(--gold); }
.nav-link[aria-current="page"] svg { color: var(--brand-text); }
.nav-link:focus-visible, .nav-project-title:focus-visible, .nav-sub-title:focus-visible { outline-color: var(--brand-text); }
.nav-count { background: var(--surface-2); color: var(--side-muted); }
.nav-alert { background: var(--gold); color: #fff; }
.nav-project + .nav-project { border-top-color: var(--side-line); }
.nav-project-title { color: var(--brand-text); }
.sidebar-user, .sidebar-foot { border-top-color: var(--side-line); }
.sidebar-user strong { color: var(--side-text); }
.scrim { background: rgba(0, 31, 63, .35); }

@media (max-width: 900px) {
  .sidebar.open { box-shadow: 0 0 32px rgba(0, 31, 63, .25); }
  .mobilebar { background: var(--side-bg); color: var(--side-text); border-bottom: 1px solid var(--side-line); padding: 8px 12px; margin-top: 4px; }
  .menu-btn { border-color: var(--side-line); color: var(--brand-text); }
  .menu-btn:focus-visible { outline-color: var(--brand-text); }
  .mobilebar-logo { height: 36px; width: auto; margin: 0; }
  .mobilebar-title { color: var(--brand-text); }
}

/* الشعار كحلي على خلفية شفافة: في الوضع الداكن يظهر أبيض */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo, :root:not([data-theme="light"]) .mobilebar-logo, :root:not([data-theme="light"]) .auth-logo { filter: brightness(0) invert(1); } }
:root[data-theme="dark"] .brand-logo, :root[data-theme="dark"] .mobilebar-logo, :root[data-theme="dark"] .auth-logo { filter: brightness(0) invert(1); }

/* ---------- البطاقات والأزرار ---------- */
.card, .role-card, .kpi, .table-wrap { border-radius: 16px; }
.btn.primary, .btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--brand-text); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- شاشة الدخول (قبل تسجيل الدخول تختفي القائمة) ---------- */
body.signed-out .sidebar, body.signed-out .mobilebar, body.signed-out .scrim { display: none; }
body.signed-out .content { max-width: none; min-height: 100vh; display: grid; place-items: center; padding: 48px 16px; }
body.signed-out .auth { width: 100%; max-width: 412px; margin: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 32px 30px 26px; box-shadow: 0 26px 60px rgba(0, 31, 63, .10); }
body.signed-out .auth .card { padding: 0; border: 0; box-shadow: none; background: none; margin-top: 18px; }
.auth-logo { display: block; width: 140px; height: auto; margin: 0 auto 18px; }
.auth h1 { color: var(--brand-text); font-size: 1.4rem; font-weight: 800; line-height: 1.5; }
.auth h1 span { color: var(--gold); }
body.signed-out .auth .btn.primary { width: 100%; min-height: 50px; font-size: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.link-btn { font: inherit; font-size: .8rem; background: none; border: 0; padding: 2px 0; color: var(--muted); text-decoration: underline; cursor: pointer; }
.link-btn:hover { color: var(--brand-text); }
.link-btn:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; border-radius: 4px; }
@media (max-width: 560px) { body.signed-out .auth { padding: 24px 20px 20px; border-radius: 16px; } }
