/* ==========================================================================
   WASL — shared shell for the two desk surfaces (Partner Portal, Management).
   The Consumer Journey deliberately does NOT use this file: it is a different
   register (immersive, mobile, brand-led) and carries its own stylesheet.
   Selector rule for this file: layout owns spacing, components never set
   outer margin. Prevents the .section/.cta specificity collisions.
   ========================================================================== */

/* --- Desk shell ---------------------------------------------------------- */
.desk {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.rail {
  background: var(--brand-deep);
  color: var(--on-brand);
  padding: var(--s-5) 0 var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}

.rail__brand {
  padding-inline: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.rail__brand svg, .rail__brand img { width: 108px; height: auto; }
.rail__wordmark {
  font-family: var(--face-display);
  font-size: var(--t-lg);
  letter-spacing: .06em;
  color: var(--kes-white);
}
.rail__sub {
  font-size: var(--t-xs);
  color: var(--green-200);
  letter-spacing: .10em;
}

.rail__nav { display: flex; flex-direction: column; }
.rail__nav a {
  padding: var(--s-3) var(--s-5);
  text-decoration: none;
  font-size: var(--t-sm);
  color: var(--green-200);
  border-left: 3px solid transparent;
}
.rail__nav a:hover { color: var(--kes-white); }
/* Active state is structural — the rule says "you are here", it is not decor. */
.rail__nav a[aria-current="page"] {
  color: var(--kes-white);
  border-left-color: var(--value);
  background: rgba(255,255,255,.05);
}

.rail__foot {
  margin-top: auto;
  padding-inline: var(--s-5);
  font-size: var(--t-xs);
  color: var(--green-200);
}

.main { background: var(--ground-sunk); min-width: 0; }

.topbar {
  background: var(--ground);
  border-bottom: 1px solid var(--rule);
  padding: var(--s-4) var(--s-6);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.topbar h1 { font-size: var(--t-md); font-weight: 700; }
.topbar__ctx { font-size: var(--t-sm); color: var(--ink-soft); }

.wrap { padding: var(--s-6); max-width: var(--shell); }
.wrap--narrow { max-width: 880px; }
.stack > * + * { margin-top: var(--s-5); }

/* --- Panels -------------------------------------------------------------- */
.panel {
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: var(--r-soft);
}
.panel__head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4);
}
.panel__head h2 { font-size: var(--t-base); font-weight: 700; }
.panel__body { padding: var(--s-5); }
.panel__body--flush { padding: 0; }

/* --- Partner Credit: the one place gold is allowed --------------------- */
.credit {
  background: var(--ground);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--value);
  border-radius: var(--r-soft);
  padding: var(--s-5);
}
.credit__label { font-size: var(--t-sm); color: var(--ink-soft); }
.credit__figure {
  font-family: var(--face-display);
  font-size: var(--t-3xl);
  color: var(--value-ink);
  line-height: 1;
  margin-top: var(--s-2);
}
.credit__split {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--rule);
  display: flex; gap: var(--s-6); font-size: var(--t-sm);
}
.credit__split div span { display: block; color: var(--ink-soft); font-size: var(--t-xs); }

/* --- Figures row --------------------------------------------------------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s-4); }
.figure {
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: var(--r-soft);
  padding: var(--s-5);
}
.figure__n { font-size: var(--t-xl); line-height: 1; font-weight: 400; }
.figure__l { font-size: var(--t-sm); color: var(--ink-soft); margin-top: var(--s-2); }

/* --- Tables -------------------------------------------------------------- */
.tbl-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.tbl th, .tbl td { padding: var(--s-3) var(--s-5); text-align: left; border-bottom: 1px solid var(--rule); }
.tbl th { font-weight: 700; color: var(--ink-soft); font-size: var(--t-xs); letter-spacing: .04em; background: var(--ground-sunk); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.r, .tbl th.r { text-align: right; }

/* Status is carried by a word plus a colour, never colour alone. */
.state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); }
.state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.state--ok { color: var(--ok); }
.state--wait { color: var(--warn); }
.state--stop { color: var(--stop); }
.state--done { color: var(--ink-soft); }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  font: inherit; font-size: var(--t-sm); font-weight: 400;
  display: inline-block; text-decoration: none; text-align: center;
  padding: var(--s-3) var(--s-5);
  border: 1px solid var(--brand);
  background: var(--brand); color: var(--on-brand);
  border-radius: var(--r-soft); cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--green-700); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn--quiet { background: transparent; color: var(--brand); }
.btn--quiet:hover { background: var(--green-50); }

/* --- Forms --------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.field label { font-size: var(--t-sm); font-weight: 400; }
.field input, .field select, .field textarea {
  font: inherit; padding: var(--s-3); border: 1px solid var(--rule-strong);
  border-radius: var(--r-soft); background: var(--ground); color: var(--ink);
}
.field input[aria-invalid="true"] { border-color: var(--stop); }
.hint { font-size: var(--t-xs); color: var(--ink-soft); }

/* Error summary — focusable, links to each bad field (WCAG pattern). */
.errsum {
  border: 1px solid var(--stop);
  border-left: 3px solid var(--stop);
  background: #FCF6F6;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-soft);
}
.errsum h2 { font-size: var(--t-base); color: var(--stop); font-weight: 700; }
.errsum ul { margin: var(--s-3) 0 0; padding-left: var(--s-5); font-size: var(--t-sm); }
.errsum a { color: var(--stop); }
.errsum[hidden] { display: none; }

/* --- Order lines --------------------------------------------------------- */
.line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 104px;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.line:last-of-type { border-bottom: 0; }
.line__name { font-weight: 400; }
.line__meta { font-size: var(--t-xs); color: var(--ink-soft); }
.line [data-sub] { font-size: var(--t-base); color: var(--ink); text-align: right; }
.stepper { display: flex; align-items: center; gap: var(--s-2); }
.stepper button {
  width: 32px; height: 32px; font: inherit; font-size: var(--t-md);
  border: 1px solid var(--rule-strong); background: var(--ground);
  border-radius: var(--r-soft); cursor: pointer; line-height: 1;
}
.stepper button:hover { border-color: var(--brand); color: var(--brand); }
.stepper input { width: 62px; text-align: center; font: inherit; padding: var(--s-2);
  border: 1px solid var(--rule-strong); border-radius: var(--r-soft); }

.totals { padding: var(--s-5); background: var(--ground-sunk); border-top: 1px solid var(--rule); }
.totals dl { display: grid; grid-template-columns: 1fr auto; gap: var(--s-3) var(--s-5); margin: 0; font-size: var(--t-sm); }
.totals dt { color: var(--ink-soft); }
.totals dd { margin: 0; text-align: right; }
.totals .grand dt, .totals .grand dd { font-size: var(--t-md); font-weight: 700; color: var(--ink);
  padding-top: var(--s-3); border-top: 1px solid var(--rule-strong); }
.totals .credited dd { color: var(--value-ink); }

@media (max-width: 880px) {
  .desk { grid-template-columns: 1fr; }
  /* A grid child defaults to min-width:auto, so the rail grew to fit its
     items instead of scrolling, and dragged the whole page wide with it. */
  .rail { flex-direction: row; align-items: center; gap: var(--s-4);
          padding: var(--s-3) 0; overflow-x: auto; min-width: 0; }
  .rail__nav { flex-direction: row; }
  .rail__nav a { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .rail__nav a[aria-current="page"] { border-left-color: transparent; border-bottom-color: var(--value); }
  .rail__foot, .rail__sub { display: none; }
  .wrap { padding: var(--s-4); }
  .line { grid-template-columns: 1fr; gap: var(--s-3); }
}

/* --- Public shell -------------------------------------------------------
   Pages reached without a login: the partner application and the
   post-purchase feedback link. No rail, no account context — the person
   here does not have an account yet, or never will.
   ---------------------------------------------------------------------- */
.public { min-height: 100vh; background: var(--ground-sunk); }

.public__head {
  background: var(--brand-deep);
  color: var(--on-brand);
  padding: var(--s-6) var(--s-5) var(--s-7);
}
.public__head-in { max-width: 760px; margin-inline: auto; }
.public__head img { width: 132px; height: auto; }
.public__head h1 {
  font-family: var(--face-display);
  font-size: var(--t-2xl);
  margin-top: var(--s-5);
}
.public__head p { color: var(--green-200); margin-top: var(--s-3); max-width: 52ch; }

.public__body { max-width: 760px; margin: calc(var(--s-6) * -1) auto 0; padding: 0 var(--s-5) var(--s-8); }

fieldset {
  border: 1px solid var(--rule);
  border-radius: var(--r-soft);
  background: var(--ground);
  padding: var(--s-5);
  margin: 0 0 var(--s-4);
}
/* Floated so the legend lays out inside the fieldset (a floated legend is not
   a "rendered legend"), rather than sitting on the top border where the card's
   background does not reach it — on apply.html the first card overlaps the
   dark header and the legend was disappearing into it. */
legend {
  float: left;
  width: 100%;
  font-weight: 700;
  font-size: var(--t-sm);
  padding: 0;
  margin: 0 0 var(--s-4);
}
legend + * { clear: both; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.grid2 .span { grid-column: 1 / -1; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

/* --- Confirmation -------------------------------------------------------- */
.done {
  background: var(--ground);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ok);
  border-radius: var(--r-soft);
  padding: var(--s-7) var(--s-5);
  text-align: center;
}
.done h2 { font-family: var(--face-display); font-size: var(--t-2xl); }
.done__id {
  font-size: var(--t-lg); margin-top: var(--s-4);
  font-variant-numeric: tabular-nums;
}
.done__note { color: var(--ink-soft); font-size: var(--t-sm); margin-top: var(--s-3); }

/* The chain of references the RFP asks to be retained, shown as a chain. */
.chain { margin-top: var(--s-6); border-top: 1px solid var(--rule); padding-top: var(--s-5); text-align: left; }
.chain dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--s-3) var(--s-5); font-size: var(--t-sm); }
.chain dt { color: var(--ink-soft); }
.chain dd { margin: 0; font-variant-numeric: tabular-nums; }

/* --- QR ------------------------------------------------------------------ */
.qr-row { display: grid; grid-template-columns: 168px 1fr; gap: var(--s-5); align-items: start; }
/* Same min-width:auto trap as the rail: the QR's intrinsic SVG size was
   setting the column's floor and pushing the page wider than the screen. */
.qr-row > * { min-width: 0; }
.qr-card {
  background: var(--ground); border: 1px solid var(--rule-strong);
  border-radius: var(--r-soft); padding: var(--s-4); text-align: center;
}
.qr-card svg, .qr-card img { width: 100%; max-width: 100%; height: auto; display: block; }
.qr-card p { font-size: var(--t-xs); color: var(--ink-soft); margin-top: var(--s-3); }
@media (max-width: 620px) { .qr-row { grid-template-columns: 1fr; } }

/* --- Sign in ------------------------------------------------------------
   The portal and the management surface never share a session. They do not
   share a look either — an internal user should never be in doubt about
   which system they are typing a password into.
   ---------------------------------------------------------------------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5); }
.signin--partner { background: var(--green-900); }
.signin--admin { background: var(--ink); }

.signin__card {
  width: 100%; max-width: 420px;
  background: var(--ground);
  border-radius: var(--r-soft);
  padding: var(--s-7) var(--s-6);
}
.signin--admin .signin__card { border-top: 3px solid var(--value); }

.signin__mark { text-align: center; margin-bottom: var(--s-6); }
.signin__mark img { width: 116px; height: auto; }
.signin__title { font-family: var(--face-display); font-size: var(--t-xl); text-align: center; }
.signin__sub { text-align: center; color: var(--ink-soft); font-size: var(--t-sm); margin-top: var(--s-2); }

.signin__form { margin-top: var(--s-6); display: grid; gap: var(--s-4); }
.signin__form .btn { width: 100%; padding: var(--s-4); font-size: var(--t-base); }

.signin__alt {
  margin-top: var(--s-6); padding-top: var(--s-5);
  border-top: 1px solid var(--rule);
  font-size: var(--t-sm); color: var(--ink-soft); text-align: center;
}

/* Demo convenience: pick an identity instead of typing a password. */
.whoami { display: grid; gap: var(--s-2); }
.whoami button {
  font: inherit; text-align: left; cursor: pointer;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--rule-strong); background: var(--ground);
  border-radius: var(--r-soft);
}
.whoami button:hover { border-color: var(--brand); background: var(--green-50); }
.whoami b { display: block; font-weight: 700; font-size: var(--t-sm); }
.whoami span { font-size: var(--t-xs); color: var(--ink-soft); }

/* --- Demo banner --------------------------------------------------------- */
.demobar {
  background: var(--value-wash);
  border-bottom: 1px solid var(--value);
  padding: var(--s-2) var(--s-5);
  font-size: var(--t-xs);
  display: flex; gap: var(--s-4); align-items: center; justify-content: space-between;
  flex-wrap: wrap;
}
.demobar button {
  font: inherit; font-size: var(--t-xs); cursor: pointer;
  background: transparent; border: 1px solid var(--value-ink);
  color: var(--value-ink); padding: 2px var(--s-3); border-radius: var(--r-soft);
}
.demobar button:hover { background: var(--value); color: var(--kes-white); border-color: var(--value); }

/* --- Filters ------------------------------------------------------------- */
.filters { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: flex-end; }
.filters .field { flex: 1 1 180px; }
.filters input, .filters select { width: 100%; }
