/* catalog: page styles on top of the design-system primitives in /styles.css.
   Tokens only (var(--...)); no hex, no rgba, no new hues. */

/* ── Toolbars and section heads ─────────────────────────────────── */
.cat-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 20px; }
.cat-toolbar .search-input { flex: 1 1 240px; max-width: 360px; }
.cat-count { font-size: var(--fs-meta); color: var(--ink-3); }
.cat-section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 6px; }
.cat-section-head h2 { margin: 0; }
.cat-section-head .search-input { flex: 0 1 260px; }
.cat-n { font-weight: 400; color: var(--ink-3); }
.cat-help { font-size: var(--fs-meta); color: var(--ink-3); margin: 0 0 14px; max-width: 72ch; }
.cat-gap { margin: 0 0 14px; }
.cat-sched-table { max-width: 620px; }

/* ── Editable tables: cells read as text until hovered or focused ── */
.cat-table { border-collapse: separate; border-spacing: 0; }
.cat-table--wide { min-width: 720px; }
.cat-table--wide td:first-child > input { min-width: 180px; }
.cat-table .link { white-space: nowrap; }
.cat-table th:first-child, .cat-table td:first-child { padding-left: 8px; }
.cat-table th:last-child, .cat-table td:last-child { padding-right: 8px; }
.cat-table td { padding-top: 8px; padding-bottom: 8px; }
.cat-table input { height: 36px; padding: 0 10px; border-color: transparent; background: transparent; }
.cat-table input:hover { border-color: var(--line); }
.cat-table input:focus { background: var(--panel); }
.cat-table code { word-break: break-word; }
.cat-table td.cat-nowrap { white-space: nowrap; }
.cat-table td > .status { vertical-align: middle; }
.cat-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; white-space: nowrap; }
.cat-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; color: inherit; font-size: inherit; }
.cat-sort:hover, th[aria-sort] .cat-sort { color: var(--ink); }

/* ── Staged edits: a tint plus an icon or words, never colour alone ── */
/* Modified value: caution tint and a pencil at the end of the field. */
td.is-mod { background: var(--tint-y); border-radius: var(--r-xs); }
.is-mod { position: relative; }
.is-mod input { padding-right: 32px; }
.is-mod::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  background: var(--caution-ink); pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M2 26h28v2H2zM25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4zm-5-5L24 7.6l-3 3L17.4 7zM6 22v-3.6l10-10l3.6 3.6l-10 10z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M2 26h28v2H2zM25.4 9c.8-.8.8-2 0-2.8l-3.6-3.6c-.8-.8-2-.8-2.8 0l-15 15V24h6.4zm-5-5L24 7.6l-3 3L17.4 7zM6 22v-3.6l10-10l3.6 3.6l-10 10z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cat-field.is-mod::after { right: 12px; }
.cat-field.is-mod input { background: var(--tint-y); }
/* Whole records: added (green), staged for archive or delete (red, struck), restored. */
.cat-row--add > td { background: var(--tint-c); }
.cat-row--archive > td { background: var(--tint-r); }
.cat-row--restore > td { background: color-mix(in oklch, var(--tint-c) 55%, transparent); }
.cat-row--archive input { text-decoration: line-through; color: var(--ink-3); }

/* ── Record (insurer / product): label + field rows ──────────────── */
.cat-record { display: grid; grid-template-columns: 180px minmax(0, 440px); align-items: center; gap: 12px 20px; }
.cat-record > label { margin: 0; font-size: var(--fs-ui); color: var(--ink-2); }
.cat-record .cat-key { font-size: var(--fs-ui); color: var(--ink-2); font-weight: 500; }
.cat-field { border-radius: var(--r-sm); }
.cat-status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 40px; }

/* ── Commission schedule under each product ─────────────────────── */
/* The schedule reads as part of the product line above it: no divider between. */
.cat-table .cat-prod-row > td { border-bottom: 0; padding-bottom: 0; }
.cat-table .cat-sched-row > td { padding: 2px 8px 12px 19px; }
.cat-sched-line { font-size: var(--fs-min); color: var(--ink-3); }
.cat-sched-editor, .cat-brackets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.cat-brackets > .cat-sched-label { font-size: var(--fs-meta); color: var(--ink-2); }
.cat-bracket {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 3px 3px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); font-size: var(--fs-meta); color: var(--ink-3); white-space: nowrap;
}
.cat-table .cat-bracket input { height: 30px; padding: 0 8px; border-color: var(--line); background: var(--panel); }
.cat-table .cat-bracket input:disabled { background: transparent; text-decoration: line-through; }
.cat-table .cat-bk-year { width: 64px; }
.cat-table .cat-bk-rate { width: 88px; }
.cat-bracket.is-del { background: var(--tint-r); border-color: transparent; }

/* ── Save bar: pinned to the bottom of the panel while edits are staged ── */
.cat-savebar-host { position: sticky; bottom: 16px; z-index: 20; margin-top: 24px; }
.cat-savebar-host:empty { display: none; }
.cat-savebar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 10px 18px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--panel); box-shadow: var(--pop-sh);
  animation: dlgIn 220ms var(--ease-out) both;
}
.cat-savebar > svg { color: var(--caution); }
.cat-savebar-text { flex: 1; min-width: 0; font-size: var(--fs-ui); color: var(--ink-2); }

@media (max-width: 640px) {
  .cat-record { grid-template-columns: 1fr; gap: 6px; }
  .cat-record > :nth-child(2n) { margin-bottom: 10px; }
  .cat-savebar { flex-wrap: wrap; padding: 12px; }
  .cat-savebar-text { flex-basis: calc(100% - 30px); }
  .cat-savebar .btn { flex: 1; }
}

/* Products table: the names get the room; row actions are icon buttons. */
.cat-prod-table th:nth-child(1) { width: 30%; }
.cat-prod-table th:nth-child(2) { width: 26%; }
.cat-prod-table th:nth-child(3), .cat-prod-table th:nth-child(4) { width: 12%; }
.cat-actions .icon-btn[aria-pressed="true"] { background: var(--soft); color: var(--ink); }
