/* kit.css — the list and record kit, one for the client app and the admin
 * (core/list.js, core/record.js; docs/EUDR_UI_HANDBOOK.md §2.2, F13). EUDR:
 * css/operator-react.css:5397-5846 (the filter bar and list), :7873-7940
 * (the record page), css/dds.css:241-267 (the badge formula), css/admin.css
 * :63-139 and :1893-1924.
 *
 * Moved here from phase1.css (the admin rebuild) as they were; the new parts
 * follow each group. Colours are tokens only, so dark.css's token flip turns
 * most of it; the few dark rules sit here (this sheet loads after dark.css).
 * Phones keep mobile.css's table-to-card restack until each area draws its
 * phone screen (core/phone.js).
 */

/* ═══════════════════════ Pills ═══════════════════════ */
/* The plain pill pages build themselves (ct-pill, ct-pill--ok|warn|cmr|lock). */
.ct-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}
.ct-pill--cmr {
  background: var(--confirmed-tint);
  color: var(--confirmed);
}
.ct-pill--ok {
  background: var(--clear-tint);
  color: var(--clear);
}
.ct-pill--warn {
  background: var(--potential-tint);
  color: var(--potential);
}
.ct-pill--lock {
  background: var(--primary-soft);
  color: var(--primary);
}
.ct-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* statusPill(): one shape, the label tells the states apart (EUDR
   .ship-st/.dds-status-badge: 0.7rem/700, uppercase, 0.04em, radius 20).
   Its colours from the badge formula: a 24 % tint, the colour 45 % into
   near-black for the ink, a 40 % edge; on dark a 22 % tint into the dark
   floor and the colour 62 % into white. Each tone is AA (≥ 6.6:1 light,
   ≥ 6.6:1 dark). Solid red and solid amber are kept for "act now". */
.ct-pill--status {
  --pill-c: var(--clear);
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--pill-c) 40%, transparent);
  border-radius: 20px;
  background: color-mix(in srgb, var(--pill-c) 24%, #ffffff);
  color: color-mix(in srgb, var(--pill-c) 45%, #1a1a1a);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-transform: uppercase;
}
.ct-pill--status[data-tone="red"] { --pill-c: var(--confirmed); }
.ct-pill--status[data-tone="amber"] { --pill-c: var(--potential); }
.ct-pill--status[data-tone="muted"] { --pill-c: var(--neutral-status); }
.ct-pill--status[data-tone="brand"] { --pill-c: var(--cyan-deep); }
/* undecided, automated, provisional: outlined, no fill */
.ct-pill--status[data-tone="open"] {
  border-color: color-mix(in srgb, var(--pill-c) 70%, transparent);
  background: transparent;
}
/* "act now": solid, the same in both themes (white on #b0443a 5.6:1;
   #3a2400 on #f5a623 7.2:1) */
.ct-pill--status[data-tone="act"] {
  border-color: #b0443a;
  background: #b0443a;
  color: #ffffff;
}
.ct-pill--status[data-tone="wait"] {
  border-color: #f5a623;
  background: #f5a623;
  color: #3a2400;
}
body.dark-mode .ct-pill--status {
  background: color-mix(in srgb, var(--pill-c) 22%, #0a2421);
  color: color-mix(in srgb, var(--pill-c) 62%, #ffffff);
  border-color: color-mix(in srgb, var(--pill-c) 45%, transparent);
}
body.dark-mode .ct-pill--status[data-tone="brand"] { --pill-c: var(--accent); }
body.dark-mode .ct-pill--status[data-tone="open"] { background: transparent; }
body.dark-mode .ct-pill--status[data-tone="act"] { background: #b0443a; border-color: #b0443a; color: #ffffff; }
body.dark-mode .ct-pill--status[data-tone="wait"] { background: #f5a623; border-color: #f5a623; color: #3a2400; }

/* ═══════════════════════ The list bar and rows ═══════════════════════ */
/* The bar: views, search, count + Clear (only when narrowed), Export. */
.ct-list-bar {
  margin-bottom: var(--space-3);
}
.ct-list-views:empty {
  display: none;
}
.ct-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
}
.ct-seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.ct-seg button:hover {
  color: var(--primary);
}
.ct-seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.ct-seg button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.ct-seg-n {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ct-filter-clear {
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.ct-filter-clear:hover {
  border-color: var(--confirmed);
  background: var(--confirmed-tint);
  color: var(--confirmed);
}
.ct-filter-clear[hidden],
.ct-toolbar-count[hidden] {
  display: none;
}
/* One Export menu. */
.ct-export {
  position: relative;
}
.ct-export > summary {
  list-style: none;
  cursor: pointer;
}
.ct-export > summary::-webkit-details-marker {
  display: none;
}
.ct-export > summary::after {
  content: "▾";
  margin-left: 6px;
  font-size: 0.8em;
}
.ct-export-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md, 0 8px 24px rgb(0 0 0 / 0.12));
}
.ct-export-menu button {
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.ct-export-menu button:hover,
.ct-export-menu button:focus-visible {
  outline: none;
  background: var(--primary-soft);
  color: var(--primary);
}
/* The dropdowns under the bar, in equal columns; their options come from the data. */
.ct-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: var(--space-3);
}
.ct-filter-grid .ct-toolbar-select {
  max-width: none;
  width: 100%;
}
/* A filter a record's card set: a chip with × (EUDR's account chip). */
.ct-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-3);
}
.ct-filter-chips[hidden] {
  display: none;
}
.ct-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 700;
}
.ct-filter-chip button {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.ct-filter-chip button:hover,
.ct-filter-chip button:focus-visible {
  outline: none;
  background: var(--surface);
}
.ct-list-summary[hidden] {
  display: none;
}
/* "You came here from …" */
.ct-return-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
  border-radius: var(--radius);
  background: var(--primary-soft);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
}
/* A row opens its record: the whole row is the target. */
.ct-table tbody tr.ct-row-link {
  cursor: pointer;
}
.ct-table tbody tr.ct-row-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.ct-table tbody tr.ct-row-inactive td {
  color: var(--text-muted);
}
.ct-pill--off {
  background: var(--confirmed-tint);
  color: var(--confirmed);
}

/* ═══════════════════════ The list (core/list.js) ═══════════════════════ */
/* filterBar(): the bar and the dropdown grid, one block (hidden until the
   list has rows). */
.ct-filterbar[hidden] {
  display: none;
}
/* The search's × (EUDR .dds-search-clear): only while there are words. */
.ct-toolbar-search {
  position: relative;
}
.ct-toolbar-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.ct-search-clear {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-inline-start: 2px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.ct-search-clear:hover,
.ct-search-clear:focus-visible {
  outline: none;
  background: var(--surface-2);
  color: var(--text);
}
.ct-search-clear[hidden] {
  display: none;
}
/* The list's own wait: the dots, centred where the rows will be. */
.ct-list-loading {
  display: flex;
  justify-content: center;
  min-height: 160px;
}
/* "Show more (n)" under a long list. */
.ct-list-more {
  display: flex;
  justify-content: center;
  margin-top: var(--space-4);
}
.ct-filter-chips:empty {
  display: none;
}
/* Phones: until a screen draws its phone version, the bar wraps two to a row
   (EUDR operator-react.css:3250-3252, 5844-5846) and the search takes the
   whole first row. */
@media (max-width: 600px) {
  .ct-list-bar .ct-toolbar-search {
    flex: 1 1 100%;
  }
  .ct-list-views {
    flex: 1 1 100%;
    overflow-x: auto;
  }
  .ct-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ═══════════════════════ A record's page ═══════════════════════ */
/* ── A record's page ── */
.ct-record-kicker {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ct-record-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
/* "·" between two facts; none after the pill. The dot wraps with its value. */
.ct-record-meta > span:not(.ct-pill) + span:not(.ct-pill)::before {
  content: "·";
  margin-right: 8px;
  color: var(--text-subtle);
}
.ct-record-status {
  max-width: 80ch;
  margin: 0 0 var(--space-4);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.5;
}
.ct-record-facts {
  display: grid;
  grid-template-columns: repeat(var(--ct-fact-cols, 2), minmax(0, 1fr));
  gap: var(--space-3) var(--space-5);
  margin: 0 0 var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--page-panel);
}
.ct-record-facts dt {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
}
.ct-record-facts dd {
  margin: 2px 0 0;
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.ct-drill-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.ct-drill-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
a.ct-drill-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
a.ct-drill-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.ct-drill-card--off {
  opacity: 0.62;
}
.ct-drill-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--page-badge);
  color: var(--page-badge-ink);
}
.ct-drill-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}
.ct-drill-title {
  font-weight: 800;
}
.ct-drill-sub {
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.ct-drill-count {
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ct-drill-arrow {
  color: var(--text-subtle);
  font-size: 1.3rem;
}
.ct-record-section {
  margin-bottom: var(--space-5);
}
.ct-record-section-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-base);
  font-weight: 800;
}
.ct-record-rows {
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ct-record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 14px;
}
.ct-record-row + .ct-record-row {
  border-top: 1px solid var(--border);
}
.ct-record-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.ct-record-inline-form label {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 700;
}
/* The foot: Back on the left, the page's one action on the right. */
.ct-record-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.ct-record-back {
  text-decoration: none;
}
.ct-record-note {
  flex: 1 1 260px;
  margin: 0;
}
.ct-record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-left: auto;
}
/* The page's one action, when it is destructive: red, never quiet grey
   (EUDR's "Delete supplier"); the confirm dialog asks first. */
.ct-record-actions .ct-btn-danger {
  border-color: var(--confirmed);
  color: var(--confirmed);
  font-weight: 700;
}
@media (max-width: 640px) {
  .ct-record-facts {
    grid-template-columns: 1fr;
  }
  .ct-record-actions {
    width: 100%;
  }
  .ct-record-actions > * {
    flex: 1 1 auto;
  }
}

/* ═══════════════════════ The record (core/record.js) ═══════════════════════ */
/* The next step at the head's top right (recordPage nextStep). */
.ct-record-next {
  align-self: flex-start;
}
