/* Picasso ERP layout: sidebar, top bar, page bar, panels. Component classes follow ui-<kind>__<part>. */
:root {
  --ui-sidebar-width: 264px;
  --ui-sidebar-bg: #0f172a;
  --ui-sidebar-fg: #c3cddc;
  --ui-sidebar-muted: #8b98ad;
  --ui-sidebar-active: #ffffff;
  --ui-sidebar-line: rgba(148, 163, 184, .14);
  --ui-sidebar-hover: rgba(148, 163, 184, .10);
  --ui-sidebar-current: rgba(99, 102, 241, .20);
  --ui-sidebar-accent: #818cf8;
  --ui-accent: #4f46e5;
  --ui-brand-glow-rgb: 129, 140, 248;  /* a brand's accent colour replaces it (app_core/branding.py) */
  --ui-page-bg: #f5f6f8;
  --ui-border: #e5e7eb;
}

body.ui-app { background: var(--ui-page-bg); font-size: 0.925rem; }

.ui-sidebar {
  width: var(--ui-sidebar-width);
  /* !important: Bootstrap's .offcanvas-lg makes the background transparent on wide screens */
  background: var(--ui-sidebar-bg) linear-gradient(180deg, #111b33 0%, #0f172a 40%, #0b1222 100%) !important;
  color: var(--ui-sidebar-fg);
  scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, .28) transparent;
  /* the menu scrolls itself at every width: on phones Bootstrap's offcanvas only scrolls an .offcanvas-body, which the
     menu does not have, so a long menu could not be scrolled. contain: the page behind does not scroll instead. */
  overflow-y: auto; overscroll-behavior: contain;
}
@media (min-width: 992px) {
  .ui-sidebar { position: fixed; inset: 0 auto 0 0; }
  .ui-main { margin-left: var(--ui-sidebar-width); }
}
/* A side panel beside the page (the AI Assistant, app_ai/ai-panel.js). While it is open the page makes room for it
   rather than lying under it, so the page can still be used: on wider screens the panel is a column on the right and
   the page narrows; on phones it is the lower part of the screen and the page scrolls above it. The panel's script
   sets html.ui-sidepanel-open (and .ui-sidepanel-tall for the taller phone size). */
:root { --ui-sidepanel-width: 400px; --ui-sidepanel-height: 50vh; }
html.ui-sidepanel-tall { --ui-sidepanel-height: 85vh; }
@supports (height: 1dvh) {
  :root { --ui-sidepanel-height: 50dvh; }
  html.ui-sidepanel-tall { --ui-sidepanel-height: 85dvh; }
}
@media (min-width: 768px) and (max-width: 1199.98px) { :root { --ui-sidepanel-width: 340px; } }
@media (min-width: 768px) {
  .ui-main { transition: margin-right .25s ease; }
  html.ui-sidepanel-open .ui-main { margin-right: var(--ui-sidepanel-width); }
  html.ui-sidepanel-open .ui-toasts { right: calc(var(--ui-sidepanel-width) + 1rem); }
}
@media (max-width: 767.98px) {
  html.ui-sidepanel-open .ui-main { padding-bottom: var(--ui-sidepanel-height); }
  html.ui-sidepanel-open .ui-toasts { bottom: calc(var(--ui-sidepanel-height) + 1rem); }
}
@media (prefers-reduced-motion: reduce) { .ui-main { transition: none; } }

.ui-topbar {
  position: sticky; top: 0; z-index: 1020; min-height: 60px;
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem 1.25rem; background: #fff; border-bottom: 1px solid var(--ui-border);
}
.ui-topbar__spacer { flex: 1; }
.ui-topbar__date { font-size: .82rem; color: var(--ui-muted); white-space: nowrap; }
.ui-topbar .form-select { max-width: 240px; }

.ui-content { padding: 1.25rem; }
.ui-pagebar {
  position: sticky; top: 53px; z-index: 1010;
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  margin: -1.25rem -1.25rem 1.25rem; padding: .75rem 1.25rem;
  background: var(--ui-page-bg); border-bottom: 1px solid var(--ui-border);
}
.ui-pagebar h1 { font-size: 1.25rem; margin: 0; font-weight: 600; }
/* the page description: what the records are for, in small quiet text under the page bar (it scrolls away) */
.ui-page-description { margin: -.5rem 0 1rem; max-width: 120ch; font-size: .8125rem; line-height: 1.5; color: var(--ui-muted); }
.ui-modal__description { font-size: .8125rem; line-height: 1.45; color: #4b5563; }
.ui-modal__description { margin: 0 0 .9rem; padding: .5rem .75rem; background: #f8fafc; border-left: 3px solid var(--ui-accent);
  border-radius: .25rem; }
/* Dialogs (ui/modal/modal_shell.html): header and footer stay put, only the body scrolls. The shell (a <form>)
   sits between .modal-content and its parts, so it must pass Bootstrap's scrollable-dialog height on. */
.ui-modal__shell { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.ui-modal__body { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.ui-modal__footer { flex-shrink: 0; background: #fff; }
/* "Discard changes?" above the footer when a dialog with unsaved changes is being closed (ui-modal.js) */
.ui-modal__discard { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem;
  padding: .55rem 1rem; background: var(--ui-tone-warning-bg); border-top: 1px solid var(--ui-tone-warning-line); font-size: .875rem; }
.ui-modal__discard > span { margin-right: auto; }
/* a dialog on top of a dialog ("+ New …" in one of its fields, ui-modal.js): each above the one under it, and the
   second shade lighter so the page does not go black */
.modal[data-ui-modal-level="1"] { z-index: 1075; }
.modal[data-ui-modal-level="2"] { z-index: 1095; }
.modal-backdrop ~ .modal-backdrop { z-index: 1070; }
.modal-backdrop ~ .modal-backdrop ~ .modal-backdrop { z-index: 1090; }
.modal-backdrop.show ~ .modal-backdrop.show { opacity: .25; }
.ui-pagebar__actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.ui-pagebar__actions .form-control { width: auto; }

.ui-panel { background: #fff; border: 1px solid var(--ui-border); border-radius: .5rem; margin-bottom: 1.25rem; }
.ui-panel__header { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem;
  border-bottom: 1px solid var(--ui-border); font-weight: 600; }
.ui-panel__header .ui-panel__actions { margin-left: auto; display: flex; gap: .4rem; }
.ui-panel__body { padding: 1rem; }
.ui-panel__body--flush { padding: 0; }
.ui-panel__body--flush .table > :not(caption) > * > :first-child { padding-left: 1rem; }
.ui-panel__body--flush .table > :not(caption) > * > :last-child { padding-right: 1rem; }

.ui-fields { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: .45rem 1rem; margin: 0; }
.ui-fields dt { color: var(--ui-muted); font-weight: 500; }
.ui-fields dd { margin: 0; white-space: pre-line; }

.ui-form { max-width: 920px; }
.ui-form--narrow { max-width: 520px; }  /* a few fields in one column (change password) */
/* password fields (ui-form.js): show / hide button inside the box, live hints under it */
.ui-password { position: relative; }
.ui-password > .form-control { padding-right: 2.6rem; }
.ui-password__toggle { position: absolute; top: 0; right: 0; height: 100%; width: 2.5rem; display: flex; align-items: center;
  justify-content: center; border: 0; background: none; color: var(--ui-muted); }
.ui-password__toggle:hover, .ui-password__toggle:focus-visible { color: var(--bs-primary); }
.ui-password__hint { margin-top: .25rem; font-size: .8125rem; color: var(--ui-muted); }
.ui-password__hint.is-ok { color: var(--ui-tone-success-fg); }
.ui-password__hint.is-warn { color: var(--ui-tone-warning-fg); }
.ui-password__notes { list-style: none; margin: 0 0 1rem; padding: .55rem .75rem; background: #f8fafc; border-radius: .35rem;
  font-size: .8125rem; color: #4b5563; display: grid; gap: .25rem; }
.ui-password__notes li { display: flex; align-items: center; gap: .45rem; }
.ui-password__notes svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--ui-muted); }
.ui-form__checks > div { display: grid; gap: .25rem; }
.ui-form__checks label { font-weight: 400; display: flex; gap: .5rem; align-items: center; }
/* a field that was refused: red border on its control(s), the message under it; the summary above the form lists them */
.ui-field--invalid .form-control, .ui-field--invalid .form-select, .ui-field--invalid .form-check-input { border-color: var(--bs-form-invalid-border-color); }
.ui-field--invalid .form-label { color: var(--bs-danger); }
.ui-form__errors { margin-bottom: 1rem; }
/* a group of fields under its heading (form.sections) */
.ui-form__heading { font-size: .78rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ui-muted);
  margin: 1.5rem 0 .75rem; padding-bottom: .35rem; border-bottom: 1px solid var(--ui-border); }
.ui-form__heading:first-child { margin-top: 0; }
/* rarely needed fields, collapsed under "More" (form.more_fields) */
.ui-form__more > summary { cursor: pointer; width: fit-content; }
.ui-form__more > summary:hover { color: var(--bs-primary) !important; }

.ui-card-stat { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.ui-card-label { font-size: .78rem; color: var(--ui-muted); text-transform: uppercase; letter-spacing: .04em; }

.ui-toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 1100; }

.ui-login { min-height: 100vh; display: grid; place-items: center; background: var(--ui-sidebar-bg); }
.ui-login__card { width: 100%; max-width: 380px; }

/* The sign-in page (app_core_erp/login.html): the brand's panel beside the form; stacked on small screens.
   Colours come from the brand (app_core/branding.py): --ui-sidebar-bg and --ui-brand-glow-rgb. */
.ui-signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.ui-signin__brand { position: relative; overflow: hidden; color: #e2e8f0; background:
    radial-gradient(circle at 15% 0%, rgba(var(--ui-brand-glow-rgb), .38), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(var(--ui-brand-glow-rgb), .18), transparent 50%),
    var(--ui-sidebar-bg); display: flex; align-items: center; }
.ui-signin__peaks { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 30%; pointer-events: none;
  fill: rgba(var(--ui-brand-glow-rgb), .10); }
.ui-signin__peaks path + path { fill: rgba(var(--ui-brand-glow-rgb), .08); }
.ui-signin__brand-inner { position: relative; z-index: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 3rem 2.5rem; }
.ui-signin__identity { display: flex; align-items: center; gap: .9rem; margin-bottom: 2rem; }
.ui-signin__logo { width: 52px; height: 52px; border-radius: .9rem; flex: none; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
span.ui-signin__logo svg { width: 26px; height: 26px; }
.ui-signin__name { font-size: 1.6rem; font-weight: 700; letter-spacing: .01em; color: #fff; line-height: 1.15; }
.ui-signin__tagline { color: rgba(226, 232, 240, .75); font-size: .95rem; }
.ui-signin__greeting { font-size: 1.35rem; font-weight: 600; color: #fff; margin: 0 0 .25rem; }
.ui-signin__date { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; color: rgba(226, 232, 240, .75); margin-bottom: 1.25rem; }
.ui-signin__date svg { width: 16px; height: 16px; }
.ui-signin__description { color: rgba(226, 232, 240, .88); line-height: 1.6; margin-bottom: 1.5rem; }
.ui-signin__highlights { list-style: none; padding: 0; margin: 0 0 1.75rem; display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1.25rem; }
.ui-signin__highlights li { display: flex; gap: .7rem; align-items: flex-start; font-size: .85rem; color: rgba(226, 232, 240, .78); line-height: 1.45; }
.ui-signin__highlights strong { display: block; color: #fff; font-size: .9rem; font-weight: 600; }
.ui-signin__icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: .6rem;
  background: rgba(var(--ui-brand-glow-rgb), .18); border: 1px solid rgba(var(--ui-brand-glow-rgb), .35); }
.ui-signin__icon svg { width: 17px; height: 17px; color: rgb(var(--ui-brand-glow-rgb)); }
.ui-signin__label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(226, 232, 240, .55); margin-bottom: .5rem; }
.ui-signin__chip { display: inline-flex; align-items: center; gap: .3rem; margin: 0 .35rem .4rem 0; padding: .2rem .6rem; font-size: .78rem;
  border-radius: 999px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12); color: #e2e8f0; }
.ui-signin__chip svg { width: 13px; height: 13px; opacity: .8; }
.ui-signin__panel { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--ui-page-bg); }
.ui-signin__form { width: 100%; max-width: 390px; background: #fff; border: 1px solid var(--ui-border); border-radius: 1rem;
  padding: 2rem; box-shadow: 0 10px 30px rgba(15, 23, 42, .06); }
.ui-signin__form .btn svg { width: 16px; height: 16px; vertical-align: -.2em; margin-right: .2rem; }
.ui-signin__identity--compact { display: none; margin-bottom: 1.25rem; }
.ui-signin__identity--compact .ui-signin__name { color: #0f172a; font-size: 1.25rem; }
.ui-signin__identity--compact .ui-signin__logo { width: 40px; height: 40px; }
.ui-signin__demo { font-size: .85rem; }
.ui-signin__demo svg { width: 18px; height: 18px; flex: none; margin-top: .1rem; }
.ui-signin__help { display: flex; gap: .55rem; margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--ui-border);
  font-size: .82rem; color: #64748b; }
.ui-signin__help svg { width: 17px; height: 17px; flex: none; margin-top: .1rem; }
.ui-signin__footer { margin: 1rem 0 0; font-size: .75rem; color: #94a3b8; text-align: center; }
@media (max-width: 991.98px) {
  .ui-signin { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .ui-signin__panel { order: -1; padding: 1.5rem 1rem; }
  .ui-signin__identity--compact { display: flex; }
  .ui-signin__brand-inner { padding: 2.25rem 1.5rem; }
  .ui-signin__brand .ui-signin__identity { display: none; }
}
@media (max-width: 575.98px) {
  .ui-signin__highlights { grid-template-columns: 1fr; }
  .ui-signin__form { padding: 1.5rem 1.25rem; }
}

.ui-matrix th, .ui-matrix td { text-align: center; vertical-align: middle; }
.ui-matrix th:first-child, .ui-matrix td:first-child { text-align: left; }
.ui-log { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; white-space: pre-wrap;
  background: #111827; color: #e5e7eb; padding: 1rem; border-radius: .5rem; max-height: 70vh; overflow: auto; }
.ui-doc img { max-width: 100%; }
.ui-doc table { width: auto; margin-bottom: 1rem; }
.ui-doc table td, .ui-doc table th { border: 1px solid var(--ui-border); padding: .25rem .5rem; }

.ui-table { background: #fff; border: 1px solid var(--ui-border); border-radius: .5rem; }
.ui-table--links .tabulator-row { cursor: pointer; }
.ui-calendar__ad { min-height: 1.1em; }

/* filter bars (templates/ui/filter/filter_bar.html): label on top, fields lined up from the top so whatever sits
   under a box (the AD date of a BS date, an error) never moves the others; the button on the boxes' line */
.ui-filters { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .75rem 1rem; }
.ui-filter { display: flex; flex-direction: column; min-width: 10rem; }
.ui-filter > .form-label { margin-bottom: .3rem; font-size: .8125rem; line-height: 1.25rem; white-space: nowrap; }
.ui-filter .ui-calendar__ad { min-height: 0; margin-top: .2rem; font-size: .75rem; }
.ui-filter--picker { min-width: 16rem; }
.ui-filter--bsdate { min-width: 0; width: 10.5rem; }
.ui-filter--checkbox, .ui-filter--action { min-width: 0; }
.ui-filter__check { display: flex; align-items: center; gap: .4rem; min-height: calc(1.5em + .5rem + 2px); margin: 0; }
.ui-filter__check .form-check-input { float: none; margin: 0; }
.ui-filter__button { white-space: nowrap; }
@media (max-width: 575.98px) { .ui-filter, .ui-filter--picker, .ui-filter--bsdate { flex: 1 1 100%; width: auto; } }
/* the BS calendar's pop-up is added to <body>: above the sticky top and page bars (1020, 1010) and above an open
   dialog (Bootstrap's modal is 1055), below the toasts (1100). The library's own 1000 hid its top under the page bar. */
body .ndp-container { z-index: 1065; }
.ui-table-toolbar { display: flex; justify-content: flex-end; gap: .5rem; margin-bottom: .5rem; }
.ui-table-toolbar__menu { min-width: 16rem; max-height: 60vh; overflow-y: auto; }

/* Dialogs and workflow */
.ui-fields--compact { grid-template-columns: minmax(110px, 160px) 1fr; gap: .25rem .75rem; font-size: .9rem; }
.ui-amount__words { min-height: 1.1em; }
.ui-timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--ui-border); }
.ui-timeline__item { position: relative; padding: 0 0 .75rem .75rem; }
.ui-timeline__item::before { content: ""; position: absolute; left: calc(-1rem - 1px - .3rem); top: .45rem; width: .6rem; height: .6rem;
  border-radius: 50%; background: var(--ui-accent); }
.ui-timeline__comment { margin-top: .2rem; padding: .35rem .6rem; background: var(--ui-page-bg); border-radius: .35rem; white-space: pre-line; }

/* the "working" indicator (ui-busy.js): a moving bar along the top and a small spinner pill */
.ui-busy { position: fixed; inset: 0 0 auto 0; z-index: 2000; pointer-events: none; }
.ui-busy[hidden] { display: none; }
.ui-busy__bar { position: absolute; top: 0; left: 0; height: 3px; width: 35%; border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, transparent, var(--ui-accent), #818cf8); animation: ui-busy-slide 1.1s ease-in-out infinite; }
.ui-busy__pill { position: fixed; top: .6rem; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center;
  gap: .45rem; padding: .3rem .8rem; border-radius: 999px; background: rgba(17, 24, 39, .88); color: #fff; font-size: .8rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.ui-busy__button { margin-right: .35rem; vertical-align: -.15em; }
@keyframes ui-busy-slide { 0% { left: -35%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .ui-busy__bar { animation: none; width: 100%; opacity: .7; }
  .ui-busy__pill .spinner-border { animation-duration: 2s; }
}

/* sidebar hints: a quiet tooltip beside the link */
.ui-hint { --bs-tooltip-bg: #111827; --bs-tooltip-max-width: 240px; --bs-tooltip-font-size: .78rem; --bs-tooltip-opacity: .96; }
.ui-hint .tooltip-inner { text-align: left; padding: .35rem .6rem; line-height: 1.35; }

/* --- sidebar ------------------------------------------------------------------------------------
   Brand with the active company, a page finder, then the sections (Work, Business, Reports, Settings): a tile
   icon, and a count of waiting items while closed. Inside, each module's pages form a group with a guide line;
   rows are rounded and the current page has a bar. Each section has its colour (ui-theme.css: data-ui-section on
   the section and on each link, so a favourite keeps its section's colour): the tile, the page icons and the bar.
   Super-admin pages are amber, administration sky blue. */
@media (min-width: 992px) { .ui-sidebar { display: flex; flex-direction: column; } }
.ui-sidebar__brand { display: flex; align-items: center; gap: .7rem; min-height: 60px; padding: .6rem 1rem;
  color: #fff; text-decoration: none; border-bottom: 1px solid var(--ui-sidebar-line); }
.ui-sidebar__brand:hover { color: #fff; }
.ui-sidebar__logo { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: .6rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 4px 12px rgba(99, 102, 241, .35); }
.ui-sidebar__logo svg { width: 18px; height: 18px; color: #fff; }
.ui-sidebar__logo--image { background: none; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); object-fit: contain; }
.ui-sidebar__brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ui-sidebar__brand-text strong { font-size: 1rem; font-weight: 650; letter-spacing: .01em; }
.ui-sidebar__brand-text small { color: var(--ui-sidebar-muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ui-sidebar__filter { position: relative; margin: .75rem .75rem .35rem; }
.ui-sidebar__filter svg { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px;
  color: var(--ui-sidebar-muted); pointer-events: none; }
.ui-sidebar__filter input { width: 100%; padding: .42rem .65rem .42rem 2.05rem; border-radius: .5rem; font-size: .84rem;
  color: #e2e8f0; background: rgba(148, 163, 184, .08); border: 1px solid var(--ui-sidebar-line); outline: none; }
.ui-sidebar__filter input::placeholder { color: var(--ui-sidebar-muted); }
.ui-sidebar__filter input:focus { border-color: var(--ui-sidebar-accent); background: rgba(148, 163, 184, .12);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, .18); }
.ui-sidebar__filter input::-webkit-search-cancel-button { filter: invert(.7); }

.ui-sidebar__nav { padding: .25rem 0 .75rem; flex: 1 0 auto; }
.ui-sidebar__empty { margin: .5rem 1.25rem; font-size: .82rem; color: var(--ui-sidebar-muted); }

/* sections */
.ui-sidebar__section + .ui-sidebar__section { margin-top: .1rem; }
.ui-sidebar__group { display: flex; align-items: center; gap: .65rem; width: calc(100% - 1.2rem); margin: 0 .6rem;
  padding: .45rem .55rem; border: 0; border-radius: .55rem; background: none; text-align: left;
  color: #e2e8f0; font-size: .875rem; font-weight: 600; letter-spacing: .01em; }
.ui-sidebar__group:hover { background: var(--ui-sidebar-hover); color: #fff; }
.ui-sidebar__group:focus-visible, .ui-sidebar__link:focus-visible {
  outline: 2px solid var(--ui-sidebar-accent); outline-offset: -2px; }
.ui-sidebar__tile { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: .5rem;
  background: var(--ui-section-glow); color: var(--ui-section-light); transition: background .15s, color .15s; }
.ui-sidebar__tile svg { width: 16px; height: 16px; }
.ui-sidebar__group--active .ui-sidebar__tile, .ui-sidebar__group[aria-expanded="true"] .ui-sidebar__tile {
  background: color-mix(in srgb, var(--ui-section) 45%, transparent); color: #fff; }
.ui-sidebar__group-label { flex: 1; min-width: 0; }
.ui-sidebar__chevron { flex: none; width: 15px; height: 15px; color: var(--ui-sidebar-muted); transition: transform .15s; }
.ui-sidebar__group[aria-expanded="true"] .ui-sidebar__chevron { transform: rotate(90deg); }
.ui-sidebar__section-body { padding: .15rem 0 .45rem; }

/* page rows */
.ui-sidebar__item { position: relative; }
.ui-sidebar__link { display: flex; align-items: center; gap: .6rem; margin: 1px .6rem; padding: .4rem 2.3rem .4rem 2.65rem;
  border-radius: .45rem; color: var(--ui-sidebar-fg); text-decoration: none; font-size: .855rem; line-height: 1.3; }
.ui-sidebar__link > svg { flex: none; width: 16px; height: 16px; color: var(--ui-section-light); opacity: .7; }
.ui-sidebar__link:hover { color: #fff; background: var(--ui-sidebar-hover); }
.ui-sidebar__link:hover > svg { opacity: 1; }
.ui-sidebar__link--active, .ui-sidebar__link--active:hover { color: #fff; background: color-mix(in srgb, var(--ui-section) 24%, transparent);
  box-shadow: inset 3px 0 0 var(--ui-section); font-weight: 550; }
.ui-sidebar__link--active > svg { opacity: 1; }
.ui-sidebar__label { flex: 1; min-width: 0; }
.ui-sidebar__context { display: block; font-size: .7rem; color: var(--ui-sidebar-muted); line-height: 1.15; }

/* headings inside a long section ("Applications", "Reports", "Setup"): labels, not buttons */
.ui-sidebar__heading { margin: .55rem .6rem .1rem; padding: 0 .55rem 0 2.65rem; color: var(--ui-sidebar-muted);
  font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; line-height: 1.6; }
.ui-sidebar__headed:first-child .ui-sidebar__heading { margin-top: .15rem; }


/* counts of waiting items; the sum shows on a closed section or group */
.ui-sidebar__count { flex: none; min-width: 1.3rem; height: 1.2rem; padding: 0 .38rem; border-radius: 999px;
  display: inline-grid; place-items: center; font-size: .7rem; font-weight: 700; line-height: 1; color: #fff; background: #4f46e5; }
.ui-sidebar__count--sum { background: rgba(99, 102, 241, .45); color: #e0e7ff; }
[aria-expanded="true"] > .ui-sidebar__count--sum { display: none; }

/* restricted pages */
.ui-sidebar__badge { flex: none; width: 14px; height: 14px; opacity: .85; }
.ui-sidebar__link--super { color: #fcd34d; }
.ui-sidebar__link--super > svg { color: #f5c04a; }
.ui-sidebar__link--super:hover { color: #fde68a; background: rgba(252, 211, 77, .08); }
.ui-sidebar__link--super.ui-sidebar__link--active { color: #fde68a; background: rgba(252, 211, 77, .14); box-shadow: inset 3px 0 0 #f59e0b; }
.ui-sidebar__link--admin { color: #93d5fb; }
.ui-sidebar__link--admin > svg { color: #67c2f2; }
.ui-sidebar__link--admin:hover { color: #bae6fd; background: rgba(125, 211, 252, .08); }
.ui-sidebar__link--admin.ui-sidebar__link--active { color: #bae6fd; background: rgba(125, 211, 252, .14); box-shadow: inset 3px 0 0 #0ea5e9; }

/* favourites: a star beside each link (on hover; faint on touch screens), gold when starred */
.ui-sidebar__star { position: absolute; top: 50%; right: 1.05rem; transform: translateY(-50%); display: inline-flex;
  padding: .2rem; border: 0; border-radius: .3rem; background: none; color: var(--ui-sidebar-muted); opacity: 0; transition: opacity .12s; }
.ui-sidebar__star svg { width: 14px; height: 14px; }
.ui-sidebar__item:hover .ui-sidebar__star, .ui-sidebar__star:focus-visible, .ui-sidebar__star.is-on { opacity: 1; }
.ui-sidebar__star:hover { color: #fde68a; background: rgba(255, 255, 255, .06); }
.ui-sidebar__star.is-on { color: #fbbf24; }
.ui-sidebar__star.is-on svg { fill: currentColor; }
@media (hover: none) { .ui-sidebar__star { opacity: .45; } }
.ui-sidebar__favorites { margin: 0 0 .35rem; padding-bottom: .4rem; border-bottom: 1px solid var(--ui-sidebar-line); }
.ui-sidebar__favorites-title { display: flex; align-items: center; gap: .5rem; padding: .5rem 1.25rem .3rem; color: #fbbf24;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ui-sidebar__favorites-title svg { width: 13px; height: 13px; fill: currentColor; }
.ui-sidebar__favorites .ui-sidebar__link { padding-left: 1.05rem; }

/* legend */
.ui-sidebar__legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; padding: .7rem 1.1rem .9rem;
  border-top: 1px solid var(--ui-sidebar-line); font-size: .72rem; color: var(--ui-sidebar-muted); }
.ui-sidebar__legend span { display: inline-flex; align-items: center; gap: .35rem; }
.ui-sidebar__legend svg { width: 12px; height: 12px; }
.ui-sidebar__legend-super { color: #fcd34d; }
.ui-sidebar__legend-admin { color: #7dd3fc; }

/* finding a page: every section and group opens, rows that do not match are hidden */
.ui-sidebar--filtering .ui-sidebar__nav .collapse { display: block !important; height: auto !important; }
.ui-sidebar--filtering .ui-sidebar__chevron, .ui-sidebar--filtering .ui-sidebar__count--sum,
.ui-sidebar--filtering #ui-sidebar-favorites { display: none; }
/* pages kept out of the menu: only while "Find a page" has text */
.ui-sidebar__more { display: none; margin-top: .5rem; padding-top: .35rem; border-top: 1px solid var(--ui-sidebar-line); }
.ui-sidebar--filtering .ui-sidebar__more:not([hidden]) { display: block; }
.ui-sidebar__more-heading { margin: .1rem 1.25rem .25rem; font-size: .7rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ui-sidebar-muted); }
.ui-sidebar--filtering mark { padding: 0; background: rgba(250, 204, 21, .35); color: inherit; border-radius: 2px; }

/* "Viewing as" banner (app_core_erp/view_as.py): a super admin sees the ERP as another user, read-only. */
.ui-view-as { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .45rem 1rem; color: #3b2300; font-size: .875rem;
  background: repeating-linear-gradient(135deg, #fbbf24 0 14px, #f59e0b 14px 28px); border-bottom: 2px solid #b45309; }
.ui-view-as__text { flex: 1 1 auto; min-width: 0; }
.ui-view-as__meta { color: #5b3a00; }
.ui-view-as form { margin: 0; }

/* Menu layouts: editor table, role summary chips and the live menu preview (a miniature of the sidebar) */
.ui-layout-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ui-layout-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px;
  background: #eef0f4; font-size: .8rem; }
.ui-layout-chip svg { width: 14px; height: 14px; }
.ui-layout-chip--changed { background: var(--ui-tone-warning-bg); color: var(--ui-tone-warning-fg); }
.ui-layout-chip--muted { background: transparent; border: 1px dashed var(--ui-border); color: var(--ui-muted); }
.ui-layout-table th { white-space: nowrap; }
.ui-layout-table__section th { background: #eef0f4; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: #475569; padding: .5rem 1rem !important; }
.ui-layout-table__section svg { width: 14px; height: 14px; vertical-align: -2px; }
.ui-layout-table tbody tr:hover > td { background: #f8f9fc; }
.ui-layout-table tr.ui-layout-changed > td { background: var(--ui-tone-warning-bg); box-shadow: none; }
.ui-layout-table tr.ui-layout-changed > td:first-child { box-shadow: inset 3px 0 0 var(--ui-tone-warning-solid); }
.ui-layout-sticky { position: sticky; top: 4.5rem; }
.ui-layout-preview { margin-bottom: .75rem; }
.ui-layout-preview .ui-panel__header { font-size: .9rem; }
.ui-layout-live { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 500; color: var(--ui-tone-success-fg); }
.ui-layout-live__dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--ui-tone-success-solid); }
#layout-preview[aria-busy="true"] .ui-layout-live__dot { background: var(--ui-tone-warning-solid); animation: ui-layout-pulse .8s infinite alternate; }
@keyframes ui-layout-pulse { to { opacity: .3; } }
.ui-layout-menu { background: var(--ui-sidebar-bg); color: var(--ui-sidebar-fg); padding: .5rem .5rem .75rem;
  max-height: calc(100vh - 17rem); overflow-y: auto; font-size: .85rem; }
.ui-layout-menu__section { display: flex; align-items: center; gap: .4rem; margin: .75rem .5rem .25rem; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ui-sidebar-muted); }
.ui-layout-menu__section svg { width: 13px; height: 13px; }
.ui-layout-menu__count { margin-left: auto; padding: 0 .4rem; border-radius: 999px; background: rgba(148, 163, 184, .22);
  font-size: .7rem; color: inherit; }
.ui-layout-table__section .ui-layout-menu__count { margin-left: .4rem; background: #dfe3ea; }
.ui-layout-menu__group { margin: .4rem .5rem 0; font-weight: 600; color: #e2e8f0; }
.ui-layout-menu__items { list-style: none; margin: 0; padding: 0; }
.ui-layout-menu__items li { display: flex; align-items: center; gap: .5rem; padding: .22rem .5rem; border-radius: .35rem; }
.ui-layout-menu__items li:hover { background: var(--ui-sidebar-hover); }
.ui-layout-menu__items li svg { width: 15px; height: 15px; flex: none; opacity: .8; }
.ui-layout-menu__items--grouped { margin-left: .75rem; border-left: 1px solid var(--ui-sidebar-line); }
.ui-layout-menu__items li.is-moved { background: var(--ui-sidebar-current); color: #fff; }
.ui-layout-menu__items li.is-moved::after, .ui-layout-menu__moved-dot { content: ""; width: .45rem; height: .45rem; border-radius: 50%;
  background: #fbbf24; margin-left: auto; flex: none; }
.ui-layout-menu__moved-dot { display: inline-block; margin: 0 .25rem 0 0; vertical-align: middle; }
.ui-layout-menu__empty { margin: 1rem .5rem; color: var(--ui-sidebar-muted); }
@media (max-width: 1199.98px) { .ui-layout-sticky { position: static; } .ui-layout-menu { max-height: none; } }
.ui-layout-menu__items li .ui-layout-menu__hide { display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.25rem; height: 1.25rem; margin: 0 0 0 auto; padding: 0; border: 0; border-radius: 50%; background: transparent;
  color: var(--ui-sidebar-muted); opacity: 0; transition: opacity .12s, background .12s, color .12s; }
.ui-layout-menu__items li:hover .ui-layout-menu__hide, .ui-layout-menu__items li .ui-layout-menu__hide:focus-visible { opacity: 1; }
.ui-layout-menu__items li .ui-layout-menu__hide:hover { background: rgba(248, 113, 113, .22); color: #fca5a5; }
.ui-layout-menu__items li .ui-layout-menu__hide svg { width: 12px; height: 12px; opacity: 1; }
.ui-layout-menu__items li.is-moved .ui-layout-menu__hide { margin-left: .4rem; }
@media (hover: none) { .ui-layout-menu__items li .ui-layout-menu__hide { opacity: .55; } }
.ui-layout-table tr.ui-flash > td { background: var(--ui-tone-danger-line); transition: background 1.4s; }
/* a box for a one-time code (colours: ui-theme.css): big, spaced digits; the hint inside stays small and unspaced */
.ui-code-input { font-family: var(--bs-font-monospace); text-align: center; font-size: 1.6rem; font-weight: 600;
  letter-spacing: .45em; padding-left: calc(.75rem + .45em); }
.ui-code-input::placeholder { font-size: 1rem; font-weight: 400; letter-spacing: normal; font-family: var(--bs-body-font-family); }
.ui-code-input--inline { font-size: 1.05rem; letter-spacing: .2em; padding-left: calc(.75rem + .2em); }
.ui-code-input--inline::placeholder { font-size: .875rem; }
.ui-code-form { max-width: 20rem; }

/* Read-only fields (ui/form/_field.html): plain text, no box, so nobody tries to type in them. */
.ui-readonly { padding: .375rem 0; min-height: calc(1.5em + .75rem); overflow-wrap: anywhere; }
.ui-readonly--empty { color: var(--ui-muted); }
/* the chosen contact under a contact picker (app_contacts/contact_card.html) */
.ui-readonly-card { padding: .75rem 1rem; border: 1px solid var(--ui-border); border-left: 3px solid var(--ui-accent);
  border-radius: .5rem; background: var(--ui-page-bg); }
.ui-new-contact-toggle { margin-top: .25rem; }

/* The three ticks at the top of the menu (ui-kinds.js): Work, Reports and Setup, in any combination. A page is
   hidden when its kind is not ticked, except while "Find a page" has text (it searches everything), and pages in
   Favourites and My Workspace are never hidden. */
.ui-sidebar__kinds { display: flex; gap: .3rem; margin: .75rem .75rem 0; }
.ui-sidebar__kind { display: inline-flex; flex: 1; align-items: center; justify-content: center; gap: .3rem; padding: .32rem .25rem;
  border-radius: .5rem; border: 1px solid var(--ui-sidebar-line); background: rgba(148, 163, 184, .06); color: var(--ui-sidebar-muted);
  font-size: .76rem; font-weight: 600; line-height: 1.2; }
.ui-sidebar__kind svg { width: 13px; height: 13px; flex: none; }
.ui-sidebar__kind:hover { color: #fff; background: var(--ui-sidebar-hover); }
.ui-sidebar__kind[aria-pressed="true"] { color: #fff; background: rgba(99, 102, 241, .32); border-color: #818cf8; }
.ui-sidebar__kind:focus-visible { outline: 2px solid var(--ui-sidebar-accent); outline-offset: 1px; }
.ui-sidebar:not(.ui-sidebar--filtering):not([data-ui-kinds~="work"]) .ui-sidebar__section [data-ui-kind="work"],
.ui-sidebar:not(.ui-sidebar--filtering):not([data-ui-kinds~="reports"]) .ui-sidebar__section [data-ui-kind="reports"],
.ui-sidebar:not(.ui-sidebar--filtering):not([data-ui-kinds~="setup"]) .ui-sidebar__section [data-ui-kind="setup"],
.ui-sidebar:not(.ui-sidebar--filtering) .ui-sidebar__section--empty { display: none; }
/* the Reports and Setup headings are needed only when more than one kind is listed (Work's own headings, such as
   Applications, always stay) */
.ui-sidebar:not(.ui-sidebar--filtering):not([data-ui-multi]) .ui-sidebar__headed[data-ui-kind="reports"] .ui-sidebar__heading,
.ui-sidebar:not(.ui-sidebar--filtering):not([data-ui-multi]) .ui-sidebar__headed[data-ui-kind="setup"] .ui-sidebar__heading { display: none; }
