/* ==========================================================================
   Saras · Components
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 38px;
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink-800);
  font-size: var(--fs-14);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.btn:hover { border-bottom-color: initial; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary {
  background: var(--seal-600);
  color: #fff;
  border-color: var(--seal-600);
}
.btn-primary:hover { background: var(--seal-700); border-color: var(--seal-700); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-800);
}
.btn-secondary:hover { background: var(--surface-sunken); border-color: var(--ink-300); }

.btn-ghost {
  background: transparent;
  color: var(--ink-600);
}
.btn-ghost:hover { background: var(--surface-inset); color: var(--ink-900); }

.btn-danger {
  background: var(--surface);
  border-color: #e6c4c1;
  color: var(--brick-600);
}
.btn-danger:hover { background: var(--brick-100); border-color: var(--brick-600); }

.btn-sm { min-height: 30px; padding: 0 var(--s-3); font-size: var(--fs-13); }
.btn-lg { min-height: 44px; padding: 0 var(--s-6); font-size: var(--fs-15); }
.btn-block { width: 100%; }

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-link {
  border: 0;
  background: none;
  padding: 0;
  min-height: 0;
  color: var(--seal-600);
  font-size: var(--fs-13);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.btn-link:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Card / panel
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.card-head h2,
.card-head h3 { font-size: var(--fs-15); font-weight: 600; }
.card-head p {
  margin: 2px 0 0;
  font-size: var(--fs-12);
  color: var(--text-muted);
}
.card-head-text { min-width: 0; flex: 1 1 240px; }

.card-body { padding: var(--s-5); }
.card-body-flush { padding: 0; }

.card-foot {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--line);
  background: var(--surface-sunken);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  flex-wrap: wrap;
}

/* Section heading inside a form panel (mirrors the spec's section rows) */
.section-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin: 0 0 var(--s-4);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--line);
}
.section-head h3 { font-size: var(--fs-14); }
.section-head .hint { font-size: var(--fs-12); color: var(--text-muted); }
.section + .section { margin-top: var(--s-7); }

/* --------------------------------------------------------------------------
   Form fields · 3-per-row grid mirrors the layout in the spec workbook
   -------------------------------------------------------------------------- */
.fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4) var(--s-4);
  align-items: start;
}
.fields-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-span-2 { grid-column: span 2; }
.field-span-3 { grid-column: 1 / -1; }

.field { min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); }

.field > label,
.field-label {
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink-700);
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.req { color: var(--brick-600); font-weight: 600; }
.doc-row-optional { color: var(--ink-400); font-size: var(--fs-12); font-weight: 400; }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-900);
  font-family: inherit;
  font-size: var(--fs-14);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder,
.textarea::placeholder { color: var(--ink-300); }

/* A select sitting in a table cell. Four of these per row on the document
   checklists, so the row has to stay the height of a table row rather than of a
   form field. */
.select-sm {
  min-height: 32px;
  padding: 2px var(--s-2);
  font-size: var(--fs-13, 13px);
}

/* Read-only display text where a field has no control at all — e.g. values
   that arrive from CBS and can never be typed or edited. */
.static-text {
  min-height: 38px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  padding: var(--s-2) 0;
  color: var(--ink-900);
  font-size: var(--fs-14);
}
.static-text.is-empty { color: var(--text-muted); }

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--ink-300); }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--seal-500);
  box-shadow: 0 0 0 3px var(--seal-100);
}
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible { outline: none; }

.textarea { min-height: 76px; resize: vertical; line-height: 1.45; }

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

.input[readonly],
.textarea[readonly],
.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-inset);
  border-color: var(--line);
  color: var(--ink-700);
  cursor: default;
  opacity: 1;
  -webkit-text-fill-color: var(--ink-700); /* Safari dims disabled text */
}

.select {
  appearance: none;
  padding-right: var(--s-7);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%235a6b66' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
}

.hint {
  font-size: var(--fs-12);
  color: var(--text-muted);
}

.error-text {
  font-size: var(--fs-12);
  color: var(--brick-600);
  display: none;
  align-items: flex-start;
  gap: 4px;
}
.field.has-error .error-text { display: flex; }
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
  border-color: var(--brick-600);
  background: #fffbfa;
}
.field.has-error .input:focus,
.field.has-error .select:focus {
  box-shadow: 0 0 0 3px var(--brick-100);
}

/* Input with a trailing control (prefix / search / reveal) */
.input-group { display: flex; gap: var(--s-2); }
.input-group .input { flex: 1 1 auto; min-width: 0; }
.input-group .btn { flex: none; }

.input-affix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.input-affix:focus-within {
  border-color: var(--seal-500);
  box-shadow: 0 0 0 3px var(--seal-100);
}
.input-affix .affix {
  display: grid;
  place-items: center;
  padding: 0 var(--s-3);
  background: var(--surface-inset);
  border-right: 1px solid var(--line);
  font-size: var(--fs-13);
  color: var(--text-muted);
  white-space: nowrap;
}
.input-affix .input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.input-affix .input:focus { box-shadow: none; }
.input-affix .affix-btn {
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-inset);
  color: var(--ink-600);
  padding: 0 var(--s-3);
  cursor: pointer;
  font-size: var(--fs-12);
  font-weight: 500;
}
.input-affix .affix-btn:hover { background: var(--line); }

/* THE SIDE OF THE BORDER FOLLOWS THE SIDE OF THE CONTROL. Both .affix and
   .affix-btn were written for the one arrangement that existed — a prefix
   label, or a trailing button — and each hard-coded the divider accordingly.
   The outstanding-amount stepper puts a button in FRONT of the input and the
   loan period puts a label AFTER it, so the divider is restated by position.
   Without this, the leading button draws its line on the far side of itself
   and the trailing unit label draws one off the end of the group. */
.input-affix .affix-btn:first-child {
  border-left: 0;
  border-right: 1px solid var(--line);
}
.input-affix .affix:last-child {
  border-right: 0;
  border-left: 1px solid var(--line);
}
/* The two stepper buttons sit either side of a figure, so they are given the
   same width — otherwise "−1k" and "+1k" differ by a hair and the input looks
   off-centre in a row of otherwise plain fields. */
.input-affix .affix-btn[data-amount-step] {
  min-width: 2.75rem;
  font-variant-numeric: tabular-nums;
}

/* Checkbox + radio */
.check {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  font-size: var(--fs-14);
  cursor: pointer;
}
.check input {
  flex: none;
  width: 17px; height: 17px;
  margin: 2px 0 0;
  accent-color: var(--seal-600);
}

/* Segmented control — used for "fetch from source" vs "enter manually" */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  gap: 2px;
}
.segmented button {
  border: 0;
  background: none;
  padding: var(--s-1) var(--s-3);
  min-height: 30px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
  color: var(--ink-600);
  cursor: pointer;
  white-space: nowrap;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink-900);
  font-weight: 500;
  box-shadow: var(--shadow-card);
}

/* Chips (multi-value entry, e.g. co-borrower names) */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-2) var(--s-1) var(--s-3);
  background: var(--seal-100);
  border: 1px solid var(--seal-200);
  color: var(--seal-800);
  border-radius: var(--r-pill);
  font-size: var(--fs-13);
}
.chip button {
  border: 0;
  background: none;
  color: var(--seal-700);
  cursor: pointer;
  line-height: 1;
  padding: 2px;
  border-radius: var(--r-pill);
  font-size: var(--fs-14);
}
.chip button:hover { background: var(--seal-200); }

/* --------------------------------------------------------------------------
   Status badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-12);
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-draft   { background: var(--surface-inset); color: var(--ink-600); border-color: var(--line-strong); }
.badge-review  { background: #ece8f7; color: var(--stamp); border-color: #d3c9ec; }
.badge-progress{ background: var(--sky-100); color: var(--sky-700); border-color: #c5dced; }
.badge-pending { background: var(--plate-100); color: var(--plate-700); border-color: #ecd694; }
.badge-approved{ background: var(--seal-100); color: var(--seal-700); border-color: var(--seal-200); }
.badge-rejected{ background: var(--brick-100); color: var(--brick-700); border-color: #ecc7c3; }
.badge-neutral { background: var(--surface-inset); color: var(--ink-500); border-color: var(--line); }
.badge-plain::before { display: none; }

/* --------------------------------------------------------------------------
   Tables · collapse to stacked rows on mobile via data-label
   -------------------------------------------------------------------------- */
.table-scroll { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-14);
}
.table th {
  text-align: left;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--ink-600);
  background: var(--surface-sunken);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
/* The row-actions cell is the narrowest column on the page, so Edit and Delete
   wrap onto two lines and the row grows taller than its neighbours. Keep them
   on one line and let the description column give up the width instead. */
.table td.row-end { white-space: nowrap; text-align: right; }
.table td.row-end .btn + .btn { margin-left: var(--s-2); }
.table tbody tr:hover { background: var(--surface-sunken); }
/* Money and counts: right-aligned, lined figures, and never wrapped — a
   currency and its amount split across two lines is unreadable in a column
   meant to be scanned down. */
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cell-strong { font-weight: 500; color: var(--ink-900); }
.cell-sub { display: block; font-size: var(--fs-12); color: var(--text-muted); }

/* THE BRANCH COLUMN, WHICH IS NOT ALWAYS WORTH A COLUMN.
   A bank with one branch — every centralised bank — would get a column
   repeating the same code down every row. So the column is in the markup and
   the script puts this class on the table when there is nothing to tell apart.
   Done in CSS rather than by rebuilding the header because the header is static
   markup, and a colspan that disagrees with the number of cells is how an empty
   state ends up one column short. */
.table.hide-branch .col-branch { display: none; }
.table-sortable th button {
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.table th[aria-sort] button { color: var(--seal-700); }

/* --------------------------------------------------------------------------
   Stepper (request wizard) — a genuine sequence, so it is numbered
   -------------------------------------------------------------------------- */
.stepper {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.step {
  flex: 1 1 0;
  min-width: 150px;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--line-strong);
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  color: var(--ink-600);
}
.step:hover { background: var(--surface-sunken); }
.step-num {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-inset);
  border: 1px solid var(--line-strong);
  font-size: var(--fs-12);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.step-label { font-size: var(--fs-13); font-weight: 500; line-height: 1.2; }
.step-meta { font-size: var(--fs-11); color: var(--text-faint); }

.step[aria-current="step"] {
  border-bottom-color: var(--seal-600);
  color: var(--ink-900);
}
.step[aria-current="step"] .step-num {
  background: var(--seal-600);
  border-color: var(--seal-600);
  color: #fff;
}
.step.is-done .step-num {
  background: var(--seal-100);
  border-color: var(--seal-200);
  color: var(--seal-700);
}
.step.is-invalid .step-num {
  background: var(--brick-100);
  border-color: #ecc7c3;
  color: var(--brick-700);
}

/* --------------------------------------------------------------------------
   Callouts, empty states, timeline
   -------------------------------------------------------------------------- */
.callout {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  font-size: var(--fs-13);
}
.callout svg { flex: none; width: 17px; height: 17px; margin-top: 2px; }
.callout-info { background: var(--sky-100); border-color: #c5dced; color: var(--sky-700); }
.callout-warn { background: var(--plate-100); border-color: #ecd694; color: var(--plate-700); }
.callout-error { background: var(--brick-100); border-color: #ecc7c3; color: var(--brick-700); }
.callout-error ul { margin: var(--s-1) 0 0; }
.callout-success { background: var(--seal-100); border-color: #bcdccf; color: var(--seal-700); }
.callout strong { display: block; margin-bottom: 2px; }

.empty {
  padding: var(--s-8) var(--s-5);
  text-align: center;
  color: var(--text-muted);
}
.empty h3 { margin-bottom: var(--s-2); }
.empty p { margin: 0 auto var(--s-4); max-width: 42ch; font-size: var(--fs-14); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: var(--s-3);
  padding-bottom: var(--s-4);
  position: relative;
}
.timeline li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 10px; top: 20px; bottom: 0;
  width: 1px;
  background: var(--line-strong);
}
.timeline-dot {
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  display: grid; place-items: center;
  color: var(--ink-500);
  z-index: 1;
}
.timeline-dot svg { width: 11px; height: 11px; }
.timeline-title { display: block; font-size: var(--fs-14); font-weight: 500; }
.timeline-meta { display: block; font-size: var(--fs-12); color: var(--text-muted); }

/* Read-only summary rows (review step, snapshot panels) */
.dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
  margin: 0;
}
.dl-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dl div { min-width: 0; }
.dl dt {
  font-size: var(--fs-12);
  color: var(--text-muted);
  margin-bottom: 2px;
}
.dl dd {
  margin: 0;
  font-size: var(--fs-14);
  color: var(--ink-900);
  overflow-wrap: anywhere;
}
.dl dd:empty::after,
.dl dd.is-empty::after {
  content: "Not provided";
  color: var(--ink-300);
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: min(360px, calc(100vw - var(--s-6)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--ink-900);
  color: var(--text-invert);
  box-shadow: var(--shadow-float);
  font-size: var(--fs-14);
  animation: toast-in 180ms var(--ease);
}
.toast-ok { border-left: 3px solid var(--seal-500); }
.toast-warn { border-left: 3px solid var(--plate-400); }
.toast-error { border-left: 3px solid var(--brick-600); }
.toast button {
  margin-left: auto;
  border: 0; background: none;
  color: var(--ink-300);
  cursor: pointer;
  font-size: var(--fs-15);
  line-height: 1;
  padding: 2px;
}
.toast button:hover { color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: var(--s-4);
  background: rgba(20, 28, 26, 0.5);
}
.modal-panel {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  max-height: 90vh;
  overflow: auto;
}
.modal-panel .card-head { border-radius: var(--r-lg) var(--r-lg) 0 0; }

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pager {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  font-size: var(--fs-13);
  color: var(--text-muted);
}
.pager-btns { display: flex; gap: var(--s-1); margin-left: auto; }
.pager-btns button {
  min-width: 32px;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--fs-13);
  color: var(--ink-700);
}
.pager-btns button[aria-current="page"] {
  background: var(--ink-900);
  border-color: var(--ink-900);
  color: #fff;
}
.pager-btns button[disabled] { opacity: 0.45; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   Document upload list (Step 4)
   -------------------------------------------------------------------------- */
.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.doc-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.doc-row.has-error { border-color: var(--brick-600); background: var(--brick-100); }
.doc-row-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: var(--surface-inset);
  color: var(--ink-500);
}
.doc-row-icon svg { width: 18px; height: 18px; }
.doc-row.is-uploaded .doc-row-icon { background: var(--seal-100); color: var(--seal-700); }
.doc-row-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-row-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 500;
  font-size: var(--fs-14);
}
.doc-row-file {
  margin-top: 2px;
  font-size: var(--fs-12);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-row-file.is-empty { color: var(--text-muted); }
.doc-row-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.doc-row-actions input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.doc-row .error-text { display: block; margin-top: var(--s-2); }

/* --------------------------------------------------------------------------
   Admin — chip-style checkbox list (assigning groups to a user, or members
   to a group)
   -------------------------------------------------------------------------- */
.chip-check-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  max-height: 220px;
  overflow-y: auto;
}
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px var(--s-3) 5px var(--s-2);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  font-size: var(--fs-13);
  cursor: pointer;
}
.chip-check input {
  width: 15px; height: 15px; margin: 0;
  accent-color: var(--seal-600);
}
.chip-check-list .hint { padding: var(--s-1); }

/* A permission this group holds that this version of the screen has no name for.
   Shown so it cannot be removed by accident — see tickList in admin.js. */
.chip-check.is-unknown {
  border-style: dashed;
  border-color: var(--plate-400);
  background: var(--plate-100);
}
.chip-check.is-unknown span { font-size: var(--fs-12, var(--fs-13)); }

/* Small role/group tags inline in a table cell */
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--surface-inset);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: var(--fs-12);
  color: var(--ink-700);
  white-space: nowrap;
}


/* --------------------------------------------------------------------------
   Responsive component behaviour
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .doc-row { flex-wrap: wrap; }
  .doc-row-actions { width: 100%; justify-content: flex-start; }

  .card-body, .card-head, .card-foot { padding: var(--s-4); }
  .fields,
  .fields-2,
  .dl,
  .dl-2 { grid-template-columns: minmax(0, 1fr); }
  .field-span-2,
  .field-span-3 { grid-column: auto; }

  .card-foot .btn { flex: 1 1 auto; }

  .stepper { gap: var(--s-1); }
  .step { min-width: 118px; padding: var(--s-2); flex-direction: column; align-items: flex-start; gap: var(--s-1); }
  .step-meta { display: none; }

  /* Stacked table rows */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin-bottom: var(--s-3);
    padding: var(--s-2) var(--s-3);
    background: var(--surface);
  }
  .table tbody tr:hover { background: var(--surface); }
  .table td {
    border: 0;
    padding: var(--s-1) 0;
    display: flex;
    gap: var(--s-3);
    align-items: baseline;
    justify-content: space-between;
  }
  .table td::before {
    content: attr(data-label);
    flex: none;
    font-size: var(--fs-12);
    color: var(--text-muted);
    font-weight: 500;
  }
  .table td.num { text-align: right; }
  .table td:not(:last-child) { border-bottom: 1px dashed var(--line); }

  .toasts { right: var(--s-3); left: var(--s-3); bottom: var(--s-3); width: auto; }
}

/* ---- platform console: administrators inside a table cell ---------------
   Each administrator is a small stack (name, id, actions) rather than a row of
   its own, because the bank is the row and its administrators belong to it. */
.admin-row { display: block; padding: 2px 0 5px; }
.admin-row + .admin-row { border-top: 1px dashed var(--line); padding-top: 6px; }
.admin-actions { display: inline-flex; gap: var(--s-2); margin-top: 3px; }
.cell-strong.is-muted { color: var(--text-muted); font-weight: 400; }
.cell-tag {
  display: inline-block; font-size: var(--fs-11, 11px); line-height: 1.5;
  padding: 0 6px; border-radius: 999px; vertical-align: 1px;
  background: var(--surface-sunken); color: var(--text-muted);
  border: 1px solid var(--line); font-weight: 500;
}

/* ---------------------------------------------------------------------------
   A table whose rows open something.
   The cursor and a firmer hover tint say the row is a target; the row itself
   carries tabindex, so the keyboard reaches it on the same terms as the mouse
   and the focus ring has to be visible inside the cell's own border.
   The buttons in the last cell stop the click from bubbling — pressing Disable
   should disable the bank, not open it.
   --------------------------------------------------------------------------- */
.table-rows-clickable tbody tr[data-open] { cursor: pointer; }
.table-rows-clickable tbody tr[data-open]:hover { background: var(--surface-sunken); }
.table-rows-clickable tbody tr[data-open]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* The way back from a detail page. Sits above the page head rather than in it,
   so the heading stays the first thing read. */
.back-link {
  display: inline-block;
  margin-bottom: var(--s-3);
  font-size: var(--fs-13);
}

/* --------------------------------------------------------------------------
   Vehicle enquiry panel
   --------------------------------------------------------------------------
   A panel, not a modal, and the difference is the whole point: there is no
   backdrop, nothing underneath is inert, and the officer can click straight
   back into the capture form with the enquiry still open beside it. It sits on
   the right because the capture form's fields are on the left, and at a width
   that leaves the form readable rather than covering it.

   Minimised, it becomes one button in the corner carrying what was searched
   for. The panel is hidden, never emptied, so restoring it shows the same
   answer rather than an empty form.
   -------------------------------------------------------------------------- */
.enq-dialog[hidden] { display: none; }
.enq-dialog {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 120;            /* over the page, under .modal (130): a confirm
                              dialog raised from underneath must still win */
  display: flex;
  padding: var(--s-3);
  pointer-events: none;    /* the gap beside the panel stays clickable */
}
.enq-panel {
  pointer-events: auto;
  width: min(560px, calc(100vw - var(--s-5)));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.enq-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken, var(--surface));
}
.enq-bar h2 {
  margin: 0;
  font-size: var(--fs-15);
  font-weight: 600;
}
.enq-bar-actions {
  margin-left: auto;
  display: flex;
  gap: var(--s-1);
}
.enq-scroll {
  overflow: auto;
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.enq-lede {
  margin: 0;
  font-size: var(--fs-13);
  color: var(--text-muted);
}
.enq-scroll .card { box-shadow: none; }
.enq-log summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-14);
}
.enq-log .hint { display: block; margin: var(--s-2) 0; }
.enq-log .table-scroll { margin-top: var(--s-2); }
.enq-log .table { font-size: var(--fs-12); }

.enq-dock[hidden] { display: none; }
.enq-dock {
  position: fixed;
  right: var(--s-4);
  bottom: var(--s-4);
  z-index: 120;
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  max-width: min(360px, calc(100vw - var(--s-5)));
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-pill, 999px);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  font: inherit;
  font-size: var(--fs-13);
  cursor: pointer;
}
.enq-dock:hover { border-color: var(--border-strong, var(--border)); }
.enq-dock-label { font-weight: 600; white-space: nowrap; }
.enq-dock-sub {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* On a phone there is no "beside": the panel takes the screen, and minimising
   is how the officer gets back to the form. */
@media (max-width: 720px) {
  .enq-dialog { left: 0; padding: 0; }
  .enq-panel { width: 100%; border-radius: 0; border: 0; }
}

/* The row whose detail is being shown beside it — the chosen make in the vehicle
   catalogue. A background rather than a border, so the row's height does not shift
   as the selection moves down the table. */
.table tr.is-chosen > td { background: var(--surface-sunken); }

/* A row for something switched off: readable, clearly not in force. Used by the
   document checklists at a bank and by the master list, where "off" has to be
   visible at a glance across a table of fifteen. The name input is dimmed with
   the rest, but the switch that turns it back on is not. */
.table tr.is-muted > td { color: var(--text-muted); }
.table tr.is-muted .input,
.table tr.is-muted .select { color: var(--text-muted); background: var(--surface-inset); }
.table tr.is-muted .chip-check { color: var(--text); }

/* A row the operator has edited and not yet saved. */
.table tr.is-dirty > td { background: var(--plate-100); }
.table tr.is-dirty > td:first-child { box-shadow: inset 3px 0 0 var(--plate-700); }

/* ---------------------------------------------------------------------------
   The request state card (v5_37)

   Everything the console's detail panel used to hold, on the request's own
   page: the status, why it came back if it did, and the workflow actions that
   apply right now. It sits above the stepper because somebody arriving from the
   list wants the state of the request before its fields.
   --------------------------------------------------------------------------- */
.request-state { margin-bottom: var(--s-5); }
.request-state .card-head-actions { margin-left: auto; }
.request-state .card-body { padding-top: var(--s-4); }

.state-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
}
/* The hint that stands in for buttons when there is nothing to do. It is the
   whole content of the row then, so it carries no top margin of its own. */
.state-actions .hint { margin: 0; }

/* A request past editing. The form is a record of what was submitted, so its
   controls read as text rather than as fields somebody forgot to fill in —
   without going so pale that the values themselves are hard to read, which is
   the usual failure of a read-only state. */
body.is-record .input[readonly],
body.is-record .select[disabled],
body.is-record .textarea[readonly] {
  background: var(--surface-sunken);
  border-color: var(--line);
  color: var(--ink-800);
  cursor: default;
}
body.is-record .input[readonly]:focus-visible,
body.is-record .textarea[readonly]:focus-visible {
  /* Still focusable, still visibly so: a record has to be readable with a
     keyboard and a screen reader, which means tabbing through it must show
     where you are. */
  outline: 2px solid var(--seal-600);
  outline-offset: 1px;
}
