/* Orvia 11.83 (work package 1) — the shared page patterns' look (design/patterns.js). Tokens only (tokens.css), so the
   console and the back office draw them alike in light and dark; logical properties only, so Arabic mirrors itself. */

/* ------------------------------------------------------------------ trail and ‹ Up (the console has no components.css) */
.o-trail { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1); margin: 0 0 var(--sp-1); padding: 0;
  background: none; border: 0; font: var(--type-small); color: var(--text-muted); }
.o-trail a { color: var(--text-secondary); text-decoration: none; min-block-size: 24px; display: inline-flex; align-items: center; }
.o-trail a:is(:hover, :focus-visible) { color: var(--text); text-decoration: underline; }
.o-up__chev { display: inline-flex; }
.o-picon { display: inline-block; line-height: 1; }
[dir="rtl"] .o-picon--flip { transform: scaleX(-1); }
.o-phead .o-up, .sh-uprow .o-up { display: inline-flex; align-items: center; gap: var(--sp-1); min-block-size: 28px; padding-inline-end: var(--sp-2);
  font: var(--type-small); font-weight: var(--fw-semibold); color: var(--text-secondary); text-decoration: none; max-inline-size: 100%; }
.o-phead .o-up--phone { display: none; }
@media (max-width: 720px) {
  .o-phead .o-up--phone { display: inline-flex; }
  .o-phead .o-up, .sh-uprow .o-up { min-block-size: 44px; }
  /* On a phone the trail gives way to ‹ Up and the title (model §1, "Where am I") — on every page header of both apps */
  .o-phead .o-trail, .o-wshead > .o-trail, .o-rechead > .o-trail { display: none; }
}

/* ------------------------------------------------------------------ the scope line */
.o-scope { display: inline-flex; align-items: center; gap: var(--sp-1); font: var(--type-label); color: var(--text-muted); }
.o-scope .o-icon { inline-size: 14px; block-size: 14px; }
.o-scope__place bdi { unicode-bidi: isolate; }

/* ------------------------------------------------------------------ the page header */
.o-phead { display: grid; gap: var(--sp-2); margin-block-end: var(--sp-4); }
.o-phead__top { display: flex; align-items: flex-start; gap: var(--sp-4); }
.o-phead__titles { flex: 1 1 auto; min-inline-size: 0; }
.o-phead__titlerow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.o-phead__title { font: var(--type-page); letter-spacing: -.01em; margin: 0; overflow-wrap: anywhere; color: var(--text); }
.o-phead__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-1); margin: var(--sp-1) 0 0; font: var(--type-small); color: var(--text-muted); }
.o-phead__dot { color: var(--text-muted); }
.o-phead__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: flex-end; flex: 0 1 auto; max-inline-size: 60%; }
@media (max-width: 720px) {
  .o-phead__top { flex-wrap: wrap; }
  .o-phead__actions { max-inline-size: none; flex: 1 1 100%; justify-content: flex-start; }
}
.o-pstatus { display: inline-flex; align-items: center; min-block-size: 22px; padding: 0 var(--sp-2); border-radius: var(--radius-pill);
  font: var(--type-label); color: var(--text-secondary); background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.o-pstatus[data-tone="success"] { color: var(--success-text); background: color-mix(in srgb, var(--success-text) 12%, var(--surface)); border-color: color-mix(in srgb, var(--success-text) 30%, var(--surface)); }
.o-pstatus[data-tone="warning"] { color: var(--warning-text); background: color-mix(in srgb, var(--warning-text) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warning-text) 30%, var(--surface)); }
.o-pstatus[data-tone="danger"] { color: var(--danger-text); background: color-mix(in srgb, var(--danger-text) 12%, var(--surface)); border-color: color-mix(in srgb, var(--danger-text) 30%, var(--surface)); }
.o-pstatus[data-tone="info"] { color: var(--info-text); background: color-mix(in srgb, var(--info-text) 12%, var(--surface)); border-color: color-mix(in srgb, var(--info-text) 30%, var(--surface)); }

/* Buttons of the patterns: 40 px on a desktop, 44 px wherever the pointer is a finger (WCAG 2.5.8 asks 24). */
.o-pbtn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1); min-block-size: var(--control-md); padding: 0 var(--sp-3);
  border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: var(--type-body-strong); text-decoration: none; cursor: pointer; white-space: nowrap; }
.o-pbtn:hover { background: var(--surface-2); }
.o-pbtn:focus-visible, .o-ptab:focus-visible, .o-lrow__main:focus-visible, .o-trail a:focus-visible, .o-pmore__item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; box-shadow: var(--focus-ring); }
.o-pbtn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.o-pbtn--primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.o-pbtn--quiet { border-color: transparent; background: none; color: var(--link, var(--brand)); }
.o-pbtn--sm { min-block-size: var(--control-sm); padding: 0 var(--sp-2); font: var(--type-small); font-weight: var(--fw-semibold); }
@media (pointer: coarse) { .o-pbtn, .o-pbtn--sm { min-block-size: 44px; } }
.o-pmore { position: relative; display: inline-flex; }
.o-pmore__menu { position: absolute; inset-block-start: calc(100% + 4px); inset-inline-end: 0; z-index: var(--z-menu); display: grid; min-inline-size: 200px;
  padding: var(--sp-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--elev-2); }
.o-pmore__menu[hidden] { display: none; }
.o-pmore__item { min-block-size: 40px; padding: 0 var(--sp-3); border: 0; background: none; color: var(--text); text-align: start; font: var(--type-body); border-radius: var(--radius-sm); cursor: pointer; }
.o-pmore__item:hover { background: var(--surface-2); }
.o-pmore__item--danger { color: var(--danger-text); }
@media (pointer: coarse) { .o-pmore__item { min-block-size: 44px; } }
.o-ptabs { display: flex; gap: var(--sp-1); overflow-x: auto; border-block-end: 1px solid var(--border); scrollbar-width: none; }
.o-ptab { display: inline-flex; align-items: center; min-block-size: 40px; padding: 0 var(--sp-3); color: var(--text-secondary); text-decoration: none;
  font: var(--type-body-strong); border-block-end: 2px solid transparent; white-space: nowrap; }
.o-ptab[aria-current="page"] { color: var(--text); border-block-end-color: var(--brand); }
@media (pointer: coarse) { .o-ptab { min-block-size: 44px; } }

/* ------------------------------------------------------------------ list and detail: one two-line row at every width */
.o-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.o-lrow + .o-lrow { border-block-start: 1px solid var(--border); }
.o-lrow__main { display: flex; align-items: center; gap: var(--sp-3); inline-size: 100%; min-block-size: 40px; padding: var(--sp-1) var(--sp-3);
  background: none; border: 0; color: var(--text); text-decoration: none; text-align: start; font: var(--type-body); cursor: pointer; }
.o-lrow__main:hover { background: var(--surface-2); }
@media (pointer: coarse), (max-width: 720px) { .o-lrow__main { min-block-size: 56px; } }
.o-lrow__text { display: grid; flex: 1 1 auto; min-inline-size: 0; }
.o-lrow__title { font: var(--type-body-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-lrow__code { font: var(--type-small); color: var(--text-muted); }
.o-lrow__sub { font: var(--type-small); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-lrow__aside { display: inline-flex; align-items: center; gap: var(--sp-2); flex: 0 0 auto; font: var(--type-small); color: var(--text-secondary); }

/* ------------------------------------------------------------------ the setting row */
.o-setrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what act" "facts facts" "why why";
  align-items: start; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) 0; border-block-end: 1px solid var(--border); }
.o-setrow__what { grid-area: what; min-inline-size: 0; }
.o-setrow__facts { grid-area: facts; }
.o-setrow__act { grid-area: act; }
.o-setrow__why { grid-area: why; }
.o-setrow__name { font: var(--type-body-strong); color: var(--text); }
.o-setrow__help { font: var(--type-small); color: var(--text-muted); margin-block-start: 2px; }
.o-setrow__facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); margin: 0; padding: var(--sp-2); border-radius: var(--radius-sm); background: var(--surface-2); }
.o-setrow__facts dt { font: var(--type-label); color: var(--text-muted); margin: 0; }
.o-setrow__facts dd { margin: 0; font: var(--type-body); color: var(--text); overflow-wrap: anywhere; }
.o-setrow__value { font-weight: var(--fw-semibold); }
.o-setrow__source { color: var(--text-secondary); }
.o-setrow__act { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: flex-end; }
.o-setrow__lock { display: inline-flex; align-items: center; gap: var(--sp-1); font: var(--type-label); color: var(--text-secondary); }
.o-setrow__why { margin: 0; font: var(--type-small); color: var(--text-secondary); }
.o-setrow--locked .o-setrow__value { color: var(--text-secondary); }
.o-setrow--changed { box-shadow: inset 3px 0 0 var(--brand); padding-inline-start: var(--sp-2); }
[dir="rtl"] .o-setrow--changed { box-shadow: inset -3px 0 0 var(--brand); }
.o-pinput { min-block-size: var(--control-md); padding: 0 var(--sp-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: var(--type-body); min-inline-size: 0; inline-size: 14em; max-inline-size: 100%; }
@media (max-width: 720px) {
  .o-setrow { grid-template-columns: minmax(0, 1fr); grid-template-areas: "what" "facts" "why" "act"; }
  .o-setrow__act { justify-content: flex-start; }
}

/* ------------------------------------------------------------------ empty, error and not-found states */
.o-pstate { display: grid; justify-items: center; gap: var(--sp-2); padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--text); }
.o-pstate__icon { color: var(--text-muted); font-size: 24px; }
.o-pstate__icon .o-icon { inline-size: 32px; block-size: 32px; }
.o-pstate__title { font: var(--type-section); margin: 0; color: var(--text); }
.o-pstate__text { font: var(--type-body); color: var(--text-secondary); margin: 0; max-inline-size: 52ch; }
.o-pstate__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; margin-block-start: var(--sp-2); }
.o-pstate[data-state="error"] .o-pstate__icon { color: var(--danger-text); }

/* ------------------------------------------------------------------ Undo */
.o-undo { position: fixed; inset-inline: var(--sp-4); inset-block-end: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px) + var(--ws-tabbar-h, 0px)); z-index: var(--z-toast);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); max-inline-size: 520px; margin-inline: auto;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-md); background: var(--inverse-surface); color: var(--inverse-text); box-shadow: var(--elev-3); }
.o-undo[hidden] { display: none; }
.o-undo .o-pbtn { background: none; color: var(--inverse-text); border-color: color-mix(in srgb, var(--inverse-text) 50%, transparent); }

/* ------------------------------------------------------------------ the frame (design/shell.js frame())
   The context chip: the company and the branch read as one chip, "Company · Branch ▾", cut at its END in either
   language. The top-bar Search field and the Needs you entry. */
.o-ctxchip { display: inline-flex; align-items: center; gap: 0; flex: 0 1 auto; min-inline-size: min(36vw, 26ch); max-inline-size: min(46vw, 420px);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface); overflow: hidden; }
/* inside the chip the two pickers share its width (admin.html gives each 16–32ch on its own) */
.o-ctxchip > select { flex: 0 1 auto !important; min-inline-size: 100px !important; max-inline-size: 24ch !important; }
.o-ctxchip select { border: 0 !important; background-color: transparent !important; min-inline-size: 0; max-inline-size: 22ch; text-overflow: ellipsis;
  border-radius: 0 !important; box-shadow: none !important; margin: 0 !important; }
.o-ctxchip select:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.o-ctxchip select[hidden] { display: none; }
.o-ctxchip__sep { color: var(--text-muted); padding: 0 2px; }
.o-ctxchip__sep[hidden] { display: none; }
.o-topsearch { display: inline-flex; align-items: center; align-self: center; gap: var(--sp-2); min-block-size: 36px; flex: 0 3 auto; min-inline-size: 44px; inline-size: clamp(140px, 20vw, 300px);
  padding: 0 var(--sp-3); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface-2);
  color: var(--text-muted); font: var(--type-small); cursor: text; text-align: start; }
.o-topsearch:hover { border-color: var(--brand); }
.o-topsearch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.o-topsearch__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-inline-size: 0; }
@media (max-width: 1440px) { .o-topsearch__key { display: none; } }
.o-topsearch__key { font: var(--type-label); color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 4px; }
.o-needsbtn { position: relative; display: inline-flex; align-items: center; align-self: center; flex: 0 0 auto; gap: var(--sp-1); min-block-size: 36px; padding: 0 var(--sp-3); border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); text-decoration: none; font: var(--type-small); font-weight: var(--fw-semibold); white-space: nowrap; }
/* the count said aloud: in the link's own text (no aria-label that differs from the visible name), never drawn */
.o-needsbtn__sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.o-needsbtn:hover { background: var(--surface-2); }
.o-needsbtn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.o-needsbtn[aria-current="page"] { border-color: var(--brand); color: var(--brand-strong); }
.o-needsbtn__n { min-inline-size: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--danger-text); color: var(--surface); font: var(--type-label); text-align: center; }
.o-needsbtn__n[hidden] { display: none; }
@media (pointer: coarse) { .o-topsearch, .o-needsbtn { min-block-size: 44px; } }
@media (max-width: 720px) {
  /* The phone keeps its bottom bar (Home · Needs you · Search · Menu): the top bar carries the chip, not these two. */
  .o-topsearch, .o-needsbtn { display: none; }
  .o-ctxchip { max-inline-size: 58vw; }
}
@media (min-width: 721px) and (max-width: 1179px) {
  .o-topsearch { inline-size: 44px; padding: 0; justify-content: center; }
  .o-topsearch__text, .o-topsearch__key { display: none; }
  /* a tablet's bar keeps Needs you as its icon and count; its words stay its name (aria-label), as Security and Sign out do */
  .o-needsbtn { padding: 0 var(--sp-2); }
  .o-needsbtn__l { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
/* The back office's bar: on a phone the chip takes the row under the bar that the two pickers shared (admin.html 11.43.0) */
html[data-ctxchip] .admin-header .ctxlab { display: none !important; }
@media (max-width: 720px) {
  #app > header .o-ctxchip { order: 20; flex: 1 1 100%; max-inline-size: none; }
  #app > header .o-ctxchip select { flex: 1 1 40%; }
}
/* the bar keeps every control on screen: the Search field gives way first (down to its icon), then the chip's names */
.admin-header .o-topsearch { flex: 0 3 auto !important; min-inline-size: 44px !important; overflow: hidden; }
.admin-header .o-ctxchip { min-inline-size: min(30vw, 22ch); }
/* inside the chip the pickers keep their order (the phone rule moves bare pickers to a row of their own, order 20) */
.o-ctxchip > * { order: 0 !important; }
