/* ==========================================================================================
   Shell — sidebar, header, content column, footer, the page header, and the sign-in frame.
   The console draws its own shell (classes `app-*`) instead of the template's `.pc-*` one: that
   one is laid out with physical left/right and mirrored by 1,300 override rules; this one is
   written once with logical properties and is the same sheet in English and Arabic.
   ========================================================================================== */

.app-shell { min-height: 100vh; }

/* ---- Sidebar ----------------------------------------------------------------------------- */
.app-sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 1040;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  color: var(--c-side-text); background: var(--c-side-bg);
  border-inline-end: 1px solid var(--c-side-border);
  transition: transform var(--t-med) var(--ease), visibility 0s linear 0s;
}
.app-sidebar :focus-visible { outline-color: var(--volt); }

.brand {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: var(--header-h); padding-inline: var(--s-5);
  color: #fff; font-weight: var(--fw-semibold); font-size: var(--fs-base); line-height: 1.3;
  text-decoration: none; flex-shrink: 0;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; flex-shrink: 0; display: block; }
.brand-name { min-width: 0; }

.side-nav { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-2) var(--s-3) var(--s-6); }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-caption {
  padding: var(--s-4) var(--s-3) 6px;
  color: var(--c-side-caption); font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1.3;
}
.side-nav li:first-child.side-caption { padding-block-start: var(--s-2); }
.side-link {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 40px; padding: 6px var(--s-3); margin-block: 1px;
  color: var(--c-side-text); font-weight: var(--fw-medium); line-height: 1.3;
  border-radius: var(--r-md); text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.side-link .ph { font-size: 1.25rem; color: var(--c-side-icon); flex-shrink: 0; transition: color var(--t-fast) var(--ease); }
.side-link:hover { color: #fff; background: var(--c-side-hover); text-decoration: none; }
.side-link:hover .ph { color: #fff; }
/* A count of things waiting behind an entry (approvals). Volt on ink: the one loud thing in the sidebar. */
.side-badge {
  margin-inline-start: auto; min-width: 22px; padding: 1px 7px;
  border-radius: var(--r-pill); background: var(--volt); color: #0b1f26;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); line-height: 1.5; text-align: center;
  font-variant-numeric: tabular-nums;
}
/* The current page: a filled pill, and a volt bar on the edge the line starts from. */
.side-link[aria-current="page"] { color: var(--c-side-active-text); background: var(--c-side-active); font-weight: var(--fw-semibold); }
.side-link[aria-current="page"] .ph { color: var(--volt); }
.side-link[aria-current="page"]::before {
  content: ""; position: absolute; inset-inline-start: 0; inset-block: 10px;
  width: 3px; background: var(--volt);
  border-start-end-radius: 3px; border-end-end-radius: 3px;
}
.side-foot {
  flex-shrink: 0; padding: var(--s-3) var(--s-5);
  color: var(--c-side-caption); font-size: var(--fs-xs);
  border-block-start: 1px solid var(--ink-750);
  display: flex; align-items: center; gap: var(--s-2);
}
.side-foot .ph { font-size: 1rem; }

.app-scrim { display: none; }

/* ---- Body column -------------------------------------------------------------------------- */
.app-body {
  min-height: 100vh; margin-inline-start: var(--sidebar-w);
  display: flex; flex-direction: column;
  transition: margin var(--t-med) var(--ease);
}
.app-shell.is-collapsed .app-sidebar { transform: translateX(-100%); visibility: hidden; transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med); }
[dir="rtl"] .app-shell.is-collapsed .app-sidebar { transform: translateX(100%); }
.app-shell.is-collapsed .app-body { margin-inline-start: 0; }

.app-header {
  position: sticky; inset-block-start: 0; z-index: 1020;
  height: var(--header-h); flex-shrink: 0;
  background: var(--c-surface); border-block-end: 1px solid var(--c-border);
}
.app-header-inner,
.app-content,
.app-footer-inner {
  width: 100%; max-width: calc(var(--content-max) + 2 * var(--gutter));
  margin-inline: auto; padding-inline: var(--gutter);
}
.app-header-inner { height: 100%; display: flex; align-items: center; gap: var(--s-2); }
.app-main { flex: 1; min-width: 0; }
.app-content { padding-block: var(--s-8) var(--s-12); }
.app-footer { flex-shrink: 0; border-block-start: 1px solid var(--c-border); }
.app-footer-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4);
  padding-block: var(--s-4); color: var(--c-muted); font-size: var(--fs-sm);
}
.app-footer-inner p { margin: 0; }

/* Header pieces */
.icon-btn {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 40px; height: 40px; padding: 0;
  color: var(--c-text-2); background: transparent; border: 0; border-radius: var(--r-md);
  font-size: 1.25rem; line-height: 1; cursor: pointer; text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { color: var(--c-text); background: var(--c-surface-3); text-decoration: none; }
.nav-toggle-mobile { display: none; }

.header-loc { display: flex; align-items: center; gap: var(--s-2); min-width: 0; margin-inline: var(--s-1) auto; color: var(--c-muted); font-size: var(--fs-base); }
.header-loc-group { white-space: nowrap; }
.header-loc-sep { font-size: 0.75rem; color: var(--c-placeholder); }
.header-loc-page { color: var(--c-text); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.header-actions { display: flex; align-items: center; gap: var(--s-1); margin-inline-start: auto; flex-shrink: 0; }
.header-divider { width: 1px; height: 24px; margin-inline: var(--s-2); background: var(--c-border); }
.lang-switch {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 40px; padding-inline: var(--s-3);
  color: var(--c-text-2); font-weight: var(--fw-medium); border-radius: var(--r-md); text-decoration: none; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.lang-switch .ph { font-size: 1.25rem; }
.lang-switch:hover { color: var(--c-text); background: var(--c-surface-3); text-decoration: none; }

.menu-wrap { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: var(--s-2);
  height: 44px; padding: 0; padding-inline: var(--s-1) var(--s-2);
  color: var(--c-text); background: transparent; border: 0; border-radius: var(--r-pill); cursor: pointer; text-align: start;
  transition: background-color var(--t-fast) var(--ease);
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--c-surface-3); }
.avatar {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 50%;
  color: var(--c-brand-text); background: var(--c-brand-tint); border: 1px solid var(--c-brand-tint-border);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); line-height: 1;
}
.user-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.user-name { font-weight: var(--fw-semibold); font-size: var(--fs-sm); white-space: nowrap; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--c-muted); font-size: var(--fs-xs); white-space: nowrap; }
.user-caret { font-size: 0.75rem; color: var(--c-muted); }
.role-chip {
  display: inline-flex; align-items: center;
  padding: 1px var(--s-2); border-radius: var(--r-pill);
  color: var(--c-brand-text); background: var(--c-brand-tint); border: 1px solid var(--c-brand-tint-border);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1.5; white-space: nowrap;
}

.menu {
  position: absolute; inset-block-start: calc(100% + var(--s-2)); inset-inline-end: 0; z-index: 1050;
  min-width: 248px; padding: var(--s-2);
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--e-3);
}
.menu[hidden] { display: none; }
.menu-head { padding: var(--s-2) var(--s-3) var(--s-3); display: grid; gap: var(--s-1); justify-items: start; }
.menu-head-name { font-weight: var(--fw-semibold); color: var(--c-text); overflow-wrap: anywhere; }
.menu-head-sub { color: var(--c-muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.menu-sep { height: 1px; margin: var(--s-1) calc(-1 * var(--s-2)) var(--s-2); background: var(--c-border); }
.menu-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  min-height: 40px; padding: var(--s-2) var(--s-3);
  color: var(--c-text); background: transparent; border: 0; border-radius: var(--r-md);
  font: inherit; font-weight: var(--fw-medium); text-align: start; text-decoration: none; cursor: pointer;
  transition: background-color var(--t-fast) var(--ease);
}
.menu-item .ph { font-size: 1.125rem; color: var(--c-muted); }
.menu-item:hover { background: var(--c-surface-3); color: var(--c-text); text-decoration: none; }

.env-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px var(--s-2); border-radius: var(--r-pill);
  color: var(--c-neutral-text); background: var(--c-neutral-tint); border: 1px solid var(--c-neutral-border);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1.5; white-space: nowrap;
}

/* ---- Page header: the one pattern every page opens with ------------------------------------ */
.page-head { margin-block-end: var(--s-6); }
.page-trail { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); margin: 0 0 var(--s-2); padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--c-muted); }
.page-trail li { display: inline-flex; align-items: center; gap: var(--s-2); }
.page-trail a { display: inline-flex; align-items: center; gap: 6px; color: var(--c-muted); font-weight: var(--fw-medium); border-radius: var(--r-xs); }
.page-trail a:hover { color: var(--c-brand-text); text-decoration: none; }
.page-trail .ph { font-size: 0.875rem; }
.page-trail li + li::before { content: "/"; color: var(--c-border-strong); }
.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-3) var(--s-6); }
.page-head-text { min-width: 0; flex: 1 1 320px; }
.page-title { margin: 0; font-size: var(--fs-xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight); overflow-wrap: anywhere; }
.page-intro { margin: var(--s-1) 0 0; max-width: 88ch; color: var(--c-muted); font-size: var(--fs-base); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); flex-shrink: 0; }
/* A page that still writes its intro as the paragraph after the header gets the same look. */
.page-head + p.text-muted { max-width: 72ch; margin-block: calc(-1 * var(--s-4)) var(--s-6); }

/* The fixtures banner: loud on purpose — every figure under it is made up. */
.banner-mocked {
  display: flex; align-items: center; gap: var(--s-3);
  margin-block-end: var(--s-6); padding: var(--s-3) var(--s-4);
  color: var(--c-warn-text); background: var(--c-warn-tint);
  border: 1px dashed var(--c-warn); border-radius: var(--r-lg); font-weight: var(--fw-medium);
}

/* ---- Sign-in and "not found": the frame outside the console ------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--c-surface); }
.auth-brand {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--s-10);
  padding: var(--s-10) clamp(var(--s-6), 5vw, 72px);
  color: #fff; background: var(--ink-900);
}
/* A faint survey grid, fading out: infrastructure drawn, not decorated. */
.auth-brand::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: linear-gradient(var(--ink-800) 1px, transparent 1px), linear-gradient(90deg, var(--ink-800) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 65%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 65%, transparent);
}
.auth-brand .brand { min-height: 0; padding: 0; font-size: var(--fs-md); }
.auth-tagline { margin: 0; max-width: 15em; font-size: clamp(1.625rem, 2.6vw, var(--fs-3xl)); font-weight: var(--fw-semibold); line-height: 1.25; color: #fff; }
html:lang(ar) .auth-tagline { line-height: 1.5; }
.auth-tagline::before { content: ""; display: block; width: 48px; height: 4px; margin-block-end: var(--s-6); background: var(--volt); border-radius: var(--r-pill); }
.auth-brand-foot { color: var(--c-side-caption); font-size: var(--fs-sm); }
.auth-env { display: none; }
.auth-panel { display: flex; flex-direction: column; padding: var(--s-6) clamp(var(--s-5), 5vw, 72px) var(--s-10); }
.auth-panel-top { display: flex; justify-content: flex-end; min-height: 40px; }
.auth-panel-body { flex: 1; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 400px; margin-inline: auto; }
.auth-title { margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-xl); }
.auth-sub { color: var(--c-muted); margin: 0 0 var(--s-6); }
.auth-panel .btn-lg { width: 100%; }
.auth-solo { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6); background: var(--c-page); }
.auth-solo-card { width: 100%; max-width: 440px; padding: var(--s-10) var(--s-8); text-align: center; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-xl); box-shadow: var(--e-2); }
.auth-solo-card .brand-mark { margin-inline: auto; margin-block-end: var(--s-5); }

/* ---- Narrower screens ---------------------------------------------------------------------- */
@media (max-width: 1199.98px) {
  :root { --gutter: 24px; }
}
@media (max-width: 991.98px) {
  /* The sidebar becomes a drawer over the page; the page keeps the full width. */
  .app-body, .app-shell.is-collapsed .app-body { margin-inline-start: 0; }
  .app-sidebar,
  .app-shell.is-collapsed .app-sidebar { transform: translateX(-100%); visibility: hidden; box-shadow: none; transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med); }
  [dir="rtl"] .app-sidebar,
  [dir="rtl"] .app-shell.is-collapsed .app-sidebar { transform: translateX(100%); }
  .app-shell.is-nav-open .app-sidebar,
  [dir="rtl"] .app-shell.is-nav-open .app-sidebar { transform: none; visibility: visible; box-shadow: var(--e-3); transition: transform var(--t-med) var(--ease), visibility 0s linear 0s; }
  .app-shell.is-nav-open .app-scrim { display: block; position: fixed; inset: 0; z-index: 1035; background: var(--c-scrim); border: 0; padding: 0; width: 100%; cursor: default; }
  .nav-toggle-desktop { display: none; }
  .nav-toggle-mobile { display: inline-grid; }
  .header-loc-group, .header-loc-sep { display: none; }
  .user-id, .user-caret { display: none; }
  .user-btn { padding-inline: var(--s-1); }
  .header-divider { display: none; }
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding-block: var(--s-6); gap: var(--s-6); }
  .auth-brand-foot { display: none; }
  .auth-env { display: block; }
  .auth-tagline { font-size: 1.375rem; }
  .auth-tagline::before { margin-block-end: var(--s-4); }
}
@media (max-width: 575.98px) {
  :root { --gutter: 16px; --header-h: 56px; }
  .app-content { padding-block: var(--s-5) var(--s-10); }
  .lang-switch { padding-inline: var(--s-2); }
  .lang-switch .ph { display: none; }
  .page-title { font-size: 1.3125rem; }
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1 1 auto; }
  .header-actions { gap: 0; }
}
