/* ==========================================================================
   shell.css : reset, page frame, top bar, module switcher, sidebar, footer.
   Written left to right first, then mirrored for Arabic with [dir="rtl"].

   Second revision. One light top bar replaces the old stacked pair of dark
   navy bars, and the sidebar is now light with a hairline border. The
   module bar is gone: module switching lives in a single control in the
   top bar, which removes a whole band of competing links from every page.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-14);
  line-height: 1.55;
  color: var(--tx-body);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html[lang="ar"] body { font-family: var(--font-ar); font-size: var(--fs-15); }
h1, h2, h3, h4, h5 { margin: 0; color: var(--tx-strong); font-weight: var(--fw-semi); line-height: 1.3; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--tx-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: var(--r-sm); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Frame --------------------------------------------------------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.app-body { flex: 1; display: flex; min-height: 0; }

/* ---- Top bar -------------------------------------------------------------
   White, one hairline at the bottom, no shadow until the page scrolls. */
.topbar {
  height: var(--h-topbar);
  background: var(--bg-chrome);
  color: var(--tx-body);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-5);
  position: sticky; top: 0; z-index: 60;
  border-bottom: 1px solid var(--line-soft);
  transition: box-shadow var(--dur) var(--ease);
}
.topbar.is-scrolled { box-shadow: var(--sh-2); }

/* Every control in the bar holds its size. Without this they shrink to fit
   and the assistant button collapses to its icon on a wide screen. */
.topbar > * { flex: none; }
.topbar-brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; text-decoration: none; color: inherit; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand .mark {
  width: 36px; height: 36px; flex: none; border-radius: var(--r-md);
  background: var(--nsr-navy-700); color: #fff; overflow: hidden;
  display: grid; place-items: center; font-size: 15px; font-weight: var(--fw-bold);
  letter-spacing: -.3px;
}
.topbar-brand .wordmark { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-brand .wordmark b { font-size: var(--fs-14); font-weight: var(--fw-semi); color: var(--tx-strong); letter-spacing: -.1px; }
.topbar-brand .wordmark span { font-size: var(--fs-11); color: var(--tx-muted); }

.topbar-sep { width: 1px; height: 26px; background: var(--line-soft); flex: none; margin: 0 var(--sp-1); }
.topbar-spacer { flex: 1 1 auto; }

/* Module switcher trigger: the single way to move between modules. */
.tb-modules {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 38px; padding: 0 var(--sp-3);
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--r-md); cursor: pointer;
  font-size: var(--fs-13); font-weight: var(--fw-med); color: var(--tx-strong);
  white-space: nowrap; max-width: 260px;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tb-modules:hover { background: var(--ac-050); border-color: var(--ac-300); color: var(--ac-700); }
.tb-modules .m-ic { font-size: 18px; line-height: 1; }
.tb-modules .m-name { overflow: hidden; text-overflow: ellipsis; }
.tb-modules .m-caret { color: var(--tx-faint); font-size: 10px; }

.topbar-search { position: relative; flex: 0 1 340px !important; min-width: 150px; }
.topbar-search input {
  width: 100%; height: 36px; padding: 0 var(--sp-3) 0 34px;
  background: var(--bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--r-md); color: var(--tx-strong); font-size: var(--fs-13);
}
[dir="rtl"] .topbar-search input { padding: 0 34px 0 var(--sp-3); }
.topbar-search input::placeholder { color: var(--tx-faint); }
.topbar-search input:focus {
  background: var(--bg-surface); border-color: var(--ac-500); outline: none;
  box-shadow: var(--sh-focus);
}
.topbar-search .ico {
  position: absolute; inset-inline-start: 11px; top: 9px; opacity: .45; pointer-events: none;
  font-size: 13px;
}

.tb-btn {
  height: 38px; min-width: 38px; padding: 0 var(--sp-3); font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  background: transparent; color: var(--tx-body);
  border: 1px solid transparent;
  border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-13);
  transition: background var(--dur-fast) var(--ease);
  white-space: nowrap; position: relative;
}
.tb-btn:hover { background: var(--bg-hover); }
.tb-btn.is-on { background: var(--ac-050); border-color: var(--ac-300); color: var(--ac-700); font-weight: var(--fw-med); }
.tb-btn.outline { border-color: var(--line); }
.tb-btn.copilot {
  background: var(--ac-600); color: #fff; border-color: var(--ac-600);
  font-weight: var(--fw-med); padding: 0 var(--sp-4);
}
.tb-btn.copilot:hover { background: var(--ac-700); }
.tb-btn .badge-dot {
  position: absolute; top: 6px; inset-inline-end: 6px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--crit-500);
  box-shadow: 0 0 0 2px var(--bg-chrome);
}

.tb-user {
  display: flex; align-items: center; gap: var(--sp-2); cursor: pointer;
  padding: var(--sp-1) var(--sp-2); border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent;
}
.tb-user:hover { background: var(--bg-hover); }
.tb-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--ac-100); color: var(--ac-700);
  display: grid; place-items: center; font-size: var(--fs-12); font-weight: var(--fw-semi);
}
.tb-user .who { line-height: 1.25; text-align: start; }
.tb-user .who b { display: block; font-size: var(--fs-13); font-weight: var(--fw-med); color: var(--tx-strong); }
.tb-user .who span { font-size: var(--fs-11); color: var(--tx-muted); }

/* ---- Module switcher panel ---------------------------------------------- */
.switcher {
  position: fixed; inset: 0; z-index: 200; display: none;
  background: var(--bg-overlay);
}
.switcher.open { display: block; }
.switcher-panel {
  position: absolute; top: calc(var(--h-topbar) + 8px);
  inset-inline-start: var(--sp-5); inset-inline-end: var(--sp-5);
  max-width: 1120px; margin-inline: auto;
  background: var(--bg-surface); border-radius: var(--r-xl);
  border: 1px solid var(--line-soft);
  box-shadow: var(--sh-4); padding: var(--sp-6); max-height: 80vh; overflow: auto;
}
.switcher-panel h4 {
  font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .8px;
  color: var(--tx-faint); margin: var(--sp-5) 0 var(--sp-3); font-weight: var(--fw-semi);
}
.switcher-panel h4:first-child { margin-top: 0; }
.switcher-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--sp-2); }
.sw-card {
  display: flex; gap: var(--sp-3); align-items: center;
  padding: var(--sp-3); border: 1px solid transparent;
  border-radius: var(--r-lg); background: transparent;
  text-decoration: none; color: inherit;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.sw-card:hover { border-color: var(--line-soft); background: var(--bg-sunken); text-decoration: none; }
.sw-card.current { border-color: var(--ac-300); background: var(--ac-050); }
.sw-card .ic {
  width: 42px; height: 42px; flex: none; border-radius: var(--r-md);
  display: grid; place-items: center; font-size: 21px;
  background: var(--bg-sunken); border: 1px solid var(--line-hair);
}
.sw-card.current .ic { background: #fff; border-color: var(--ac-300); }
.sw-card b { display: block; font-size: var(--fs-13); color: var(--tx-strong); font-weight: var(--fw-semi); }
.sw-card span { display: block; font-size: var(--fs-11); color: var(--tx-muted); margin-top: 1px; line-height: 1.35; }

/* ---- Sidebar -------------------------------------------------------------
   Light, hairline separated, quiet. Active item reads through weight and a
   tinted ground rather than a saturated block of colour. */
.sidebar {
  width: var(--w-sidebar); flex: none; background: var(--bg-sidebar);
  color: var(--tx-body); display: flex; flex-direction: column;
  position: sticky; top: var(--h-topbar);
  height: calc(100vh - var(--h-topbar));
  overflow-y: auto;
  border-inline-end: 1px solid var(--line-soft);
  transition: width var(--dur) var(--ease);
}
.sidebar.collapsed { width: var(--w-sidebar-collapsed); }
.sidebar.collapsed .sb-text, .sidebar.collapsed .sb-group-title,
.sidebar.collapsed .sb-head .sb-sub, .sidebar.collapsed .sb-count { display: none; }
.sidebar.collapsed .sb-head { padding: var(--sp-3) 0; text-align: center; }
.sidebar.collapsed .sb-item { justify-content: center; padding: 9px 0; }

.sb-head { padding: var(--sp-5) var(--sp-4) var(--sp-4); }
.sb-head h3 { font-size: var(--fs-15); color: var(--tx-strong); letter-spacing: -.1px; }
.sb-head .sb-sub { margin: 3px 0 0; font-size: var(--fs-11); color: var(--tx-muted); line-height: 1.4; }
.sb-nav { padding: 0 var(--sp-2) var(--sp-6); }
.sb-group-title {
  font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .8px;
  color: var(--tx-faint); padding: var(--sp-4) var(--sp-3) var(--sp-2);
  font-weight: var(--fw-semi);
}
.sb-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 7px var(--sp-3); border-radius: var(--r-md);
  color: var(--tx-body); font-size: var(--fs-13); text-decoration: none;
  margin-bottom: 1px; position: relative;
  transition: background var(--dur-fast) var(--ease);
}
.sb-item:hover { background: var(--bg-hover); color: var(--tx-strong); text-decoration: none; }
.sb-item.active {
  background: var(--ac-050); color: var(--ac-700); font-weight: var(--fw-semi);
}
.sb-item .ic {
  width: 26px; height: 26px; flex: none; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: 15px; line-height: 1;
  background: var(--bg-sunken); transition: background var(--dur-fast) var(--ease);
}
.sb-item:hover .ic { background: var(--line-hair); }
.sb-item.active .ic { background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.10); }
.sb-item .sb-count {
  margin-inline-start: auto; font-size: var(--fs-11); background: var(--bg-sunken);
  color: var(--tx-muted); border: 1px solid var(--line-hair);
  padding: 0 6px; border-radius: var(--r-pill); font-variant-numeric: tabular-nums;
  line-height: 17px;
}
.sb-item .sb-count.alert { background: var(--crit-050); color: var(--crit-700); border-color: var(--crit-100); font-weight: var(--fw-semi); }
.sb-foot { margin-top: auto; padding: var(--sp-3); border-top: 1px solid var(--line-soft); }
.sb-collapse {
  width: 100%; background: transparent; border: 1px solid var(--line-soft); color: var(--tx-muted);
  padding: 6px; border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-12);
}
.sb-collapse:hover { background: var(--bg-hover); color: var(--tx-strong); }

/* ---- Main ----------------------------------------------------------------
   More room around the content. A page should breathe. */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-inner {
  flex: 1; padding: var(--sp-6) var(--sp-7) var(--sp-10);
  max-width: var(--w-content-max); width: 100%;
}

.crumbs {
  display: flex; align-items: center; gap: 6px; font-size: var(--fs-12);
  color: var(--tx-faint); margin-bottom: var(--sp-2); flex-wrap: wrap;
}
.crumbs a { color: var(--tx-muted); }
.crumbs a:hover { color: var(--tx-link); }
.crumbs .sep { opacity: .55; }

.page-head {
  display: flex; align-items: flex-start; gap: var(--sp-5);
  margin-bottom: var(--sp-5); flex-wrap: wrap;
}

/* ---- Object header -------------------------------------------------------
   On a record page the title block and the identity facts are drawn as one
   card rather than two stacked ones. UI.hoistObjectHeader moves the facts
   in and adds this class. */
.page-head.has-object {
  background: var(--bg-surface); box-shadow: var(--sh-card);
  border-radius: var(--r-lg); border-inline-start: 4px solid var(--ac-600);
  padding: var(--sp-4) var(--sp-5); gap: var(--sp-4);
  align-items: center; margin-bottom: var(--sp-4);
}
.page-head.has-object h1 { font-size: var(--fs-20); display: inline; margin-inline-end: var(--sp-2); }
.page-head.has-object .ph-main > .pill { vertical-align: 3px; }
.page-head.has-object .ph-sub {
  margin-top: 5px; font-size: var(--fs-13); max-width: 96ch;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.page-head.has-object .ph-actions { padding-top: 0; }
/* The facts run full width on their own row, under a hairline. */
.page-head.has-object .ident-strip {
  flex: 0 0 100%; background: none; box-shadow: none; border: 0;
  border-radius: 0; padding: var(--sp-3) 0 0; margin: 0;
  border-top: 1px solid var(--line-hair);
}
.page-head.has-object .ident-strip .is-top { margin-bottom: 0; }
.page-head.has-object .ident-strip .is-top .is-doc { margin-inline-end: var(--sp-4); }
/* The document number joins the fact row rather than sitting above it. */
.page-head.has-object .ident-strip .is-top,
.page-head.has-object .ident-strip .is-grid { display: inline-flex; flex-wrap: wrap; vertical-align: top; }
.page-head.has-object .ident-strip .is-grid .is-cell:first-child {
  padding-inline-start: var(--sp-4); border-inline-start: 1px solid var(--line-hair);
}
/* The explanation stays, but on a record page one line of it is enough on
   screen. The full sentence is kept as the element's title. */
.page-head.has-object .ph-sub { -webkit-line-clamp: 1; }

/* Figures inside the header lose their card and are divided by hairlines,
   so a row of four reads as part of the object rather than as four more
   floating tiles below it. */
.page-head.has-figures .metrics {
  flex: 0 0 100%; margin: var(--sp-3) 0 0; gap: 0;
  border-top: 1px solid var(--line-hair); padding-top: var(--sp-3);
}
.page-head.has-figures .metrics .kpi {
  box-shadow: none; background: none; border-radius: 0; min-height: 0;
  padding: 0 var(--sp-5); border-inline-end: 1px solid var(--line-hair);
}
.page-head.has-figures .metrics .kpi:first-child { padding-inline-start: 0; }
.page-head.has-figures .metrics .kpi:last-child { border-inline-end: 0; }
.page-head.has-figures .metrics .kpi .k-value { font-size: var(--fs-20); margin-top: 2px; line-height: 1.2; }
/* The supporting sentence is dropped in the compact header. It stays in the
   markup for the pages that show figures as full cards further down. */
.page-head.has-figures .metrics .kpi .k-sub { display: none; }
.page-head.has-figures .metrics .kpi .k-label { font-size: 10px; letter-spacing: .6px; }
.page-head.has-figures .metrics .kpi.lead::before { display: none; }
.page-head.has-figures .metrics .kpi .k-open,
.page-head.has-figures .metrics .kpi .k-spark { display: none; }
@media (max-width: 760px) {
  .page-head.has-figures .metrics .kpi {
    padding-inline: 0; border-inline-end: 0; border-bottom: 1px solid var(--line-hair);
    padding-block: var(--sp-2);
  }
}
.page-head .ph-main { flex: 1; min-width: 280px; }
.page-head h1 { font-size: var(--fs-26); letter-spacing: -.4px; font-weight: var(--fw-semi); }
.page-head .ph-sub {
  margin: var(--sp-2) 0 0; color: var(--tx-muted); font-size: var(--fs-14);
  max-width: 76ch; line-height: 1.6;
}
.page-head .ph-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; padding-top: 3px; }

.app-foot {
  padding: var(--sp-5) var(--sp-7); border-top: 1px solid var(--line-soft);
  color: var(--tx-faint); font-size: var(--fs-11);
  display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  background: var(--bg-surface);
}

/* ---- Right hand utility rails ------------------------------------------- */
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: 440px; max-width: 94vw;
  background: var(--bg-surface); box-shadow: var(--sh-4); z-index: 300;
  transform: translateX(100%); transition: transform var(--dur-slow) var(--ease);
  display: flex; flex-direction: column;
}
[dir="rtl"] .drawer { transform: translateX(-100%); }
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: var(--sp-3);
}
.drawer-head h3 { flex: 1; font-size: var(--fs-16); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.drawer-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line-soft); background: var(--bg-sunken); }

.scrim { position: fixed; inset: 0; background: var(--bg-overlay); z-index: 290; display: none; }
.scrim.open { display: block; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1180px) {
  .sidebar { position: fixed; z-index: 250; transform: translateX(-100%); box-shadow: var(--sh-3); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .topbar-search { flex-basis: 200px; }
  .main-inner { padding: var(--sp-5) var(--sp-5) var(--sp-9); }
}
@media (max-width: 860px) {
  .topbar-search { display: none; }
  .tb-btn .tb-label { display: none; }
  .tb-user .who { display: none; }
  .topbar-brand .wordmark { display: none; }
  .tb-modules { max-width: 160px; }
}
@media (max-width: 640px) {
  .main-inner { padding: var(--sp-4) var(--sp-4) var(--sp-8); }
  .page-head h1 { font-size: var(--fs-22); }
}
