/* ==========================================================================
   KPS Warranty — Component vocabulary
   One shape language everywhere. Every interactive component ships
   default / hover / focus / active / disabled / loading / error.
   ========================================================================== */

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-line: var(--hairline-2);
  /* Hover is a token too. Hard-coding it here meant a variant with light ink
     — a button on the graphite ground — turned white-on-white on hover,
     because the base rule out-specified the variant's own colours. */
  --btn-bg-hover: var(--surface-3);
  --btn-line-hover: var(--hairline-3);
  --btn-ink-hover: var(--btn-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--ctl);
  padding: 0 var(--s-3);
  border: 1px solid var(--btn-line);
  border-radius: var(--r-2);
  background-color: var(--btn-bg);
  color: var(--btn-ink);
  font-size: var(--t-13);
  font-weight: 550;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--d-state) var(--ease-out),
              border-color   var(--d-state) var(--ease-out),
              color          var(--d-state) var(--ease-out),
              transform      var(--d-press) var(--ease-out),
              box-shadow     var(--d-state) var(--ease-out);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) {
    background-color: var(--btn-bg-hover);
    border-color: var(--btn-line-hover);
    color: var(--btn-ink-hover);
  }
}

.btn--primary {
  --btn-bg: var(--stamp); --btn-ink: var(--ink-invert); --btn-line: var(--stamp);
  --btn-bg-hover: var(--stamp-hover); --btn-line-hover: var(--stamp-hover);
  box-shadow: var(--shadow-1);
}
.btn--primary:active:not(:disabled) { background-color: var(--stamp-active); }

.btn--ghost {
  --btn-bg: transparent; --btn-line: transparent; --btn-ink: var(--ink-2);
  --btn-bg-hover: var(--surface-3); --btn-line-hover: transparent; --btn-ink-hover: var(--ink);
}

.btn--danger {
  --btn-ink: var(--decline); --btn-line: var(--decline-line);
  --btn-bg-hover: var(--decline-bg); --btn-line-hover: var(--decline);
}

/* Buttons that sit on the graphite ground — the marketing header, the CTA
   rows, the bulk-action bar, the copy button on a code block. Their ink is
   light, so their hover has to darken rather than lighten. */
.btn--on-dark {
  --btn-bg: transparent;
  --btn-ink: var(--chrome-ink);
  --btn-line: var(--chrome-3);
  --btn-bg-hover: var(--chrome-2);
  --btn-line-hover: var(--chrome-ink-2);
  --btn-ink-hover: var(--chrome-ink);
}
.btn--on-dark.btn--filled { --btn-bg: var(--chrome-2); --btn-bg-hover: var(--chrome-3); }

.btn--sm { height: var(--ctl-sm); padding: 0 var(--s-2); font-size: var(--t-12); gap: var(--s-1); }
.btn--lg { height: var(--ctl-lg); padding: 0 var(--s-5); font-size: var(--t-14); }
.btn--icon { width: var(--ctl); padding: 0; }
.btn--icon.btn--sm { width: var(--ctl-sm); }
.btn--icon.btn--lg { width: var(--ctl-lg); }
.btn--block { width: 100%; }

.btn .icon { width: 16px; height: 16px; flex: none; }
.btn--lg .icon { width: 18px; height: 18px; }

/* loading: content stays in place so the button never resizes */
.btn[data-loading="true"] { pointer-events: none; position: relative; color: transparent; }
.btn[data-loading="true"] .icon { opacity: 0; }
.btn[data-loading="true"]::after {
  content: ""; position: absolute;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in oklab, currentColor 25%, transparent);
  border-top-color: var(--btn-ink);
  animation: spin 620ms linear infinite;
}
.btn--primary[data-loading="true"]::after { border-top-color: var(--ink-invert); }
@keyframes spin { to { transform: rotate(360deg); } }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r-2); padding: 2px; gap: 2px; }
.seg button {
  height: 28px; padding: 0 var(--s-3);
  border-radius: 4px; font-size: var(--t-12); font-weight: 550;
  color: var(--ink-2);
  transition: background-color var(--d-state) var(--ease-out), color var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .seg button:hover { color: var(--ink); } }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1);
}

/* filter pills */
.pill-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: var(--ctl-sm); padding: 0 var(--s-3);
  border: 1px solid var(--hairline); border-radius: var(--r-full);
  background: var(--surface); color: var(--ink-2);
  font-size: var(--t-12); font-weight: 550; cursor: pointer;
  transition: background-color var(--d-state) var(--ease-out),
              border-color var(--d-state) var(--ease-out),
              color var(--d-state) var(--ease-out),
              transform var(--d-press) var(--ease-out);
}
.pill:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .pill:hover { border-color: var(--hairline-3); color: var(--ink); }
}
.pill[aria-pressed="true"] {
  background: var(--stamp-soft); border-color: var(--stamp-line); color: var(--stamp);
}
.pill .count {
  font-family: var(--font-data); font-size: var(--t-11);
  color: var(--ink-3); font-weight: 500;
}
.pill[aria-pressed="true"] .count { color: var(--stamp); }

/* ==========================================================================
   FORM CONTROLS
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.field > label, .label {
  font-size: var(--t-12);
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.005em;
}
.label .req { color: var(--decline); margin-left: 2px; }
.hint { font-size: var(--t-12); color: var(--ink-3); line-height: var(--lh-snug); }
.err  { font-size: var(--t-12); color: var(--decline); font-weight: 500; display: flex; gap: var(--s-1); align-items: center; }
.err .icon { width: 14px; height: 14px; flex: none; }

.input, .select, .textarea {
  width: 100%;
  height: var(--ctl);
  padding: 0 var(--s-3);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-14);
  transition: border-color var(--d-state) var(--ease-out),
              box-shadow var(--d-state) var(--ease-out),
              background-color var(--d-state) var(--ease-out);
}
.textarea { height: auto; min-height: 84px; padding: var(--s-2) var(--s-3); line-height: var(--lh-body); resize: vertical; }
@media (hover: hover) and (pointer: fine) {
  .input:hover:not(:disabled), .select:hover:not(:disabled), .textarea:hover:not(:disabled) {
    border-color: var(--hairline-3);
  }
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-3); color: var(--ink-3); cursor: not-allowed;
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--decline);
}
.input[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--decline) 20%, transparent);
}

.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.input--data { font-family: var(--font-data); letter-spacing: 0.02em; }
.input--sm { height: var(--ctl-sm); font-size: var(--t-13); padding: 0 var(--s-2); }

/* search input with leading icon */
.search { position: relative; display: flex; align-items: center; }
.search .icon {
  position: absolute; left: var(--s-3); width: 15px; height: 15px;
  color: var(--ink-3); pointer-events: none;
}
.search .input { padding-left: calc(var(--s-3) + 15px + var(--s-2)); }

/* checkbox & radio: native control, restyled minimally */
.check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: var(--t-13); }
.check input[type="checkbox"], .check input[type="radio"] {
  appearance: none;
  width: 16px; height: 16px; flex: none;
  border: 1px solid var(--hairline-3);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  display: grid; place-content: center;
  transition: background-color var(--d-state) var(--ease-out),
              border-color var(--d-state) var(--ease-out);
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--stamp); border-color: var(--stamp); }
.check input[type="checkbox"]::after {
  content: ""; width: 9px; height: 9px;
  transform: scale(0);
  transition: transform var(--d-press) var(--ease-out);
  background: var(--ink-invert);
  clip-path: polygon(14% 45%, 0 60%, 39% 100%, 100% 22%, 84% 8%, 39% 70%);
}
.check input[type="radio"]::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-invert);
  transform: scale(0);
  transition: transform var(--d-press) var(--ease-out);
}
.check input:checked::after { transform: scale(1); }
.check input:indeterminate { background: var(--stamp); border-color: var(--stamp); }
.check input:indeterminate::after {
  transform: scale(1);
  clip-path: polygon(0 40%, 100% 40%, 100% 60%, 0 60%);
}
.check input:disabled { opacity: 0.45; cursor: not-allowed; }
.check:has(input:disabled) { cursor: not-allowed; color: var(--ink-3); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--t-13); }
.switch input {
  appearance: none;
  width: 34px; height: 20px; flex: none;
  border-radius: var(--r-full);
  background: var(--hairline-3);
  position: relative; cursor: pointer;
  transition: background-color var(--d-state) var(--ease-out);
}
.switch input::after {
  content: ""; position: absolute;
  top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: transform var(--d-state) var(--ease-out);
}
.switch input:checked { background: var(--stamp); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:disabled { opacity: 0.45; cursor: not-allowed; }

/* ==========================================================================
   STATUS PILLS — filled + worded. Owned by claim outcome & warranty state.
   ========================================================================== */

.status {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 22px; padding: 0 var(--s-2) 0 var(--s-2);
  border-radius: var(--r-1);
  font-size: var(--t-11); font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid transparent;
}
.status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}
.status--accept   { background: var(--accept-bg);   color: var(--accept);   border-color: var(--accept-line); }
.status--decline  { background: var(--decline-bg);  color: var(--decline);  border-color: var(--decline-line); }
.status--no-fault { background: var(--no-fault-bg); color: var(--no-fault); border-color: var(--no-fault-line); }
.status--info     { background: var(--info-bg);     color: var(--info);     border-color: var(--info-line); }
.status--stamp    { background: var(--stamp-soft);  color: var(--stamp);    border-color: var(--stamp-line); }
.status--neutral  { background: var(--surface-3);   color: var(--ink-2);    border-color: var(--hairline); }

/* Workflow status pill takes its colour from the status config (data-driven,
   FR-23) via inline custom properties set by the renderer. */
.status--wf {
  background: var(--wf-bg, var(--surface-3));
  color: var(--wf-fg, var(--ink-2));
  border-color: var(--wf-line, var(--hairline));
}

/* Warranty verdict — larger, reads as a determination not a tag */
.verdict {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 26px; padding: 0 var(--s-3);
  border-radius: var(--r-2);
  font-size: var(--t-12); font-weight: 650; letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.verdict--in  { background: var(--accept-bg);  color: var(--accept);  border-color: var(--accept-line); }
.verdict--out { background: var(--decline-bg); color: var(--decline); border-color: var(--decline-line); }
.verdict--none{ background: var(--warn-bg);    color: var(--warn);    border-color: var(--warn-line); }
.verdict--pending { background: var(--surface-3); color: var(--ink-3); border-color: var(--hairline); }
.verdict .icon { width: 14px; height: 14px; flex: none; }

/* ==========================================================================
   BRAND CHIPS — outlined + mono + swatch. DATA, never status.
   The different shape is what keeps a Red-brand chip from reading as a
   Decline pill. Colour is the secondary cue, never the only one.
   ========================================================================== */

.brand-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 20px; padding: 0 var(--s-2);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-1);
  background: transparent;
  font-family: var(--font-data);
  font-size: var(--t-11); font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.brand-chip::before {
  content: ""; width: 7px; height: 7px; flex: none;
  border-radius: 1px;
  background: var(--chip, var(--brand-unmapped));
}
.brand-chip[data-brand="Red"]     { --chip: var(--brand-red); }
.brand-chip[data-brand="Emerald"] { --chip: var(--brand-emerald); }
.brand-chip[data-unmapped="true"] {
  border-style: dashed; border-color: var(--warn-line); color: var(--warn);
}

/* small key/value tag */
.tag {
  display: inline-flex; align-items: center; gap: var(--s-1);
  height: 20px; padding: 0 var(--s-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  background: var(--surface-2);
  font-size: var(--t-11); font-weight: 550; color: var(--ink-2);
  white-space: nowrap;
}
.tag--data { font-family: var(--font-data); letter-spacing: 0.02em; }

kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border: 1px solid var(--hairline-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--font-data); font-size: var(--t-11); font-weight: 500;
  color: var(--ink-2);
}

/* ==========================================================================
   PANELS
   ========================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  overflow: hidden;
}
.panel__head {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 46px;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
}
.panel__title { font-size: var(--t-13); font-weight: 650; letter-spacing: -0.005em; }
.panel__sub { font-size: var(--t-12); color: var(--ink-3); }
.panel__body { padding: var(--s-4); }
.panel__body--flush { padding: 0; }
.panel__foot {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}

/* A callout. Full border + background tint — never a side stripe. */
.note {
  display: flex; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--surface-2);
  font-size: var(--t-13); line-height: var(--lh-body);
  color: var(--ink-2);
}
.note .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--ink-3); }
.note strong { color: var(--ink); font-weight: 600; }
.note--warn   { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.note--warn .icon, .note--warn strong { color: var(--warn); }
.note--error  { background: var(--decline-bg); border-color: var(--decline-line); color: var(--decline); }
.note--error .icon, .note--error strong { color: var(--decline); }
.note--ok     { background: var(--accept-bg); border-color: var(--accept-line); color: var(--accept); }
.note--ok .icon, .note--ok strong { color: var(--accept); }
.note--stamp  { background: var(--stamp-soft); border-color: var(--stamp-line); color: var(--stamp); }
.note--stamp .icon, .note--stamp strong { color: var(--stamp); }

/* Definition list — the docket's own layout */
.dl { display: grid; grid-template-columns: minmax(120px, 160px) 1fr; gap: var(--s-1) var(--s-4); align-items: baseline; }
.dl dt { font-size: var(--t-12); color: var(--ink-3); font-weight: 550; }
.dl dd { margin: 0; font-size: var(--t-13); color: var(--ink); }
.dl--rows { display: block; }
.dl--rows > div {
  display: flex; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--hairline);
}
.dl--rows > div:last-child { border-bottom: 0; }

/* ==========================================================================
   TABLES
   ========================================================================== */

.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }

table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-13); }
.tbl thead th {
  position: sticky; top: 0; z-index: var(--z-raised);
  padding: var(--s-2) var(--s-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline-2);
  font-size: var(--t-11); font-weight: 650;
  letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  white-space: nowrap;
}
.tbl thead th.sortable { cursor: pointer; user-select: none; }
@media (hover: hover) and (pointer: fine) {
  .tbl thead th.sortable:hover { color: var(--ink); background: var(--surface-3); }
}
.tbl thead th .sort-mark { opacity: 0; margin-left: var(--s-1); font-size: 9px; }
.tbl thead th[aria-sort] { color: var(--ink); }
.tbl thead th[aria-sort] .sort-mark { opacity: 1; }

.tbl tbody td {
  padding: 7px var(--s-3);
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
  color: var(--ink-2);
}
.tbl tbody td.strong { color: var(--ink); font-weight: 550; }
.tbl tbody tr { transition: background-color var(--d-state) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .tbl tbody tr:hover { background: var(--surface-2); }
}
.tbl tbody tr[aria-selected="true"] { background: var(--stamp-soft); }
.tbl tbody tr[aria-selected="true"] td { border-bottom-color: var(--stamp-line); }
.tbl tbody tr.is-clickable { cursor: pointer; }
.tbl td.tar, .tbl th.tar { text-align: right; }
.tbl .col-check { width: 36px; padding-right: 0; }
.tbl .col-tight { width: 1%; white-space: nowrap; }

/* group header row (group-by-shipment / group-by-property) */
.tbl tbody tr.group-row td {
  background: var(--surface-3);
  border-bottom: 1px solid var(--hairline-2);
  border-top: 1px solid var(--hairline-2);
  padding: var(--s-2) var(--s-3);
  font-weight: 600; color: var(--ink);
}
.tbl tbody tr.group-row:hover td { background: var(--surface-3); }

.tbl--compact tbody td { padding: 4px var(--s-3); }

/* Free-text cells get a ceiling and truncate rather than wrapping the row
   to two lines — row height is what makes a dense table scannable. */
.tbl td .cell-text {
  display: block; max-width: 22ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tbl td .cell-text--wide { max-width: 30ch; }
@media (min-width: 1500px) {
  .tbl td .cell-text { max-width: 32ch; }
  .tbl td .cell-text--wide { max-width: 44ch; }
}

/* ==========================================================================
   TABS
   ========================================================================== */

.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--hairline); overflow-x: auto; }
.tabs button {
  position: relative;
  padding: var(--s-3) var(--s-3);
  font-size: var(--t-13); font-weight: 550;
  color: var(--ink-3);
  white-space: nowrap;
  transition: color var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .tabs button:hover { color: var(--ink); } }
.tabs button::after {
  content: ""; position: absolute; left: var(--s-2); right: var(--s-2); bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--stamp);
  transform: scaleX(0);
  transition: transform var(--d-state) var(--ease-out);
}
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after { transform: scaleX(1); }

/* ==========================================================================
   MODAL — centred (not anchored, so transform-origin stays centre)
   ========================================================================== */

.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-backdrop);
  background: oklch(0.17 0.004 285 / 0.4);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: var(--s-4);
  opacity: 0;
  transition: opacity var(--d-modal) var(--ease-out);
}
.modal-backdrop[data-open="true"] { opacity: 1; }

.modal {
  position: relative; z-index: var(--z-modal);
  width: 100%; max-width: 560px;
  max-height: min(88vh, 900px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-3);
  transform: scale(0.96) translateY(8px);
  opacity: 0;
  transition: transform var(--d-modal) var(--ease-out), opacity var(--d-modal) var(--ease-out);
}
.modal-backdrop[data-open="true"] .modal { transform: scale(1) translateY(0); opacity: 1; }
.modal--wide { max-width: 780px; }
.modal--xwide { max-width: 1020px; }

.modal__head {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--hairline);
}
.modal__title { font-size: var(--t-16); font-weight: 650; }
.modal__sub { font-size: var(--t-12); color: var(--ink-3); margin-top: 2px; }
.modal__body { padding: var(--s-5); overflow-y: auto; flex: 1 1 auto; }
.modal__foot {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}

@media (prefers-reduced-motion: reduce) {
  .modal { transform: none; }
  .modal-backdrop[data-open="true"] .modal { transform: none; }
}

/* ==========================================================================
   POPOVER / DROPDOWN — origin-aware, scales from its trigger
   ========================================================================== */

.pop {
  position: fixed; z-index: var(--z-dropdown);
  min-width: 180px; max-width: 320px;
  padding: var(--s-1);
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
  transform-origin: var(--pop-origin, top left);
  transform: scale(0.96);
  opacity: 0;
  transition: transform var(--d-pop) var(--ease-out), opacity var(--d-pop) var(--ease-out);
}
.pop[data-open="true"] { transform: scale(1); opacity: 1; }
.pop__item {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; padding: var(--s-2) var(--s-2);
  border-radius: 4px;
  font-size: var(--t-13); color: var(--ink-2);
  text-align: left; text-decoration: none;
  transition: background-color var(--d-state) var(--ease-out), color var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .pop__item:hover { background: var(--surface-3); color: var(--ink); }
}
.pop__item[aria-current="true"] { color: var(--stamp); font-weight: 600; }
.pop__item .icon { width: 15px; height: 15px; flex: none; }
.pop__sep { height: 1px; background: var(--hairline); margin: var(--s-1) 0; }
.pop__label {
  padding: var(--s-2) var(--s-2) var(--s-1);
  font-size: var(--t-11); font-weight: 650; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ==========================================================================
   TOASTS — transitions, not keyframes (rapid re-trigger must retarget)
   ========================================================================== */

.toast-stack {
  position: fixed; right: var(--s-4); bottom: var(--s-4);
  z-index: var(--z-toast);
  display: flex; flex-direction: column-reverse; gap: var(--s-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 260px; max-width: 400px;
  padding: var(--s-3) var(--s-4);
  background: var(--chrome); color: var(--chrome-ink);
  border: 1px solid var(--chrome-line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-3);
  font-size: var(--t-13);
  pointer-events: auto;
  opacity: 1; transform: translateY(0);
  transition: opacity var(--d-modal) var(--ease-out), transform var(--d-modal) var(--ease-out);
}
.toast[data-leaving="true"] { opacity: 0; transform: translateY(100%); }
@starting-style { .toast { opacity: 0; transform: translateY(100%); } }
.toast .icon { width: 16px; height: 16px; flex: none; }
.toast--ok .icon { color: oklch(0.78 0.14 152); }
.toast--error .icon { color: oklch(0.75 0.16 27); }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast[data-leaving="true"] { transform: none; }
  @starting-style { .toast { transform: none; } }
}

/* ==========================================================================
   EMPTY / LOADING
   ========================================================================== */

.empty {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s-3); padding: var(--s-12) var(--s-6);
  text-align: center;
}
.empty__glyph {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px dashed var(--hairline-2);
  border-radius: var(--r-3);
  color: var(--ink-3);
}
.empty__glyph .icon { width: 20px; height: 20px; }
.empty__title { font-size: var(--t-14); font-weight: 600; color: var(--ink); }
.empty__body { font-size: var(--t-13); color: var(--ink-3); max-width: 42ch; line-height: var(--lh-body); }

.skel {
  background: linear-gradient(90deg,
    var(--surface-3) 25%, var(--surface-4) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-1);
  animation: skel 1.3s linear infinite;
}
@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; background: var(--surface-3); }
}

/* ==========================================================================
   PROGRESS / METERS
   ========================================================================== */

.meter { height: 6px; border-radius: var(--r-full); background: var(--surface-4); overflow: hidden; }
.meter > span {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--stamp);
  transition: width var(--d-modal) var(--ease-out);
}
.meter--accept > span { background: var(--accept); }
.meter--decline > span { background: var(--decline); }
.meter--no-fault > span { background: var(--no-fault); }
.meter--warn > span { background: var(--warn); }

/* stacked bar for per-brand / per-outcome breakdowns */
.stackbar { display: flex; height: 8px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-4); }
.stackbar > span { display: block; height: 100%; }

/* ==========================================================================
   STEPS (importer wizard, lifecycle)
   ========================================================================== */

.steps { display: flex; align-items: center; gap: 0; overflow-x: auto; }
.step {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-12); font-weight: 550; color: var(--ink-3);
  white-space: nowrap;
}
.step__n {
  width: 20px; height: 20px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--hairline-2); border-radius: 50%;
  font-family: var(--font-data); font-size: var(--t-11);
  background: var(--surface);
}
.step[data-state="done"] { color: var(--ink-2); }
.step[data-state="done"] .step__n {
  background: var(--stamp); border-color: var(--stamp); color: var(--ink-invert);
}
.step[data-state="active"] { color: var(--ink); }
.step[data-state="active"] .step__n {
  border-color: var(--stamp); color: var(--stamp);
  box-shadow: 0 0 0 3px var(--stamp-soft);
}
.step__line { width: 24px; height: 1px; background: var(--hairline-2); flex: none; }

/* ==========================================================================
   TIMELINE (claim status history, FR-19 / FR-35)
   ========================================================================== */

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: var(--s-3); }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-dot {
  width: 9px; height: 9px; border-radius: 50%; margin-top: 6px;
  background: var(--surface); border: 2px solid var(--hairline-3); flex: none;
}
.tl-item[data-kind="reverted"] .tl-dot { border-color: var(--warn); }
.tl-item[data-kind="current"] .tl-dot { border-color: var(--stamp); background: var(--stamp); }
.tl-line { width: 1px; flex: 1 1 auto; background: var(--hairline); min-height: var(--s-3); }
.tl-body { padding-bottom: var(--s-5); min-width: 0; }
.tl-item:last-child .tl-body { padding-bottom: 0; }
.tl-head { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.tl-meta { font-size: var(--t-12); color: var(--ink-3); margin-top: 2px; }
.tl-data {
  margin-top: var(--s-2);
  display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2);
}

/* ==========================================================================
   KANBAN BOARD (workbenches, FR-36 / FR-37)
   ========================================================================== */

.board { display: grid; gap: var(--s-4); align-items: start; }
@media (min-width: 900px) { .board { grid-template-columns: 1fr 1fr; } }

.col {
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  min-height: 220px;
}
.col__head {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: var(--z-raised);
  background: var(--surface-2);
  border-radius: var(--r-3) var(--r-3) 0 0;
}
.col__title { font-size: var(--t-13); font-weight: 650; }
.col__count {
  font-family: var(--font-data); font-size: var(--t-11);
  padding: 2px var(--s-2); border-radius: var(--r-full);
  background: var(--surface-4); color: var(--ink-2);
}
.col__body { padding: var(--s-2); display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }

.unit {
  display: grid; gap: var(--s-2);
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  transition: border-color var(--d-state) var(--ease-out),
              box-shadow var(--d-state) var(--ease-out),
              opacity var(--d-state) var(--ease-out),
              transform var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .unit:hover { border-color: var(--hairline-3); box-shadow: var(--shadow-1); }
}
.unit[data-moving="true"] { opacity: 0; transform: scale(0.97); }
.unit__top { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; min-width: 0; }
.unit__top > * { min-width: 0; }
.unit__top .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit__top .push { margin-left: auto; }
.unit__meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-2); font-size: var(--t-12); color: var(--ink-3); min-width: 0; }
.unit__meta > * { min-width: 0; }
.unit__actions { display: flex; gap: var(--s-2); }

/* ==========================================================================
   ICONS
   ========================================================================== */

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor;
        stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon--lg { width: 20px; height: 20px; }
.icon--sm { width: 13px; height: 13px; }

/* ==========================================================================
   STATUS TONES — the palette a workflow status may be configured with.
   A fixed set rather than a free colour picker: every tone is contrast-
   checked, so no configuration can produce an unreadable badge.
   ========================================================================== */

.tone-neutral  { background: var(--surface-3);   color: var(--ink-2);    border-color: var(--hairline); }
.tone-info     { background: var(--info-bg);     color: var(--info);     border-color: var(--info-line); }
.tone-progress { background: transparent;        color: var(--info);     border-color: var(--info); }
.tone-active   { background: var(--ink);         color: var(--surface);  border-color: var(--ink); }
.tone-accept   { background: var(--accept-bg);   color: var(--accept);   border-color: var(--accept-line); }
.tone-decline  { background: var(--decline-bg);  color: var(--decline);  border-color: var(--decline-line); }
.tone-no-fault { background: var(--no-fault-bg); color: var(--no-fault); border-color: var(--no-fault-line); }
.tone-pending  { background: var(--warn-bg);     color: var(--warn);     border-color: var(--warn-line); }

/* A small square of the tone, for legends and pickers. */
.tone-swatch { width: 10px; height: 10px; border-radius: 2px; border: 1px solid; flex: none; }

/* ==========================================================================
   WARRANTY PANEL — the live determination, shared by the customer form,
   the advance modal and the landing page.
   ========================================================================== */

.warranty {
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--surface);
}
.warranty__top {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
}
.warranty[data-verdict="in"]  .warranty__top { background: var(--accept-bg);   border-bottom-color: var(--accept-line); }
.warranty[data-verdict="out"] .warranty__top { background: var(--decline-bg);  border-bottom-color: var(--decline-line); }
.warranty[data-verdict="batch"] .warranty__top { background: var(--warn-bg); border-bottom-color: var(--warn-line); }
.warranty__msg { font-size: var(--t-13); font-weight: 550; }
.warranty[data-verdict="in"]  .warranty__msg { color: var(--accept); }
.warranty[data-verdict="out"] .warranty__msg { color: var(--decline); }
.warranty[data-verdict="batch"] .warranty__msg { color: var(--warn); }
.warranty__body { padding: var(--s-3) var(--s-4); }

/* The derivation, step by step. Shown because "trust me" is not an
   acceptable answer when money follows from the result. */
.trace { display: flex; flex-direction: column; gap: 0; }
.trace__row {
  display: grid; grid-template-columns: 150px 1fr; gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px dashed var(--hairline);
  font-size: var(--t-12);
}
.trace__row:last-child { border-bottom: 0; }
.trace__k { color: var(--ink-3); font-weight: 600; }
.trace__v { color: var(--ink-2); line-height: var(--lh-snug); }
@media (max-width: 600px) {
  .trace__row { grid-template-columns: 1fr; gap: 2px; }
}

/* Outcome contributions — which input decided it. */
.contrib { display: flex; flex-direction: column; gap: var(--s-1); }
.contrib__row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--surface);
  font-size: var(--t-12);
}
.contrib__row[data-decisive="true"] { border-color: var(--hairline-3); background: var(--surface-2); }
.contrib__k { color: var(--ink-3); width: 128px; flex: none; font-weight: 600; }
.contrib__v { color: var(--ink); font-weight: 550; }
.contrib__o { margin-left: auto; }

/* ==========================================================================
   ALLOWANCE LEDGER — the per-property allocation, with its derivation
   ========================================================================== */

.alloc { border: 1px solid var(--hairline); border-radius: var(--r-3); overflow: hidden; }
.alloc__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2); border-bottom: 1px solid var(--hairline);
}
.alloc__addr { font-size: var(--t-13); font-weight: 650; }
.alloc__sum { margin-left: auto; font-family: var(--font-data); font-weight: 600; font-size: var(--t-14); }
.alloc__sum[data-zero="true"] { color: var(--ink-3); font-weight: 500; }

.invariant {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-2);
  font-size: var(--t-12); font-weight: 600;
  background: var(--accept-bg); color: var(--accept); border: 1px solid var(--accept-line);
}
.invariant[data-ok="false"] { background: var(--decline-bg); color: var(--decline); border-color: var(--decline-line); }
.invariant .icon { width: 14px; height: 14px; }

/* ==========================================================================
   MINI BAR — an inline magnitude, for tables and stat strips
   ========================================================================== */
.minibar { display: flex; align-items: center; gap: var(--s-2); }
.minibar__track { flex: 1 1 auto; height: 4px; border-radius: var(--r-full); background: var(--surface-4); min-width: 40px; }
.minibar__fill { height: 100%; border-radius: var(--r-full); background: var(--ink-3); }

/* A swatch is a solid chip of the tone, not a miniature of the pill. */
.tone-swatch[class*="tone-"] { background: currentColor; border-color: currentColor; }

/* On a phone the unit card gives the warranty verdict its own line rather
   than squeezing four things onto one. */
@media (max-width: 560px) {
  .unit__top .push { margin-left: 0; flex: 1 0 100%; }
  .unit__top .mono { flex: 0 1 auto; }
}
