/* ===========================================================================
   Procura design system
   ---------------------------------------------------------------------------
   The interface is an instrument panel for people who read price tables all
   day, not a marketing page. Two ideas drive the visual language:

   1. Numbers are the content. Figures use tabular lining numerals so columns
      align, and are set larger and lighter than their labels - the label is
      dense and small, the number is open. Totals carry the double rule above
      them that accounting documents use, because it encodes "this is a sum".

   2. Incomplete data must look incomplete. A missing input renders as a
      hatched cell with an em dash, never a zero, and any figure derived from
      incomplete inputs carries a confidence chip. This is the one place the
      design raises its voice, and it exists because a procurement decision
      made on a silently-wrong number is the failure mode that matters.
   =========================================================================== */

:root {
  /* Ledger paper: cool and slightly green, not warm cream. */
  --paper: #f7f8f6;
  --paper-raised: #ffffff;
  --paper-sunken: #eef0ed;
  --paper-rail: #11211f;

  /* Ink */
  --ink: #161a19;
  --ink-muted: #4a5351;
  --ink-faint: #767f7c;
  --ink-inverse: #f2f5f3;

  /* Deep teal: verification and action. */
  --accent: #0f5257;
  --accent-hover: #0b3f43;
  --accent-wash: #e4eeee;
  --accent-edge: #9cbfc1;

  /* Brass: reserved for "needs attention". Never decorative. */
  --attention: #8a6a2f;
  --attention-wash: #f7f0e2;
  --attention-edge: #d8c08a;

  /* Outcomes */
  --positive: #1e6b4f;
  --positive-wash: #e4f0ea;
  --negative: #9b2c2c;
  --negative-wash: #f8e8e8;

  /* Unknown / insufficient data */
  --unknown: #8c938f;
  --unknown-wash: #e9ebe9;

  --rule: #d8ddda;
  --rule-strong: #b4bcb8;

  --radius: 3px;
  --radius-lg: 5px;

  --rail-width: 232px;
  --measure: 68ch;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* Type scale: 1.2 ratio from 13px, tightened for data density. */
  --t-micro: 0.6875rem;
  --t-small: 0.8125rem;
  --t-body: 0.875rem;
  --t-lead: 1rem;
  --t-h3: 1.125rem;
  --t-h2: 1.375rem;
  --t-h1: 1.75rem;
  --t-figure: 2rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Numbers align in columns, everywhere. */
.num,
td.num,
th.num,
.figure,
input[type='number'],
table.data td,
table.data th {
  font-variant-numeric: tabular-nums lining-nums;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.011em;
  line-height: 1.25;
}
h1 {
  font-size: var(--t-h1);
}
h2 {
  font-size: var(--t-h2);
}
h3 {
  font-size: var(--t-h3);
}
h4 {
  font-size: var(--t-body);
}

p {
  margin: 0 0 var(--space-3);
  max-width: var(--measure);
}

a {
  color: var(--accent);
  text-decoration-color: var(--accent-edge);
  text-underline-offset: 2px;
}
a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

/* Keyboard focus is always visible and never removed. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.rail :focus-visible {
  outline-color: #7fd4d8;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------------------------------------------------------------------------
   Shell
   --------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--paper-rail);
  color: var(--ink-inverse);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.rail__toggle {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.rail__menu-btn { display: none; }

.rail__brand {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.rail__mark {
  font-size: var(--t-lead);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
}

.rail__org {
  margin-top: var(--space-1);
  font-size: var(--t-small);
  color: rgba(242, 245, 243, 0.62);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail__nav {
  padding: var(--space-3) var(--space-2);
  flex: 1;
}

.rail__group + .rail__group {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.rail__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.3rem var(--space-3);
  border-radius: var(--radius);
  color: rgba(242, 245, 243, 0.78);
  text-decoration: none;
  font-size: var(--t-small);
}
.rail__link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}
.rail__link[aria-current='page'] {
  background: rgba(124, 212, 216, 0.14);
  color: #fff;
  font-weight: 500;
  box-shadow: inset 2px 0 0 #7fd4d8;
}

.rail__count {
  font-size: var(--t-micro);
  color: rgba(242, 245, 243, 0.55);
  font-variant-numeric: tabular-nums;
}
.rail__count--attention {
  color: var(--attention-edge);
  font-weight: 600;
}

.rail__foot {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: var(--t-small);
}
.rail__user {
  color: rgba(242, 245, 243, 0.82);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rail__role {
  color: rgba(242, 245, 243, 0.5);
  font-size: var(--t-micro);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--paper-raised);
  border-bottom: 1px solid var(--rule);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.topbar__titles {
  min-width: 0;
}
.topbar__sub {
  margin: var(--space-1) 0 0;
  color: var(--ink-muted);
  font-size: var(--t-small);
  max-width: var(--measure);
}

.topbar__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.content {
  padding: var(--space-5);
  flex: 1;
}

/* Demo data must always be identifiable as demo data. */
.demo-banner {
  background: var(--attention-wash);
  border-bottom: 1px solid var(--attention-edge);
  color: #5d4718;
  padding: var(--space-2) var(--space-5);
  font-size: var(--t-small);
}

/* ---------------------------------------------------------------------------
   Panels
   --------------------------------------------------------------------------- */

.panel {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
}
.panel + .panel {
  margin-top: var(--space-5);
}

.panel__head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.panel__title {
  font-size: var(--t-body);
  font-weight: 600;
}

.panel__note {
  font-size: var(--t-micro);
  color: var(--ink-faint);
}

.panel__body {
  padding: var(--space-4);
}
.panel__body--flush {
  padding: 0;
}

.grid {
  display: grid;
  gap: var(--space-4);
}
.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* ---------------------------------------------------------------------------
   Figures
   ---------------------------------------------------------------------------
   The label is small and dense; the figure is large and light. Each figure
   states its basis, because "spend" is ambiguous unless you say whether it
   means ordered, received or invoiced.
   --------------------------------------------------------------------------- */

.figure-block {
  padding: var(--space-4);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
}

.figure-block__label {
  font-size: var(--t-micro);
  color: var(--ink-muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.figure {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--t-figure);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.figure__unit {
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--ink-muted);
  margin-right: 0.3ch;
}

/* States an explicit date and value basis. Non-optional for every metric. */
.figure-block__basis {
  margin-top: var(--space-2);
  font-size: var(--t-micro);
  color: var(--ink-faint);
  line-height: 1.4;
}

.figure--unknown {
  color: var(--unknown);
  font-weight: 400;
}

.delta {
  font-size: var(--t-small);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.delta--up {
  color: var(--negative);
}
.delta--down {
  color: var(--positive);
}
.delta--flat {
  color: var(--ink-faint);
}

/* ---------------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
}

table.data th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-muted);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
  background: var(--paper-raised);
  position: sticky;
  top: 0;
  z-index: 1;
}

table.data td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

table.data tbody tr:hover {
  background: var(--paper-sunken);
}

table.data .num,
table.data th.num {
  text-align: right;
}

/* The accounting double rule: this row is a sum of the rows above it. */
table.data tfoot td,
table.data tr.is-total td {
  border-top: 3px double var(--rule-strong);
  border-bottom: none;
  font-weight: 600;
  padding-top: var(--space-2);
}

table.data td.cell-main {
  font-weight: 500;
  color: var(--ink);
}
table.data .cell-sub {
  display: block;
  font-size: var(--t-micro);
  color: var(--ink-faint);
  margin-top: 1px;
}

/* -- The hatched unknown cell ----------------------------------------------
   A value that could not be computed is drawn as hatched, never as 0. This
   is the design's loudest signal and it is used only for genuinely missing
   or non-comparable data.
   ------------------------------------------------------------------------- */
.cell-unknown {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    var(--unknown-wash) 4px,
    var(--unknown-wash) 8px
  );
  color: var(--unknown);
  text-align: right;
}
.cell-unknown abbr {
  text-decoration: none;
  border-bottom: 1px dotted var(--unknown);
  cursor: help;
}

.row-flagged {
  box-shadow: inset 3px 0 0 var(--attention);
}
.row-breach {
  box-shadow: inset 3px 0 0 var(--negative);
}

/* ---------------------------------------------------------------------------
   Status pills and chips
   --------------------------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 2px;
  font-size: var(--t-micro);
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
}
.pill--neutral {
  background: var(--paper-sunken);
  color: var(--ink-muted);
  border-color: var(--rule-strong);
}
.pill--accent {
  background: var(--accent-wash);
  color: var(--accent);
  border-color: var(--accent-edge);
}
.pill--positive {
  background: var(--positive-wash);
  color: var(--positive);
  border-color: #a8ccba;
}
.pill--attention {
  background: var(--attention-wash);
  color: #5d4718;
  border-color: var(--attention-edge);
}
.pill--negative {
  background: var(--negative-wash);
  color: var(--negative);
  border-color: #dba9a9;
}
.pill--unknown {
  background: var(--unknown-wash);
  color: #5c625f;
  border-color: var(--rule-strong);
}

/* Data-confidence chip: attached to any derived figure. */
.confidence {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--t-micro);
  color: var(--ink-muted);
}
.confidence__dots {
  display: inline-flex;
  gap: 2px;
}
.confidence__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rule-strong);
}
.confidence__dot--on {
  background: var(--accent);
}
.confidence--low .confidence__dot--on {
  background: var(--attention);
}

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */

.field {
  margin-bottom: var(--space-4);
}
.field__label {
  display: block;
  font-size: var(--t-small);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.field__hint {
  display: block;
  font-size: var(--t-micro);
  color: var(--ink-faint);
  margin-top: var(--space-1);
  max-width: var(--measure);
}
.field__error {
  display: block;
  font-size: var(--t-micro);
  color: var(--negative);
  margin-top: var(--space-1);
  font-weight: 500;
}
.field__req {
  color: var(--negative);
  margin-left: 2px;
}

input:not([type]),
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='search'],
input[type='tel'],
input[type='url'],
select,
textarea {
  width: 100%;
  padding: 0.4rem 0.55rem;
  font: inherit;
  font-size: var(--t-small);
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-wash);
  outline-offset: 0;
}
input[aria-invalid='true'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-color: var(--negative);
}
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--paper-sunken);
  color: var(--ink-faint);
  cursor: not-allowed;
}
textarea {
  min-height: 5rem;
  resize: vertical;
  line-height: 1.5;
}

.field-row {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

fieldset {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: 0 0 var(--space-5);
}
legend {
  font-size: var(--t-small);
  font-weight: 600;
  padding: 0 var(--space-2);
}

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: var(--t-small);
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  background: var(--paper-raised);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  background: var(--paper-sunken);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.btn--danger {
  background: var(--paper-raised);
  border-color: #dba9a9;
  color: var(--negative);
}
.btn--danger:hover {
  background: var(--negative-wash);
}
.btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
}
.btn--quiet:hover {
  background: var(--accent-wash);
}
.btn--small {
  padding: 0.2rem 0.5rem;
  font-size: var(--t-micro);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-group {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

/* ---------------------------------------------------------------------------
   Filters and toolbars
   --------------------------------------------------------------------------- */

.toolbar {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-raised);
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  flex-wrap: wrap;
}
.toolbar .field {
  margin-bottom: 0;
}
.toolbar__spacer {
  flex: 1;
}

.filter-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--rule);
  font-size: var(--t-micro);
  align-items: center;
  background: var(--paper-sunken);
}
.filter-chip {
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0.1rem 0.4rem;
}
.filter-chip a {
  text-decoration: none;
  color: var(--ink-faint);
  margin-left: 0.3rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Messages
   --------------------------------------------------------------------------- */

.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule-strong);
  background: var(--paper-raised);
  font-size: var(--t-small);
  margin-bottom: var(--space-4);
}
.notice__title {
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.notice p:last-child {
  margin-bottom: 0;
}
.notice--success {
  background: var(--positive-wash);
  border-color: #a8ccba;
  color: #14452f;
}
.notice--error {
  background: var(--negative-wash);
  border-color: #dba9a9;
  color: #6f1f1f;
}
.notice--attention {
  background: var(--attention-wash);
  border-color: var(--attention-edge);
  color: #5d4718;
}
.notice--info {
  background: var(--accent-wash);
  border-color: var(--accent-edge);
  color: #0a3b3e;
}

/* ---------------------------------------------------------------------------
   Empty states: an invitation to act, not an apology.
   --------------------------------------------------------------------------- */

.empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--ink-muted);
}
.empty__title {
  font-size: var(--t-lead);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: var(--space-2);
}
.empty__body {
  max-width: 46ch;
  margin: 0 auto var(--space-4);
  font-size: var(--t-small);
}

/* Distinct from "empty": the data exists but cannot support the metric. */
.insufficient {
  padding: var(--space-5);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-lg);
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 5px,
    var(--unknown-wash) 5px,
    var(--unknown-wash) 10px
  );
}
.insufficient__title {
  font-weight: 600;
  font-size: var(--t-small);
  margin-bottom: var(--space-2);
}
.insufficient__body {
  font-size: var(--t-small);
  color: var(--ink-muted);
  max-width: 60ch;
  margin: 0;
}

/* ---------------------------------------------------------------------------
   Detail pages
   --------------------------------------------------------------------------- */

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
  align-items: start;
}

.kv {
  display: grid;
  grid-template-columns: minmax(120px, 36%) 1fr;
  gap: var(--space-2) var(--space-3);
  font-size: var(--t-small);
  margin: 0;
}
.kv dt {
  color: var(--ink-muted);
  font-weight: 500;
}
.kv dd {
  margin: 0;
}

.masked {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------------------
   Pagination
   --------------------------------------------------------------------------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--rule);
  font-size: var(--t-small);
  flex-wrap: wrap;
}
.pager__status {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--paper);
}
.auth__card {
  width: 100%;
  max-width: 25rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.auth__mark {
  font-size: var(--t-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-1);
}
.auth__intro {
  color: var(--ink-muted);
  font-size: var(--t-small);
  margin-bottom: var(--space-5);
}
.auth__foot {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
  font-size: var(--t-micro);
  color: var(--ink-faint);
}

/* ---------------------------------------------------------------------------
   Utilities
   --------------------------------------------------------------------------- */

.u-muted {
  color: var(--ink-muted);
}
.u-faint {
  color: var(--ink-faint);
}
.u-small {
  font-size: var(--t-small);
}
.u-micro {
  font-size: var(--t-micro);
}
.u-right {
  text-align: right;
}
.u-nowrap {
  white-space: nowrap;
}
.u-mono {
  font-family: var(--mono);
  font-size: 0.95em;
}
.u-stack > * + * {
  margin-top: var(--space-4);
}
.u-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}
.u-mt-0 {
  margin-top: 0;
}
.u-mb-0 {
  margin-bottom: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  transform: translateY(-120%);
  background: var(--accent);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  z-index: 100;
}
.skip-link:focus {
  transform: none;
}

/* ---------------------------------------------------------------------------
   Responsive: approvals and receiving happen on phones in corridors
   and loading bays, so those flows must work at narrow widths.
   --------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .rail {
    position: static;
    height: auto;
    flex-direction: column;
  }
  /* On a phone the menu is closed until asked for, so the page starts with its content. */
  .rail__menu-btn {
    display: inline-flex;
    align-items: center;
    float: inline-end;
    min-height: 2.5rem;
    padding: 0 var(--space-4);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
  }
  .rail__toggle:focus-visible ~ .rail__brand .rail__menu-btn { outline: 2px solid #fff; outline-offset: 2px; }
  .rail__toggle:checked ~ .rail__brand .rail__menu-btn { background: rgba(255, 255, 255, 0.16); }
  .rail__brand { padding: var(--space-3); }
  .rail__toggle:not(:checked) ~ .rail__nav,
  .rail__toggle:not(:checked) ~ .rail__foot { display: none; }
  .rail__nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--space-1);
  }
  .rail__group + .rail__group {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
  .content {
    padding: var(--space-4) var(--space-3);
  }
  .topbar {
    padding: var(--space-3);
  }

  /* Tables reflow into labelled rows rather than scrolling sideways. */
  table.data.data--stack thead {
    display: none;
  }
  table.data.data--stack tr {
    display: block;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    padding: var(--space-2);
    background: var(--paper-raised);
  }
  table.data.data--stack td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    border: none;
    padding: var(--space-1) var(--space-2);
    text-align: right;
  }
  table.data.data--stack td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ink-muted);
    font-size: var(--t-micro);
    text-align: left;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
  .kv dt {
    margin-top: var(--space-2);
  }
}

/* ---------------------------------------------------------------------------
   Print: documents must print as documents.
   --------------------------------------------------------------------------- */

@media print {
  .rail,
  .topbar__actions,
  .toolbar,
  .pager,
  .skip-link {
    display: none !important;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  body {
    background: #fff;
    font-size: 11pt;
  }
  .panel {
    border: none;
    break-inside: avoid;
  }
  table.data thead {
    display: table-header-group;
  }
  table.data tr {
    break-inside: avoid;
  }
}

/* ===========================================================================
   Enhancement layer
   ---------------------------------------------------------------------------
   Styles for behaviour added by app.js. Everything here degrades to nothing
   when JavaScript is unavailable, because the markup it styles is created by
   the script rather than rendered by the server.
   =========================================================================== */

/* -- Toasts --------------------------------------------------------------- */

.toast-host {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(26rem, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-left-width: 3px;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px rgba(22, 26, 25, 0.13);
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.toast--leaving {
  opacity: 0;
  transition: opacity 0.2s ease;
}
.toast--success {
  border-left-color: var(--positive);
}
.toast--error {
  border-left-color: var(--negative);
}
.toast--attention {
  border-left-color: var(--attention);
}
.toast--info {
  border-left-color: var(--accent);
}
.toast__body {
  flex: 1;
  min-width: 0;
}
.toast__title {
  font-size: var(--t-small);
  font-weight: 600;
}
.toast__detail {
  font-size: var(--t-micro);
  color: var(--ink-muted);
  margin-top: 2px;
}
.toast__close {
  background: none;
  border: none;
  font-size: var(--t-lead);
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 2px;
}
.toast__close:hover {
  color: var(--ink);
}

/* -- Modal confirmation --------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 26, 25, 0.42);
  display: grid;
  place-items: center;
  z-index: 300;
  padding: var(--space-4);
}
.modal {
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  max-width: 28rem;
  width: 100%;
  box-shadow: 0 12px 40px rgba(22, 26, 25, 0.24);
}
.modal__text {
  font-size: var(--t-body);
  margin-bottom: var(--space-4);
  max-width: none;
}

/* -- Pack preview --------------------------------------------------------- */
/* The live answer to "what does this pack actually come to". */

.pack-preview {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--rule);
  font-size: var(--t-small);
}
.pack-preview--empty {
  color: var(--ink-faint);
  background: var(--paper-sunken);
}
.pack-preview--warn {
  background: var(--attention-wash);
  border-color: var(--attention-edge);
  color: #5d4718;
}
.pack-preview--ok {
  background: var(--accent-wash);
  border-color: var(--accent-edge);
}
.pack-preview__sum {
  font-size: var(--t-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.pack-preview__working,
.pack-preview__example {
  font-size: var(--t-micro);
  color: var(--ink-muted);
  margin-top: var(--space-1);
  font-variant-numeric: tabular-nums;
}

/* -- Command palette ------------------------------------------------------ */

.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 26, 25, 0.38);
  z-index: 300;
  padding: 10vh var(--space-4) var(--space-4);
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.palette {
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 34rem;
  box-shadow: 0 16px 48px rgba(22, 26, 25, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.palette__input {
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: var(--space-4);
  font-size: var(--t-lead);
  width: 100%;
  background: transparent;
}
.palette__input:focus {
  outline: none;
  border-color: var(--rule);
}
.palette__results {
  overflow-y: auto;
  flex: 1;
}
.palette__group {
  padding: var(--space-2) var(--space-4) var(--space-1);
  font-size: var(--t-micro);
  font-weight: 600;
  color: var(--ink-faint);
  background: var(--paper-sunken);
  border-bottom: 1px solid var(--rule);
}
.palette__item {
  display: block;
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
}
.palette__item--active,
.palette__item:hover {
  background: var(--accent-wash);
}
.palette__item-main {
  display: block;
  font-size: var(--t-small);
  font-weight: 500;
}
.palette__item-sub {
  display: block;
  font-size: var(--t-micro);
  color: var(--ink-faint);
}
.palette__empty {
  padding: var(--space-5) var(--space-4);
  text-align: center;
  color: var(--ink-faint);
  font-size: var(--t-small);
}
.palette__hint {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--rule);
  font-size: var(--t-micro);
  color: var(--ink-faint);
  background: var(--paper-sunken);
}

/* -- Search trigger in the rail ------------------------------------------- */

.rail__search {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  margin-top: var(--space-3);
  padding: 0.3rem var(--space-3);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  color: rgba(242, 245, 243, 0.68);
  font: inherit;
  font-size: var(--t-small);
  cursor: pointer;
  text-align: left;
}
.rail__search:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.rail__search kbd {
  font-family: var(--mono);
  font-size: var(--t-micro);
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  color: rgba(242, 245, 243, 0.6);
}

/* -- Getting started checklist -------------------------------------------- */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}
.step {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--rule);
  align-items: flex-start;
}
.step:last-child {
  border-bottom: none;
}
.step__mark {
  flex: 0 0 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 1.5px solid var(--rule-strong);
  display: grid;
  place-items: center;
  font-size: var(--t-micro);
  font-weight: 700;
  color: var(--ink-faint);
  margin-top: 1px;
}
.step--done .step__mark {
  background: var(--positive);
  border-color: var(--positive);
  color: #fff;
}
.step--done .step__title {
  color: var(--ink-muted);
}
.step__body {
  flex: 1;
  min-width: 0;
}
.step__title {
  font-size: var(--t-small);
  font-weight: 600;
}
.step__text {
  font-size: var(--t-micro);
  color: var(--ink-muted);
  margin: 2px 0 0;
  max-width: 62ch;
}
.step__action {
  margin-top: var(--space-2);
}

/* -- Breadcrumbs ---------------------------------------------------------- */

.crumbs {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-size: var(--t-micro);
  color: var(--ink-faint);
  margin-bottom: var(--space-1);
  flex-wrap: wrap;
}
.crumbs a {
  color: var(--ink-muted);
  text-decoration: none;
}
.crumbs a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* -- Collapsed "not built yet" nav group ---------------------------------- */

.rail__coming {
  margin: var(--space-3) var(--space-2) 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: var(--space-3);
}
.rail__coming summary {
  padding: 0.2rem var(--space-3);
  font-size: var(--t-micro);
  color: rgba(242, 245, 243, 0.45);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.rail__coming summary::-webkit-details-marker {
  display: none;
}
.rail__coming summary:hover {
  color: rgba(242, 245, 243, 0.7);
  background: rgba(255, 255, 255, 0.05);
}
.rail__coming-item {
  display: block;
  padding: 0.2rem var(--space-3);
  font-size: var(--t-micro);
  color: rgba(242, 245, 243, 0.34);
}

/* -- Inline help ---------------------------------------------------------- */

.help {
  display: block;
  margin-top: var(--space-2);
  padding: var(--space-3);
  background: var(--accent-wash);
  border-left: 2px solid var(--accent-edge);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--t-micro);
  color: #0a3b3e;
  max-width: 66ch;
}
.help strong {
  display: block;
  margin-bottom: 2px;
}
.help code {
  font-family: var(--mono);
  background: rgba(255, 255, 255, 0.6);
  padding: 0 3px;
  border-radius: 2px;
}

/* -- Section intro -------------------------------------------------------- */

.intro {
  font-size: var(--t-small);
  color: var(--ink-muted);
  max-width: 70ch;
  margin: 0 0 var(--space-4);
}

/* -- Compact definition row used on setup pages --------------------------- */

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-small);
}
.mini-table td {
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--rule);
}
.mini-table tr:last-child td {
  border-bottom: none;
}
.mini-table td:last-child {
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .toast-host {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
    max-width: none;
  }
  .palette-backdrop {
    padding: var(--space-3);
  }
}

.rail__group-label {
  padding: 0 var(--space-3) var(--space-1);
  font-size: var(--t-micro);
  font-weight: 600;
  color: rgba(242, 245, 243, 0.38);
}

/* ---------------------------------------------------------------------------
   Reports: filter bar, charts, share bars, compact tables
   --------------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}
.filter-bar .field {
  margin: 0;
  min-width: 9rem;
  flex: 0 1 auto;
}
.filter-bar .btn-group {
  margin-bottom: 2px;
}

.data--compact th,
.data--compact td {
  padding: var(--space-2) var(--space-3);
  font-size: var(--t-small);
  vertical-align: top;
}
.data--compact th[scope='row'] {
  font-weight: 500;
  color: var(--ink-muted);
  text-align: left;
}

/* A share bar carries no information the number does not; it is there to make
   the table scannable, so it is hidden from assistive technology. */
.share-bar {
  display: block;
  margin-top: 3px;
  height: 3px;
  background: var(--paper-sunken);
  border-radius: 2px;
  overflow: hidden;
}
.share-bar__fill {
  display: block;
  height: 100%;
  background: var(--accent-edge);
}

.cell-unknown-inline {
  color: var(--unknown);
  font-style: italic;
  font-size: var(--t-small);
}
.cell-unknown-inline abbr {
  text-decoration: underline dotted;
  cursor: help;
}

.chart {
  margin: 0;
}
.chart__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.chart__grid {
  stroke: var(--rule);
  stroke-width: 1;
}
.chart__axis {
  stroke: var(--rule-strong);
  stroke-width: 1;
}
.chart__tick {
  font-family: var(--sans);
  font-size: 10px;
  fill: var(--ink-faint);
}
.chart__axis-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  fill: var(--ink-muted);
}
.chart__bar {
  fill: var(--accent);
}
.chart__bar:hover {
  fill: var(--accent-hover);
}
.chart__line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}
.chart__dot {
  fill: var(--paper-raised);
  stroke: var(--accent);
  stroke-width: 2;
}
.chart__dot:hover {
  fill: var(--accent);
}
.chart__caption {
  margin-top: var(--space-2);
}
.chart__data {
  margin-top: var(--space-2);
}
.chart__data summary {
  font-size: var(--t-micro);
  color: var(--ink-muted);
  cursor: pointer;
}
.chart__data table {
  margin-top: var(--space-2);
  max-height: 18rem;
  display: block;
  overflow-y: auto;
}

.u-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.u-wrap {
  flex-wrap: wrap;
}

@media (max-width: 760px) {
  .filter-bar .field {
    min-width: 100%;
  }
}

@media print {
  .rail,
  .filter-bar,
  .btn,
  .btn-group {
    display: none !important;
  }
  .chart__data[open] summary {
    display: none;
  }
  .panel {
    break-inside: avoid;
  }
}

/* A compact key/value table must not let a long label push the figure out of
   the panel: the label wraps, the figure keeps its own column. */
.data--compact th[scope='row'] {
  width: auto;
  padding-right: var(--space-4);
  overflow-wrap: anywhere;
}
.data--compact td.num {
  white-space: nowrap;
  width: 1%;
}

/* ---------------------------------------------------------------------------
   Milestone 3: budgets, quotation comparison, LPO
   --------------------------------------------------------------------------- */

/* Budget usage: actual then committed, stacked against the budget amount. */
.budget-bar {
  display: flex;
  height: 10px;
  background: var(--paper-sunken);
  border-radius: 5px;
  overflow: hidden;
}
.budget-bar__actual { background: var(--accent); }
.budget-bar__committed {
  /* Hatched, so committed reads as "promised, not yet landed" rather than as
     a second shade of spent. */
  background: repeating-linear-gradient(
    -45deg,
    var(--accent-edge) 0 4px,
    var(--accent-wash) 4px 8px
  );
}
.budget-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -1px;
}
.budget-key--actual { background: var(--accent); }
.budget-key--committed {
  background: repeating-linear-gradient(-45deg, var(--accent-edge) 0 3px, var(--accent-wash) 3px 6px);
}

/* The offer the comparison names. A left rule, not a fill, so it does not
   read as "selected" before anyone has chosen it. */
.row-leader > td:first-child { box-shadow: inset 3px 0 0 var(--positive); }

/* LPO print view */
body.lpo {
  background: #fff;
  color: #111;
  max-width: 52rem;
  margin: 0 auto;
  padding: 24px;
  position: relative;
}
.lpo__head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 2px solid #111;
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.lpo__brand {
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: var(--t-micro);
  color: var(--accent);
}
.lpo__org { font-weight: 600; font-size: var(--t-lead); }
.lpo__title { text-align: right; }
.lpo__title h1 { margin: 0 0 4px; font-size: var(--t-h2); }
.lpo__meta { font-size: var(--t-small); line-height: 1.6; color: #333; }
.lpo__parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 16px;
  font-size: var(--t-small);
}
.lpo__label {
  font-size: var(--t-micro);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #555;
  margin-bottom: 4px;
}
.lpo__lines { width: 100%; }
.lpo__lines tfoot th, .lpo__lines tfoot td { border-top: 1px solid #ccc; }
.lpo__notes { margin-top: 16px; font-size: var(--t-small); white-space: pre-line; }
.lpo__approval {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid #ccc;
  font-size: var(--t-small);
}
.lpo__watermark {
  position: absolute;
  top: 40%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 3rem;
  font-weight: 700;
  color: rgba(155, 44, 44, 0.12);
  transform: rotate(-18deg);
  pointer-events: none;
}
@media (max-width: 640px) {
  .lpo__head, .lpo__parties { display: block; }
  .lpo__title { text-align: left; margin-top: 12px; }
}
@media print {
  .no-print { display: none !important; }
  body.lpo { padding: 0; max-width: none; }
  .lpo__watermark { color: rgba(0, 0, 0, 0.1); }
}

/* Notification centre */
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
}
.notification:last-child { border-bottom: 0; }
.notification--unread { background: var(--accent-wash); }
.notification__main { min-width: 0; }
.notification__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* Tabs */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tabs__tab {
  padding: var(--space-2) var(--space-3);
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  font-size: var(--t-small);
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab--active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* Receiving: orders due */
.receive-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--paper-raised); }
.receive-list__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
}
.receive-list__item:last-child { border-bottom: 0; }
.receive-list__item--late { box-shadow: inset 3px 0 0 var(--negative); }
.receive-list__ref { font-weight: 600; }
.receive-list__who { margin: 2px 0; }

/* Receiving: the delivery form. Large targets, one line per card. */
.receive-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 56rem; }
.receive-lines__head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.receive-lines { display: flex; flex-direction: column; gap: var(--space-3); }
.receive-line {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper-raised);
  padding: var(--space-3) var(--space-4);
  margin: 0;
  min-width: 0;
}
.receive-line__title { font-weight: 600; padding: 0; }
.receive-line__meta { margin: 2px 0 var(--space-3); }
.receive-line__inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 12rem)); gap: var(--space-3); }
.receive-line__inputs input { font-size: 1.125rem; padding: 10px 12px; }
.receive-line__reject { margin-top: var(--space-2); }
.receive-line__reject summary { cursor: pointer; font-size: var(--t-small); color: var(--ink-muted); }
.receive-form__submit { display: flex; gap: var(--space-3); align-items: center; }
.btn--large { padding: 12px 22px; font-size: var(--t-lead); }
@media (max-width: 640px) {
  .receive-line__inputs { grid-template-columns: 1fr 1fr; }
  .receive-form__submit { position: sticky; bottom: 0; background: var(--paper); padding: var(--space-3) 0; border-top: 1px solid var(--rule); }
  .receive-form__submit .btn--primary { flex: 1; }
  .receive-list__item { flex-direction: column; align-items: stretch; }
}

/* Small event and attachment lists */
.event-list, .attachment-list { list-style: none; margin: 0; padding: 0; }
.event-list li { padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--rule); font-size: var(--t-small); }
.event-list li:last-child { border-bottom: 0; }
.attachment-list li { padding: var(--space-1) 0; display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }

/* Invoice matching */
.finding-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.finding { border-left: 3px solid var(--attention-edge); padding: var(--space-1) 0 var(--space-1) var(--space-3); }
.finding--accepted { border-left-color: var(--rule-strong); opacity: 0.85; }
.finding__head { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.finding__msg { margin: var(--space-1) 0; font-size: var(--t-small); }
.finding__form { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.finding__form input { flex: 1; min-width: 12rem; }
.match-table .cell-flag { background: var(--attention-wash); font-weight: 600; }
.match-table .row-flagged td:first-child { box-shadow: inset 3px 0 0 var(--attention); }
.invoice-lines input { width: 100%; min-width: 5rem; }
.invoice-lines td[data-label="Description"] input { min-width: 12rem; }

/* Supplier portal: its own plain frame, no staff navigation */
body.portal { background: var(--paper); margin: 0; }
.portal__bar {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-3) var(--space-5); background: var(--paper-rail); color: var(--ink-inverse);
}
.portal__brand { font-weight: 600; }
.portal__who { font-size: var(--t-small); opacity: 0.8; }
.portal__nav { display: flex; gap: var(--space-4); align-items: center; flex-wrap: wrap; }
.portal__nav a { color: var(--ink-inverse); text-decoration: none; font-size: var(--t-small); }
.portal__nav form { margin: 0; }
.portal__main { max-width: 72rem; margin: 0 auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.portal__title { margin: 0; font-size: 1.5rem; }
.portal .crumbs { font-size: var(--t-small); color: var(--ink-muted); }
.portal .demo-banner { background: var(--attention-wash); border: 1px solid var(--attention-edge); padding: var(--space-2) var(--space-3); font-size: var(--t-small); border-radius: var(--radius); }
@media (max-width: 640px) { .portal__main { padding: var(--space-3); } }

/* Scorecards */
.scorecard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--space-4); margin: var(--space-4) 0; }
.scorecard__label { font-size: var(--t-small); color: var(--ink-muted); }
.scorecard__value { font-size: var(--t-figure); font-variant-numeric: tabular-nums; margin: var(--space-1) 0; }
.scorecard__basis { font-size: var(--t-micro); color: var(--ink-muted); }
.scorecard__def { font-size: var(--t-micro); color: var(--ink-faint); margin: var(--space-2) 0 0; }

/* ---------------------------------------------------------------------------
   Marketplace, supplier workspace and platform
   --------------------------------------------------------------------------- */

.filter-checks label { display: block; }
.sponsored {
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-4) var(--space-4);
  border: 1px dashed var(--attention-edge);
  border-radius: var(--radius-lg);
  background: var(--attention-wash);
}
.sponsored__label {
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--attention);
  margin-bottom: var(--space-2);
}
.supplier-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.supplier-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  color: var(--ink);
  text-decoration: none;
}
.supplier-card:hover { border-color: var(--accent-edge); }
.supplier-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.supplier-card__name { font-weight: 600; font-size: 1rem; color: var(--accent); padding-right: 5rem; }
.supplier-card__meta { font-size: var(--t-small); color: var(--ink-muted); }
.supplier-card__tagline { font-size: var(--t-small); }
.supplier-card__facts { font-size: var(--t-micro); color: var(--ink-faint); }
.supplier-card__badges { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.supplier-card__sponsored {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  font-size: var(--t-micro);
  font-weight: 600;
  color: var(--attention);
  border: 1px solid var(--attention-edge);
  border-radius: var(--radius);
  padding: 0 var(--space-1);
}
.badge-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.badge-list li { display: grid; gap: 2px; justify-items: start; }
.thread { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: grid; gap: var(--space-3); max-width: 48rem; }
.thread__msg { padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); border: 1px solid var(--rule); background: var(--paper-raised); }
.thread__msg p { margin: var(--space-1) 0 0; white-space: pre-line; }
.thread__msg--supplier { background: var(--accent-wash); border-color: var(--accent-edge); margin-left: var(--space-6); }
.thread__msg--buyer { margin-right: var(--space-6); }
.checklist { margin: 0; padding-left: 1.25rem; display: grid; gap: var(--space-2); font-size: var(--t-small); }
.checklist .is-done a { color: var(--positive); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--space-1) var(--space-3); }
.fieldset { border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); margin: 0; }
.fieldset legend { font-size: var(--t-small); font-weight: 600; padding: 0 var(--space-1); }
.inline-form { display: inline-flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.progress-steps { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; margin: 0 0 var(--space-5); counter-reset: step; }
.progress-steps li {
  counter-increment: step;
  font-size: var(--t-small);
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--ink-faint);
}
.progress-steps li::before { content: counter(step) '. '; }
.progress-steps li.is-done { color: var(--positive); border-color: var(--positive); background: var(--positive-wash); }
@media (max-width: 640px) {
  .thread__msg--supplier { margin-left: var(--space-3); }
  .thread__msg--buyer { margin-right: var(--space-3); }
}
.tabs__tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs { margin-bottom: var(--space-4); }
.tabs--sub { border-bottom: 0; }
.tabs--sub .tabs__tab { border: 1px solid var(--rule); border-radius: 999px; padding: var(--space-1) var(--space-3); }
.tabs--sub .tabs__tab[aria-current="page"] { border-color: var(--accent); background: var(--accent-wash); }

/* Subscription banner and registration */
.billing-banner { margin: 0 0 var(--space-4); padding: var(--space-2) var(--space-4); border-radius: var(--radius-lg); font-size: var(--t-small); border: 1px solid var(--rule); }
.billing-banner--info { background: var(--accent-wash); border-color: var(--accent-edge); }
.billing-banner--warn { background: var(--attention-wash); border-color: var(--attention-edge); }
.billing-banner--error { background: var(--negative-wash); border-color: var(--negative); }
.billing-banner .pill { margin-left: var(--space-2); }
.auth__card--wide { max-width: 40rem; }
.auth__title { font-size: 1.25rem; margin: var(--space-2) 0; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-3); }
.choice { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3); border: 1px solid var(--rule); border-radius: var(--radius-lg); cursor: pointer; background: var(--paper-raised); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
@media (max-width: 560px) { .choice-row { grid-template-columns: 1fr; } }

/* Accounting and payables */
.stat-tile { display: grid; gap: 2px; padding: var(--space-3) var(--space-4); border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--paper-raised); color: var(--ink); text-decoration: none; }
a.stat-tile:hover { border-color: var(--accent-edge); }
.stat-tile__n { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile__l { font-size: var(--t-small); color: var(--ink-muted); }
.cell-warn { color: var(--negative); font-weight: 600; }
.row-total td { border-top: 2px solid var(--rule); }

/* Barcode scanning */
.scan-bar { display: grid; gap: var(--space-1); padding: var(--space-3); border: 1px dashed var(--border, #ccd); border-radius: var(--radius, 8px); margin-block: var(--space-3); }
.scan-bar__row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.scan-bar__row input { flex: 1 1 14rem; min-width: 0; }
.scan-video { width: 100%; max-width: 28rem; border-radius: var(--radius, 8px); background: #000; }
.receive-line.is-flash { outline: 2px solid var(--accent, #2a6); transition: outline-color .3s; }
.timeline { list-style: none; padding: 0; margin: 0 0 var(--space-3); display: grid; gap: var(--space-2); }
.timeline li { padding-left: var(--space-3); border-left: 2px solid var(--border, #ccd); }

/* Invoice inbox: the document beside the form */
.intake-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-4); align-items: start; }
.intake-doc { position: sticky; top: var(--space-4); display: grid; gap: var(--space-3); min-width: 0; }
.intake-form { min-width: 0; }
.intake-image { width: 100%; height: auto; border: 1px solid var(--border, #ccd); border-radius: var(--radius, 8px); }
.intake-text { white-space: pre-wrap; font-size: 0.8rem; max-height: 24rem; overflow: auto; }
@media (max-width: 960px) { .intake-grid { grid-template-columns: 1fr; } .intake-doc { position: static; } }

/* Catalogue */
.catalogue { display: grid; gap: var(--space-3); }
.catalogue__cat { font-size: 1rem; margin: var(--space-4) 0 0; }
.catalogue__item { border: 1px solid var(--border, #ccd); border-radius: var(--radius, 8px); padding: var(--space-3); display: grid; gap: var(--space-2); background: var(--surface, #fff); }
.catalogue__name { display: grid; }
.catalogue__offer { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding-top: var(--space-2); border-top: 1px dashed var(--border, #ccd); }
.catalogue__offer > span:first-of-type { flex: 1 1 12rem; min-width: 0; }

/* WhatsApp messages */
.wa-list { list-style: none; margin: 0; padding: var(--space-3); display: grid; gap: var(--space-2); }
.wa { max-width: 34rem; padding: var(--space-2) var(--space-3); border-radius: 10px; background: var(--surface-2, #f2f4f3); }
.wa--in { justify-self: end; background: #dcf8c6; color: #111; }
.wa__meta { font-size: 0.75rem; opacity: 0.8; margin-bottom: 2px; }
.wa__body { white-space: pre-wrap; font: inherit; margin: 0; }

/* "+ New" menu */
.new-menu { position: relative; display: inline-block; }
.new-menu > summary { list-style: none; cursor: pointer; }
.new-menu > summary::-webkit-details-marker { display: none; }
.new-menu__list { position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 30; min-width: 15rem; display: grid; background: var(--paper-raised); border: 1px solid var(--paper-sunken); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; }
.new-menu__list a { padding: 0.5rem 0.75rem; border-radius: 6px; color: var(--ink); text-decoration: none; }
.new-menu__list a:hover, .new-menu__list a:focus { background: var(--accent-wash); }
.topbar__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* Help panels */
.help-panel { border: 1px solid var(--accent-edge); background: var(--accent-wash); border-radius: 8px; padding: 0.5rem 0.9rem; margin-bottom: var(--space-3); font-size: 0.9rem; }
.help-panel summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.help-panel ul { margin: 0.5rem 0 0.25rem; padding-inline-start: 1.2rem; }

.lang-switch { margin-top: var(--space-2); }
.lang-switch .btn { width: 100%; color: inherit; }
.recovery { font-size: 1rem; background: var(--paper-sunken); padding: 0.75rem; border-radius: 6px; user-select: all; }
.setup-key { font-size: 1.05rem; background: var(--paper-sunken); padding: 0.1rem 0.4rem; border-radius: 4px; user-select: all; }
.trust { max-width: 46rem; margin: 2rem auto; padding: 0 16px; line-height: 1.6; }
.trust h2 { margin-top: 1.6rem; font-size: 1.15rem; }

/* Right-to-left (Arabic) */
[dir="rtl"] body { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", Arial, sans-serif; }
[dir="rtl"] .num, [dir="rtl"] td.num, [dir="rtl"] th.num { text-align: left; }
[dir="rtl"] .crumbs span[aria-hidden="true"] { display: inline-block; transform: scaleX(-1); }
.rail__security { display: block; margin-top: var(--space-2); font-size: 0.8rem; color: inherit; opacity: .85; }
.totp-setup { display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.totp-setup__qr svg { width: 220px; height: 220px; max-width: 100%; border: 1px solid var(--paper-sunken); border-radius: 8px; }
.totp-setup .steps-list { flex: 1 1 18rem; min-width: 0; }

/* Search box above a long item dropdown */
.item-search { display: block; width: 100%; margin-bottom: var(--space-1); }
td > .item-search { min-width: 10rem; }

/* Panels and notices stacked directly after one another keep a gap. */
.content > .u-stack + .panel,
.content > .notice + .panel,
.content > details + .panel,
.content > nav + .panel,
.content > form + .panel,
.content > .panel + form,
.content > .panel + .u-stack,
.content > .panel + details,
.content > .detail-grid + .panel,
.content > .panel + .detail-grid { margin-top: var(--space-5); }

/* Dashboard to-do list */
.work-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: var(--space-1) var(--space-5); }
.work-list a { display: flex; align-items: baseline; gap: var(--space-2); padding: var(--space-2) 0; text-decoration: none; color: inherit; }
.work-list a:hover { text-decoration: underline; }
.work-list__dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--accent); }
.work-list__dot--now { background: #b3261e; }
