/* ==========================================================================
   Quali5Care IMS — theme tokens
   Values extracted from the live legacy application (docs/03-theme-tokens.md).
   The LOOK is reproduced; none of the legacy CSS is reused.
   ========================================================================== */

:root {
  /* Typography */
  --font-sans: "Nunito", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-base: 16px;
  --fs-table-head: 13px;
  --fs-input: 13px;
  --fs-btn: 12px;
  --fs-badge: 9.75px;
  --fs-sidebar: 13.6px;          /* 0.85rem — the legacy's sidebar scale */
  --fw-table-head: 600;
  --fw-badge: 700;

  /* Surfaces */
  --color-page-bg: #ffffff;
  --color-card-bg: #ffffff;
  --color-border: #e1e7ef;
  --color-row-border: #e3e6f0;
  --color-text: #3a3b45;
  --color-muted: #858796;

  /* Sidebar */
  --color-sidebar-bg: #0f1729;
  --color-sidebar-text: #ffffff;
  --color-sidebar-muted: rgba(255,255,255,.42);
  --color-sidebar-active: #1364f1;
  /*
   | The legacy's rail is 14rem (224px). At that width "Product Management" fits
   | with ONE pixel to spare, which a font fallback would swallow — so 232px, which
   | is close enough to read as the same design and leaves the longest label room.
   */
  --sidebar-width: 232px;

  /* Brand / actions */
  --color-primary: #155dfc;
  --color-primary-contrast: #ffffff;

  /* Status palette */
  --color-success: #1cc88a;
  --color-warning: #f6c23e;
  --color-info: #36b9cc;
  --color-danger: #e74a3b;

  /* Geometry */
  --radius-sm: 0.35rem;
  --radius-md: 6px;
  --radius-lg: 8px;
  --input-height: 37px;
  --header-height: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--color-text);
  background: var(--color-page-bg);
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----------------------------------------------------------------- layout */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
  z-index: 30;
}

.sidebar__brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .3px;
}
.sidebar__brand img { max-width: 160px; height: auto; display: block; }

/* Section captions: the legacy's 0.65rem / 800 / uppercase, left aligned. */
.sidebar__section {
  padding: 18px 18px 7px;
  font-size: 10.4px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--color-sidebar-muted);
}

.sidebar__link {
  position: relative;
  display: flex;
  align-items: center;
  margin: 1px 8px;
  /* Tight enough that the two longest labels — "Product Management" and
     "Inventory Movement" — fit the legacy's 224px rail without clipping. */
  gap: 8px;
  padding: 8px 8px 8px 9px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.82);        /* the legacy's resting colour */
  font-size: var(--fs-sidebar);
  line-height: 1.35;
  border: 0;
  background: none;
  width: calc(100% - 16px);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.sidebar__link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }

/*
   The current page. The legacy marks it with white bold text and no background,
   which is easy to miss; a pill reads at a glance. It is INSET and rounded rather
   than a full-bleed bar — the bar looked like a rendering fault, especially on the
   indented sub-items (docs/11-known-issues.md #57).
*/
.sidebar__link.is-active {
  background: var(--color-sidebar-active);
  color: #fff;
  font-weight: 700;
}
.sidebar__link.is-active::before {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  width: 3px; height: 18px;
  margin-top: -9px;
  border-radius: 0 2px 2px 0;
  background: #fff;
}

/* Icons sit back until the row matters — the legacy uses rgba(255,255,255,.3). */
.sidebar__link svg { width: 15px; height: 15px; flex: 0 0 15px; color: rgba(255,255,255,.45); }
.sidebar__link:hover svg,
.sidebar__link.is-active svg,
.sidebar__group.is-current > .sidebar__link svg { color: inherit; }

/* The caret is sized here, not by the SVG's own width attribute: at 16px the two
   longest labels were exactly 1px over and wrapped onto a second line. */
.sidebar__caret {
  margin-left: auto;
  flex: 0 0 10px;
  width: 10px; height: 10px;
  opacity: .55;
  transition: transform .15s ease;
}

/* A label never wraps. If one ever outgrows the rail it is clipped, which reads as
   a long name; wrapping read as a broken row. */
.sidebar__link > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar__group[open] > .sidebar__link .sidebar__caret { transform: rotate(90deg); }
.sidebar__group > summary { list-style: none; }
.sidebar__group > summary::-webkit-details-marker { display: none; }

/* An open group's children, held together by a hairline rather than floating. */
.sidebar__sub {
  margin: 2px 8px 6px 25px;
  padding-left: 9px;
  border-left: 1px solid rgba(255,255,255,.12);
}
.sidebar__sub .sidebar__link {
  margin: 1px 0;
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  color: rgba(255,255,255,.72);
}
.sidebar__sub .sidebar__link.is-active::before { left: -10px; height: 15px; margin-top: -7.5px; }

.main {
  flex: 1 1 auto;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--color-row-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__spacer { margin-left: auto; }
.topbar__user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.topbar__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

.content { padding: 22px; flex: 1 1 auto; }
.page-title { font-size: 22px; font-weight: 800; margin: 0 0 4px; color: #2b2c37; }
.page-subtitle { margin: 0 0 18px; color: var(--color-muted); font-size: 14px; }

/* ------------------------------------------------------------- components */

.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-row-border);
  border-radius: var(--radius-sm);
  padding: 18px;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit;
  font-size: var(--fs-btn);
  font-weight: 400;
  padding: 5px 10px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  line-height: 1.6;
}
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn--primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.btn--ghost { background: #fff; color: var(--color-text); border-color: var(--color-border); }
.btn--block { width: 100%; justify-content: center; padding: 10px 14px; font-size: 14px; font-weight: 700; letter-spacing: .04em; }

.form-label { display: block; font-size: 13px; font-weight: 700; margin: 0 0 6px; color: #2b2c37; }
.form-control {
  width: 100%;
  height: var(--input-height);
  font-family: inherit;
  font-size: var(--fs-input);
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  color: var(--color-text);
}
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(21,93,252,.12); }
.form-group { margin-bottom: 14px; }
.form-error { color: var(--color-danger); font-size: 12px; margin-top: 5px; }

/* An invalid field, marked by form-validate.js. The legacy puts a red border on
   the control and the message underneath (`purchaseOrder/add.blade.php:833`);
   same idea, this build's tokens. `:invalid` is deliberately NOT used — it would
   paint every required field red before the user has typed anything. */
.form-control.is-invalid,
.ss.is-invalid .ss__control,
.ms.is-invalid .ms__control {
    border-color: var(--color-danger);
}
.form-control.is-invalid:focus,
.ss.is-invalid .ss__control:focus,
.ms.is-invalid .ms__control:focus {
    outline-color: var(--color-danger);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger) 18%, transparent);
}

.badge {
  display: inline-block;
  font-size: var(--fs-badge);
  font-weight: var(--fw-badge);
  color: #fff;
  padding: 2.44px 3.9px;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  white-space: nowrap;
}
.badge--success { background: var(--color-success); }
.badge--warning { background: var(--color-warning); }
.badge--info    { background: var(--color-info); }
.badge--danger  { background: var(--color-danger); }

.table { width: 100%; border-collapse: collapse; }
.table thead th {
  background: transparent;
  color: #000;
  font-size: var(--fs-table-head);
  font-weight: var(--fw-table-head);
  padding: 5px 30px 5px 10px;
  text-align: left;
  white-space: nowrap;
}
.table tbody td { padding: 10px; border-bottom: 1px solid var(--color-row-border); font-size: 13px; }

.alert { padding: 10px 12px; border-radius: var(--radius-lg); font-size: 13px; margin-bottom: 14px; }
.alert--danger { background: #fdecea; color: #a4281c; border: 1px solid #f6c7c2; }

/* ------------------------------------------------------------------ login */

.login { min-height: 100vh; display: grid; place-items: center; background: #f6f7fb; padding: 20px; }
.login__card { width: 100%; max-width: 380px; background: #fff; border-radius: 12px; padding: 30px 28px; box-shadow: 0 10px 40px rgba(16,24,40,.08); }
.login__logo { display: block; margin: 0 auto 22px; max-width: 200px; }
.login__footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--color-row-border); text-align: center; color: var(--color-muted); font-size: 12px; }
.captcha-row { display: flex; align-items: center; gap: 8px; }
.captcha-row .form-control { flex: 1 1 auto; }
.captcha-row img { height: var(--input-height); border-radius: var(--radius-lg); border: 1px solid var(--color-border); }
.captcha-reload {
  height: var(--input-height); width: var(--input-height);
  display: grid; place-items: center;
  border-radius: var(--radius-lg); border: 0;
  background: var(--color-primary); color: #fff; cursor: pointer;
}
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 38px; }
.pw-toggle { position: absolute; right: 6px; top: 0; height: var(--input-height); width: 30px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--color-muted); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .app.is-sidebar-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
}

/* ------------------------------------------------------- list screens */

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar__spacer { margin-left: auto; }
.toolbar .form-control { width: 260px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--color-row-border); border-radius: var(--radius-sm); background: #fff; }
.table-wrap .table { min-width: 100%; }
.table tbody tr:hover { background: #fafbfe; }
.table-empty { padding: 26px; text-align: center; color: var(--color-muted); font-size: 14px; }

.row-actions { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.row-action {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: #fff; cursor: pointer; color: var(--color-muted); padding: 0;
}
.row-action:hover { background: #f3f5fa; }

.row-menu { position: relative; display: inline-block; }
.row-menu__list {
  display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 40;
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(16,24,40,.12); min-width: 184px; padding: 5px;
}
.row-menu.is-open .row-menu__list { display: block; }
.row-menu__list button {
  display: block; width: 100%; text-align: left; padding: 8px 10px;
  border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px;
  border-radius: var(--radius-md); color: var(--color-text);
}
.row-menu__list button:hover { background: #f3f5fa; }

.dt-info { font-size: 13px; color: var(--color-muted); }
.dt-pager { display: inline-flex; gap: 5px; }
.dt-pager button {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: #fff; cursor: pointer; font: inherit; font-size: 13px;
}
.dt-pager button[disabled] { opacity: .45; cursor: not-allowed; }
.dt-pager button.is-current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ------------------------------------------------------------- modals */

.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(16,24,40,.45); padding: 24px; overflow-y: auto;
}
.modal-backdrop.is-open { display: block; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  margin: 24px auto; box-shadow: 0 20px 60px rgba(16,24,40,.2);
}
.modal--wide { max-width: 900px; }
.modal__head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--color-row-border); }
.modal__title { font-size: 16px; font-weight: 800; margin: 0; }
.modal__close { margin-left: auto; border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--color-muted); }
.modal__body { padding: 20px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--color-row-border); }

/* ------------------------------------------------------- read-only detail */
/* The view screen (resources/views/detail.blade.php). Deliberately typographic
   rather than form-like: nothing here is editable, so nothing should look it. */

.badge--muted { background: var(--color-muted); }

.detail__head {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px;
}
.detail__head .page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail__head .page-subtitle { margin-bottom: 0; }
.detail__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.detail__card { margin-bottom: 16px; }
.detail__heading {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--color-muted);
  margin: 0 0 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--color-row-border);
}

.detail__grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 24px; margin: 0;
}
.detail__field { min-width: 0; }
.detail__label { font-size: 12px; font-weight: 600; color: var(--color-muted); margin-bottom: 3px; }
.detail__value { margin: 0; font-size: 14px; color: var(--color-text); overflow-wrap: anywhere; }
.detail__dash { color: #c3c7d1; }
.detail__money, .detail__qty { font-variant-numeric: tabular-nums; font-weight: 600; }
.detail__uom { font-weight: 400; color: var(--color-muted); font-size: 12px; }
.detail__note { margin: 0; font-size: 14px; white-space: pre-wrap; }
.detail__empty { margin: 0; color: var(--color-muted); font-size: 14px; }
.detail__file::before { content: "📎 "; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-block; font-size: 12px; line-height: 1.6;
  padding: 1px 9px; border-radius: 999px;
  background: #eef2fb; color: #2b3b5e; border: 1px solid #dde4f2;
}

.table td.is-numeric, .table th.is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--color-row-border); }

/* ------------------------------------------------------ form components */
/* Shared classes for things that were previously repeated as inline styles
   on every form: hints under a field, callouts above one, radio rows. */

.form-hint { color: var(--color-muted); font-size: 12px; margin-top: 5px; }
.form-control--area { height: auto; min-height: calc(var(--input-height) * 2); resize: vertical; }
.form-control:disabled, .form-control[readonly] { background: #f6f7fb; color: var(--color-muted); }
.form-required { color: var(--color-danger); }

.radio-row { display: flex; gap: 18px; align-items: center; min-height: var(--input-height); }
.radio { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }

.callout {
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-info);
  border-radius: var(--radius-md);
  background: #f7fbfd;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
}
.callout--warn { border-left-color: var(--color-warning); background: #fffaf0; }
.callout--danger { border-left-color: var(--color-danger); background: #fdf5f4; }

/* ------------------------------------------------------------ multi-select */
/* public/assets/js/multi-select.js. The native <select multiple> stays in the
   DOM — pinned to a 1px box so it still serialises — and this draws over it. */

.ms { position: relative; }
.ms__native {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; pointer-events: none; z-index: -1;
}

.ms__control {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  min-height: var(--input-height);
  padding: 4px 30px 4px 7px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  cursor: text;
}
.ms.is-open .ms__control { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(21,93,252,.12); }
.ms.is-invalid .ms__control { border-color: var(--color-danger); }

.ms__chips { display: contents; }
.ms__chip {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 100%;
  font-size: 12px; line-height: 1.7;
  padding: 0 3px 0 9px;
  border-radius: 999px;
  background: #eef2fb; color: #2b3b5e; border: 1px solid #dde4f2;
}
.ms__chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms__chip-x {
  border: 0; background: none; cursor: pointer; line-height: 1;
  font-size: 15px; color: #6b7a99; padding: 0 3px; border-radius: 999px;
}
.ms__chip-x:hover { background: #d9e2f5; color: var(--color-danger); }

.ms__search {
  flex: 1 1 90px; min-width: 90px;
  border: 0; outline: none; background: none;
  font-family: inherit; font-size: var(--fs-input); color: var(--color-text);
  height: 27px;
}
.ms__caret {
  position: absolute; top: 0; right: 0; width: 28px; height: 100%;
  border: 0; background: none; cursor: pointer;
}
.ms__caret::after {
  content: ""; position: absolute; top: 50%; right: 11px;
  width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.5px solid var(--color-muted); border-bottom: 1.5px solid var(--color-muted);
  transform: rotate(45deg);
}
.ms.is-open .ms__caret::after { transform: rotate(-135deg); margin-top: -1px; }

.ms__menu {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(24,34,58,.14);
  overflow: hidden;
}
.ms__bulk {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-bottom: 1px solid var(--color-row-border);
  background: #fafbfe;
}
.ms__bulk-btn {
  border: 0; background: none; cursor: pointer; padding: 0;
  font-family: inherit; font-size: 12px; font-weight: 600; color: var(--color-primary);
}
.ms__bulk-btn:hover { text-decoration: underline; }
.ms__count { margin-left: auto; font-size: 12px; color: var(--color-muted); }

.ms__list { list-style: none; margin: 0; padding: 4px; max-height: 240px; overflow-y: auto; }
.ms__option {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--radius-md);
  font-size: 13px; cursor: pointer;
}
.ms__option.is-active { background: #eef2fb; }
.ms__option:hover { background: #eef2fb; }
.ms__tick {
  flex: 0 0 15px; width: 15px; height: 15px;
  border: 1px solid #bcc4d6; border-radius: 3px; background: #fff;
  position: relative;
}
.ms__option.is-selected .ms__tick { background: var(--color-primary); border-color: var(--color-primary); }
.ms__option.is-selected .ms__tick::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(42deg);
}
.ms__empty { margin: 0; padding: 14px 12px; font-size: 13px; color: var(--color-muted); text-align: center; }

/* ------------------------------------------------------ searchable select */
/* public/assets/js/searchable-select.js — reuses the multi-select menu. */

.ss { position: relative; }
.ss__native { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; z-index: -1; }

.ss__control {
  display: flex; align-items: center; width: 100%;
  height: var(--input-height);
  padding: 6px 30px 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: #fff;
  font-family: inherit; font-size: var(--fs-input); color: var(--color-text);
  text-align: left; cursor: pointer; position: relative;
}
.ss__control::after {
  content: ""; position: absolute; top: 50%; right: 12px;
  width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.5px solid var(--color-muted); border-bottom: 1.5px solid var(--color-muted);
  transform: rotate(45deg);
}
.ss.is-open .ss__control { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(21,93,252,.12); }
.ss.is-open .ss__control::after { transform: rotate(-135deg); margin-top: -1px; }
.ss.is-disabled .ss__control { background: #f6f7fb; color: var(--color-muted); cursor: not-allowed; }

.ss__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss__value.is-placeholder { color: var(--color-muted); }

.ss__search-wrap { padding: 7px; border-bottom: 1px solid var(--color-row-border); background: #fafbfe; }
.ss__search {
  width: 100%; height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-family: inherit; font-size: var(--fs-input); color: var(--color-text);
  outline: none;
}
.ss__search:focus { border-color: var(--color-primary); }
.ss__option { padding-left: 10px; }

/* ------------------------------------------------------------- rich text */
/* The six order description fields hold HTML from the legacy's editor
   (docs/11-known-issues.md #39). Sanitised by App\Support\Html\RichText. */

.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich p { margin: 0 0 8px; }
.rich ul, .rich ol { margin: 0 0 8px; padding-left: 20px; }
.rich li { margin-bottom: 3px; }
.rich h3, .rich h4 { font-size: 14px; margin: 12px 0 6px; }
.rich blockquote { margin: 0 0 8px; padding-left: 12px; border-left: 3px solid var(--color-row-border); color: var(--color-muted); }

/* ------------------------------------------------------- rich-text field */
/* public/assets/js/rich-text.js */

.rt { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: #fff; overflow: hidden; }
.rt:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(21,93,252,.12); }
.rt__source { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; z-index: -1; }

.rt__bar { display: flex; gap: 2px; padding: 5px 6px; background: #fafbfe; border-bottom: 1px solid var(--color-row-border); }
.rt__btn {
  min-width: 26px; height: 24px; padding: 0 6px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; color: var(--color-text); line-height: 1;
}
.rt__btn:hover { background: #e8eefb; border-color: #d4dff5; }

.rt__body {
  min-height: 84px; max-height: 320px; overflow-y: auto;
  padding: 9px 12px;
  font-family: inherit; font-size: var(--fs-input); color: var(--color-text);
  outline: none;
}
.rt__body:empty::before { content: attr(data-placeholder); color: var(--color-muted); }
.table td.is-nowrap, .table th.is-nowrap { white-space: nowrap; }

/* The header follows its column: `data-align="right"` on a <th> aligns the
   heading, and list-screen.js puts the matching class on every cell below it. */
.table th[data-align="right"] { text-align: right; }
.table th[data-nowrap] { white-space: nowrap; }

/* A column with no fixed width is the one carrying the name, and the browser
   gives it whatever the fixed columns leave — which on a 1440px screen was 121px
   for "ORTHOSUT BIOMEDICAL AND ENGINEERING". `data-grow` claims a floor; the
   table scrolls inside .table-wrap rather than squeezing it. */
.table th[data-grow] { min-width: 220px; }

/* The record being approved or rejected, named in the confirmation dialog. */
.swal-record {
  font-size: 15px; font-weight: 700; color: #2b2c37;
  margin: -4px 0 2px; word-break: break-word;
}

/* A hint that is reporting an assumption rather than a looked-up value. */
.form-hint--warn { color: #9a6700; font-weight: 600; }

/* --------------------------------------------------------------- errors */
/* resources/views/errors/*. Standalone — an error can happen before login. */

.error-page {
  max-width: 520px;
  margin: 0 auto;
  padding: 18vh 24px 40px;
  text-align: center;
}
.error-page__code {
  font-size: 56px; font-weight: 800; line-height: 1;
  color: var(--color-border); margin: 0 0 6px;
  font-variant-numeric: tabular-nums;
}
.error-page__title { font-size: 22px; font-weight: 800; color: #2b2c37; margin: 0 0 10px; }
.error-page__body { font-size: 15px; color: var(--color-muted); margin: 0 0 6px; }
.error-page__detail {
  font-size: 13px; color: var(--color-text);
  background: #f6f7fb; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 9px 12px; margin: 12px 0 0;
}
.error-page__actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

/* The collapsed group that holds the current page — tinted so the trail to the
   highlighted item is visible even before the group is scrolled into view. */
.sidebar__group.is-current > .sidebar__link { color: #fff; }
.sidebar__group.is-current > .sidebar__link .sidebar__caret { color: var(--color-sidebar-active); }
.ms.is-disabled .ms__control { background: #f6f7fb; cursor: not-allowed; }
.ms.is-disabled .ms__search { pointer-events: none; }

/* The topbar name links to My Profile — it is the only way in. */
a.topbar__user { text-decoration: none; color: inherit; border-radius: var(--radius-md); padding: 3px 6px; }
a.topbar__user:hover { background: #eef2fb; text-decoration: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════
   The landing page after login, so it is the one screen every user sees every
   day. It had been laid out with inline styles and rendered its pipeline stages
   with `.form-group` / `.form-label` — a FORM idiom, which made four key figures
   read as a disabled form (docs/11-known-issues.md #65).

   The legacy pairs every figure with a coloured icon; that is most of why it
   reads better, and it is reproduced here with the icons this build already has.
*/

.dash-grid {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}
.dash-grid--kpi  { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.dash-grid--wide { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ---------------------------------------------------------------- KPI card */

.stat {
    background: var(--color-card-bg);
    border: 1px solid var(--color-row-border);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.stat__icon {
    flex: 0 0 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    /* A 12% wash of the tone, so the icon reads without shouting. */
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
}
.stat__icon svg { width: 18px; height: 18px; }

.stat--success .stat__icon { color: var(--color-success); background: color-mix(in srgb, var(--color-success) 12%, transparent); }
.stat--warning .stat__icon { color: #b8860b;             background: color-mix(in srgb, var(--color-warning) 18%, transparent); }
.stat--danger  .stat__icon { color: var(--color-danger);  background: color-mix(in srgb, var(--color-danger) 12%, transparent); }
.stat--info    .stat__icon { color: var(--color-info);    background: color-mix(in srgb, var(--color-info) 12%, transparent); }

.stat__body  { min-width: 0; flex: 1; }
.stat__label { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--color-muted); }
.stat__value { font-size: 24px; font-weight: 700; line-height: 1.25; margin: 4px 0 2px; color: var(--color-text); }
.stat__value--sm { font-size: 19px; }
.stat__note  { font-size: 11.5px; color: var(--color-muted); }
.stat__note strong { color: var(--color-text); }

/* ------------------------------------------------------------- section head */

.dash-section { margin-top: 18px; }
.dash-section__title { font-size: 15px; font-weight: 700; margin: 0 0 2px; }
.dash-section__hint  { font-size: 12px; color: var(--color-muted); margin: 0 0 14px; }

/* ------------------------------------------------------------- the pipeline */

.pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.pipeline__stage {
    position: relative;
    border: 1px solid var(--color-row-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    background: var(--color-card-bg);
}

/* The chevron between stages — drawn, not a character, so it cannot wrap. */
.pipeline__stage::after {
    content: "";
    position: absolute;
    right: -11px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--color-border);
    border-right: 2px solid var(--color-border);
    transform: translateY(-50%) rotate(45deg);
    z-index: 1;
}
.pipeline__stage:last-child::after { display: none; }

/* Stacked on a narrow screen, the chevrons would point into empty space. */
@media (max-width: 760px) {
    .pipeline__stage::after { display: none; }
}

.pipeline__head  { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pipeline__label { font-size: 12px; font-weight: 700; color: var(--color-muted); }
.pipeline__units { font-size: 19px; font-weight: 700; }
.pipeline__value { font-size: 12px; color: var(--color-muted); }

/* ------------------------------------------------------- queue / list rows */

.queue { display: flex; flex-direction: column; gap: 2px; }

.queue__row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    color: inherit;
}
.queue__row:hover { background: color-mix(in srgb, var(--color-primary) 6%, transparent); }
.queue__label { flex: 1; font-size: 13px; }
.queue__count {
    min-width: 34px;
    text-align: center;
    font-weight: 700;
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-warning) 22%, transparent);
    color: #8a6100;
}

/* --------------------------------------------------------- labelled bars */

.meter { margin-bottom: 12px; }
.meter:last-child { margin-bottom: 0; }
.meter__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 12.5px;
    margin-bottom: 5px;
}
.meter__name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter__figure { color: var(--color-muted); white-space: nowrap; }
.meter__track { background: var(--color-border); border-radius: 4px; height: 8px; overflow: hidden; }
.meter__fill  { background: var(--color-primary); height: 100%; border-radius: 4px; }

/* ------------------------------------------------------------ donut legend */

.donut-row { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
/* `flex-basis`, not `min-width`: a min-width alone does not make a flex item wrap,
   so the legend was squeezed under the donut and truncated "Finished Goods" to
   "Finished Go…" in a card wide enough to hold it twice over. */
.donut-legend { flex: 1 1 210px; display: flex; flex-direction: column; gap: 7px; }
.donut-legend__item { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.donut-legend__swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.donut-legend__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend__value { color: var(--color-muted); white-space: nowrap; }

/* Rows-per-page selector. The legacy offers 10/25/50/100 on every list and this
   build had no selector at all, fixed at 25 (#66). */
.dt-length { font-size: 12px; color: var(--color-muted); display: inline-flex; align-items: center; gap: 6px; }
.dt-length select {
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-card-bg);
    color: var(--color-text);
}
